Java Code Examples for android.content.DialogInterface

The following are top voted examples for showing how to use android.content.DialogInterface. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: my-ministry-assistant   File: HelpUtils.java View source code 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    WebView webView = new WebView(getActivity());
    webView.loadUrl("file:///android_asset/licenses.html");

    return new AlertDialog.Builder(getActivity())
            .setTitle(R.string.pref_about_licenses)
            .setView(webView)
            .setPositiveButton(R.string.ok,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.dismiss();
                        }
                    }
            )
            .create();
}
 
Example 2
Project: android-quick-library   File: QuickSlidingSampleAct.java View source code 6 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_BACK) {
		if (isSlidingMenuOpen()) {
			getSlidingMenu().toggle();
			return true;
		}

		DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface arg0, int arg1) {
				if (arg1 == DialogInterface.BUTTON_POSITIVE) {
					QuickToolHelper.appExit();
				}
			}
		};
		QuickToolHelper.showDialog(this, "exit app?", listener, false);
		return true;
	}
	return super.onKeyDown(keyCode, event);
}
 
Example 3
Project: sawan-bar   File: CallFeaturesSetting.java View source code 6 votes vote down vote up
public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
    switch (which){
        case DialogInterface.BUTTON_NEUTRAL:
            if (DBG) log("Neutral button");
            break;
        case DialogInterface.BUTTON_NEGATIVE:
            if (DBG) log("Negative button");
            if (mCurrentDialogId == FW_GET_RESPONSE_ERROR) {
                // We failed to get current forwarding settings and the user
                // does not wish to continue.
                switchToPreviousVoicemailProvider();
            }
            break;
        case DialogInterface.BUTTON_POSITIVE:
            if (DBG) log("Positive button");
            if (mCurrentDialogId == FW_GET_RESPONSE_ERROR) {
                // We failed to get current forwarding settings but the user
                // wishes to continue changing settings to the new vm provider
                saveVoiceMailAndForwardingNumberStage2();
            } else {
                finish();
            }
            return;
        default:
            // just let the dialog close and go back to the input
    }
    // In all dialogs, all buttons except BUTTON_POSITIVE lead to the end of user interaction
    // with settings UI. If we were called to explicitly configure voice mail then
    // we finish the settings activity here to come back to whatever the user was doing.
    if (getIntent().getAction().equals(ACTION_ADD_VOICEMAIL)) {
        finish();
    }
}
 
Example 4
Project: sawan-bar   File: CallFeaturesSetting.java View source code 6 votes vote down vote up
public void onDialogClosed(EditPhoneNumberPreference preference, int buttonClicked) {
    if (DBG) log("onPreferenceClick: request preference click on dialog close: " +
            buttonClicked);
    if (buttonClicked == DialogInterface.BUTTON_NEGATIVE) {
        return;
    }
    if (preference instanceof EditPhoneNumberPreference) {
        EditPhoneNumberPreference epn = preference;

        if (epn == mSubMenuVoicemailSettings) {
            handleVMBtnClickRequest();
        }
    }
}
 
Example 5
Project: gcmobile   File: InstanceUploaderActivity.java View source code 6 votes vote down vote up
private void createAlertDialog(String message) {
    mAlertDialog = new AlertDialog.Builder(this).create();
    mAlertDialog.setTitle(getString(R.string.upload_results));
    mAlertDialog.setMessage(message);
    DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
                case DialogInterface.BUTTON1: // ok
                    // always exit this activity since it has no interface
                    mAlertShowing = false;
                    finish();
                    break;
            }
        }
    };
    mAlertDialog.setCancelable(false);
    mAlertDialog.setButton(getString(R.string.ok), quitListener);
    mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
    mAlertShowing = true;
    mAlertMsg = message;
    mAlertDialog.show();
}
 
Example 6
Project: phonegap-geolocation   File: CordovaActivity.java View source code 6 votes vote down vote up
/**
 * Show the spinner.  Must be called from the UI thread.
 *
 * @param title         Title of the dialog
 * @param message       The message of the dialog
 */
public void spinnerStart(final String title, final String message) {
    if (this.spinnerDialog != null) {
        this.spinnerDialog.dismiss();
        this.spinnerDialog = null;
    }
    final CordovaActivity me = this;
    this.spinnerDialog = ProgressDialog.show(CordovaActivity.this, title, message, true, true,
            new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    me.spinnerDialog = null;
                }
            });
}
 
Example 7
Project: thermospy   File: MainActivity.java View source code 6 votes vote down vote up
@Override
public void onShowCreateLogSessionDialog(DialogInterface.OnDismissListener dismissListener) {
    FragmentManager fm = getFragmentManager();
    LogSessionDialogFragment editNameDialog = LogSessionDialogFragment.newInstance(Coordinator.getInstance().getServerSettings());
    editNameDialog.setDismissListener(dismissListener);
    editNameDialog.show(fm, "fragment_edit_name");

}
 
