List of usage examples for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener
DialogInterface.OnClickListener
From source file:cm.aptoide.pt.MainActivity.java
public void showAbout() { View aboutView = LayoutInflater.from(this).inflate(R.layout.dialog_about, null); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this).setView(aboutView); final AlertDialog aboutDialog = dialogBuilder.create(); aboutDialog.setIcon(android.R.drawable.ic_menu_help); aboutDialog.setTitle(getString(R.string.about)); aboutDialog.setCancelable(true);/*from w ww . ja v a 2 s .c o m*/ WindowManager.LayoutParams params = aboutDialog.getWindow().getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; aboutDialog.getWindow().setAttributes(params); aboutDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.btn_chlog), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Uri uri = Uri.parse(getString(R.string.change_log_url)); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); aboutDialog.show(); }
From source file:com.juick.android.MainActivity.java
private void doNavigationItemMenu(final NavigationItem theItem) { ArrayList<String> menuItems = theItem.getMenuItems(); final String[] menuItemsA = menuItems.toArray(new String[menuItems.size()]); new AlertDialog.Builder(MainActivity.this).setItems(menuItemsA, new DialogInterface.OnClickListener() { @Override/*from w ww.ja v a 2 s . c om*/ public void onClick(DialogInterface dialog, int which) { theItem.handleMenuAction(which, menuItemsA[which]); } }).setCancelable(true).create().show(); }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
private void showContactUsDialog() { new AlertDialog.Builder(context).setItems(new CharSequence[] { "Twitter", "Google+", "Email" }, new DialogInterface.OnClickListener() { @Override//from w w w .j av a2 s . c o m public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { final Intent tweet = new Intent(context, ComposeActivity.class); new AlertDialog.Builder(context) .setItems(new CharSequence[] { "@TestAndroid", "@daiv" }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { tweet.putExtra("user", "@TestAndroid"); } else { tweet.putExtra("user", "@daiv"); } startActivity(tweet); } }) .create().show(); } else if (i == 1) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://goo.gl/KCXlZk"))); } else { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "support@daivapps.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test (Classic)"); emailIntent.setType("plain/text"); startActivity(emailIntent); } } }).create().show(); }
From source file:og.android.tether.MainActivity.java
public Dialog openLaunchedDialog(final boolean noroot) { final long value = noroot ? 1 : 0; EasyTracker.getTracker().trackEvent("ui_action", "create_dialog", "meshclient", value); Dialog dialog = new AlertDialog.Builder(this) .setMessage(noroot ? R.string.dialog_noroot_text : R.string.dialog_launched_text) .setTitle(getString(R.string.dialog_launched_title)).setIcon(R.drawable.og_app_icon) .setCancelable(false).setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) MainActivity.this.finish(); if (keyCode < KeyEvent.KEYCODE_DPAD_UP || keyCode > KeyEvent.KEYCODE_DPAD_CENTER) return true; else return false; }//from w ww .j a v a 2 s . co m }).setPositiveButton(getString(R.string.main_activity_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { EasyTracker.getTracker().trackEvent("ui_action", "button_press", "meshclient_positive", value); startGooglePlayMeshclient(noroot ? "fail_noroot" : "fail"); } }) .setNegativeButton(getString(R.string.main_activity_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { EasyTracker.getTracker().trackEvent("ui_action", "button_press", "meshclient_negative", value); } }).create(); dialog.show(); return dialog; }
From source file:com.juick.android.MainActivity.java
private void logoutFromSomeServices() { new Thread("Get logged in accounts") { @Override// w w w .j a va 2 s . c o m public void run() { final HashSet<AccountProof> accountProofs = JAXMPPClient.getAccountProofs(MainActivity.this, false); runOnUiThread(new Runnable() { @Override public void run() { if (accountProofs.size() == 0) { Toast.makeText(MainActivity.this, getString(R.string.NoAuth), Toast.LENGTH_LONG).show(); return; } final CharSequence[] arr = new CharSequence[accountProofs.size()]; int ix = 0; for (AccountProof accountProof : accountProofs) { arr[ix++] = accountProof.getProofAccountType(); } new AlertDialog.Builder(MainActivity.this) .setItems(arr, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String what = arr[which].toString(); ArrayList<Utils.URLAuth> authorizers = Utils.authorizers; for (Utils.URLAuth authorizer : authorizers) { if (authorizer.isForBlog(what)) { authorizer.reset(MainActivity.this, handler); } } Toast.makeText(MainActivity.this, getString(R.string.AuthHasBeenClearedFor) + " " + what, Toast.LENGTH_LONG).show(); } }).setCancelable(true).create().show(); } }); } }.start(); }
From source file:com.klinker.android.twitter.activities.drawer_activities.DrawerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { try {/*ww w . ja v a 2s . c o m*/ if (mDrawerToggle.onOptionsItemSelected(item)) { if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) { mDrawerLayout.closeDrawer(Gravity.RIGHT); } return true; } } catch (Exception e) { // landscape } switch (item.getItemId()) { case R.id.menu_search: overridePendingTransition(0, 0); finish(); overridePendingTransition(0, 0); return super.onOptionsItemSelected(item); case R.id.menu_compose: Intent compose = new Intent(context, ComposeActivity.class); sharedPrefs.edit().putBoolean("from_notification_bool", false).commit(); startActivity(compose); return super.onOptionsItemSelected(item); case R.id.menu_direct_message: Intent dm = new Intent(context, ComposeDMActivity.class); sharedPrefs.edit().putBoolean("from_notification_bool", false).commit(); startActivity(dm); return super.onOptionsItemSelected(item); case R.id.menu_settings: context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION")); Intent settings = new Intent(context, SettingsActivity.class); finish(); sharedPrefs.edit().putBoolean("should_refresh", false).commit(); overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit); startActivity(settings); return super.onOptionsItemSelected(item); case R.id.menu_dismiss: InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markAllRead(DrawerActivity.settings.currentAccount); mDrawerLayout.closeDrawer(Gravity.RIGHT); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); return super.onOptionsItemSelected(item); case R.id.menu_notifications: if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) { mDrawerLayout.closeDrawer(Gravity.LEFT); } if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) { mDrawerLayout.closeDrawer(Gravity.RIGHT); } else { mDrawerLayout.openDrawer(Gravity.RIGHT); } return super.onOptionsItemSelected(item); case R.id.menu_to_first: context.sendBroadcast(new Intent("com.klinker.android.twitter.TOP_TIMELINE")); return super.onOptionsItemSelected(item); case R.id.menu_tweetmarker: context.sendBroadcast(new Intent("com.klinker.android.twitter.TWEETMARKER")); return super.onOptionsItemSelected(item); case R.id.menu_get_help: new AlertDialog.Builder(context).setTitle(R.string.faq).setMessage(R.string.faq_first) .setPositiveButton("FAQ", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { XmlFaqUtils.showFaqDialog(context); } }).setNegativeButton(R.string.contact, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showContactUsDialog(); } }).setNeutralButton(R.string.follow, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { showFollowDialog(); } }).create().show(); return super.onOptionsItemSelected(item); default: return super.onOptionsItemSelected(item); } }
From source file:org.mozilla.gecko.GeckoApp.java
/** * @param aPermissions//from w w w.ja v a2 s.c o m * Array of JSON objects to represent site permissions. * Example: { type: "offline-app", setting: "Store Offline Data: Allow" } */ private void showSiteSettingsDialog(String aHost, JSONArray aPermissions) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); View customTitleView = getLayoutInflater().inflate(R.layout.site_setting_title, null); ((TextView) customTitleView.findViewById(R.id.title)).setText(R.string.site_settings_title); ((TextView) customTitleView.findViewById(R.id.host)).setText(aHost); builder.setCustomTitle(customTitleView); // If there are no permissions to clear, show the user a message about that. // In the future, we want to disable the menu item if there are no permissions to clear. if (aPermissions.length() == 0) { builder.setMessage(R.string.site_settings_no_settings); } else { // Eventually we should use a list adapter and custom checkable list items // to make a two-line UI to match the mock-ups CharSequence[] items = new CharSequence[aPermissions.length()]; boolean[] states = new boolean[aPermissions.length()]; for (int i = 0; i < aPermissions.length(); i++) { try { items[i] = aPermissions.getJSONObject(i).getString("setting"); // Make all the items checked by default states[i] = true; } catch (JSONException e) { Log.i(LOGTAG, "JSONException: " + e); } } builder.setMultiChoiceItems(items, states, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int item, boolean state) { // Do nothing } }); builder.setPositiveButton(R.string.site_settings_clear, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ListView listView = ((AlertDialog) dialog).getListView(); SparseBooleanArray checkedItemPositions = listView.getCheckedItemPositions(); // An array of the indices of the permissions we want to clear JSONArray permissionsToClear = new JSONArray(); for (int i = 0; i < checkedItemPositions.size(); i++) { boolean checked = checkedItemPositions.get(i); if (checked) permissionsToClear.put(i); } GeckoAppShell.sendEventToGecko( GeckoEvent.createBroadcastEvent("Permissions:Clear", permissionsToClear.toString())); } }); } builder.setNegativeButton(R.string.site_settings_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); mMainHandler.post(new Runnable() { public void run() { builder.create().show(); } }); }
From source file:com.klinker.android.twitter.ui.drawer_activities.DrawerActivity.java
private void showContactUsDialog() { new AlertDialog.Builder(context).setItems(new CharSequence[] { "Twitter", "Google+", "Email" }, new DialogInterface.OnClickListener() { @Override// w w w .j a v a2s .c o m public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { final Intent tweet = new Intent(context, ComposeActivity.class); new AlertDialog.Builder(context) .setItems(new CharSequence[] { "@TalonAndroid", "@lukeklinker" }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { tweet.putExtra("user", "@TalonAndroid"); } else { tweet.putExtra("user", "@lukeklinker"); } startActivity(tweet); } }) .create().show(); } else if (i == 1) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://goo.gl/KCXlZk"))); } else { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "support@klinkerapps.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Talon (Classic)"); emailIntent.setType("plain/text"); startActivity(emailIntent); } } }).create().show(); }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
public void showFollowDialog() { new AlertDialog.Builder(context).setItems(new CharSequence[] { "@TestAndroid", "@daiv", "'s Google+" }, new DialogInterface.OnClickListener() { @Override//from w w w. ja v a 2 s .c o m public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { } else if (i == 1) { // "" (twitter) } else { // "" (google+) startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com/+daiv"))); } } }).create().show(); }
From source file:com.klinker.android.twitter.activities.drawer_activities.DrawerActivity.java
private void showContactUsDialog() { new AlertDialog.Builder(context).setItems(new CharSequence[] { "Twitter", "Google+", "Email" }, new DialogInterface.OnClickListener() { @Override/*from w w w .ja va2 s . c om*/ public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { final Intent tweet = new Intent(context, ComposeActivity.class); new AlertDialog.Builder(context) .setItems(new CharSequence[] { "@TalonAndroid", "@lukeklinker" }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { tweet.putExtra("user", "@TalonAndroid"); } else { tweet.putExtra("user", "@lukeklinker"); } startActivity(tweet); } }) .create().show(); } else if (i == 1) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://goo.gl/KCXlZk"))); } else { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "luke@klinkerapps.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Talon (Classic)"); emailIntent.setType("plain/text"); startActivity(emailIntent); } } }).create().show(); }