List of usage examples for android.app AlertDialog.Builder setIcon
public void setIcon(Drawable icon)
From source file:com.fastbootmobile.encore.app.fragments.DspProvidersFragment.java
public void showAddEffect() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.add_effect); // Lookup all the DSP effects providers that aren't already in the chain final List<DSPConnection> availableDsp = PluginsLookup.getDefault().getAvailableDSPs(); final List<ProviderIdentifier> chain = PlaybackProxy.getDSPChain(); final List<DSPConnection> dsps = PluginsLookup.getDefault().getAvailableDSPs(); for (ProviderIdentifier pi : chain) { for (DSPConnection dsp : dsps) { if (dsp.getIdentifier().equals(pi)) { availableDsp.remove(dsp); }/*from www. j a v a 2s . c o m*/ } } if (availableDsp.size() > 0) { CharSequence[] items = new CharSequence[availableDsp.size()]; int i = 0; for (DSPConnection dsp : availableDsp) { items[i] = dsp.getProviderName(); i++; } builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { addEffectToChain(availableDsp.get(i)); updateDspChain(); dialogInterface.dismiss(); } }); builder.setIcon(R.drawable.ic_nav_listen_now); builder.setCancelable(true); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.show(); } else { Utils.shortToast(getActivity(), R.string.all_dsp_in_use); } }
From source file:net.evecom.android.PublicOpinionLookActivity.java
/** * /* w ww .j a va 2 s. c o m*/ */ private String submit() { /** */ if (ztEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (fsddEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (lylxButton.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (years == 0 || month == 0 || day == 0) { DialogToast(""); return ""; } else if (lyrEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (xxnrEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (lxdhEditText.getText().toString().trim().length() >= 1) { if (isCellphone(lxdhEditText.getText().toString().trim()) == false) { DialogToast(""); return ""; } } if ("4".equals(zt1)) { DialogToast(""); return ""; } else if ("2".equals(zt1)) { DialogToast(""); return ""; } else if ("3".equals(zt1)) { DialogToast(""); return ""; } final AlertDialog.Builder builder = new AlertDialog.Builder(PublicOpinionLookActivity.this); builder.setTitle(""); builder.setIcon(R.drawable.qq_dialog_default_icon);// builder.setMessage(""); builder.setPositiveButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { progressDialog = ProgressDialog.show(PublicOpinionLookActivity.this, "", "..."); formSubmit1(); } }); builder.setNegativeButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); return "1"; }
From source file:com.speed.traquer.app.TraqComplaintTaxi.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_traq_complaint_taxi); easyTracker = EasyTracker.getInstance(TraqComplaintTaxi.this); //onCreateView(savedInstanceState); //InitialSetupUI(); //Added UIHelper uiHelper = new UiLifecycleHelper(this, null); uiHelper.onCreate(savedInstanceState); inputTaxi = (EditText) findViewById(R.id.taxi_id); taxiDriver = (EditText) findViewById(R.id.taxi_driver); taxiLic = (EditText) findViewById(R.id.taxi_license); geoLat = (TextView) findViewById(R.id.geoLat); geoLong = (TextView) findViewById(R.id.geoLong); editDate = (EditText) findViewById(R.id.editDate); editTime = (EditText) findViewById(R.id.editTime); editCurrTime = (EditText) findViewById(R.id.editCurrTime); complainSend = (Button) findViewById(R.id.complain_send); ProgressBar barProgress = (ProgressBar) findViewById(R.id.progressLoading); ProgressBar barProgressFrom = (ProgressBar) findViewById(R.id.progressLoadingFrom); ProgressBar barProgressTo = (ProgressBar) findViewById(R.id.progressLoadingTo); actv_comp_taxi = (AutoCompleteTextView) findViewById(R.id.search_taxi_comp); SuggestionAdapter sa = new SuggestionAdapter(this, actv_comp_taxi.getText().toString(), taxiUrl, "compcode"); sa.setLoadingIndicator(barProgress); actv_comp_taxi.setAdapter(sa);/* w w w . j a va 2 s . c o m*/ actv_from = (AutoCompleteTextView) findViewById(R.id.search_from); SuggestionAdapter saFrom = new SuggestionAdapter(this, actv_from.getText().toString(), locUrl, "location"); saFrom.setLoadingIndicator(barProgressFrom); actv_from.setAdapter(saFrom); actv_to = (AutoCompleteTextView) findViewById(R.id.search_to); SuggestionAdapter saTo = new SuggestionAdapter(this, actv_to.getText().toString(), locUrl, "location"); saTo.setLoadingIndicator(barProgressTo); actv_to.setAdapter(saTo); /*if(isNetworkConnected()) { new getTaxiComp().execute(new ApiConnector()); }*/ //Setting Fonts String fontPath = "fonts/segoeuil.ttf"; Typeface tf = Typeface.createFromAsset(getAssets(), fontPath); complainSend.setTypeface(tf); inputTaxi.setTypeface(tf); editDate.setTypeface(tf); editTime.setTypeface(tf); actv_comp_taxi.setTypeface(tf); actv_to.setTypeface(tf); actv_from.setTypeface(tf); taxiDriver.setTypeface(tf); taxiLic.setTypeface(tf); TextView txtComp = (TextView) findViewById(R.id.taxi_comp); txtComp.setTypeface(tf); TextView txtTaxiDriver = (TextView) findViewById(R.id.txt_taxi_driver); txtTaxiDriver.setTypeface(tf); TextView txtTaxiLic = (TextView) findViewById(R.id.txt_taxi_license); txtTaxiLic.setTypeface(tf); TextView txtNumber = (TextView) findViewById(R.id.taxi_number); txtNumber.setTypeface(tf); TextView txtTo = (TextView) findViewById(R.id.to); txtTo.setTypeface(tf); TextView txtDate = (TextView) findViewById(R.id.date); txtDate.setTypeface(tf); TextView txtTime = (TextView) findViewById(R.id.time); txtTime.setTypeface(tf); gLongitude = this.getIntent().getExtras().getDouble("Longitude"); gLatitude = this.getIntent().getExtras().getDouble("Latitude"); speedTaxiExceed = this.getIntent().getExtras().getDouble("SpeedTaxiExceed"); isTwitterSelected = false; isFacebookSelected = false; isDefaultSelected = false; isSmsSelected = false; geoLat.setText(Double.toString(gLatitude)); geoLong.setText(Double.toString(gLongitude)); rateBtnBus = (ImageButton) findViewById(R.id.btn_rate_bus); rateBtnBus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (actv_comp_taxi.length() != 0) { final AlertDialog.Builder alertBox = new AlertDialog.Builder(TraqComplaintTaxi.this); alertBox.setIcon(R.drawable.info_icon); alertBox.setCancelable(false); alertBox.setTitle("Do you want to cancel complaint?"); alertBox.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // finish used for destroyed activity easyTracker.send(MapBuilder .createEvent("Complaint", "Cancel Complaint (Yes)", "Complaint event", null) .build()); finish(); } }); alertBox.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { easyTracker.send(MapBuilder .createEvent("Complaint", "Cancel Complaint (No)", "Complaint event", null) .build()); dialog.cancel(); } }); alertBox.show(); } else { Intent intent = new Intent(getApplicationContext(), TraqComplaint.class); intent.putExtra("Latitude", gLatitude); intent.putExtra("Longitude", gLongitude); intent.putExtra("SpeedBusExceed", speedTaxiExceed); startActivity(intent); } } }); complainSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String taxi_id = inputTaxi.getText().toString().toUpperCase(); String taxi_comp = actv_comp_taxi.getText().toString(); /*if(taxi_comp.length() == 0){ Toast.makeText(TraqComplaintTaxi.this, "Taxi Company is required!", Toast.LENGTH_SHORT).show(); }else */ if (taxi_comp.length() < 2) { Toast.makeText(TraqComplaintTaxi.this, "Invalid Taxi Company.", Toast.LENGTH_SHORT).show(); } else if (taxi_id.length() == 0) { Toast.makeText(TraqComplaintTaxi.this, "Taxi Plate Number is required!", Toast.LENGTH_SHORT) .show(); } else if (taxi_id.length() < 7) { Toast.makeText(TraqComplaintTaxi.this, "Invalid Taxi Number.", Toast.LENGTH_SHORT).show(); } else { easyTracker.send( MapBuilder.createEvent("Complaint", "Dialog Prompt", "Complaint event", null).build()); PromptCustomDialog(); } } }); setCurrentDateOnView(); getCurrentTime(); //Shi Chuan's Code StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); cd = new ConnectionDetector(getApplicationContext()); // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog(TraqComplaintTaxi.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return; } // Check if twitter keys are set if (TWITTER_CONSUMER_KEY.trim().length() == 0 || TWITTER_CONSUMER_SECRET.trim().length() == 0) { // Internet Connection is not present alert.showAlertDialog(TraqComplaintTaxi.this, "Twitter oAuth tokens", "Please set your twitter oauth tokens first!", false); // stop executing code by return return; } // Shared Preferences mSharedPreferences = getApplicationContext().getSharedPreferences("MyPref", 0); /** This if conditions is tested once is * redirected from twitter page. Parse the uri to get oAuth * Verifier * */ if (!isTwitterLoggedInAlready()) { Uri uri = getIntent().getData(); if (uri != null && uri.toString().startsWith(TWITTER_CALLBACK_URL)) { // oAuth verifier String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER); try { // Get the access token AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier); // Shared Preferences SharedPreferences.Editor e = mSharedPreferences.edit(); // After getting access token, access token secret // store them in application preferences e.putString(PREF_KEY_OAUTH_TOKEN, accessToken.getToken()); e.putString(PREF_KEY_OAUTH_SECRET, accessToken.getTokenSecret()); // Store login status - true e.putBoolean(PREF_KEY_TWITTER_LOGIN, true); e.commit(); // save changes Log.e("Twitter OAuth Token", "> " + accessToken.getToken()); // Getting user details from twitter // For now i am getting his name only long userID = accessToken.getUserId(); User user = twitter.showUser(userID); String username = user.getName(); String description = user.getDescription(); // Displaying in xml ui //lblUserName.setText(Html.fromHtml("<b>Welcome " + username + "</b>" + description)); } catch (Exception e) { // Check log for login errors Log.e("Twitter Login Error", "> " + e.getMessage()); } } } //LocationManager lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); //LocationListener ll = new passengerLocationListener(); //lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll); }
From source file:eu.alefzero.owncloud.ui.activity.FileDisplayActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;/*from w ww . j av a2 s .c om*/ AlertDialog.Builder builder; switch (id) { case DIALOG_SETUP_ACCOUNT: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.main_tit_accsetup); builder.setMessage(R.string.main_wrn_accsetup); builder.setCancelable(false); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(android.R.string.cancel, this); dialog = builder.create(); break; case DIALOG_ABOUT_APP: { builder = new AlertDialog.Builder(this); builder.setTitle("About"); PackageInfo pkg; try { pkg = getPackageManager().getPackageInfo(getPackageName(), 0); builder.setMessage("ownCloud android client\n\nversion: " + pkg.versionName); builder.setIcon(android.R.drawable.ic_menu_info_details); dialog = builder.create(); } catch (NameNotFoundException e) { builder = null; dialog = null; e.printStackTrace(); } break; } case DIALOG_CREATE_DIR: { builder = new Builder(this); final EditText dirNameInput = new EditText(getBaseContext()); final Account a = AccountUtils.getCurrentOwnCloudAccount(this); builder.setView(dirNameInput); builder.setTitle(R.string.uploader_info_dirname); int typed_color = getResources().getColor(R.color.setup_text_typed); dirNameInput.setTextColor(typed_color); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { String directoryName = dirNameInput.getText().toString(); if (directoryName.trim().length() == 0) { dialog.cancel(); return; } // Figure out the path where the dir needs to be created String path; if (mCurrentDir == null) { // this is just a patch; we should ensure that mCurrentDir never is null if (!mStorageManager.fileExists(OCFile.PATH_SEPARATOR)) { OCFile file = new OCFile(OCFile.PATH_SEPARATOR); mStorageManager.saveFile(file); } mCurrentDir = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); } path = FileDisplayActivity.this.mCurrentDir.getRemotePath(); // Create directory path += directoryName + OCFile.PATH_SEPARATOR; Thread thread = new Thread(new DirectoryCreator(path, a)); thread.start(); // Save new directory in local database OCFile newDir = new OCFile(path); newDir.setMimetype("DIR"); newDir.setParentId(mCurrentDir.getFileId()); mStorageManager.saveFile(newDir); // Display the new folder right away dialog.dismiss(); mFileList.listDirectory(mCurrentDir); } }); builder.setNegativeButton(R.string.common_cancel, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); dialog = builder.create(); break; } default: dialog = null; } return dialog; }
From source file:com.owncloud.android.ui.activity.Uploader.java
@Override protected Dialog onCreateDialog(final int id) { final AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_WAITING: final ProgressDialog pDialog = new ProgressDialog(this, R.style.ProgressDialogTheme); pDialog.setIndeterminate(false); pDialog.setCancelable(false);/* w ww. j ava 2s . c o m*/ pDialog.setMessage(getResources().getString(R.string.uploader_info_uploading)); pDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ProgressBar v = (ProgressBar) pDialog.findViewById(android.R.id.progress); v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.color_accent), android.graphics.PorterDuff.Mode.MULTIPLY); } }); return pDialog; case DIALOG_NO_ACCOUNT: builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.uploader_wrn_no_account_title); builder.setMessage( String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name))); builder.setCancelable(false); builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) { // using string value since in API7 this // constatn is not defined // in API7 < this constatant is defined in // Settings.ADD_ACCOUNT_SETTINGS // and Settings.EXTRA_AUTHORITIES Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() }); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } else { // since in API7 there is no direct call for // account setup, so we need to // show our own AccountSetupAcricity, get // desired results and setup // everything for ourself Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } } }); builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); case DIALOG_MULTIPLE_ACCOUNT: CharSequence ac[] = new CharSequence[mAccountManager .getAccountsByType(MainApp.getAccountType()).length]; for (int i = 0; i < ac.length; ++i) { ac[i] = DisplayUtils.convertIdn(mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false); } builder.setTitle(R.string.common_choose_account); builder.setItems(ac, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]); onAccountSet(mAccountWasRestored); dialog.dismiss(); mAccountSelected = true; mAccountSelectionShowing = false; } }); builder.setCancelable(true); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mAccountSelectionShowing = false; dialog.cancel(); finish(); } }); return builder.create(); case DIALOG_NO_STREAM: builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.uploader_wrn_no_content_title); builder.setMessage(R.string.uploader_wrn_no_content_text); builder.setCancelable(false); builder.setNegativeButton(R.string.common_cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); default: throw new IllegalArgumentException("Unknown dialog id: " + id); } }
From source file:csh.cryptonite.Cryptonite.java
/** Called when the activity is first created. */ @Override// w ww. j a va 2 s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); getResources(); if (!hasJni) { jniFail(); return; } mDataSource = new VolumesDataSource(this); mDataSource.open(); encfsVersion = "EncFS " + jniEncFSVersion(); opensslVersion = jniOpenSSLVersion(); bcWallet = jniBcWallet(); textOut = encfsVersion + "\n" + opensslVersion + "\nBC donations: " + bcWallet; Log.v(TAG, encfsVersion + " " + opensslVersion); updateDecryptDelayed = false; SharedPreferences prefs = getBaseContext().getSharedPreferences(ACCOUNT_PREFS_NAME, 0); setupReadDirs(prefs.getBoolean("cb_extcache", false)); StorageManager.INSTANCE.initLocalStorage(this); if (!externalStorageIsWritable() || !ShellUtils.supportsFuse()) { mountInfo = getString(R.string.mount_info_unsupported); } else { mountInfo = getString(R.string.mount_info); DirectorySettings.INSTANCE.mntDir = prefs.getString("txt_mntpoint", Cryptonite.defaultMntDir()); File mntDirF = new File(DirectorySettings.INSTANCE.mntDir); if (!mntDirF.exists()) { mntDirF.mkdirs(); } } DirectorySettings.INSTANCE.binDirPath = getFilesDir().getParentFile().getPath(); DirectorySettings.INSTANCE.encFSBin = DirectorySettings.INSTANCE.binDirPath + "/encfs"; hasFuse = ShellUtils.supportsFuse(); /* Running from Instrumentation? */ if (getIntent() != null) { mInstrumentation = getIntent().getBooleanExtra("csh.cryptonite.instrumentation", false); } else { mInstrumentation = false; } if (needsEncFSBinary()) { ProgressDialogFragment.showDialog(this, R.string.copying_bins, "copyingBins"); new Thread(new Runnable() { public void run() { cpBin("encfs"); cpBin("truecrypt"); runOnUiThread(new Runnable() { public void run() { ProgressDialogFragment.dismissDialog(Cryptonite.this, "copyingBins"); setEncFSBinaryVersion(); } }); } }).start(); } mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); mTabsAdapter.addTab(mTabHost.newTabSpec(DBTAB_TAG).setIndicator(getString(R.string.dropbox_tabtitle)), DropboxFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(LOCALTAB_TAG).setIndicator(getString(R.string.local_tabtitle)), LocalFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(EXPERTTAB_TAG).setIndicator(getString(R.string.expert_tabtitle)), ExpertFragment.class, null); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); opMode = savedInstanceState.getInt("opMode"); if (savedInstanceState.getString("currentReturnPath") != null) { currentReturnPath = savedInstanceState.getString("currentReturnPath"); } if (savedInstanceState.getString("currentDialogStartPath") != null) { currentDialogStartPath = savedInstanceState.getString("currentDialogStartPath"); } if (savedInstanceState.getString("currentDialogRoot") != null) { currentDialogRoot = savedInstanceState.getString("currentDialogRoot"); } if (savedInstanceState.getString("currentDialogLabel") != null) { currentDialogLabel = savedInstanceState.getString("currentDialogLabel"); } if (savedInstanceState.getString("currentDialogButtonLabel") != null) { currentDialogButtonLabel = savedInstanceState.getString("currentDialogButtonLabel"); } if (savedInstanceState.getString("currentDialogRootName") != null) { currentDialogRootName = savedInstanceState.getString("currentDialogRootName"); } if (savedInstanceState.getString("currentOpenPath") != null) { currentOpenPath = savedInstanceState.getString("currentOpenPath"); } if (savedInstanceState.getString("currentUploadTargetPath") != null) { currentUploadTargetPath = savedInstanceState.getString("currentUploadTargetPath"); } if (savedInstanceState.getString("encfsBrowseRoot") != null) { encfsBrowseRoot = savedInstanceState.getString("encfsBrowseRoot"); } if (savedInstanceState.getString("currentConfigFile") != null) { currentConfigFile = savedInstanceState.getString("currentConfigFile"); } if (savedInstanceState.getStringArray("currentReturnPathList") != null) { currentReturnPathList = savedInstanceState.getStringArray("currentReturnPathList"); } if (savedInstanceState.getInt("currentDialogMode") != 0) { currentDialogMode = savedInstanceState.getInt("currentDialogMode"); } disclaimerShown = savedInstanceState.getBoolean("disclaimerShown"); if (currentReturnPath != null && currentDialogStartPath != null) { DirectorySettings.INSTANCE.currentBrowsePath = currentReturnPath; DirectorySettings.INSTANCE.currentBrowseStartPath = currentDialogStartPath; } int storageType = savedInstanceState.getInt("storageType"); if (storageType != Storage.STOR_UNDEFINED) { StorageManager.INSTANCE.initEncFSStorage(this, storageType); if (savedInstanceState.getString("encFSPath") != null) { StorageManager.INSTANCE.setEncFSPath(savedInstanceState.getString("encFSPath")); } } } String oAuth2AccessToken = getOAuth2AccessToken(); if (oAuth2AccessToken != null) { if (prefs.getBoolean("dbDecided", false)) { setSession(prefs.getBoolean("cb_appfolder", false), false); updateDecryptButtons(); } } if (DropboxInterface.INSTANCE.getDBApi() != null && DropboxInterface.INSTANCE.getDBApi().getSession() != null) { mLoggedIn = DropboxInterface.INSTANCE.getDBApi().getSession().isLinked(); } else { mLoggedIn = false; } if (!mInstrumentation && !prefs.getBoolean("cb_norris", false) && !disclaimerShown) { AlertDialog.Builder builder = new AlertDialog.Builder(Cryptonite.this); builder.setIcon(R.drawable.ic_launcher_cryptonite).setTitle(R.string.disclaimer) .setMessage(R.string.no_warranty) .setPositiveButton(R.string.understand, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { disclaimerShown = true; } }); AlertDialog dialog = builder.create(); dialog.show(); } }
From source file:com.cerema.cloud2.ui.activity.Uploader.java
@Override protected Dialog onCreateDialog(final int id) { final AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_WAITING: final ProgressDialog pDialog = new ProgressDialog(this, R.style.ProgressDialogTheme); pDialog.setIndeterminate(false); pDialog.setCancelable(false);/* ww w.j ava 2 s. co m*/ pDialog.setMessage(getResources().getString(R.string.uploader_info_uploading)); pDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ProgressBar v = (ProgressBar) pDialog.findViewById(android.R.id.progress); v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.color_accent), android.graphics.PorterDuff.Mode.MULTIPLY); } }); return pDialog; case DIALOG_NO_ACCOUNT: builder.setIcon(R.drawable.ic_warning); builder.setTitle(R.string.uploader_wrn_no_account_title); builder.setMessage( String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name))); builder.setCancelable(false); builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) { // using string value since in API7 this // constant is not defined // in API7 < this constant is defined in // Settings.ADD_ACCOUNT_SETTINGS // and Settings.EXTRA_AUTHORITIES Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() }); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } else { // since in API7 there is no direct call for // account setup, so we need to // show our own AccountSetupAcricity, get // desired results and setup // everything for ourself Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } } }); builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); case DIALOG_MULTIPLE_ACCOUNT: CharSequence ac[] = new CharSequence[mAccountManager .getAccountsByType(MainApp.getAccountType()).length]; for (int i = 0; i < ac.length; ++i) { ac[i] = DisplayUtils.convertIdn(mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false); } builder.setTitle(R.string.common_choose_account); builder.setItems(ac, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]); onAccountSet(mAccountWasRestored); dialog.dismiss(); mAccountSelected = true; mAccountSelectionShowing = false; } }); builder.setCancelable(true); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mAccountSelectionShowing = false; dialog.cancel(); finish(); } }); return builder.create(); case DIALOG_NO_STREAM: builder.setIcon(R.drawable.ic_warning); builder.setTitle(R.string.uploader_wrn_no_content_title); builder.setMessage(R.string.uploader_wrn_no_content_text); builder.setCancelable(false); builder.setNegativeButton(R.string.common_cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); default: throw new IllegalArgumentException("Unknown dialog id: " + id); } }
From source file:com.synox.android.ui.activity.Uploader.java
@Override protected Dialog onCreateDialog(final int id) { final AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_WAITING: final ProgressDialog pDialog = new ProgressDialog(this, R.style.ProgressDialogTheme); pDialog.setIndeterminate(false); pDialog.setCancelable(false);/*from ww w .j av a2 s .com*/ pDialog.setMessage(getResources().getString(R.string.uploader_info_uploading)); pDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ProgressBar v = (ProgressBar) pDialog.findViewById(android.R.id.progress); v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.accent), android.graphics.PorterDuff.Mode.MULTIPLY); } }); return pDialog; case DIALOG_NO_ACCOUNT: builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.uploader_wrn_no_account_title); builder.setMessage( String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name))); builder.setCancelable(false); builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) { // using string value since in API7 this // constatn is not defined // in API7 < this constatant is defined in // Settings.ADD_ACCOUNT_SETTINGS // and Settings.EXTRA_AUTHORITIES Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() }); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } else { // since in API7 there is no direct call for // account setup, so we need to // show our own AccountSetupAcricity, get // desired results and setup // everything for ourself Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } } }); builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); case DIALOG_MULTIPLE_ACCOUNT: CharSequence ac[] = new CharSequence[mAccountManager .getAccountsByType(MainApp.getAccountType()).length]; for (int i = 0; i < ac.length; ++i) { ac[i] = DisplayUtils.convertIdn(mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false); } builder.setTitle(R.string.common_choose_account); builder.setItems(ac, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]); onAccountSet(mAccountWasRestored); dialog.dismiss(); mAccountSelected = true; mAccountSelectionShowing = false; } }); builder.setCancelable(true); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mAccountSelectionShowing = false; dialog.cancel(); finish(); } }); return builder.create(); case DIALOG_NO_STREAM: builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.uploader_wrn_no_content_title); builder.setMessage(R.string.uploader_wrn_no_content_text); builder.setCancelable(false); builder.setNegativeButton(R.string.common_cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); default: throw new IllegalArgumentException("Unknown dialog id: " + id); } }
From source file:jackpal.androidterm.Term.java
private void confirmCloseWindow() { final AlertDialog.Builder b = new AlertDialog.Builder(this); b.setIcon(android.R.drawable.ic_dialog_alert); b.setMessage(R.string.confirm_window_close_message); final Runnable closeWindow = new Runnable() { public void run() { doCloseWindow();// w w w.j a va2 s . c o m } }; b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); mHandler.post(closeWindow); } }); b.setNegativeButton(android.R.string.no, null); b.show(); }