Search in sources :

Example 91 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project easypermissions by googlesamples.

the class AppSettingsDialogTest method shouldPositiveListener_whenClickingPositiveButtonFromSupportFragment.

@Test
public void shouldPositiveListener_whenClickingPositiveButtonFromSupportFragment() {
    AlertDialog alertDialog = new AppSettingsDialog.Builder(spyFragment).setTitle(TITLE).setRationale(RATIONALE).setPositiveButton(POSITIVE).setNegativeButton(NEGATIVE).setThemeResId(R.style.Theme_AppCompat).build().showDialog(positiveListener, negativeListener);
    Button positive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
    positive.performClick();
    verify(positiveListener, times(1)).onClick(any(DialogInterface.class), anyInt());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) DialogInterface(android.content.DialogInterface) Test(org.junit.Test)

Example 92 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project easypermissions by googlesamples.

the class AppSettingsDialogTest method shouldNegativeListener_whenClickingPositiveButtonFromSupportFragment.

@Test
public void shouldNegativeListener_whenClickingPositiveButtonFromSupportFragment() {
    AlertDialog alertDialog = new AppSettingsDialog.Builder(spyFragment).setTitle(TITLE).setRationale(RATIONALE).setPositiveButton(POSITIVE).setNegativeButton(NEGATIVE).setThemeResId(R.style.Theme_AppCompat).build().showDialog(positiveListener, negativeListener);
    Button positive = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    positive.performClick();
    verify(negativeListener, times(1)).onClick(any(DialogInterface.class), anyInt());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) DialogInterface(android.content.DialogInterface) Test(org.junit.Test)

Example 93 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project K6nele by Kaljurand.

the class Utils method getTextEntryDialog.

public static AlertDialog getTextEntryDialog(Context context, String title, String initialText, final ExecutableString ex) {
    final View textEntryView = LayoutInflater.from(context).inflate(R.layout.alert_dialog_url_entry, null);
    final EditText et = textEntryView.findViewById(R.id.url_edit);
    if (initialText != null) {
        et.setText(initialText);
        et.setHint(initialText);
        et.setSelection(initialText.length());
    }
    final AlertDialog ad = new AlertDialog.Builder(context).setTitle(title).setView(textEntryView).setPositiveButton(R.string.buttonOk, (dialog, whichButton) -> ex.execute(et.getText().toString())).setNegativeButton(R.string.buttonCancel, (dialog, whichButton) -> dialog.cancel()).create();
    et.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            ex.execute(et.getText().toString());
            ad.cancel();
            return true;
        }
        return false;
    });
    return ad;
}
Also used : EditText(android.widget.EditText) AlertDialog(androidx.appcompat.app.AlertDialog) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Context(android.content.Context) Arrays(java.util.Arrays) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) PackageManager(android.content.pm.PackageManager) Uri(android.net.Uri) R(ee.ioc.phon.android.speak.R) Intent(android.content.Intent) ExecutableString(ee.ioc.phon.android.speak.ExecutableString) PreferenceUtils(ee.ioc.phon.android.speechutils.utils.PreferenceUtils) PackageInfo(android.content.pm.PackageInfo) Drawable(android.graphics.drawable.Drawable) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) ArrayList(java.util.ArrayList) Combo(ee.ioc.phon.android.speak.model.Combo) RecognizerIntent(android.speech.RecognizerIntent) RecognitionServiceManager(ee.ioc.phon.android.speechutils.RecognitionServiceManager) View(android.view.View) Canvas(android.graphics.Canvas) Icon(android.graphics.drawable.Icon) Build(android.os.Build) TargetApi(android.annotation.TargetApi) Cursor(android.database.Cursor) Log(ee.ioc.phon.android.speak.Log) SpeechActionActivity(ee.ioc.phon.android.speak.activity.SpeechActionActivity) Executable(ee.ioc.phon.android.speak.Executable) Iterator(java.util.Iterator) ShortcutInfo(android.content.pm.ShortcutInfo) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) Set(java.util.Set) TextUtils(android.text.TextUtils) BitmapDrawable(android.graphics.drawable.BitmapDrawable) CommandMatcher(ee.ioc.phon.android.speechutils.editor.CommandMatcher) ShortcutManager(android.content.pm.ShortcutManager) Extras(ee.ioc.phon.android.speechutils.Extras) List(java.util.List) UtteranceRewriter(ee.ioc.phon.android.speechutils.editor.UtteranceRewriter) SharedPreferences(android.content.SharedPreferences) Bitmap(android.graphics.Bitmap) CallerInfo(ee.ioc.phon.android.speak.model.CallerInfo) EditorInfo(android.view.inputmethod.EditorInfo) Collections(java.util.Collections) EditText(android.widget.EditText) Resources(android.content.res.Resources) View(android.view.View)

Example 94 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project J2ME-Loader by nikita36078.

the class Display method showAlert.

private void showAlert(Alert alert) {
    ViewHandler.postEvent(() -> {
        AlertDialog alertDialog = alert.prepareDialog();
        alertDialog.show();
        if (alert.finiteTimeout()) {
            ViewHandler.postDelayed(alertDialog::dismiss, alert.getTimeout());
        }
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog)

Example 95 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project J2ME-Loader by nikita36078.

the class EditNameAlert method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    @SuppressLint("InflateParams") View v = inflater.inflate(R.layout.dialog_change_name, null);
    EditText editText = v.findViewById(R.id.editText);
    Button btNegative = v.findViewById(R.id.btNegative);
    Button btPositive = v.findViewById(R.id.btPositive);
    AlertDialog dialog = new AlertDialog.Builder(requireActivity()).setTitle(mTitle).setView(v).create();
    btNegative.setOnClickListener(v1 -> dismiss());
    btPositive.setOnClickListener(v1 -> onClickOk(editText));
    return dialog;
}
Also used : EditText(android.widget.EditText) AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) SuppressLint(android.annotation.SuppressLint) View(android.view.View) NonNull(androidx.annotation.NonNull)

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)256 Test (org.junit.Test)89 View (android.view.View)48 DialogInterface (android.content.DialogInterface)40 Button (android.widget.Button)39 TextView (android.widget.TextView)39 Intent (android.content.Intent)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 NonNull (androidx.annotation.NonNull)27 Context (android.content.Context)26 Bundle (android.os.Bundle)20 SuppressLint (android.annotation.SuppressLint)17 EditText (android.widget.EditText)17 ArrayList (java.util.ArrayList)17 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)14 List (java.util.List)12 Activity (android.app.Activity)11 Uri (android.net.Uri)11 LayoutInflater (android.view.LayoutInflater)11 ListView (android.widget.ListView)10