List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:org.anhonesteffort.flock.SubscriptionGoogleFragment.java
private void handlePromptCancelSubscription() { AlertDialog.Builder builder = new AlertDialog.Builder(subscriptionActivity); builder.setTitle(R.string.cancel_subscription); builder.setMessage(R.string.are_you_sure_you_want_to_cancel_your_flock_subscription); builder.setNegativeButton(R.string.no, null); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override/*from ww w . ja va2s. co m*/ public void onClick(DialogInterface dialog, int id) { handleCancelSubscription(); } }); alertDialog = builder.show(); }
From source file:net.reichholf.dreamdroid.activities.ServiceListActivity.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { mCurrentItem = mMapList.get(position); final String ref = mCurrentItem.getString(Event.SERVICE_REFERENCE); final String nam = mCurrentItem.getString(Event.SERVICE_NAME); final String title = mCurrentItem.getString(Event.EVENT_TITLE); if (isBouquetReference(ref)) { if (!isListTaskRunning()) { mIsBouquetList = true;/*from ww w. j a v a 2s.c o m*/ // Second hierarchy level -> we get a List of Services now if (isBouquetReference(mReference)) { mIsBouquetList = false; } ExtendedHashMap map = new ExtendedHashMap(); map.put(Event.SERVICE_REFERENCE, String.valueOf(mReference)); map.put(Event.SERVICE_NAME, String.valueOf(mName)); mHistory.add(map); mReference = ref; mName = nam; reload(); } else { showToast(getText(R.string.wait_request_finished)); } } else { if (mPickMode) { ExtendedHashMap map = new ExtendedHashMap(); map.put(Event.SERVICE_REFERENCE, ref); map.put(Event.SERVICE_NAME, nam); Intent intent = new Intent(); intent.putExtra(sData, map); setResult(RESULT_OK, intent); finish(); } else { CharSequence[] actions = { getText(R.string.current_event), getText(R.string.browse_epg), getText(R.string.zap), getText(R.string.similar), getText(R.string.stream) }; AlertDialog.Builder adBuilder = new AlertDialog.Builder(this); adBuilder.setTitle(getText(R.string.pick_action)); adBuilder.setItems(actions, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: removeDialog(DIALOG_EPG_ITEM_ID); showDialog(DIALOG_EPG_ITEM_ID); break; case 1: openEpg(ref, nam); break; case 2: zapTo(ref); break; case 3: openSimilar(title); break; case 4: streamService(ref); break; } } }); AlertDialog alert = adBuilder.create(); alert.show(); } } }
From source file:dtu.ds.warnme.app.dialog.RegisterDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_register, null); builder.setView(view);// w ww .j av a2 s . co m builder.setTitle(R.string.register); builder.setPositiveButton(R.string.register, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing to do here... } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing to do here... } }); progressView = view.findViewById(R.id.dialog_register_progress); formView = view.findViewById(R.id.dialog_register_form); usernameEditText = (EditText) view.findViewById(R.id.dialog_register_edit_text_username); usernameEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // Nothing to do here... } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do here... } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { usernameEditText.setError(null); } }); passwordEditText = (EditText) view.findViewById(R.id.dialog_register_edit_text_password); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // Nothing to do here... } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do here... } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { passwordEditText.setError(null); } }); emailEditText = (EditText) view.findViewById(R.id.dialog_register_edit_text_email); emailEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // Nothing to do here... } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do here... } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { emailEditText.setError(null); } }); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = usernameEditText.getText().toString(); String password = passwordEditText.getText().toString(); String email = emailEditText.getText().toString(); boolean formOk = true; if (StringUtils.isBlank(username)) { usernameEditText.setError(getString(R.string.cannot_be_empty)); formOk = false; } if (StringUtils.isBlank(password)) { passwordEditText.setError(getString(R.string.cannot_be_empty)); formOk = false; } if (StringUtils.isBlank(email)) { emailEditText.setError(getString(R.string.cannot_be_empty)); formOk = false; } if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) { emailEditText.setError(getString(R.string.invalid_email)); formOk = false; } if (!formOk) { Log.d(TAG, "Form contains errors."); return; } password = SecurityUtils.hashSHA512Base64(password); User newUser = new User(); newUser.setUsername(username); newUser.setPassword(password); newUser.setEmail(email); tempRestClient = new RestClient(Prefs.getHost(), Prefs.getPort(), Prefs.getWsContextPath(), username, password, Prefs.getRealm()); tempRestClient.registerUser(dialog.getContext(), newUser, new GsonHttpResponseHandler<User>(new TypeToken<User>() { }.getType()) { @Override public void onFailure(int statusCode, Header[] headers, String responseBody, Throwable error) { Log.e(TAG, "Registration failed. [statusCode = " + statusCode + ", error=" + error + "]"); if (statusCode == 0) { Toast.makeText(dialog.getOwnerActivity(), R.string.check_connection, Toast.LENGTH_LONG).show(); ; return; } Toast.makeText(dialog.getContext(), R.string.pick_different_username, Toast.LENGTH_LONG).show(); listener.onRegisterFailure(); } @Override public void onFinish() { positiveButton.setEnabled(true); UiUtilities.fadeInFadeOut(formView, progressView); } @Override public void onStart() { positiveButton.setEnabled(false); UiUtilities.fadeInFadeOut(progressView, formView); } @Override public void onSuccess(int statusCode, Header[] headers, User object) { Log.i(TAG, "Registration succeeded. [statusCode = " + statusCode + "]"); dialog.dismiss(); listener.onRegisterSuccess(); } }); } }); final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (tempRestClient != null) { tempRestClient.cancelRequests(dialog.getOwnerActivity(), true); } dialog.dismiss(); } }); } }); return dialog; }
From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java
private Dialog assignFailDialog(Context context, String str) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false);/*from w w w .j a va 2 s. c om*/ builder.setTitle(R.string.assign_confirm_title); builder.setMessage(str); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { setHints(); } }); return builder.create(); }
From source file:com.chaturs.notepad.NoteEditor.java
private void showDialogForTitle() { View view = LayoutInflater.from(this).inflate(R.layout.dialog_title, null); final EditText edit = (EditText) view.findViewById(R.id.edit); Button okButton = (Button) view.findViewById(R.id.ok); Button cancelButton = (Button) view.findViewById(R.id.cancel); edit.setText(title);//from w w w .j av a2 s .c om AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Enter Title"); builder.setView(view); builder.setCancelable(false); okButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { title = edit.getText().toString(); if (title.trim().length() == 0) { edit.setError("Please Enter Some Text !"); return; } saveNote(); setTitle(title); dialog.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); }
From source file:com.safecell.ManageProfile_Activity.java
void displayDialog(String title, String inputText, final int position) { LayoutInflater li = LayoutInflater.from(this); View dialogView = li.inflate(R.layout.dialog_edittext_input, null); dialogInputEditText = (EditText) dialogView.findViewById(R.id.DialogEditTextInputEditText); dialogInputEditText.setText(inputText); dialogInputEditText.setInputType(setInputTypeKeyBoard(position)); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title).setInverseBackgroundForced(true).setView(dialogView).setCancelable(false) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { String text = dialogInputEditText.getText().toString(); if (!text.equalsIgnoreCase("")) { if (position == 2) { if (validationForEmailAddress(text)) { setDialogValuesListArrayAdapter(position); dialog.cancel(); } else { dialog.cancel(); }/*from w w w . j a va2 s .c om*/ } else { setDialogValuesListArrayAdapter(position); dialog.cancel(); } } else { Toast.makeText(context, "Blank not allowed.", Toast.LENGTH_SHORT).show(); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); }
From source file:com.irccloud.android.fragment.EditConnectionFragment.java
private void init(View v) { channelsWrapper = (LinearLayout) v.findViewById(R.id.channels_wrapper); presets = (Spinner) v.findViewById(R.id.presets); hostname = (EditText) v.findViewById(R.id.hostname); port = (EditText) v.findViewById(R.id.port); ssl = (SwitchCompat) v.findViewById(R.id.ssl); nickname = (EditText) v.findViewById(R.id.nickname); realname = (EditText) v.findViewById(R.id.realname); channels = (EditText) v.findViewById(R.id.channels); nickserv_pass = (EditText) v.findViewById(R.id.nickservpassword); join_commands = (EditText) v.findViewById(R.id.commands); server_pass = (EditText) v.findViewById(R.id.serverpassword); network = (EditText) v.findViewById(R.id.network); presets.setOnItemSelectedListener(new OnItemSelectedListener() { @Override//from www . java 2 s . c o m public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { if (server != null) { hostname.setText(server.hostname); port.setText(String.valueOf(server.port)); ssl.setChecked(server.ssl == 1); } else { if (default_hostname != null) hostname.setText(default_hostname); else hostname.setText(""); port.setText(String.valueOf(default_port)); ssl.setChecked(default_port == 6697); } } else { PresetServersAdapter.PresetServer s = (PresetServersAdapter.PresetServer) adapter .getItem(position); hostname.setText(s.host); port.setText(String.valueOf(s.port)); ssl.setChecked(s.port == 6697); } } @Override public void onNothingSelected(AdapterView<?> parent) { if (server != null) { hostname.setText(server.hostname); port.setText(String.valueOf(server.port)); ssl.setChecked(server.ssl == 1); } else { if (default_hostname != null) hostname.setText(default_hostname); else hostname.setText(""); port.setText(String.valueOf(default_port)); ssl.setChecked(default_port == 6697); } } }); if (NetworkConnection.getInstance().getUserInfo() != null && !NetworkConnection.getInstance().getUserInfo().verified) { Button b = (Button) v.findViewById(R.id.resend); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NetworkConnection.getInstance().resend_verify_email(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Confirmation Sent"); builder.setMessage("You should shortly receive an email with a link to confirm your address."); builder.setNeutralButton("Close", null); builder.show(); } }); v.findViewById(R.id.unverified).setVisibility(View.VISIBLE); } }
From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java
void createAccountWithFbId() { mPrefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = mPrefs.edit(); editor.putString("access_token", facebook.getAccessToken()); editor.putLong("access_expires", facebook.getAccessExpires()); editor.commit();/*from w ww .j a v a 2 s. com*/ String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if (access_token != null) { facebook.setAccessToken(access_token); } if (expires != 0) { facebook.setAccessExpires(expires); } /* * Only call authorize if the access_token has expired. */ if (facebook.isSessionValid()) { Log.i(tag, "Session is valid"); JSONObject json; try { json = Util.parseJson(facebook.request("me", new Bundle())); Log.i(tag, "json: " + json); fbId = json.getString("id"); String username = json.getString("id"); JSONArray existingUser = new Cloud(getApplicationContext(), fbId, null).findExistingFbUser(fbId, countryCode + mPhone); Log.i(tag, "existingUser: " + existingUser.getString(0)); LayoutInflater factory = LayoutInflater.from(this); textEntryView = factory.inflate(R.layout.facebook_email_layout, null); TextView fbUsername = (TextView) textEntryView.findViewById(R.id.facebookLogin_email); TextView fbPassword = (TextView) textEntryView.findViewById(R.id.facebookLogin_password); Button fbAccountButton = (Button) textEntryView.findViewById(R.id.facebookLogin); if (existingUser.getString(0).trim().length() == 0) { Log.i(tag, "email: " + Text.isEmail(username)); if (!(Text.isEmail(username))) { AlertDialog.Builder newBuilder = new AlertDialog.Builder(this); newBuilder.setTitle("FbLogin to Phonebook"); newBuilder.setView(textEntryView); Button existingFbAccount = (Button) textEntryView .findViewById(R.id.existingAccountfacebookLogin); existingFbAccount.setVisibility(View.GONE); AlertDialog newAlert = newBuilder.create(); newAlert.show(); } } else { fbAccountButton.setVisibility(View.GONE); fbUsername.setText(existingUser.getString(0)); fbUsername.setEnabled(false); fbPassword.requestFocus(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("FbLogin to Phonebook"); builder.setView(textEntryView); AlertDialog alert = builder.create(); alert.show(); } //mPhone = mPhoneEdit.getText().toString(); //new Cloud(getApplicationContext(), userId, userId).loginWithFacebook(countryCode + mPhone); /*mUsername = userName; mPassword = userId;*/ //finishLogin(); // mUsernameEdit.setText(userName); // mPasswordEdit.setText(userId); Log.i(tag, "userName: " + username + " userId: " + fbId); Log.i(tag, "response:" + json); } catch (Exception e1) { Log.e(tag, "Exception logging on with Facebook: " + e1); e1.printStackTrace(); } catch (FacebookError e) { Log.e(tag, "Facebook error logging on with Facebook: " + e); e.printStackTrace(); } } }
From source file:com.guardtrax.ui.screens.SplashScreen.java
private void initialize() { if (locationManagerObj == null) { locationManagerObj = (LocationManager) getSystemService(Context.LOCATION_SERVICE); try {/*from ww w. ja v a 2 s.c o m*/ gps_enabled = locationManagerObj.isProviderEnabled(LocationManager.GPS_PROVIDER); //network_enabled = locationManagerObj.isProviderEnabled(LocationManager.NETWORK_PROVIDER); } catch (Exception ex) { } } // don't start listeners if no provider is enabled - Changed to to look for both //if (!gps_enabled) if (!gps_enabled && !network_enabled) { AlertDialog.Builder dialog = new AlertDialog.Builder(SplashScreen.this); dialog.setTitle("Info"); dialog.setMessage("Please enable GPS!"); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { System.exit(0); } }); dialog.show(); } else { Runnable showWaitDialog = new Runnable() { @Override public void run() { Looper.prepare(); int i = 0; //if syncComplete is true already it means that we are not trying to sync, hence delay so that splash screen can close slowly if (syncComplete) { try { Thread.sleep(1000); } catch (Exception e) { } } else { while (!syncComplete || i++ < 10) { try { Thread.sleep(1000); } catch (Exception e) { break; } } //make sure background task is completed. If not, force it closed if (!syncComplete) { try { if (syncdb.getStatus() != AsyncTask.Status.FINISHED) syncdb.cancel(true); } catch (Exception e) { } } } //After receiving first GPS Fix dismiss the Progress Dialog dialog.dismiss(); //calling the tab class causes the current tab to be displayed (set to tab(0) which is the HomeScreen) Intent intent = new Intent(); intent.setClass(SplashScreen.this, HomeScreen.class); startActivity(intent); //transition from splash to main menu is slowed down to a fade by this command overridePendingTransition(R.anim.activityfadein, R.anim.splashfadeout); SplashScreen.this.finish(); } }; // Create a Dialog to let the User know that we're waiting for a GPS Fix dialog = ProgressDialog.show(SplashScreen.this, "Please wait", "Initializing ...", true); Thread t = new Thread(showWaitDialog); t.start(); } }
From source file:fi.mikuz.boarder.gui.internet.InternetMenu.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.internet_menu); setTitle("Internet Menu"); this.setVolumeControlStream(AudioManager.STREAM_MUSIC); mWaitDialog = new TimeoutProgressDialog(this, "Waiting for response", TAG, true); mInternetDownload = (Button) findViewById(R.id.internet_download); mInternetRegisterSettings = (Button) findViewById(R.id.internet_register_settings); mInternetLoginLogout = (Button) findViewById(R.id.internet_login_logout); mInternetUploads = (Button) findViewById(R.id.internet_uploads); mInternetFavorites = (Button) findViewById(R.id.internet_favorites); mAccountMessage = (TextView) findViewById(R.id.account_message_text); mDbHelper = new LoginDbAdapter(this); mDbHelper.open();/*from w w w. j a va2 s. c o m*/ mGlobalVariableDbHelper = new GlobalVariablesDbAdapter(this); mGlobalVariableDbHelper.open(); int dbTosVersion = 0; try { Cursor variableCursor = mGlobalVariableDbHelper.fetchVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY); startManagingCursor(variableCursor); dbTosVersion = variableCursor.getInt(variableCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)); } catch (SQLException e) { mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, 0); Log.d(TAG, "Couldn't get tosVersion", e); } catch (CursorIndexOutOfBoundsException e) { mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, 0); Log.d(TAG, "Couldn't get tosVersion", e); } if (dbTosVersion < mTosVersion) { AlertDialog.Builder builder = new AlertDialog.Builder(InternetMenu.this); builder.setTitle("Terms of service"); builder.setMessage("Excited to get your hands on those sweet boards? - Good.\n\n" + "There are some terms you must agree to and follow to get things rolling smoothly;\n\n" + "You may only communicate in English in the Boarder Internet service.\n\n" + "An uploaded board may contain any languages. However, if the board is not 'in English' that must be visibly stated in the description.\n\n" + "You agree to always follow applicable laws when using Boarder.\n\n" + "Pornographic and other adult only material is not allowed.\n\n" + "You must be at least 13 years old to register to the Boarder Internet service.\n\n" + "You may never transmit anything or communicate a way that can be deemed offensive.\n\n" + "Don't make cheap copies of another users boards.\n\n" + "We can use material(s) publicly shared by you as promotional material.\n\n" + "We will suspend your Boarder releated accounts and/or remove your material from the Boarder service if you behave badly."); builder.setPositiveButton("Agree", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mGlobalVariableDbHelper.updateIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, mTosVersion); } }); builder.setNegativeButton("Disagree", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { InternetMenu.this.finish(); } }); builder.setCancelable(false); builder.show(); } if (mLoginInfo == null) { try { String userId; String sessionToken; Cursor loginCursor = mDbHelper.fetchLogin(USER_ID_KEY); startManagingCursor(loginCursor); userId = loginCursor.getString(loginCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)); loginCursor = mDbHelper.fetchLogin(SESSION_TOKEN_KEY); startManagingCursor(loginCursor); sessionToken = loginCursor.getString(loginCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)); mLoginInfo = new HashMap<String, String>(); mLoginInfo.put(USER_ID_KEY, userId); mLoginInfo.put(SESSION_TOKEN_KEY, sessionToken); sendDonationInfo(); mSessionValidityChecked = false; checkSessionValidity(); } catch (CursorIndexOutOfBoundsException e) { Log.d(TAG, "Couldn't get database session info", e); mSessionValidityChecked = true; } } getVersionInfo(); // Keep under login stuff mInternetDownload.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(InternetMenu.this, DownloadBoardList.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivity(i); } }); mInternetRegisterSettings.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mInternetRegisterSettings.getText().toString().equals(SETTINGS_TEXT)) { Intent i = new Intent(InternetMenu.this, Settings.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivityForResult(i, LOGIN_RETURN); } else { Intent i = new Intent(InternetMenu.this, Register.class); startActivity(i); } } }); mInternetLoginLogout.setOnClickListener(new OnClickListener() { public void onClick(View v) { startLogin(); } }); mInternetUploads.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(InternetMenu.this, Uploads.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivityForResult(i, LOGIN_RETURN); } }); mInternetFavorites.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(InternetMenu.this, Favorites.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivityForResult(i, LOGIN_RETURN); } }); }