List of usage examples for android.app AlertDialog setCanceledOnTouchOutside
public void setCanceledOnTouchOutside(boolean cancel)
From source file:org.quantumbadger.redreader.reddit.prepared.RedditPreparedPost.java
public static void showActionMenu(final Activity activity, final RedditPreparedPost post) { final EnumSet<Action> itemPref = PrefsUtility.pref_menus_post_context_items(activity, PreferenceManager.getDefaultSharedPreferences(activity)); if (itemPref.isEmpty()) return;//from w w w . j av a 2s . c o m final RedditAccount user = RedditAccountManager.getInstance(activity).getDefaultAccount(); final ArrayList<RPVMenuItem> menu = new ArrayList<RPVMenuItem>(); if (!RedditAccountManager.getInstance(activity).getDefaultAccount().isAnonymous()) { if (itemPref.contains(Action.UPVOTE)) { if (!post.isUpvoted()) { menu.add(new RPVMenuItem(activity, R.string.action_upvote, Action.UPVOTE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_upvote_remove, Action.UNVOTE)); } } if (itemPref.contains(Action.DOWNVOTE)) { if (!post.isDownvoted()) { menu.add(new RPVMenuItem(activity, R.string.action_downvote, Action.DOWNVOTE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_downvote_remove, Action.UNVOTE)); } } if (itemPref.contains(Action.SAVE)) { if (!post.isSaved()) { menu.add(new RPVMenuItem(activity, R.string.action_save, Action.SAVE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_unsave, Action.UNSAVE)); } } if (itemPref.contains(Action.HIDE)) { if (!post.isHidden()) { menu.add(new RPVMenuItem(activity, R.string.action_hide, Action.HIDE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_unhide, Action.UNHIDE)); } } if (itemPref.contains(Action.DELETE) && user.username.equalsIgnoreCase(post.src.author)) { menu.add(new RPVMenuItem(activity, R.string.action_delete, Action.DELETE)); } if (itemPref.contains(Action.REPORT)) menu.add(new RPVMenuItem(activity, R.string.action_report, Action.REPORT)); } if (itemPref.contains(Action.EXTERNAL)) menu.add(new RPVMenuItem(activity, R.string.action_external, Action.EXTERNAL)); if (itemPref.contains(Action.SELFTEXT_LINKS) && post.src.selftext != null && post.src.selftext.length() > 1) menu.add(new RPVMenuItem(activity, R.string.action_selftext_links, Action.SELFTEXT_LINKS)); if (itemPref.contains(Action.SAVE_IMAGE) && post.mIsProbablyAnImage) menu.add(new RPVMenuItem(activity, R.string.action_save_image, Action.SAVE_IMAGE)); if (itemPref.contains(Action.GOTO_SUBREDDIT)) menu.add(new RPVMenuItem(activity, R.string.action_gotosubreddit, Action.GOTO_SUBREDDIT)); if (itemPref.contains(Action.SHARE)) menu.add(new RPVMenuItem(activity, R.string.action_share, Action.SHARE)); if (itemPref.contains(Action.SHARE_COMMENTS)) menu.add(new RPVMenuItem(activity, R.string.action_share_comments, Action.SHARE_COMMENTS)); if (itemPref.contains(Action.COPY)) menu.add(new RPVMenuItem(activity, R.string.action_copy, Action.COPY)); if (itemPref.contains(Action.USER_PROFILE)) menu.add(new RPVMenuItem(activity, R.string.action_user_profile, Action.USER_PROFILE)); if (itemPref.contains(Action.PROPERTIES)) menu.add(new RPVMenuItem(activity, R.string.action_properties, Action.PROPERTIES)); final String[] menuText = new String[menu.size()]; for (int i = 0; i < menuText.length; i++) { menuText[i] = menu.get(i).title; } final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setItems(menuText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { onActionMenuItemSelected(post, activity, menu.get(which).action); } }); //builder.setNeutralButton(R.string.dialog_cancel, null); final AlertDialog alert = builder.create(); alert.setTitle(R.string.action_menu_post_title); alert.setCanceledOnTouchOutside(true); alert.show(); }
From source file:org.catrobat.catroid.ui.dialogs.TermsOfUseDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { Bundle fragmentDialogArguments = getArguments(); boolean acceptTermsOfUse = false; if (fragmentDialogArguments != null) { acceptTermsOfUse = fragmentDialogArguments.getBoolean(DIALOG_ARGUMENT_TERMS_OF_USE_ACCEPT, false); }//from ww w.java 2 s. c om View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_terms_of_use, null); final CheckBox checkBoxTermsOfUseAcceptedPermanently = (CheckBox) view .findViewById(R.id.dialog_terms_of_use_check_box_agree_permanently); TextView termsOfUseUrlTextView = (TextView) view.findViewById(R.id.dialog_terms_of_use_text_view_url); termsOfUseUrlTextView.setMovementMethod(LinkMovementMethod.getInstance()); String termsOfUseUrl = getString(R.string.terms_of_use_link_template, Constants.CATROBAT_TERMS_OF_USE_URL, getString(R.string.dialog_terms_of_use_link_text)); termsOfUseUrlTextView.setText(Html.fromHtml(termsOfUseUrl)); AlertDialog.Builder termsOfUseDialogBuilder = new AlertDialog.Builder(getActivity()).setView(view) .setTitle(R.string.dialog_terms_of_use_title); if (!acceptTermsOfUse) { termsOfUseDialogBuilder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); } else { termsOfUseDialogBuilder.setNegativeButton(R.string.dialog_terms_of_use_do_not_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { getActivity().finish(); dialog.dismiss(); } }); termsOfUseDialogBuilder.setPositiveButton(R.string.dialog_terms_of_use_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (checkBoxTermsOfUseAcceptedPermanently.isChecked()) { SettingsActivity.setTermsOfServiceAgreedPermanently(getActivity(), true); } dialog.dismiss(); DroneInitializer droneInitializer = ((PreStageActivity) getActivity()) .getDroneInitializer(); if (droneInitializer != null) { droneInitializer.initialiseDrone(); } } }); termsOfUseDialogBuilder.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { Log.d(TAG, "prevent canceling the dialog with back button"); return true; } }); checkBoxTermsOfUseAcceptedPermanently.setVisibility(CheckBox.VISIBLE); checkBoxTermsOfUseAcceptedPermanently.setText(R.string.dialog_terms_of_use_agree_permanent); termsOfUseDialogBuilder.setCancelable(false); } AlertDialog termsOfUseDialog = termsOfUseDialogBuilder.create(); if (!acceptTermsOfUse) { termsOfUseDialog.setCanceledOnTouchOutside(true); } else { termsOfUseDialog.setCancelable(false); termsOfUseDialog.setCanceledOnTouchOutside(false); } return termsOfUseDialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.TermsOfUseDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { Bundle fragmentDialogArguments = getArguments(); boolean acceptTermsOfUse = false; if (fragmentDialogArguments != null) { acceptTermsOfUse = fragmentDialogArguments.getBoolean(DIALOG_ARGUMENT_TERMS_OF_USE_ACCEPT, false); }/* w w w.jav a 2 s . com*/ View view = LayoutInflater.from(getActivity()).inflate(hku.fyp14017.blencode.R.layout.dialog_terms_of_use, null); final CheckBox checkBoxTermsOfUseAcceptedPermanently = (CheckBox) view .findViewById(hku.fyp14017.blencode.R.id.dialog_terms_of_use_check_box_agree_permanently); TextView termsOfUseUrlTextView = (TextView) view .findViewById(hku.fyp14017.blencode.R.id.dialog_terms_of_use_text_view_url); termsOfUseUrlTextView.setMovementMethod(LinkMovementMethod.getInstance()); String termsOfUseUrl = getString(hku.fyp14017.blencode.R.string.terms_of_use_link_template, Constants.CATROBAT_TERMS_OF_USE_URL, getString(hku.fyp14017.blencode.R.string.dialog_terms_of_use_link_text)); termsOfUseUrlTextView.setText(Html.fromHtml(termsOfUseUrl)); AlertDialog.Builder termsOfUseDialogBuilder = new AlertDialog.Builder(getActivity()).setView(view) .setTitle(hku.fyp14017.blencode.R.string.dialog_terms_of_use_title); if (!acceptTermsOfUse) { termsOfUseDialogBuilder.setNeutralButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); } else { termsOfUseDialogBuilder.setNegativeButton( hku.fyp14017.blencode.R.string.dialog_terms_of_use_do_not_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { getActivity().finish(); dialog.dismiss(); } }); termsOfUseDialogBuilder.setPositiveButton(hku.fyp14017.blencode.R.string.dialog_terms_of_use_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (checkBoxTermsOfUseAcceptedPermanently.isChecked()) { SettingsActivity.setTermsOfServiceAgreedPermanently(getActivity(), true); } dialog.dismiss(); DroneInitializer droneInitializer = ((PreStageActivity) getActivity()) .getDroneInitializer(); if (droneInitializer != null) { droneInitializer.initialiseDrone(); } } }); termsOfUseDialogBuilder.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { Log.d(TAG, "prevent canceling the dialog with back button"); return true; } }); checkBoxTermsOfUseAcceptedPermanently.setVisibility(CheckBox.VISIBLE); checkBoxTermsOfUseAcceptedPermanently .setText(hku.fyp14017.blencode.R.string.dialog_terms_of_use_agree_permanent); termsOfUseDialogBuilder.setCancelable(false); } AlertDialog termsOfUseDialog = termsOfUseDialogBuilder.create(); if (!acceptTermsOfUse) { termsOfUseDialog.setCanceledOnTouchOutside(true); } else { termsOfUseDialog.setCancelable(false); termsOfUseDialog.setCanceledOnTouchOutside(false); } return termsOfUseDialog; }
From source file:com.mobicage.rogerthat.AddQRCodeActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { T.UI();/*from w ww . j a v a 2 s. co m*/ if (resultCode == RESULT_OK) { // No need to do anything if requestCode == ScanTabActivity.MARKET_INSTALL_RESULT if (requestCode == ScanTabActivity.ZXING_SCAN_RESULT) { final String rawScanResult = intent.getStringExtra("SCAN_RESULT"); if (rawScanResult == null) { UIUtils.showLongToast(AddQRCodeActivity.this, getString(R.string.scanner_failure)); } else { L.d("Scanned " + rawScanResult); // Ask for the QR code name final View view = getLayoutInflater().inflate(R.layout.add_qr_code_name, null); String message = getString(R.string.qr_code_scanned); String positiveCaption = getString(R.string.save); SafeDialogClick positiveClick = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface di, int id) { final EditText editText = (EditText) view.findViewById(R.id.qr_code_name); final SystemPlugin systemPlugin = mService.getPlugin(SystemPlugin.class); systemPlugin.createQRCode(new QRCode(editText.getText().toString(), rawScanResult)); di.dismiss(); finish(); } }; AlertDialog alertDialog = UIUtils.showDialog(this, null, message, positiveCaption, positiveClick, null, null, view); alertDialog.setCanceledOnTouchOutside(true); } } } hideProgressDialog(); }
From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedPost.java
public static void showActionMenu(final AppCompatActivity activity, final RedditPreparedPost post) { final EnumSet<Action> itemPref = PrefsUtility.pref_menus_post_context_items(activity, PreferenceManager.getDefaultSharedPreferences(activity)); if (itemPref.isEmpty()) return;/*ww w . j a v a2 s .com*/ final RedditAccount user = RedditAccountManager.getInstance(activity).getDefaultAccount(); final ArrayList<RPVMenuItem> menu = new ArrayList<>(); if (!RedditAccountManager.getInstance(activity).getDefaultAccount().isAnonymous()) { if (itemPref.contains(Action.UPVOTE)) { if (!post.isUpvoted()) { menu.add(new RPVMenuItem(activity, R.string.action_upvote, Action.UPVOTE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_upvote_remove, Action.UNVOTE)); } } if (itemPref.contains(Action.DOWNVOTE)) { if (!post.isDownvoted()) { menu.add(new RPVMenuItem(activity, R.string.action_downvote, Action.DOWNVOTE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_downvote_remove, Action.UNVOTE)); } } if (itemPref.contains(Action.SAVE)) { if (!post.isSaved()) { menu.add(new RPVMenuItem(activity, R.string.action_save, Action.SAVE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_unsave, Action.UNSAVE)); } } if (itemPref.contains(Action.HIDE)) { if (!post.isHidden()) { menu.add(new RPVMenuItem(activity, R.string.action_hide, Action.HIDE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_unhide, Action.UNHIDE)); } } if (itemPref.contains(Action.EDIT) && post.isSelf() && user.username.equalsIgnoreCase(post.src.getAuthor())) { menu.add(new RPVMenuItem(activity, R.string.action_edit, Action.EDIT)); } if (itemPref.contains(Action.DELETE) && user.username.equalsIgnoreCase(post.src.getAuthor())) { menu.add(new RPVMenuItem(activity, R.string.action_delete, Action.DELETE)); } if (itemPref.contains(Action.REPORT)) menu.add(new RPVMenuItem(activity, R.string.action_report, Action.REPORT)); } if (itemPref.contains(Action.EXTERNAL)) menu.add(new RPVMenuItem(activity, R.string.action_external, Action.EXTERNAL)); if (itemPref.contains(Action.SELFTEXT_LINKS) && post.src.getRawSelfText() != null && post.src.getRawSelfText().length() > 1) menu.add(new RPVMenuItem(activity, R.string.action_selftext_links, Action.SELFTEXT_LINKS)); if (itemPref.contains(Action.SAVE_IMAGE) && post.mIsProbablyAnImage) menu.add(new RPVMenuItem(activity, R.string.action_save_image, Action.SAVE_IMAGE)); if (itemPref.contains(Action.GOTO_SUBREDDIT)) menu.add(new RPVMenuItem(activity, R.string.action_gotosubreddit, Action.GOTO_SUBREDDIT)); if (post.showSubreddit) { try { String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit()); if (itemPref.contains(Action.BLOCK) && post.showSubreddit) { final List<String> blockedSubreddits = PrefsUtility.pref_blocked_subreddits(activity, PreferenceManager.getDefaultSharedPreferences(activity)); if (blockedSubreddits.contains(subredditCanonicalName)) { menu.add(new RPVMenuItem(activity, R.string.action_unblock_subreddit, Action.UNBLOCK)); } else { menu.add(new RPVMenuItem(activity, R.string.action_block_subreddit, Action.BLOCK)); } } if (itemPref.contains(Action.PIN) && post.showSubreddit) { List<String> pinnedSubreddits = PrefsUtility.pref_pinned_subreddits(activity, PreferenceManager.getDefaultSharedPreferences(activity)); if (pinnedSubreddits.contains(subredditCanonicalName)) { menu.add(new RPVMenuItem(activity, R.string.action_unpin_subreddit, Action.UNPIN)); } else { menu.add(new RPVMenuItem(activity, R.string.action_pin_subreddit, Action.PIN)); } } if (!RedditAccountManager.getInstance(activity).getDefaultAccount().isAnonymous()) { if (itemPref.contains(Action.SUBSCRIBE)) { if (RedditSubredditSubscriptionManager .getSingleton(activity, RedditAccountManager.getInstance(activity).getDefaultAccount()) .getSubscriptionState( subredditCanonicalName) == RedditSubredditSubscriptionManager.SubredditSubscriptionState.SUBSCRIBED) { menu.add(new RPVMenuItem(activity, R.string.action_unsubscribe_subreddit, Action.UNSUBSCRIBE)); } else { menu.add(new RPVMenuItem(activity, R.string.action_subscribe_subreddit, Action.SUBSCRIBE)); } } } } catch (RedditSubreddit.InvalidSubredditNameException ex) { throw new RuntimeException(ex); } } if (itemPref.contains(Action.SHARE)) menu.add(new RPVMenuItem(activity, R.string.action_share, Action.SHARE)); if (itemPref.contains(Action.SHARE_COMMENTS)) menu.add(new RPVMenuItem(activity, R.string.action_share_comments, Action.SHARE_COMMENTS)); if (itemPref.contains(Action.SHARE_IMAGE) && post.mIsProbablyAnImage) menu.add(new RPVMenuItem(activity, R.string.action_share_image, Action.SHARE_IMAGE)); if (itemPref.contains(Action.COPY)) menu.add(new RPVMenuItem(activity, R.string.action_copy, Action.COPY)); if (itemPref.contains(Action.USER_PROFILE)) menu.add(new RPVMenuItem(activity, R.string.action_user_profile, Action.USER_PROFILE)); if (itemPref.contains(Action.PROPERTIES)) menu.add(new RPVMenuItem(activity, R.string.action_properties, Action.PROPERTIES)); final String[] menuText = new String[menu.size()]; for (int i = 0; i < menuText.length; i++) { menuText[i] = menu.get(i).title; } final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setItems(menuText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onActionMenuItemSelected(post, activity, menu.get(which).action); } }); //builder.setNeutralButton(R.string.dialog_cancel, null); final AlertDialog alert = builder.create(); alert.setCanceledOnTouchOutside(true); alert.show(); }
From source file:com.apptentive.android.sdk.Apptentive.java
private static void init(Activity activity) { ///*from w w w . j av a 2 s . com*/ // First, initialize data relies on synchronous reads from local resources. // final Context appContext = activity.getApplicationContext(); if (!GlobalInfo.initialized) { SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); // First, Get the api key, and figure out if app is debuggable. GlobalInfo.isAppDebuggable = false; String apiKey = null; boolean apptentiveDebug = false; String logLevelOverride = null; try { ApplicationInfo ai = appContext.getPackageManager().getApplicationInfo(appContext.getPackageName(), PackageManager.GET_META_DATA); Bundle metaData = ai.metaData; if (metaData != null) { apiKey = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_API_KEY); logLevelOverride = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_LOG_LEVEL); apptentiveDebug = metaData.getBoolean(Constants.MANIFEST_KEY_APPTENTIVE_DEBUG); ApptentiveClient.useStagingServer = metaData .getBoolean(Constants.MANIFEST_KEY_USE_STAGING_SERVER); } if (apptentiveDebug) { Log.i("Apptentive debug logging set to VERBOSE."); ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE); } else if (logLevelOverride != null) { Log.i("Overriding log level: %s", logLevelOverride); ApptentiveInternal.setMinimumLogLevel(Log.Level.parse(logLevelOverride)); } else { GlobalInfo.isAppDebuggable = (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; if (GlobalInfo.isAppDebuggable) { ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE); } } } catch (Exception e) { Log.e("Unexpected error while reading application info.", e); } Log.i("Debug mode enabled? %b", GlobalInfo.isAppDebuggable); // If we are in debug mode, but no api key is found, throw an exception. Otherwise, just assert log. We don't want to crash a production app. String errorString = "No Apptentive api key specified. Please make sure you have specified your api key in your AndroidManifest.xml"; if ((Util.isEmpty(apiKey))) { if (GlobalInfo.isAppDebuggable) { AlertDialog alertDialog = new AlertDialog.Builder(activity).setTitle("Error") .setMessage(errorString).setPositiveButton("OK", null).create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } Log.e(errorString); } GlobalInfo.apiKey = apiKey; Log.i("API Key: %s", GlobalInfo.apiKey); // Grab app info we need to access later on. GlobalInfo.appPackage = appContext.getPackageName(); GlobalInfo.androidId = Settings.Secure.getString(appContext.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); // Check the host app version, and notify modules if it's changed. try { PackageManager packageManager = appContext.getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(appContext.getPackageName(), 0); Integer currentVersionCode = packageInfo.versionCode; String currentVersionName = packageInfo.versionName; VersionHistoryStore.VersionHistoryEntry lastVersionEntrySeen = VersionHistoryStore .getLastVersionSeen(appContext); if (lastVersionEntrySeen == null) { onVersionChanged(appContext, null, currentVersionCode, null, currentVersionName); } else { if (!currentVersionCode.equals(lastVersionEntrySeen.versionCode) || !currentVersionName.equals(lastVersionEntrySeen.versionName)) { onVersionChanged(appContext, lastVersionEntrySeen.versionCode, currentVersionCode, lastVersionEntrySeen.versionName, currentVersionName); } } GlobalInfo.appDisplayName = packageManager .getApplicationLabel(packageManager.getApplicationInfo(packageInfo.packageName, 0)) .toString(); } catch (PackageManager.NameNotFoundException e) { // Nothing we can do then. GlobalInfo.appDisplayName = "this app"; } // Grab the conversation token from shared preferences. if (prefs.contains(Constants.PREF_KEY_CONVERSATION_TOKEN) && prefs.contains(Constants.PREF_KEY_PERSON_ID)) { GlobalInfo.conversationToken = prefs.getString(Constants.PREF_KEY_CONVERSATION_TOKEN, null); GlobalInfo.personId = prefs.getString(Constants.PREF_KEY_PERSON_ID, null); } GlobalInfo.initialized = true; Log.v("Done initializing..."); } else { Log.v("Already initialized..."); } // Initialize the Conversation Token, or fetch if needed. Fetch config it the token is available. if (GlobalInfo.conversationToken == null || GlobalInfo.personId == null) { asyncFetchConversationToken(appContext.getApplicationContext()); } else { asyncFetchAppConfiguration(appContext.getApplicationContext()); InteractionManager.asyncFetchAndStoreInteractions(appContext.getApplicationContext()); } // TODO: Do this on a dedicated thread if it takes too long. Some devices are slow to read device data. syncDevice(appContext); syncSdk(appContext); syncPerson(appContext); Log.d("Default Locale: %s", Locale.getDefault().toString()); SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); Log.d("Conversation id: %s", prefs.getString(Constants.PREF_KEY_CONVERSATION_ID, "null")); }
From source file:org.catrobat.catroid.ui.dialogs.NewSoundDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_new_sound, (ViewGroup) getView(), false); setupRecordButton(dialogView);//w w w . j a va 2s .com setupGalleryButton(dialogView); setupMediaLibraryButton(dialogView); AlertDialog dialog; AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView) .setTitle(R.string.new_sound_dialog_title); dialog = createDialog(dialogBuilder); dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.NewLookDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(hku.fyp14017.blencode.R.layout.dialog_new_look, null);//from w ww .ja v a 2 s. c om setupPaintroidButton(dialogView); setupGalleryButton(dialogView); setupCameraButton(dialogView); AlertDialog dialog; AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.new_look_dialog_title); dialog = createDialog(dialogBuilder); dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:org.catrobat.catroid.ui.dialogs.NewLookDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_new_look, null); setupPaintroidButton(dialogView);//w w w . ja v a2 s .c o m setupGalleryButton(dialogView); setupCameraButton(dialogView); setupMediaLibraryButton(dialogView); AlertDialog dialog; AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView) .setTitle(R.string.new_look_dialog_title); dialog = createDialog(dialogBuilder); dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:com.wellsandwhistles.android.redditsp.adapters.AccountListAdapter.java
@Override protected void onBindContentItemViewHolder(VH holder, final int position) { final VH1Text vh = (VH1Text) holder; final RedditAccount account = accounts.get(position); final BetterSSB username = new BetterSSB(); if (account.isAnonymous()) { username.append(context.getString(R.string.accounts_anon), 0); } else {/*from ww w . j a v a 2 s . co m*/ username.append(account.username, 0); } if (account.equals(RedditAccountManager.getInstance(context).getDefaultAccount())) { final TypedArray attr = context.obtainStyledAttributes(new int[] { R.attr.srListSubtitleCol }); final int col = attr.getColor(0, 0); attr.recycle(); username.append(" (" + context.getString(R.string.accounts_active) + ")", BetterSSB.FOREGROUND_COLOR | BetterSSB.SIZE, col, 0, 0.8f); } vh.text.setText(username.get()); vh.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final RedditAccount account = accounts.get(position); final String[] items = account.isAnonymous() ? new String[] { context.getString(R.string.accounts_setactive) } : new String[] { context.getString(R.string.accounts_setactive), context.getString(R.string.accounts_delete) }; final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String selected = items[which]; if (selected.equals(context.getString(R.string.accounts_setactive))) { RedditAccountManager.getInstance(context).setDefaultAccount(account); } else if (selected.equals(context.getString(R.string.accounts_delete))) { new AlertDialog.Builder(context).setTitle(R.string.accounts_delete) .setMessage(R.string.accounts_delete_sure) .setPositiveButton(R.string.accounts_delete, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { RedditAccountManager.getInstance(context) .deleteAccount(account); } }) .setNegativeButton(R.string.dialog_cancel, null).show(); } } }); builder.setNeutralButton(R.string.dialog_cancel, null); final AlertDialog alert = builder.create(); alert.setTitle( account.isAnonymous() ? context.getString(R.string.accounts_anon) : account.username); alert.setCanceledOnTouchOutside(true); alert.show(); } }); }