Example 8
Project: appaloosa-android-tools   File: AlertDialogUtils.java View source code 6 votes vote down vote up
public static void showConfirmDialog(final Activity activity, String title, String message, DialogInterface.OnClickListener positiveButtonListener) throws NullActivityException {
    if(positiveButtonListener == null) {
        positiveButtonListener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        };
    }
    if (activity==null) {
        throw new NullActivityException();
    }

    new AlertDialog.Builder(activity)
            .setTitle(title)
            .setMessage(message)
            .setPositiveButton(android.R.string.ok, positiveButtonListener)
            .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            })
            .show();
}
 
Example 9
Project: gcmobile   File: FormEntryActivity.java View source code 6 votes vote down vote up
/**
 * Creates and displays a dialog asking the user if they'd like to create a repeat of the
 * current group.
 */
private void createRepeatDialog() {
    mAlertDialog = new AlertDialog.Builder(this).create();
    mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
    DialogInterface.OnClickListener repeatListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
                case DialogInterface.BUTTON1: // yes, repeat
                    try {
                        mFormController.newRepeat();
                    } catch (XPathTypeMismatchException e) {
                        FormEntryActivity.this.createErrorDialog(e.getMessage(), EXIT);
                        return;
                    }
                    showNextView();
                    break;
                case DialogInterface.BUTTON2: // no, no repeat
                    showNextView();
                    break;
            }
        }
    };
    if (mFormController.getLastRepeatCount() > 0) {
        mAlertDialog.setTitle(getString(R.string.leaving_repeat_ask));
        mAlertDialog.setMessage(getString(R.string.add_another_repeat,
            mFormController.getLastGroupText()));
        mAlertDialog.setButton(getString(R.string.add_another), repeatListener);
        mAlertDialog.setButton2(getString(R.string.leave_repeat_yes), repeatListener);

    } else {
        mAlertDialog.setTitle(getString(R.string.entering_repeat_ask));
        mAlertDialog.setMessage(getString(R.string.add_repeat,
            mFormController.getLastGroupText()));
        mAlertDialog.setButton(getString(R.string.entering_repeat), repeatListener);
        mAlertDialog.setButton2(getString(R.string.add_repeat_no), repeatListener);
    }
    mAlertDialog.setCancelable(false);
    mAlertDialog.show();
    mBeenSwiped = false;
}
 
Example 10
Project: sawan-bar   File: OtaUtils.java View source code 6 votes vote down vote up
/**
 * Show SPC failure notice when SPC attempts exceed 15 times.
 * During OTA provisioning, if SPC code is incorrect OTA provisioning will
 * fail. When SPC attempts are over 15, it shows SPC failure notice for one minute and
 * then phone will power down.
 */
private void otaShowSpcErrorNotice(int length) {
    if (DBG) log("OtaShowSpcErrorNotice()...");
    if (mOtaWidgetData.spcErrorDialog == null) {
        mApplication.cdmaOtaProvisionData.inOtaSpcState = true;
        DialogInterface.OnKeyListener keyListener;
        keyListener = new DialogInterface.OnKeyListener() {
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                log("Ignoring key events...");
                return true;
            }};
        mOtaWidgetData.spcErrorDialog = new AlertDialog.Builder(mInCallScreen)
                .setMessage(R.string.ota_spc_failure)
                .setOnKeyListener(keyListener)
                .create();
        mOtaWidgetData.spcErrorDialog.getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        mOtaWidgetData.spcErrorDialog.show();
        //close the dialer if open
        if (isDialerOpened()) {
            mDialer.closeDialer(false);
        }
        long noticeTime = length*1000;
        if (DBG) log("OtaShowSpcErrorNotice(), remaining SPC noticeTime" + noticeTime);
        mInCallScreen.requestCloseSpcErrorNotice(noticeTime);
    }
}
 
Example 11
Project: chbosync4android   File: AndroidDisplayManager.java View source code 6 votes vote down vote up
public int promptMultipleSelection(Screen screen, String title,
        String okButtonLabel, String cancelButtonLabel,
        String[] choices, boolean[] checkedChoices,
        DialogInterface.OnMultiChoiceClickListener multiChoiceClickListener,
        DialogInterface.OnClickListener okButtonClickListener,
        DialogInterface.OnClickListener cancelButtonClickListener) {

    int dialogId = getNextDialogId();
    Activity a = (Activity) screen.getUiScreen();

    AlertDialog.Builder builder = new AlertDialog.Builder(a)
            .setCustomTitle(buildAlertTitle(a, title, 18))
            .setMultiChoiceItems(choices, checkedChoices, multiChoiceClickListener)
            .setPositiveButton(okButtonLabel, okButtonClickListener)
            .setNegativeButton(cancelButtonLabel, cancelButtonClickListener);

    holdingDialogs.put(dialogId, builder.create());
    a.showDialog(dialogId);
    return dialogId;
}
 
Example 12
Project: RedditInPictures   File: LoginDialogFragment.java View source code 6 votes vote down vote up
/**
 * We have to override setOnShowListener here (min API level 8) in order to validate
 * the inputs before closing the dialog. Just overriding setPositiveButton closes the
 * automatically when the button is pressed
 *
 * @return The onShowListener for the AlertDialog
 */
private OnShowListener getDialogOnShowListener() {
    return new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button login = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            login.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    doLogin();
                }
            });
        }
    };
}