List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:com.jdom.get.stuff.done.android.AndroidApplicationContextFactory.java
public void displayProVersionPromo(String proAppName, String proVersionLink) { final String text = "For the cost of a soda, $0.99, you can enable the following features:\n" + "- No advertisements\n" + "- Sync frequency/action configuration\n" + "- Configure the fields displayed in the add/edit task page.\n\n" + "Click the OK button to load the pro version in the market viewer, or Cancel to stay with the free version."; AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle("Upgrade"); builder.setMessage(text);/* ww w . j a v a 2 s . co m*/ builder.setPositiveButton(OK_BUTTON_TEXT, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(Constants.PRO_VERSION_LINK)); activity.startActivity(intent); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.show(); }
From source file:dtu.ds.warnme.app.dialog.WarningDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Event event = (Event) getArguments().get(MainActivity.KEY_EVENT); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); dialogBuilder.setTitle(R.string.warning); dialogBuilder.setMessage(getMessage(event)); dialogBuilder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override//from ww w . ja va2s .c o m public void onClick(DialogInterface dialog, int which) { // Nothing to do here... } }); dialogBuilder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Nothing to do here... } }); dialog = dialogBuilder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { RestClientHolder.getRestClient().upVoteEvent(dialog.getContext(), event, new AsyncHttpResponseHandler() { @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Log.i(TAG, "Failed to upvote event " + event.getId() + " cause: " + error); } @Override public void onFinish() { dialog.dismiss(); } @Override public void onStart() { positiveButton.setEnabled(false); negativeButton.setEnabled(false); } @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Log.i(TAG, "Event " + event.getId() + " upvoted with success"); } }); } }); negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { RestClientHolder.getRestClient().downVoteEvent(dialog.getContext(), event, new AsyncHttpResponseHandler() { @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Log.i(TAG, "Failed to downvote event " + event.getId() + " cause: " + error); } @Override public void onFinish() { dialog.dismiss(); } @Override public void onStart() { positiveButton.setEnabled(false); negativeButton.setEnabled(false); } @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Log.i(TAG, "Event " + event.getId() + " downvoted with success"); } }); } }); } }); return dialog; }
From source file:com.app.sniffy.MainActivity.java
public void showTerms() { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View dialoglayout = inflater.inflate(R.layout.terms, null); WebView webView = (WebView) dialoglayout.findViewById(R.id.termsView); webView.loadUrl("file:///android_asset/license.html"); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Terms & Conditions"); builder.setView(dialoglayout).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { CheckBox checkBox = (CheckBox) dialoglayout.findViewById(R.id.checkBox); if (checkBox.isChecked()) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("userconsent", true); editor.commit(); try { new GetKey(context).execute( new URI(Utils.getConfigProperty(getResources(), "generate-key") + mDeviceId + Utils.getConfigProperty(getResources(), "securekey"))); } catch (URISyntaxException e1) { Log.d("main activity key generate", e1.toString()); }//from w w w .jav a 2s .c o m } else { showTerms(); } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.example.run_tracker.ProfileFragment.java
@Override public void onClick(View arg0) { Log.v(TAG, "click"); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Enter Password"); alert.setMessage("Please enter your password"); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); alert.setView(input);/*from ww w. ja va 2 s . c o m*/ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String password = input.getText().toString(); String new_password = null; if (!mPassword1.getText().toString().equals(mPassword2.getText().toString())) { Toast.makeText(getActivity(), "Passwords dont match", Toast.LENGTH_LONG).show(); } else { if (isEmpty(mPassword1) || (isEmpty(mPassword2))) { new_password = password; } else { new_password = mPassword1.getText().toString(); } Make_edit_profile_request(password, new_password); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
From source file:com.saulcintero.moveon.fragments.History.java
public static void sendAction(final Activity act, int[] idList, String[] nameList, String[] activityList, String[] shortDescriptionList, String[] longDescriptionList) { ArrayList<Integer> positions = new ArrayList<Integer>(); for (int p = 0; p < idList.length; p++) { String nameToSearch = osmFilesNameFromUploadPosition.get(p).substring(0, osmFilesNameFromUploadPosition.get(p).length() - 4); positions.add(ArrayUtils.indexOf(listOfFiles, nameToSearch)); }//from w ww.ja va 2 s. c om for (int j = 0; j < idList.length; j++) { final String name = nameList[j]; final String activity = activityList[j]; final String shortDescription = shortDescriptionList[j]; final String longDescription = longDescriptionList[j]; final String url = osmUrlsToShare.get(positions.get(j)); Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); sendIntent.setType("text/plain"); List<ResolveInfo> activities = act.getPackageManager().queryIntentActivities(sendIntent, 0); AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(act.getText(R.string.send_to) + " " + name + " " + act.getText(R.string.share_with)); final ShareIntentListAdapter adapter = new ShareIntentListAdapter(act, R.layout.social_share, activities.toArray()); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ResolveInfo info = (ResolveInfo) adapter.getItem(which); if (info.activityInfo.packageName.contains("facebook")) { Intent i = new Intent("android.intent.action.PUBLISH_TO_FB_WALL"); i.putExtra("name", activity + " " + name); i.putExtra("msg", String.format("%s", shortDescription)); i.putExtra("link", String.format("%s", url)); act.sendBroadcast(i); } else { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); intent.setType("text/plain"); if ((info.activityInfo.packageName.contains("twitter")) || (info.activityInfo.packageName.contains("sms")) || (info.activityInfo.packageName.contains("mms"))) { intent.putExtra(Intent.EXTRA_TEXT, shortDescription + url); } else { intent.putExtra(Intent.EXTRA_TEXT, longDescription + url); } act.startActivity(intent); } } }); builder.create().show(); } }
From source file:pl.bcichecki.rms.client.android.dialogs.DeviceDetailsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (device == null) { throw new IllegalStateException("Device has not been set!"); }/* w w w. j a v a 2s .c om*/ context = getActivity(); eventsRestClient = new EventsRestClient(getActivity(), UserProfileHolder.getUsername(), UserProfileHolder.getPassword(), SharedPreferencesWrapper.getServerRealm(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); dialogBuilder.setTitle(getString(R.string.dialog_device_details_title, device.getName())); dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_device_details, null)); dialogBuilder.setNeutralButton(R.string.dialog_device_details_btn_show_reservations, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Date now = new Date(); final Date from = DateUtils.round(DateUtils.addDays(now, DAYS_BACK - 1), Calendar.DAY_OF_MONTH); final Date till = DateUtils.round(DateUtils.addDays(now, DAYS_AHEAD + 1), Calendar.DAY_OF_MONTH); final FragmentManager fragmentManager = getFragmentManager(); Log.d(getTag(), "Retrieving device's events for " + device); eventsRestClient.getDevicesEvents(device, from, till, new GsonHttpResponseHandler<List<Event>>(new TypeToken<List<Event>>() { }.getType(), true) { @Override public void onFailure(Throwable error, String content) { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " failed. [error=" + error + ", content=" + content + "]"); if (error instanceof HttpResponseException) { if (((HttpResponseException) error) .getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { AppUtils.showCenteredToast(context, R.string.general_unathorized_error_message_title, Toast.LENGTH_LONG); } else { AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } else { AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } @Override public void onFinish() { Log.d(getTag(), "Retrieving device's events finished."); } @Override public void onStart() { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " started."); } @Override public void onSuccess(int statusCode, List<Event> events) { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " successful. Retrieved " + events.size() + " objects."); DeviceReservationsDialog deviceReservationsDialog = new DeviceReservationsDialog(); deviceReservationsDialog.setDevice(device); deviceReservationsDialog.setEvents(events); deviceReservationsDialog.show(fragmentManager, getTag()); } }); } }); dialogBuilder.setPositiveButton(R.string.general_close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Nothing to do... } }); AlertDialog dialog = dialogBuilder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { TextView nameTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_device_details_name_text); nameTextView.setText(device.getName()); TextView descriptionTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_device_details_description_text); descriptionTextView.setText(device.getName()); } }); return dialog; }
From source file:com.chaosinmotion.securechat.fragments.LoginAccount.java
private void displayError() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.login_error_message); builder.setTitle(R.string.login_error_title); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override//from www. ja v a 2 s. c o m public void onClick(DialogInterface dialog, int which) { // Ignore } }); builder.show(); return; }
From source file:com.chaosinmotion.securechat.fragments.OnboardingCreateAccount.java
@Override public void doNext() { String uname = username.getText().toString(); String pwd = password.getText().toString(); if (!PasswordComplexity.complexityTest(pwd)) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.weak_password_message); builder.setTitle(R.string.weak_password_title); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override/*from www .j a va 2 s. c om*/ public void onClick(DialogInterface dialog, int which) { // Ignore } }); builder.show(); } final SCNetworkCredentials creds = new SCNetworkCredentials(uname); creds.setPasswordFromClearText(pwd); try { JSONObject json = new JSONObject(); json.put("username", creds.getUsername()); json.put("password", creds.getPassword()); json.put("deviceid", SCRSAManager.shared().getDeviceUUID()); json.put("pubkey", SCRSAManager.shared().getPublicKey()); SCNetwork.get().request("login/createaccount", json, this, new SCNetwork.ResponseInterface() { @Override public void responseResult(SCNetwork.Response response) { if (response.isSuccess()) { /* * Success. Save the username and password, * and save the whole thing to the back end. */ SCRSAManager.shared().setCredentials(creds.getUsername(), creds.getPassword()); SCRSAManager.shared().encodeSecureData(getActivity()); /* * We have what we need to start the queue */ SCMessageQueue.get().startQueue(getActivity()); /* * Done. Go to the next page */ wizardInterface.transitionToFragment(new OnboardingFinished()); } } }); } catch (JSONException ex) { } }
From source file:com.chaosinmotion.securechat.fragments.ChangePasswordStart.java
@Override public void doNext() { String password = newPassword.getText().toString(); if (!PasswordComplexity.complexityTest(password)) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.weak_password_message); builder.setTitle(R.string.weak_password_title); builder.setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() { @Override/*from w w w. j a v a 2 s . co m*/ public void onClick(DialogInterface dialog, int which) { // Ignore } }); builder.show(); return; } String retypedPassword = copyPassword.getText().toString(); if (!retypedPassword.equals(password)) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.change_password_not_matched_message); builder.setTitle(R.string.change_password_not_matched_title); builder.setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Ignore } }); builder.show(); return; } changePassword(oldPassword.getText().toString(), password); }
From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java
private void handleExtra(Intent intent) { Bundle extras = intent.getExtras();/* w w w. ja v a 2 s . c om*/ if (extras != null && extras.size() > 0) { for (String k : extras.keySet()) { Log.i(TAG, "k = " + k + " : " + extras.getString(k)); } } if (extras != null && "dialog".equals(extras.get("_extra1"))) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle("" + extras.get("_extra2")); alertDialogBuilder.setMessage("" + extras.get("_extra3")).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialogBuilder.create().show(); } }