Java Code Examples for org.telegram.ui.ActionBar.AlertDialog#setCanceledOnTouchOutside()

The following examples show how to use org.telegram.ui.ActionBar.AlertDialog#setCanceledOnTouchOutside() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void showErrorDialog(CharSequence message){
       AlertDialog dlg = new DarkAlertDialog.Builder(VoIPActivity.this)
               .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed))
               .setMessage(message)
               .setPositiveButton(LocaleController.getString("OK", R.string.OK), null)
               .show();
       dlg.setCanceledOnTouchOutside(true);
       dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
           @Override
           public void onDismiss(DialogInterface dialog) {
               finish();
           }
       });
}
 
Example 2
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void showErrorDialog(CharSequence message){
       AlertDialog dlg = new DarkAlertDialog.Builder(VoIPActivity.this)
               .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed))
               .setMessage(message)
               .setPositiveButton(LocaleController.getString("OK", R.string.OK), null)
               .show();
       dlg.setCanceledOnTouchOutside(true);
       dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
           @Override
           public void onDismiss(DialogInterface dialog) {
               finish();
           }
       });
}
 
Example 3
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void showErrorDialog(CharSequence message) {
    AlertDialog dlg = new DarkAlertDialog.Builder(VoIPActivity.this)
            .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed))
            .setMessage(message)
            .setPositiveButton(LocaleController.getString("OK", R.string.OK), null)
            .show();
    dlg.setCanceledOnTouchOutside(true);
    dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            finish();
        }
    });
}
 
Example 4
Source File: VoIPActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void showErrorDialog(CharSequence message) {
    AlertDialog dlg = new DarkAlertDialog.Builder(VoIPActivity.this)
            .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed))
            .setMessage(message)
            .setPositiveButton(LocaleController.getString("OK", R.string.OK), null)
            .show();
    dlg.setCanceledOnTouchOutside(true);
    dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            finish();
        }
    });
}
 
Example 5
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static AlertDialog showSecretLocationAlert(Context context, int currentAccount, final Runnable onSelectRunnable, boolean inChat) {
    ArrayList<String> arrayList = new ArrayList<>();
    ArrayList<Integer> types = new ArrayList<>();
    int providers = MessagesController.getInstance(currentAccount).availableMapProviders;
    if ((providers & 1) != 0) {
        arrayList.add(LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram));
        types.add(0);
    }
    if ((providers & 2) != 0) {
        arrayList.add(LocaleController.getString("MapPreviewProviderGoogle", R.string.MapPreviewProviderGoogle));
        types.add(1);
    }
    if ((providers & 4) != 0) {
        arrayList.add(LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex));
        types.add(3);
    }
    arrayList.add(LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody));
    types.add(2);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(LocaleController.getString("MapPreviewProviderTitle", R.string.MapPreviewProviderTitle));
    final LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    builder.setView(linearLayout);

    for (int a = 0; a < arrayList.size(); a++) {
        RadioColorCell cell = new RadioColorCell(context);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(arrayList.get(a), SharedConfig.mapPreviewType == types.get(a));
        linearLayout.addView(cell);
        cell.setOnClickListener(v -> {
            Integer which = (Integer) v.getTag();
            SharedConfig.setSecretMapPreviewType(types.get(which));
            if (onSelectRunnable != null) {
                onSelectRunnable.run();
            }
            builder.getDismissRunnable().run();
        });
    }
    if (!inChat) {
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    }
    AlertDialog dialog = builder.show();
    if (inChat) {
        dialog.setCanceledOnTouchOutside(false);
    }
    return dialog;
}
 
Example 6
Source File: AlertsCreator.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public static AlertDialog showSecretLocationAlert(Context context, int currentAccount, final Runnable onSelectRunnable, boolean inChat) {
    ArrayList<String> arrayList = new ArrayList<>();
    ArrayList<Integer> types = new ArrayList<>();
    int providers = MessagesController.getInstance(currentAccount).availableMapProviders;
    if ((providers & 1) != 0) {
        arrayList.add(LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram));
        types.add(0);
    }
    if ((providers & 2) != 0) {
        arrayList.add(LocaleController.getString("MapPreviewProviderGoogle", R.string.MapPreviewProviderGoogle));
        types.add(1);
    }
    if ((providers & 4) != 0) {
        arrayList.add(LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex));
        types.add(3);
    }
    arrayList.add(LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody));
    types.add(2);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(LocaleController.getString("MapPreviewProviderTitle", R.string.MapPreviewProviderTitle));
    final LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    builder.setView(linearLayout);

    for (int a = 0; a < arrayList.size(); a++) {
        RadioColorCell cell = new RadioColorCell(context);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(arrayList.get(a), SharedConfig.mapPreviewType == types.get(a));
        linearLayout.addView(cell);
        cell.setOnClickListener(v -> {
            Integer which = (Integer) v.getTag();
            SharedConfig.setSecretMapPreviewType(types.get(which));
            if (onSelectRunnable != null) {
                onSelectRunnable.run();
            }
            builder.getDismissRunnable().run();
        });
    }
    if (!inChat) {
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    }
    AlertDialog dialog = builder.show();
    if (inChat) {
        dialog.setCanceledOnTouchOutside(false);
    }
    return dialog;
}