List of usage examples for android.app AlertDialog show
public void show()
From source file:cm.aptoide.pt.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { AptoideThemePicker.setAptoideTheme(this); super.onCreate(savedInstanceState); serviceDownloadManagerIntent = new Intent(this, ServiceDownloadManager.class); startService(serviceDownloadManagerIntent); mContext = this; File sdcard_file = new File(SDCARD); if (!sdcard_file.exists() || !sdcard_file.canWrite()) { View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView); final AlertDialog noSDDialog = dialogBuilder.create(); noSDDialog.setTitle(getText(R.string.remote_in_noSD_title)); noSDDialog.setIcon(android.R.drawable.ic_dialog_alert); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText(getText(R.string.remote_in_noSD)); noSDDialog.setCancelable(false); noSDDialog.setButton(Dialog.BUTTON_NEUTRAL, getString(android.R.string.ok), new Dialog.OnClickListener() { @Override//from ww w . j a v a 2s . co m public void onClick(DialogInterface arg0, int arg1) { finish(); } }); noSDDialog.show(); } else { StatFs stat = new StatFs(sdcard_file.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); long availableBlocks = stat.getAvailableBlocks(); long total = (blockSize * totalBlocks) / 1024 / 1024; long avail = (blockSize * availableBlocks) / 1024 / 1024; Log.d("Aptoide", "* * * * * * * * * *"); Log.d("Aptoide", "Total: " + total + " Mb"); Log.d("Aptoide", "Available: " + avail + " Mb"); if (avail < 10) { Log.d("Aptoide", "No space left on SDCARD..."); Log.d("Aptoide", "* * * * * * * * * *"); View simpleView = LayoutInflater.from(this).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(this).setView(simpleView); final AlertDialog noSpaceDialog = dialogBuilder.create(); noSpaceDialog.setIcon(android.R.drawable.ic_dialog_alert); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText(getText(R.string.remote_in_noSDspace)); noSpaceDialog.setButton(Dialog.BUTTON_NEUTRAL, getText(android.R.string.ok), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }); noSpaceDialog.show(); } else { SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(mContext); editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit(); if (!sPref.contains("matureChkBox")) { editor.putBoolean("matureChkBox", ApplicationAptoide.MATURECONTENTSWITCHVALUE); SharedPreferences sPrefOld = getSharedPreferences("aptoide_prefs", MODE_PRIVATE); if (sPrefOld.getString("app_rating", "none").equals("Mature")) { editor.putBoolean("matureChkBox", false); } } if (!sPref.contains("version")) { ApplicationAptoide.setRestartLauncher(true); try { editor.putInt("version", getPackageManager().getPackageInfo(getPackageName(), 0).versionCode); } catch (NameNotFoundException e) { e.printStackTrace(); } } if (sPref.getString("myId", null) == null) { String rand_id = UUID.randomUUID().toString(); editor.putString("myId", rand_id); } if (sPref.getInt("scW", 0) == 0 || sPref.getInt("scH", 0) == 0) { DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); editor.putInt("scW", dm.widthPixels); editor.putInt("scH", dm.heightPixels); } editor.commit(); File file = new File(LOCAL_PATH + "/apks"); if (!file.exists()) { file.mkdirs(); } new Thread(new Runnable() { @Override public void run() { // Note the L that tells the compiler to interpret the // number as a Long final long MAXFILEAGE = 2678400000L; // 1 month in // milliseconds // Get file handle to the directory. In this case the // application files dir File dir = new File(LOCAL_PATH + "/apks"); // Optain list of files in the directory. // listFiles() returns a list of File objects to each // file found. File[] files = dir.listFiles(); // Loop through all files for (File f : files) { // Get the last modified date. Miliseconds since // 1970 long lastmodified = f.lastModified(); // Do stuff here to deal with the file.. // For instance delete files older than 1 month if (lastmodified + MAXFILEAGE < System.currentTimeMillis()) { f.delete(); } } } }).start(); db = Database.getInstance(); Intent i = new Intent(mContext, MainService.class); startService(i); bindService(i, conn, Context.BIND_AUTO_CREATE); order = Order.values()[PreferenceManager.getDefaultSharedPreferences(mContext).getInt("order_list", 0)]; registerReceiver(updatesReceiver, new IntentFilter("update")); registerReceiver(statusReceiver, new IntentFilter("status")); registerReceiver(loginReceiver, new IntentFilter("login")); registerReceiver(storePasswordReceiver, new IntentFilter("401")); registerReceiver(redrawInstalledReceiver, new IntentFilter("pt.caixamagica.aptoide.REDRAW")); if (!ApplicationAptoide.MULTIPLESTORES) { registerReceiver(parseFailedReceiver, new IntentFilter("PARSE_FAILED")); } registerReceiver(newRepoReceiver, new IntentFilter("pt.caixamagica.aptoide.NEWREPO")); registered = true; categoriesStrings = new HashMap<String, Integer>(); // categoriesStrings.put("Applications", R.string.applications); boolean serversFileIsEmpty = true; if (sPref.getBoolean("firstrun", true)) { // Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); // shortcutIntent.setClassName("cm.aptoide.pt", // "cm.aptoide.pt.Start"); // final Intent intent = new Intent(); // intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, // shortcutIntent); // // intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, // getString(R.string.app_name)); // Parcelable iconResource = // Intent.ShortcutIconResource.fromContext(this, // R.drawable.ic_launcher); // // intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, // iconResource); // intent.putExtra("duplicate", false); // intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); // sendBroadcast(intent); if (new File(LOCAL_PATH + "/servers.xml").exists() && ApplicationAptoide.DEFAULTSTORENAME == null) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); MyappHandler handler = new MyappHandler(); sp.parse(new File(LOCAL_PATH + "/servers.xml"), handler); ArrayList<String> server = handler.getServers(); if (server.isEmpty()) { serversFileIsEmpty = true; } else { getIntent().putExtra("newrepo", server); } } catch (Exception e) { e.printStackTrace(); } } editor.putBoolean("firstrun", false); editor.putBoolean("orderByCategory", true); editor.commit(); } if (getIntent().hasExtra("newrepo")) { ArrayList<String> repos = (ArrayList<String>) getIntent().getSerializableExtra("newrepo"); for (final String uri2 : repos) { View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView); final AlertDialog addNewRepoDialog = dialogBuilder.create(); addNewRepoDialog.setTitle(getString(R.string.add_store)); addNewRepoDialog.setIcon(android.R.drawable.ic_menu_add); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText((getString(R.string.newrepo_alrt) + uri2 + " ?")); addNewRepoDialog.setCancelable(false); addNewRepoDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogAddStore(uri2, null, null); } }); addNewRepoDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.cancel(); } }); addNewRepoDialog.show(); } } else if (db.getStores(false).getCount() == 0 && ApplicationAptoide.DEFAULTSTORENAME == null && serversFileIsEmpty) { View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView); final AlertDialog addAppsRepoDialog = dialogBuilder.create(); addAppsRepoDialog.setTitle(getString(R.string.add_store)); addAppsRepoDialog.setIcon(android.R.drawable.ic_menu_add); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText(getString(R.string.myrepo_alrt) + "\n" + "http://apps.store.aptoide.com/"); addAppsRepoDialog.setCancelable(false); addAppsRepoDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogAddStore("http://apps.store.aptoide.com", null, null); } }); addAppsRepoDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.cancel(); } }); addAppsRepoDialog.show(); } new Thread(new Runnable() { @Override public void run() { try { getUpdateParameters(); if (getPackageManager().getPackageInfo(getPackageName(), 0).versionCode < Integer .parseInt(updateParams.get("versionCode"))) { runOnUiThread(new Runnable() { @Override public void run() { requestUpdateSelf(); } }); } } catch (Exception e) { e.printStackTrace(); } } }).start(); } featuredView = LayoutInflater.from(mContext).inflate(R.layout.page_featured, null); availableView = LayoutInflater.from(mContext).inflate(R.layout.page_available, null); updateView = LayoutInflater.from(mContext).inflate(R.layout.page_updates, null); banner = (LinearLayout) availableView.findViewById(R.id.banner); breadcrumbs = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.breadcrumb_container, null); installedView = new ListView(mContext); updatesListView = (ListView) updateView.findViewById(R.id.updates_list); availableListView = (ListView) availableView.findViewById(R.id.available_list); joinStores = (CheckBox) availableView.findViewById(R.id.join_stores); availableAdapter = new AvailableListAdapter(mContext, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); installedAdapter = new InstalledAdapter(mContext, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER, db); updatesAdapter = new UpdatesAdapter(mContext, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); pb = (TextView) availableView.findViewById(R.id.loading_pb); addStoreButton = availableView.findViewById(R.id.add_store); bannerStoreAvatar = (ImageView) banner.findViewById(R.id.banner_store_avatar); bannerStoreName = (TextView) banner.findViewById(R.id.banner_store_name); bannerStoreDescription = (AutoScaleTextView) banner.findViewById(R.id.banner_store_description); } }
From source file:net.homelinux.penecoptero.android.citybikes.app.MainActivity.java
private void showAutoNetworkDialog(int method) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_map); final int mth = method; try {/* www . j av a2s . c o m*/ mNDBAdapter.update(); final JSONObject network = mNDBAdapter.getAutomaticNetwork(hOverlay.getPoint(), method); alertDialog.setTitle(R.string.bike_network_alert_success_title); alertDialog.setMessage(getString(R.string.bike_network_alert_success_text0) + ":\n- (" + network.getString("city") + ") " + network.getString("name") + "\n" + getString(R.string.bike_network_alert_success_text1)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.sure), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { mNDBAdapter.setManualNetwork(network.getInt("id")); fillData(view_all); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.try_again), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); alertDialog.setTitle(R.string.bike_network_alert_error_title); alertDialog.setMessage(getString(R.string.bike_network_alert_error_text)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.try_again), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mth == 0) showAutoNetworkDialog(1); else showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); } alertDialog.show(); }
From source file:cm.aptoide.pt.MainActivity.java
private void requestUpdateSelf() { View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView); final AlertDialog updateSelfDialog = dialogBuilder.create(); updateSelfDialog.setTitle(getText(R.string.update_self_title)); updateSelfDialog.setIcon(R.drawable.icon_brand_aptoide); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText(getString(R.string.update_self_msg, ApplicationAptoide.MARKETNAME)); updateSelfDialog.setCancelable(false); updateSelfDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override/* w w w. ja va2s . c om*/ public void onClick(DialogInterface arg0, int arg1) { new DownloadSelfUpdate().execute(); } }); updateSelfDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.dismiss(); } }); updateSelfDialog.show(); }
From source file:com.lgallardo.qbittorrentclient.RefreshListener.java
public void genericOkDialog(int title, int message, DialogInterface.OnClickListener okListener) { if (!isFinishing()) { Builder builder = new Builder(this); // Title//from w ww.java 2 s.c o m if (title != -1) { builder.setTitle(title); } // Message builder.setMessage(message); // Ok builder.setPositiveButton(R.string.ok, okListener); // Create dialog AlertDialog dialog = builder.create(); // Show dialog dialog.show(); } }
From source file:com.lgallardo.qbittorrentclient.RefreshListener.java
private void genericOkCancelDialog(int title, int message, DialogInterface.OnClickListener okListener) { if (!isFinishing()) { Builder builder = new Builder(this); // Title/*from w w w.ja va2s .co m*/ if (title != -1) { builder.setTitle(title); } // Message builder.setMessage(message); // Ok builder.setPositiveButton(R.string.ok, okListener); // Cancel builder.setNegativeButton(R.string.cancel, null); // Create dialog AlertDialog dialog = builder.create(); // Show dialog dialog.show(); } }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
/** * setup a filter//from www .j av a 2s .c o m */ private void filter() { Log.v(TAG, "setting filter"); final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(HciDebuggerActivity.this); LayoutInflater inflater = getLayoutInflater(); final View dialogView = inflater.inflate(R.layout.filter_dialog, null); dialogBuilder.setView(dialogView); //packet type setupSpinnerAdapter(R.array.packet_type_array, dialogView, R.id.packet_type_filter, filters.getPacketTypeFilter()); //event type setupSpinnerAdapter(R.array.event_type_array, dialogView, R.id.event_type_filter, filters.getEventTypeFilter()); //ogf setupSpinnerAdapter(R.array.ogf_array, dialogView, R.id.cmd_ogf_filter, filters.getOgfFilter()); //subevent_type_filter setupSpinnerAdapter(R.array.subevent_array, dialogView, R.id.subevent_type_filter, filters.getSubeventFilter()); EditText addressText = (EditText) dialogView.findViewById(R.id.device_address_edit); addressText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { filters.setAddress(s.toString()); SharedPreferences.Editor editor = prefs.edit(); editor.putString(Constants.PREFERENCES_ADVERTISING_ADDR, s.toString()); editor.commit(); } @Override public void afterTextChanged(Editable s) { } }); addressText.setText(filters.getAdvertizingAddr()); final AlertDialog alertDialog = dialogBuilder.create(); final Button button_withdraw_filter = (Button) dialogView.findViewById(R.id.button_withdraw_filter); if (isFiltered) button_withdraw_filter.setVisibility(View.VISIBLE); else button_withdraw_filter.setVisibility(View.GONE); button_withdraw_filter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { isFiltered = false; packetAdapter.setPacketList(packetList); notifyAdapter(); alertDialog.cancel(); alertDialog.dismiss(); packetFilteredList.clear(); } }); Button button_apply = (Button) dialogView.findViewById(R.id.button_apply_filter); button_apply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Spinner packet_type_filter = (Spinner) dialogView.findViewById(R.id.packet_type_filter); Spinner ogf_filter = (Spinner) dialogView.findViewById(R.id.cmd_ogf_filter); Spinner event_type_filter = (Spinner) dialogView.findViewById(R.id.event_type_filter); Spinner subevent_type_filter = (Spinner) dialogView.findViewById(R.id.subevent_type_filter); EditText device_address_edit = (EditText) dialogView.findViewById(R.id.device_address_edit); filters = new Filters(HciDebuggerActivity.this, packet_type_filter.getSelectedItem().toString(), event_type_filter.getSelectedItem().toString(), ogf_filter.getSelectedItem().toString(), subevent_type_filter.getSelectedItem().toString(), device_address_edit.getText().toString()); packetFilteredList = new ArrayList<Packet>(); for (int i = 0; i < packetList.size(); i++) { if (matchFilter(packetList.get(i))) { packetFilteredList.add(packetList.get(i)); } } isFiltered = true; packetAdapter.setPacketList(packetFilteredList); notifyAdapter(); alertDialog.cancel(); alertDialog.dismiss(); } }); Button button_cancel = (Button) dialogView.findViewById(R.id.button_cancel_filter); button_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.cancel(); alertDialog.dismiss(); } }); alertDialog.show(); }
From source file:self.philbrown.droidQuery.$.java
/** * Show an alert// www . j ava 2 s . c om * @param context used to display the alert window * @param title the title of the alert window. Use {@code null} to show no title * @param text the alert message * @see #alert(Context, String) */ public static void alert(Context context, String title, String text) { AlertDialog alert = new AlertDialog.Builder(context).create(); alert.setTitle(title); alert.setMessage(text); alert.setButton("OK", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); }
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
@SuppressLint("InflateParams") private void saveThisPage() { if (!CompatibilityUtils.hasAccessStorage(activity)) return;/*from w w w. j a v a 2 s .c o m*/ DownloadingService.DownloadingQueueItem check = new DownloadingService.DownloadingQueueItem( tabModel.pageModel, presentationModel.source.boardModel, DownloadingService.MODE_DOWNLOAD_ALL); String itemName = resources.getString(R.string.downloading_thread_format, tabModel.pageModel.boardName, tabModel.pageModel.threadNumber); if (DownloadingService.isInQueue(check)) { Toast.makeText(activity, resources.getString(R.string.notification_download_already_in_queue, itemName), Toast.LENGTH_LONG).show(); } else { Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? new ContextThemeWrapper(activity, R.style.Theme_Neutron) : activity; View saveThreadDialogView = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_save_thread, null); final CheckBox saveThumbsChkbox = (CheckBox) saveThreadDialogView .findViewById(R.id.dialog_save_thread_thumbs); final CheckBox saveAllChkbox = (CheckBox) saveThreadDialogView .findViewById(R.id.dialog_save_thread_all); switch (settings.getDownloadThreadMode()) { case DownloadingService.MODE_DOWNLOAD_ALL: saveThumbsChkbox.setChecked(true); saveAllChkbox.setChecked(true); break; case DownloadingService.MODE_DOWNLOAD_THUMBS: saveThumbsChkbox.setChecked(true); saveAllChkbox.setChecked(false); break; default: saveThumbsChkbox.setChecked(false); saveAllChkbox.setChecked(false); saveAllChkbox.setEnabled(false); break; } saveThumbsChkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (saveThumbsChkbox.isChecked()) { saveAllChkbox.setEnabled(true); } else { saveAllChkbox.setEnabled(false); saveAllChkbox.setChecked(false); } } }); DialogInterface.OnClickListener save = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int mode = DownloadingService.MODE_ONLY_CACHE; if (saveThumbsChkbox.isChecked()) { mode = DownloadingService.MODE_DOWNLOAD_THUMBS; } if (saveAllChkbox.isChecked()) { mode = DownloadingService.MODE_DOWNLOAD_ALL; } settings.saveDownloadThreadMode(mode); Intent savePageIntent = new Intent(activity, DownloadingService.class); savePageIntent.putExtra(DownloadingService.EXTRA_DOWNLOADING_ITEM, new DownloadingService.DownloadingQueueItem(tabModel.pageModel, presentationModel.source.boardModel, mode)); activity.startService(savePageIntent); } }; AlertDialog saveThreadDialog = new AlertDialog.Builder(dialogContext).setView(saveThreadDialogView) .setTitle(R.string.dialog_save_thread_title) .setPositiveButton(R.string.dialog_save_thread_save, save) .setNegativeButton(android.R.string.cancel, null).create(); saveThreadDialog.setCanceledOnTouchOutside(false); saveThreadDialog.show(); } }