List of usage examples for android.app ProgressDialog setIndeterminate
public void setIndeterminate(boolean indeterminate)
From source file:com.koushikdutta.superuser.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Settings.applyDarkThemeSetting(this, R.style.SuperuserDarkActivity); super.onCreate(savedInstanceState); if (Settings.getBoolean(this, "first_run", true)) { saveWhatsNew();/*from w ww . java 2s. c o m*/ Settings.setBoolean(this, "first_run", false); } final ProgressDialog dlg = new ProgressDialog(this); dlg.setTitle(R.string.superuser); dlg.setMessage(getString(R.string.checking_superuser)); dlg.setIndeterminate(true); dlg.show(); new Thread() { public void run() { boolean _error = false; try { SuHelper.checkSu(MainActivity.this); } catch (Exception e) { e.printStackTrace(); _error = true; } final boolean error = _error; dlg.dismiss(); runOnUiThread(new Runnable() { @Override public void run() { if (error) { doInstall(); } else { doWhatsNew(); } } }); }; }.start(); }
From source file:org.xwiki.android.authenticator.auth.AuthenticatorActivity.java
public void showProgress(CharSequence message, final AsyncTask asyncTask) { // To avoid repeatedly create if (mProgressDialog != null && mProgressDialog.isShowing()) { return;/*from w w w . j ava2s. c o m*/ } final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(message); dialog.setIndeterminate(true); dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (asyncTask != null) { asyncTask.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. mProgressDialog = dialog; mProgressDialog.show(); }
From source file:org.klnusbaum.udj.auth.AuthActivity.java
@Override protected Dialog onCreateDialog(int id) { final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.authenticating)); dialog.setIndeterminate(true); dialog.setCancelable(true);/*from w w w. jav a 2 s . c om*/ dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (mAuthTask != null) { mAuthTask.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. We can't just call dismissDialog(0) because the system // can lose track of our dialog if there's an orientation change. mProgressDialog = dialog; return dialog; }
From source file:com.koushikdutta.superuser.MainActivity.java
void doSystemInstall() { final ProgressDialog dlg = new ProgressDialog(this); dlg.setTitle(R.string.installing);/* ww w . ja v a2 s . co m*/ dlg.setMessage(getString(R.string.installing_superuser)); dlg.setIndeterminate(true); dlg.show(); new Thread() { public void run() { boolean _error = false; try { final File su = extractSu(); final String command = "mount -orw,remount /system\n" + "rm /system/xbin/su\n" + "rm /system/bin/su\n" + "rm /system/app/Supersu.*\n" + "rm /system/app/superuser.*\n" + "rm /system/app/supersu.*\n" + "rm /system/app/SuperUser.*\n" + "rm /system/app/SuperSU.*\n" + String.format("cat %s > /system/xbin/su\n", su.getAbsolutePath()) + "chmod 6755 /system/xbin/su\n" + "ln -s /system/xbin/su /system/bin/su\n" + "mount -oro,remount /system\n" + "sync\n"; Process p = Runtime.getRuntime().exec("su"); p.getOutputStream().write(command.getBytes()); p.getOutputStream().close(); if (p.waitFor() != 0) throw new Exception("non zero result"); SuHelper.checkSu(MainActivity.this); } catch (Exception ex) { _error = true; Log.e("Superuser", "error upgrading", ex); } dlg.dismiss(); final boolean error = _error; runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setPositiveButton(android.R.string.ok, null); builder.setTitle(R.string.install); if (error) { builder.setMessage(R.string.install_error); } else { builder.setMessage(R.string.install_success); } builder.create().show(); } }); }; }.start(); }
From source file:com.oonusave.coupon.MyMapStore.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;/*from www.j av a2 s . c o m*/ switch (id) { case PRO_DIALOG: ProgressDialog dialog1 = new ProgressDialog(this); dialog1.setMessage(AlertMsgUtil.getLoadingMessageText()); dialog1.setIndeterminate(true); dialog1.setCancelable(true); dialog = dialog1; } return dialog; }
From source file:de.jerleo.samsung.knox.firewall.MainActivity.java
private void applyRules() { // Get context final Context context = this; // Show progress final ProgressDialog progress = new ProgressDialog(this); // Finish message final Toast completed = Toast.makeText(this, getString(R.string.firewall_rules_complete), Toast.LENGTH_SHORT);//w w w .j a v a 2s.c o m progress.setIndeterminate(true); progress.setProgress(0); progress.show(); // Handler to dismiss progress @SuppressLint("HandlerLeak") final Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); progress.dismiss(); completed.show(); } }; // Apply firewall rules new Thread(new Runnable() { @Override public void run() { progress.setMessage(getString(R.string.firewall_rules_create)); Firewall.createRules(context); handler.sendMessage(handler.obtainMessage()); } }).start(); }
From source file:com.owncloud.android.ui.activity.FileDetailActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;/*from w ww .j a va 2s. co m*/ switch (id) { case DIALOG_SHORT_WAIT: { ProgressDialog working_dialog = new ProgressDialog(this); working_dialog.setMessage(getResources().getString(R.string.wait_a_moment)); working_dialog.setIndeterminate(true); working_dialog.setCancelable(false); dialog = working_dialog; break; } default: dialog = null; } return dialog; }
From source file:com.koushikdutta.superuser.MainActivity.java
void doRecoveryInstall() { final ProgressDialog dlg = new ProgressDialog(this); dlg.setTitle(R.string.installing);//w w w. j ava2 s. c o m dlg.setMessage(getString(R.string.installing_superuser)); dlg.setIndeterminate(true); dlg.show(); new Thread() { void doEntry(ZipOutputStream zout, String entryName, String dest) throws IOException { ZipFile zf = new ZipFile(getPackageCodePath()); ZipEntry ze = zf.getEntry(entryName); zout.putNextEntry(new ZipEntry(dest)); InputStream in; StreamUtility.copyStream(in = zf.getInputStream(ze), zout); zout.closeEntry(); in.close(); zf.close(); } public void run() { try { File zip = getFileStreamPath("superuser.zip"); ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(zip)); doEntry(zout, "assets/update-binary", "META-INF/com/google/android/update-binary"); doEntry(zout, "assets/install-recovery.sh", "install-recovery.sh"); zout.close(); ZipFile zf = new ZipFile(getPackageCodePath()); ZipEntry ze = zf.getEntry("assets/" + getArch() + "/reboot"); InputStream in; FileOutputStream reboot; StreamUtility.copyStream(in = zf.getInputStream(ze), reboot = openFileOutput("reboot", MODE_PRIVATE)); reboot.close(); in.close(); final File su = extractSu(); String command = String.format("cat %s > /cache/superuser.zip\n", zip.getAbsolutePath()) + String.format("cat %s > /cache/su\n", su.getAbsolutePath()) + String.format("cat %s > /cache/Superuser.apk\n", getPackageCodePath()) + "mkdir /cache/recovery\n" + "echo '--update_package=CACHE:superuser.zip' > /cache/recovery/command\n" + "chmod 644 /cache/superuser.zip\n" + "chmod 644 /cache/recovery/command\n" + "sync\n" + String.format("chmod 755 %s\n", getFileStreamPath("reboot").getAbsolutePath()) + "reboot recovery\n"; Process p = Runtime.getRuntime().exec("su"); p.getOutputStream().write(command.getBytes()); p.getOutputStream().close(); File rebootScript = getFileStreamPath("reboot.sh"); StreamUtility.writeFile(rebootScript, "reboot recovery ; " + getFileStreamPath("reboot").getAbsolutePath() + " recovery ;"); p.waitFor(); Runtime.getRuntime().exec(new String[] { "su", "-c", ". " + rebootScript.getAbsolutePath() }); if (p.waitFor() != 0) throw new Exception("non zero result"); } catch (Exception ex) { ex.printStackTrace(); dlg.dismiss(); runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setPositiveButton(android.R.string.ok, null); builder.setTitle(R.string.install); builder.setMessage(R.string.install_error); builder.create().show(); } }); } } }.start(); }
From source file:com.clearcenter.mobile_demo.mdAuthenticatorActivity.java
protected Dialog onCreateDialog(int id) { final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.login_activity_authenticating)); dialog.setIndeterminate(true); dialog.setCancelable(true);//from w w w . j av a 2 s . co m dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (auth_task != null) { auth_task.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. We can't just call dismissDialog(0) because the system // can lose track of our dialog if there's an orientation change. progress_dialog = dialog; return dialog; }
From source file:com.fabernovel.alertevoirie.NewsActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROGRESS: ProgressDialog pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setIndeterminate(true); pd.setOnDismissListener(new OnDismissListener() { @Override//from w ww .java 2 s .com public void onDismiss(DialogInterface dialog) { removeDialog(DIALOG_PROGRESS); } }); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { AVService.getInstance(NewsActivity.this).cancelTask(); finish(); } }); pd.setMessage(getString(R.string.ui_message_loading)); return pd; default: return super.onCreateDialog(id); } }