List of usage examples for android.widget RelativeLayout addView
public void addView(View child)
Adds a child view.
From source file:com.goftagram.telegram.ui.Components.PasscodeView.java
private void checkFingerprint() { Activity parentActivity = (Activity) getContext(); if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint && !ApplicationLoader.mainInterfacePaused) { try {//from ww w. j a v a2s .co m if (fingerprintDialog != null && fingerprintDialog.isShowing()) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat .from(ApplicationLoader.applicationContext); if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) { RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(16), AndroidUtilities.dp(24), AndroidUtilities.dp(8)); TextView fingerprintTextView = new TextView(getContext()); fingerprintTextView.setTextColor(0xff939393); fingerprintTextView.setId(id_fingerprint_textview); fingerprintTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead); fingerprintTextView .setText(LocaleController.getString("FingerprintInfo", R.string.FingerprintInfo)); relativeLayout.addView(fingerprintTextView); RelativeLayout.LayoutParams layoutParams = LayoutHelper .createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); fingerprintTextView.setLayoutParams(layoutParams); fingerprintImageView = new ImageView(getContext()); fingerprintImageView.setImageResource(R.drawable.ic_fp_40px); fingerprintImageView.setId(id_fingerprint_imageview); relativeLayout.addView(fingerprintImageView, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0, RelativeLayout.ALIGN_PARENT_START, RelativeLayout.BELOW, id_fingerprint_textview)); fingerprintStatusTextView = new TextView(getContext()); fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL); fingerprintStatusTextView .setText(LocaleController.getString("FingerprintHelp", R.string.FingerprintHelp)); fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Body1); fingerprintStatusTextView.setTextColor(0x42000000); relativeLayout.addView(fingerprintStatusTextView); layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.setMarginStart(AndroidUtilities.dp(16)); layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.ALIGN_TOP, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.END_OF, id_fingerprint_imageview); fingerprintStatusTextView.setLayoutParams(layoutParams); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setView(relativeLayout); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (cancellationSignal != null) { selfCancelled = true; cancellationSignal.cancel(); cancellationSignal = null; } } }); if (fingerprintDialog != null) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } } fingerprintDialog = builder.show(); cancellationSignal = new CancellationSignal(); selfCancelled = false; fingerprintManager.authenticate(null, 0, cancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { if (!selfCancelled) { showFingerprintError(errString); } } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { showFingerprintError(helpString); } @Override public void onAuthenticationFailed() { showFingerprintError(LocaleController.getString("FingerprintNotRecognized", R.string.FingerprintNotRecognized)); } @Override public void onAuthenticationSucceeded( FingerprintManagerCompat.AuthenticationResult result) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } fingerprintDialog = null; processDone(true); } }, null); } } catch (Throwable e) { //ignore } } }
From source file:kr.wdream.ui.Components.PasscodeView.java
private void checkFingerprint() { Activity parentActivity = (Activity) getContext(); if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint && !ApplicationLoader.mainInterfacePaused) { try {//from www. j a v a 2 s . c o m if (fingerprintDialog != null && fingerprintDialog.isShowing()) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat .from(ApplicationLoader.applicationContext); if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) { RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(16), AndroidUtilities.dp(24), AndroidUtilities.dp(8)); TextView fingerprintTextView = new TextView(getContext()); fingerprintTextView.setTextColor(0xff939393); fingerprintTextView.setId(id_fingerprint_textview); fingerprintTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead); fingerprintTextView.setText(LocaleController.getString("FingerprintInfo", kr.wdream.storyshop.R.string.FingerprintInfo)); relativeLayout.addView(fingerprintTextView); RelativeLayout.LayoutParams layoutParams = LayoutHelper .createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); fingerprintTextView.setLayoutParams(layoutParams); fingerprintImageView = new ImageView(getContext()); fingerprintImageView.setImageResource(kr.wdream.storyshop.R.drawable.ic_fp_40px); fingerprintImageView.setId(id_fingerprint_imageview); relativeLayout.addView(fingerprintImageView, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0, RelativeLayout.ALIGN_PARENT_START, RelativeLayout.BELOW, id_fingerprint_textview)); fingerprintStatusTextView = new TextView(getContext()); fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL); fingerprintStatusTextView.setText(LocaleController.getString("FingerprintHelp", kr.wdream.storyshop.R.string.FingerprintHelp)); fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Body1); fingerprintStatusTextView.setTextColor(0x42000000); relativeLayout.addView(fingerprintStatusTextView); layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.setMarginStart(AndroidUtilities.dp(16)); layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.ALIGN_TOP, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.END_OF, id_fingerprint_imageview); fingerprintStatusTextView.setLayoutParams(layoutParams); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName)); builder.setView(relativeLayout); builder.setNegativeButton( LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (cancellationSignal != null) { selfCancelled = true; cancellationSignal.cancel(); cancellationSignal = null; } } }); if (fingerprintDialog != null) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } } fingerprintDialog = builder.show(); cancellationSignal = new CancellationSignal(); selfCancelled = false; fingerprintManager.authenticate(null, 0, cancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { if (!selfCancelled) { showFingerprintError(errString); } } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { showFingerprintError(helpString); } @Override public void onAuthenticationFailed() { showFingerprintError(LocaleController.getString("FingerprintNotRecognized", kr.wdream.storyshop.R.string.FingerprintNotRecognized)); } @Override public void onAuthenticationSucceeded( FingerprintManagerCompat.AuthenticationResult result) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } fingerprintDialog = null; processDone(true); } }, null); } } catch (Throwable e) { //ignore } } }
From source file:fiskinfoo.no.sintef.fiskinfoo.CardViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_card_view, container, false); RelativeLayout textAreaPlaceHolder = (RelativeLayout) rootView.findViewById(R.id.card_view_container); TextView title = (TextView) rootView.findViewById(R.id.card_view_title_text_view); if (subscription != null) { title.setText(subscription.GeoDataServiceName); TextView idView = generateTextViewWithText("id: " + subscription.Id, title); TextView geoDataServiceNameView = generateTextViewWithText( "Navn p kartlaget: " + subscription.GeoDataServiceName, idView); TextView fileFormatTypeView = generateTextViewWithText("Filformat: " + subscription.FileFormatType, geoDataServiceNameView); TextView userEmailView = generateTextViewWithText("Bruker e-post: " + subscription.UserEmail, fileFormatTypeView);// ww w . j a v a 2 s .c om TextView subscriptionEmailView = generateTextViewWithText( "Abbonents e-post: " + subscription.SubscriptionEmail, userEmailView); TextView subscriptionIntervalNameView = generateTextViewWithText( "Kartet sendes: " + subscription.SubscriptionIntervalName, subscriptionEmailView); TextView createdView = generateTextViewWithText("Opprettet: " + subscription.Created, subscriptionIntervalNameView); TextView lastModifiedView = generateTextViewWithText("Sist oppdatert: " + subscription.LastModified, createdView); textAreaPlaceHolder.addView(idView); textAreaPlaceHolder.addView(geoDataServiceNameView); textAreaPlaceHolder.addView(fileFormatTypeView); textAreaPlaceHolder.addView(userEmailView); textAreaPlaceHolder.addView(subscriptionEmailView); textAreaPlaceHolder.addView(subscriptionIntervalNameView); textAreaPlaceHolder.addView(createdView); textAreaPlaceHolder.addView(lastModifiedView); } if (propertyDescription != null) { title.setText(propertyDescription.Name); Button notificationIconButton = (Button) rootView.findViewById(R.id.card_notification_image_view); CardViewInformationRow row; Button downloadMapButton; Button showOnMapButton; final ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.card_view_scroll_view); final LinearLayout informationContainer = (LinearLayout) rootView .findViewById(R.id.card_view_information_container); LinearLayout bottomButtonContainer = (LinearLayout) rootView.findViewById(R.id.bottom_button_container); showOnMapButton = new Button(getActivity()); downloadMapButton = (Button) rootView.findViewById(R.id.card_view_download_map_button); row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.last_updated), propertyDescription.LastUpdated.replace('T', ' '), true); informationContainer.addView(row.getView()); String description = (propertyDescription.LongDescription == null || propertyDescription.LongDescription.trim().equals("")) ? propertyDescription.Description : propertyDescription.LongDescription; String hyperlink = null; description = description.replace("<p>", ""); description = description.replace("</p>", ""); // TODO: should rewrite in order to handle multiple links. if (description.contains("<a href=\"")) { hyperlink = "<a href='" + description.substring(description.indexOf("href=") + 6, description.indexOf(">", description.indexOf("href=")) - 1) + "'>" + "\t\t\t* " + getString(R.string.see_more_info) + "</a>"; description = description.substring(0, description.indexOf("<a href")) + description.substring(description.indexOf(">", description.indexOf("<a href")) + 1, description.indexOf("</a")) + "*" + (description.indexOf("a>") > description.length() - 3 ? "" : description.substring(description.indexOf("a>") + 2, description.length())); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.information), description, true); informationContainer.addView(row.getView()); if (hyperlink != null) { TextView textView = new TextView(getActivity()); textView.setClickable(true); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(Html.fromHtml(hyperlink)); textView.setTextSize(getResources().getInteger(R.integer.hyperlinkTextSize)); informationContainer.addView(textView); } String updateFrequency = (propertyDescription.UpdateFrequencyText == null || propertyDescription.UpdateFrequencyText.trim().equals("")) ? getString(R.string.update_frequency_not_available) : propertyDescription.UpdateFrequencyText; row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.update_frequency), updateFrequency, true); informationContainer.addView(row.getView()); if (ApiErrorType.getType(propertyDescription.ErrorType) == ApiErrorType.WARNING) { row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.error_text), propertyDescription.ErrorText, true); final View dataField = row.getView(); final Animation animation = getBlinkAnimation(); notificationIconButton.setVisibility(View.VISIBLE); notificationIconButton .setBackground(ContextCompat.getDrawable(getActivity(), R.drawable.ic_warning_black_36dp)); row.setTextColor(getResources().getColor(R.color.warning_orange)); notificationIconButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { focusOnView(scrollView, dataField); dataField.startAnimation(animation); } }); informationContainer.addView(row.getView()); } else if (ApiErrorType.getType(propertyDescription.ErrorType) == ApiErrorType.WARNING) { row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.error_text), propertyDescription.ErrorText, true); final TextView dataField = row.getFieldDataTextView(); final Animation animation = getBlinkAnimation(); notificationIconButton.setVisibility(View.VISIBLE); notificationIconButton.setBackground( ContextCompat.getDrawable(getActivity(), R.drawable.ic_error_outline_black_36dp)); row.setTextColor(getResources().getColor(R.color.error_red)); notificationIconButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { focusOnView(scrollView, dataField); dataField.startAnimation(animation); } }); informationContainer.addView(row.getView()); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.data_owner), propertyDescription.DataOwner, true); informationContainer.addView(row.getView()); if (propertyDescription.DataOwnerLink != null && !propertyDescription.DataOwnerLink.trim().equals("")) { String partnerLink = (propertyDescription.DataOwnerLink.contains("http") || propertyDescription.DataOwnerLink.contains("www")) ? "<a href='" + propertyDescription.DataOwnerLink + "'>" + propertyDescription.DataOwnerLink + "</a>" : "<a href='" + getString(R.string.about_partners_base_address) + propertyDescription.DataOwnerLink + "'>" + getString(R.string.about_partners_base_address) + propertyDescription.DataOwnerLink + "</a>"; row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.data_owner_link), partnerLink, true); row.setHyperlink(partnerLink); row.getFieldDataTextView().setMovementMethod(LinkMovementMethod.getInstance()); informationContainer.addView(row.getView()); } StringBuilder stringBuilder = new StringBuilder(); for (String format : propertyDescription.Formats) { stringBuilder.append(format); stringBuilder.append("\n"); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.formats), stringBuilder.toString().trim(), false); informationContainer.addView(row.getView()); stringBuilder.setLength(0); for (String interval : propertyDescription.SubscriptionInterval) { stringBuilder.append(SubscriptionInterval.getType(interval).toString()); stringBuilder.append("\n"); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.subscription_frequencies), stringBuilder.toString().trim(), false); informationContainer.addView(row.getView()); row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.map_creation_date), propertyDescription.Created.substring(0, propertyDescription.Created.indexOf('T')), true); informationContainer.addView(row.getView()); LinearLayout.LayoutParams bottomButtonLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); bottomButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL; bottomButtonLayoutParams.weight = (float) 0.5; showOnMapButton.setLayoutParams(bottomButtonLayoutParams); showOnMapButton.setText(getString(R.string.show_on_map)); showOnMapButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO: Need to update the toolbar as well. List<String> layersList = new ArrayList<>(); String layerName = propertyDescription.Name; layersList.add("Grunnkart"); layersList.add(layerName); user.setActiveLayers(layersList); user.writeToSharedPref(getActivity()); getFragmentManager().beginTransaction().replace(R.id.fragment_container, new FiskInfoUtility().createFragment(MapFragment.TAG, user, TAG), MapFragment.TAG) .addToBackStack(null).commit(); } }); bottomButtonContainer.addView(showOnMapButton); downloadMapButton.setOnClickListener(utilityOnClickListeners .getSubscriptionDownloadButtonOnClickListener(getActivity(), propertyDescription, user, TAG)); } if (warning != null) { TextView content = generateTextViewWithText(warning, title); textAreaPlaceHolder.addView(content); } clearIds(); return rootView; }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the clear image cache button, add listener for clear image cache. * @return the relative layout//from w w w . ja v a 2 s .c om */ private RelativeLayout createClearImageCacheButton() { RelativeLayout clearImageView = new RelativeLayout(this); clearImageView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); Button clearImgCacheBtn = new Button(this); clearImgCacheBtn.setText("Clear Image Cache"); RelativeLayout.LayoutParams clearButtonLayout = new RelativeLayout.LayoutParams(150, LayoutParams.WRAP_CONTENT); clearButtonLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); clearImgCacheBtn.setLayoutParams(clearButtonLayout); clearImgCacheBtn.setOnClickListener(new OnClickListener() { public void onClick(View v) { ViewHelper.showAlertViewWithTitleYesOrNo(AppSettingsActivity.this, "", "Are you sure you want to clear image cache?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { FileUtil.clearImagesInCache(AppSettingsActivity.this); } }); } }); clearImageView.addView(clearImgCacheBtn); return clearImageView; }
From source file:ir.besteveryeverapp.ui.Components.PasscodeView.java
private void checkFingerprint() { Activity parentActivity = (Activity) getContext(); if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint && !ApplicationLoader.mainInterfacePaused) { try {//from ww w . j a v a2s. co m if (fingerprintDialog != null && fingerprintDialog.isShowing()) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat .from(ApplicationLoader.applicationContext); if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) { RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(16), AndroidUtilities.dp(24), AndroidUtilities.dp(8)); TextView fingerprintTextView = new TextView(getContext()); fingerprintTextView.setTypeface(FontManager.instance().getTypeface()); fingerprintTextView.setTextColor(0xff939393); fingerprintTextView.setId(id_fingerprint_textview); fingerprintTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead); fingerprintTextView .setText(LocaleController.getString("FingerprintInfo", R.string.FingerprintInfo)); relativeLayout.addView(fingerprintTextView); RelativeLayout.LayoutParams layoutParams = LayoutHelper .createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); fingerprintTextView.setLayoutParams(layoutParams); fingerprintImageView = new ImageView(getContext()); fingerprintImageView.setImageResource(R.drawable.ic_fp_40px); fingerprintImageView.setId(id_fingerprint_imageview); relativeLayout.addView(fingerprintImageView, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0, RelativeLayout.ALIGN_PARENT_START, RelativeLayout.BELOW, id_fingerprint_textview)); fingerprintStatusTextView = new TextView(getContext()); fingerprintStatusTextView.setTypeface(FontManager.instance().getTypeface()); fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL); fingerprintStatusTextView .setText(LocaleController.getString("FingerprintHelp", R.string.FingerprintHelp)); fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Body1); fingerprintStatusTextView.setTextColor(0x42000000); relativeLayout.addView(fingerprintStatusTextView); layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.setMarginStart(AndroidUtilities.dp(16)); layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.ALIGN_TOP, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.END_OF, id_fingerprint_imageview); fingerprintStatusTextView.setLayoutParams(layoutParams); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setView(relativeLayout); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (cancellationSignal != null) { selfCancelled = true; cancellationSignal.cancel(); cancellationSignal = null; } } }); if (fingerprintDialog != null) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } } fingerprintDialog = builder.show(); cancellationSignal = new CancellationSignal(); selfCancelled = false; fingerprintManager.authenticate(null, 0, cancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { if (!selfCancelled) { showFingerprintError(errString); } } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { showFingerprintError(helpString); } @Override public void onAuthenticationFailed() { showFingerprintError(LocaleController.getString("FingerprintNotRecognized", R.string.FingerprintNotRecognized)); } @Override public void onAuthenticationSucceeded( FingerprintManagerCompat.AuthenticationResult result) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } fingerprintDialog = null; processDone(true); } }, null); } } catch (Throwable e) { //ignore } } }
From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { AnalyticsHelper.reportScreen(this, AnalyticsManager.SCREEN_SAMSUNG_SNOTE_EDITOR); super.onCreate(savedInstanceState); setContentView(R.layout.snote_editor); context = this; // TOOLBAR/*from ww w . ja va 2s . c o m*/ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } // Retrieve information String action = getIntent().getAction(); if (Intent.ACTION_VIEW.equals(action)) { if (getIntent().getData() != null) { String filePath = BaseActionUtils.getPath(this, getIntent().getData()); file = new File(filePath); } else { AlfrescoNotificationManager.getInstance(this).showLongToast(getString(R.string.editor_error_open)); finish(); return; } } // Init Spen boolean isSpenFeatureEnabled = false; Spen spenPackage = new Spen(); try { spenPackage.initialize(this); isSpenFeatureEnabled = spenPackage.isFeatureEnabled(Spen.DEVICE_PEN); } catch (SsdkUnsupportedException e) { if (SNoteUtils.processUnsupportedException(this, e)) { return; } } catch (Exception e1) { Log.e(TAG, Log.getStackTraceString(e1)); finish(); } FrameLayout spenViewContainer = (FrameLayout) findViewById(R.id.spenViewContainer); RelativeLayout spenViewLayout = (RelativeLayout) findViewById(R.id.spenViewLayout); // PEN SETTINGS spenSettingView = new SpenSettingPenLayout(context, "", spenViewLayout); if (spenSettingView == null) { finish(); } spenViewContainer.addView(spenSettingView); // ERASER SETTINGS eraserSettingView = new SpenSettingEraserLayout(context, "", spenViewLayout); if (eraserSettingView == null) { finish(); } spenViewContainer.addView(eraserSettingView); // TEXT SETTINGS textSettingView = new SpenSettingTextLayout(context, "", new HashMap<String, String>(), spenViewLayout); if (textSettingView == null) { finish(); } spenViewContainer.addView(textSettingView); // SELECTION SETTINGS selectionSettingView = new SpenSettingSelectionLayout(context, "", spenViewLayout); if (textSettingView == null) { finish(); } spenViewContainer.addView(selectionSettingView); // SURFACE VIEW spenSurfaceView = new SpenSurfaceView(context); if (spenSurfaceView == null) { finish(); } spenViewLayout.addView(spenSurfaceView); spenSettingView.setCanvasView(spenSurfaceView); eraserSettingView.setCanvasView(spenSurfaceView); textSettingView.setCanvasView(spenSurfaceView); selectionSettingView.setCanvasView(spenSurfaceView); // NOTE DOCUMENT Display display = getWindowManager().getDefaultDisplay(); Rect mScreenRect = new Rect(); display.getRectSize(mScreenRect); try { if (file != null && file.length() > 0) { spenNoteDoc = new SpenNoteDoc(context, file.getAbsolutePath(), mScreenRect.width(), SpenNoteDoc.MODE_WRITABLE); if (spenNoteDoc.getPageCount() == 0) { spenPageDoc = spenNoteDoc.appendPage(); } else { spenPageDoc = spenNoteDoc.getPage(spenNoteDoc.getLastEditedPageIndex()); } } else { spenNoteDoc = new SpenNoteDoc(context, SpenNoteDoc.ORIENTATION_LANDSCAPE, (mScreenRect.width() > mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height(), (mScreenRect.width() < mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height()); spenPageDoc = spenNoteDoc.appendPage(); spenPageDoc.setBackgroundColor(getResources().getColor(android.R.color.white)); spenPageDoc.clearHistory(); } } catch (Exception e) { finish(); } // Display Document spenSurfaceView.setPageDoc(spenPageDoc, true); spenSurfaceView.setBlankColor(getResources().getColor(R.color.grey_light)); if (!isSpenFeatureEnabled) { mToolType = SpenSurfaceView.TOOL_FINGER; spenSurfaceView.setToolTypeAction(mToolType, SpenSurfaceView.ACTION_STROKE); // Touch listener for swipe if on Finger mode gdt = new GestureDetector(context, new GestureListener()); spenSurfaceView.setOnTouchListener(touchListener); } // Init Pages mTxtView = (TextView) findViewById(R.id.spen_page); mTxtView.setText(String.format(getString(R.string.editor_paging), String.valueOf((spenNoteDoc.getPageIndexById(spenPageDoc.getId()) + 1)), spenNoteDoc.getPageCount())); // INIT Setting & Listeners initSettingInfo(); spenSurfaceView.setTouchListener(penTouchListener); spenSurfaceView.setControlListener(controlListener); spenSurfaceView.setFlickListener(mFlickListener); }
From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java
private void handleBusRoute(@NonNull final FavoritesViewHolder holder, @NonNull final BusRoute busRoute) { holder.stationNameTextView.setText(busRoute.getId()); holder.favoriteImage.setImageResource(R.drawable.ic_directions_bus_white_24dp); final List<BusDetailsDTO> busDetailsDTOs = new ArrayList<>(); final Map<String, Map<String, List<BusArrival>>> busArrivals = favoritesData .getBusArrivalsMapped(busRoute.getId()); for (final Entry<String, Map<String, List<BusArrival>>> entry : busArrivals.entrySet()) { // Build data for button outside of the loop final String stopName = entry.getKey(); final String stopNameTrimmed = Util.trimBusStopNameIfNeeded(stopName); final Map<String, List<BusArrival>> value = entry.getValue(); for (final String key2 : value.keySet()) { final BusArrival busArrival = value.get(key2).get(0); final String boundTitle = busArrival.getRouteDirection(); final BusDirection.BusDirectionEnum busDirectionEnum = BusDirection.BusDirectionEnum .fromString(boundTitle); final BusDetailsDTO busDetails = BusDetailsDTO.builder().busRouteId(busArrival.getRouteId()) .bound(busDirectionEnum.getShortUpperCase()).boundTitle(boundTitle) .stopId(Integer.toString(busArrival.getStopId())).routeName(busRoute.getName()) .stopName(stopName).build(); busDetailsDTOs.add(busDetails); }//from w w w . j a v a2 s. com boolean newLine = true; int i = 0; for (final Entry<String, List<BusArrival>> entry2 : value.entrySet()) { final LinearLayout.LayoutParams containParams = getInsideParams(newLine, i == value.size() - 1); final LinearLayout container = new LinearLayout(context); container.setOrientation(LinearLayout.HORIZONTAL); container.setLayoutParams(containParams); // Left final LinearLayout.LayoutParams leftParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); final RelativeLayout left = new RelativeLayout(context); left.setLayoutParams(leftParams); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId); destinationParams.setMargins(pixelsHalf, 0, 0, 0); final String bound = BusDirection.BusDirectionEnum.fromString(entry2.getKey()).getShortLowerCase(); final String leftString = stopNameTrimmed + " " + bound; final SpannableString destinationSpannable = new SpannableString(leftString); destinationSpannable.setSpan(new RelativeSizeSpan(0.65f), stopNameTrimmed.length(), leftString.length(), 0); // set size destinationSpannable.setSpan(new ForegroundColorSpan(grey5), 0, leftString.length(), 0); // set color final TextView boundCustomTextView = new TextView(context); boundCustomTextView.setText(destinationSpannable); boundCustomTextView.setSingleLine(true); boundCustomTextView.setLayoutParams(destinationParams); left.addView(lineIndication); left.addView(boundCustomTextView); // Right final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rightParams.setMargins(marginLeftPixel, 0, 0, 0); final LinearLayout right = new LinearLayout(context); right.setOrientation(LinearLayout.VERTICAL); right.setLayoutParams(rightParams); final List<BusArrival> buses = entry2.getValue(); final StringBuilder currentEtas = new StringBuilder(); for (final BusArrival arri : buses) { currentEtas.append(" ").append(arri.getTimeLeftDueDelay()); } final TextView arrivalText = new TextView(context); arrivalText.setText(currentEtas); arrivalText.setGravity(Gravity.END); arrivalText.setSingleLine(true); arrivalText.setTextColor(grey5); arrivalText.setEllipsize(TextUtils.TruncateAt.END); right.addView(arrivalText); container.addView(left); container.addView(right); holder.mainLayout.addView(container); newLine = false; i++; } } holder.mapButton.setText(activity.getString(R.string.favorites_view_buses)); holder.detailsButton .setOnClickListener(new BusStopOnClickListener(activity, holder.parent, busDetailsDTOs)); holder.mapButton.setOnClickListener(v -> { if (!Util.isNetworkAvailable(context)) { Util.showNetworkErrorMessage(activity); } else { final Set<String> bounds = Stream.of(busDetailsDTOs).map(BusDetailsDTO::getBound) .collect(Collectors.toSet()); final Intent intent = new Intent(activity.getApplicationContext(), BusMapActivity.class); final Bundle extras = new Bundle(); extras.putString(activity.getString(R.string.bundle_bus_route_id), busRoute.getId()); extras.putStringArray(activity.getString(R.string.bundle_bus_bounds), bounds.toArray(new String[bounds.size()])); intent.putExtras(extras); activity.startActivity(intent); } }); }
From source file:fr.cph.chicago.core.adapter.NearbyAdapter.java
private View handleBikes(final int position, @NonNull final ViewGroup parent) { final LayoutInflater vi = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View convertView = vi.inflate(R.layout.list_nearby, parent, false); final int index = position - (stations.size() + busStops.size()); final BikeStation bikeStation = bikeStations.get(index); final LinearLayout favoritesData = (LinearLayout) convertView.findViewById(R.id.nearby_results); final ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); imageView.setImageDrawable(/* w w w . j a v a 2s .c o m*/ ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_directions_bike_white_24dp)); final TextView routeView = (TextView) convertView.findViewById(R.id.station_name); routeView.setText(bikeStation.getName()); final LinearLayout llh = new LinearLayout(context); llh.setOrientation(LinearLayout.HORIZONTAL); llh.setPadding(line1PaddingColor, stopsPaddingTop, 0, 0); final LinearLayout availableLayout = new LinearLayout(context); availableLayout.setOrientation(LinearLayout.VERTICAL); final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final RelativeLayout availableBikes = new RelativeLayout(context); availableBikes.setLayoutParams(leftParam); availableBikes.setPadding(line1PaddingColor, 0, 0, 0); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams availableParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); availableParam.addRule(RelativeLayout.RIGHT_OF, lineId); availableParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0); final TextView availableBike = new TextView(context); availableBike.setText(context.getString(R.string.bike_available_bikes)); availableBike.setTextColor(ContextCompat.getColor(context, R.color.grey_5)); availableBike.setLayoutParams(availableParam); int availableBikeId = Util.generateViewId(); availableBike.setId(availableBikeId); final RelativeLayout.LayoutParams amountParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); amountParam.addRule(RelativeLayout.RIGHT_OF, availableBikeId); final TextView amountBike = new TextView(context); final String amountBikeText = String.valueOf(bikeStation.getAvailableBikes()); amountBike.setText(amountBikeText); int color = bikeStation.getAvailableBikes() == 0 ? R.color.red : R.color.green; amountBike.setTextColor(ContextCompat.getColor(context, color)); amountBike.setLayoutParams(amountParam); availableBikes.addView(lineIndication); availableBikes.addView(availableBike); availableBikes.addView(amountBike); final LinearLayout.LayoutParams leftParam2 = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final RelativeLayout availableDocks = new RelativeLayout(context); availableDocks.setLayoutParams(leftParam2); availableDocks.setPadding(line1PaddingColor, 0, 0, 0); final RelativeLayout lineIndication2 = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId2 = Util.generateViewId(); lineIndication2.setId(lineId2); final RelativeLayout.LayoutParams availableDockParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); availableDockParam.addRule(RelativeLayout.RIGHT_OF, lineId2); availableDockParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0); final TextView availableDock = new TextView(context); availableDock.setText(context.getString(R.string.bike_available_docks)); availableDock.setTextColor(ContextCompat.getColor(context, R.color.grey_5)); availableDock.setLayoutParams(availableDockParam); int availableDockBikeId = Util.generateViewId(); availableDock.setId(availableDockBikeId); final RelativeLayout.LayoutParams amountParam2 = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); amountParam2.addRule(RelativeLayout.RIGHT_OF, availableDockBikeId); final TextView amountDock = new TextView(context); final String amountDockText = String.valueOf(bikeStation.getAvailableDocks()); amountDock.setText(amountDockText); color = bikeStation.getAvailableDocks() == 0 ? R.color.red : R.color.green; amountDock.setTextColor(ContextCompat.getColor(context, color)); amountDock.setLayoutParams(amountParam2); availableDocks.addView(lineIndication2); availableDocks.addView(availableDock); availableDocks.addView(amountDock); availableLayout.addView(availableBikes); availableLayout.addView(availableDocks); llh.addView(availableLayout); favoritesData.addView(llh); convertView.setOnClickListener(new NearbyOnClickListener(googleMap, markers, bikeStation.getId(), bikeStation.getLatitude(), bikeStation.getLongitude())); return convertView; }
From source file:com.near.chimerarevo.fragments.PostFragment.java
private void addYoutubeVideo(String url) { final String yturl; if (url.contains("embed")) { String temp = url.split("embed/")[1]; if (url.contains("feature")) { temp = temp.split("feature=")[0]; yturl = temp.substring(0, temp.length() - 1); } else//from w w w .j av a2s .c om yturl = temp; } else if (url.contains("youtu.be")) { yturl = url.split("youtu.be/")[1]; } else return; final RelativeLayout rl = new RelativeLayout(getActivity()); YouTubeThumbnailView yt = new YouTubeThumbnailView(getActivity()); ImageView icon = new ImageView(getActivity()); try { yt.setTag(yturl); yt.initialize(Constants.YOUTUBE_API_TOKEN, new OnInitializedListener() { @Override public void onInitializationFailure(YouTubeThumbnailView thumbView, YouTubeInitializationResult error) { rl.setVisibility(View.GONE); } @Override public void onInitializationSuccess(YouTubeThumbnailView thumbView, YouTubeThumbnailLoader thumbLoader) { thumbLoader.setVideo(yturl); } }); } catch (Exception e) { e.printStackTrace(); } RelativeLayout.LayoutParams obj_params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); obj_params.addRule(RelativeLayout.CENTER_HORIZONTAL); obj_params.addRule(RelativeLayout.CENTER_VERTICAL); yt.setLayoutParams(obj_params); icon.setImageResource(R.drawable.yt_play_button); icon.setLayoutParams(obj_params); RelativeLayout.LayoutParams rl_params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rl_params.setMargins(0, 10, 0, 0); rl.setLayoutParams(rl_params); rl.setGravity(Gravity.CENTER_HORIZONTAL); rl.setClickable(true); rl.addView(yt); rl.addView(icon); rl.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getActivity(), YoutubeActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra(Constants.KEY_VIDEO_URL, yturl); startActivity(i); } }); lay.addView(rl); }