androidx.appcompat.app.AlertDialog Java Examples

The following examples show how to use androidx.appcompat.app.AlertDialog. 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: MainActivity.java    From SimplicityBrowser with MIT License 6 votes vote down vote up
private AlertDialog createDialog() {
    return new AlertDialog.Builder(MainActivity.this)
            .setPositiveButton(getString(R.string.download), (dialog, which) -> {
                if (!shortcutNameEditText.getText().toString().isEmpty()) {
                    UserPreferences.putString("file_name_new", shortcutNameEditText.toString());
                } else {
                    UserPreferences.putString("file_name_new", "");
                }
                requestStoragePermission();
                if(checker.isChecked()){
                    UserPreferences.putBoolean("rename", true);
                }
            })
            .setNegativeButton(getString(R.string.cancel), (dialog, which) -> {
            })
            .setCancelable(true)
            .create();
}
 
Example #2
Source File: AlertDialogsHelper.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
public static AlertDialog getProgressDialog(final ThemedActivity activity, String title, String message) {
    AlertDialog.Builder progressDialog = new AlertDialog.Builder(activity, activity.getDialogStyle());
    View dialogLayout = activity.getLayoutInflater().inflate(com.alienpants.leafpicrevived.R.layout.dialog_progress, null);
    TextView dialogTitle = dialogLayout.findViewById(R.id.progress_dialog_title);
    TextView dialogMessage = dialogLayout.findViewById(R.id.progress_dialog_text);

    dialogTitle.setBackgroundColor(activity.getPrimaryColor());
    ((CardView) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.progress_dialog_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
    ((ProgressBar) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.progress_dialog_loading)).getIndeterminateDrawable().setColorFilter(activity.getPrimaryColor(), android.graphics
            .PorterDuff.Mode.SRC_ATOP);

    dialogTitle.setText(title);
    dialogMessage.setText(message);
    dialogMessage.setTextColor(activity.getTextColor());

    progressDialog.setCancelable(false);
    progressDialog.setView(dialogLayout);
    return progressDialog.create();
}
 
Example #3
Source File: ProfileActivity.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public void onEditName() {
  if (chatIsGroup) {
    Intent intent = new Intent(this, GroupCreateActivity.class);
    intent.putExtra(GroupCreateActivity.EDIT_GROUP_CHAT_ID, chatId);
    if (dcContext.getChat(chatId).isVerified()) {
      intent.putExtra(GroupCreateActivity.GROUP_CREATE_VERIFIED_EXTRA, true);
    }
    startActivity(intent);
  }
  else {
    DcContact dcContact = dcContext.getContact(contactId);
    final EditText txt = new EditText(this);
    txt.setText(dcContact.getName());
    new AlertDialog.Builder(this)
        .setTitle(R.string.menu_edit_name)
        .setView(txt)
        .setPositiveButton(android.R.string.ok, (dialog, whichButton) -> {
          String newName = txt.getText().toString();
          dcContext.createContact(newName, dcContact.getAddr());
        })
        .setNegativeButton(android.R.string.cancel, null)
        .show();
  }
}
 
Example #4
Source File: DialogWebChromeClient.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
  LayoutInflater inflater = LayoutInflater.from(context);
  View promptView = inflater.inflate(R.layout.dialog_js_prompt, null, false);
  TextView messageView = promptView.findViewById(R.id.message);
  messageView.setText(message);
  final EditText valueView = promptView.findViewById(R.id.value);
  valueView.setText(defaultValue);

  new AlertDialog.Builder(context)
      .setView(promptView)
      .setPositiveButton(android.R.string.ok, (dialog, which) -> result.confirm(valueView.getText().toString()))
      .setOnCancelListener(dialog -> result.cancel())
      .show();

  return true;
}
 
Example #5
Source File: APDE.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
public EditText createAlertDialogEditText(Activity context, AlertDialog.Builder builder, String content, boolean selectAll) {
	final EditText input = new EditText(context);
	input.setSingleLine();
	input.setText(content);
	if (selectAll) {
		input.selectAll();
	}
	
	// http://stackoverflow.com/a/27776276/
	FrameLayout frameLayout = new FrameLayout(context);
	FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
	
	// http://stackoverflow.com/a/35211225/
	float dpi = getResources().getDisplayMetrics().density;
	params.leftMargin = (int) (19 * dpi);
	params.topMargin = (int) (5 * dpi);
	params.rightMargin = (int) (14 * dpi);
	params.bottomMargin = (int) (5 * dpi);
	
	frameLayout.addView(input, params);
	
	builder.setView(frameLayout);
	
	return input;
}
 
Example #6
Source File: GalleryActivity.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private void pageDialogListener(AlertDialog.Builder builder, CharSequence[] items, int page){
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mGalleryProvider == null) {
                return;
            }

            switch (which) {
                case 0: // Refresh
                    mGalleryProvider.removeCache(page);
                    mGalleryProvider.forceRequest(page);
                    break;
                case 1: // Share
                    shareImage(page);
                    break;
                case 2: // Save
                    saveImage(page);
                    break;
                case 3: // Save to
                    saveImageTo(page);
                    break;
            }
        }
    });
}
 
Example #7
Source File: AdvancedFragment.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private static void importData(final Context context) {
    final File dir = AppConfig.getExternalDataDir();
    if (null == dir) {
        Toast.makeText(context, R.string.cant_get_data_dir, Toast.LENGTH_SHORT).show();
        return;
    }
    final String[] files = dir.list();
    if (null == files || files.length <= 0) {
        Toast.makeText(context, R.string.cant_find_any_data, Toast.LENGTH_SHORT).show();
        return;
    }
    Arrays.sort(files);
    new AlertDialog.Builder(context).setItems(files, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            File file = new File(dir, files[which]);
            String error = EhDB.importDB(context, file);
            if (null == error) {
                error = context.getString(R.string.settings_advanced_import_data_successfully);
            }
            Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
        }
    }).show();
}
 
Example #8
Source File: DialogFragmentPermissionRationale.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    alertDialogBuilder = new AlertDialog.Builder(requireActivity());
    alertDialogBuilder.setIcon(R.drawable.ic_info_outline);
    alertDialogBuilder.setPositiveButton(getString(R.string.ok), (dialog, which) -> ((StoragePermissionListener)getParentFragment()).requestPermission());
    if(isDeniedForever){
        message = message + getString(R.string.permission_rationale_settings);
        alertDialogBuilder.setNeutralButton(getString(R.string.settings), (dialog, which) -> {
            final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.fromParts("package", getContext().getPackageName(), null));
            startActivity(intent);
        });
    }
    return super.onCreateDialog(savedInstanceState);
}
 
Example #9
Source File: ProjectSelectorDialogFragment.java    From ground-android with Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  super.onCreateDialog(savedInstanceState);
  AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
  dialog.setTitle(R.string.join_project);
  LayoutInflater inflater = getActivity().getLayoutInflater();
  ViewGroup dialogView = (ViewGroup) inflater.inflate(R.layout.project_selector_dialog, null);
  ButterKnife.bind(this, dialogView);
  listAdapter =
      new ArrayAdapter(getContext(), R.layout.project_selector_list_item, R.id.project_name);
  listView.setAdapter(listAdapter);
  viewModel.getProjectSummaries().observe(this, this::updateProjectList);
  listView.setOnItemClickListener(this::onItemSelected);
  dialog.setView(dialogView);
  dialog.setCancelable(false);
  return dialog.create();
}
 
Example #10
Source File: FragmentSetup.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    return new AlertDialog.Builder(getContext())
            .setMessage(R.string.title_setup_doze_instructions)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        startActivity(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS));
                    } catch (Throwable ex) {
                        Log.e(ex);
                    }
                }
            })
            .setNegativeButton(android.R.string.cancel, null)
            .create();
}
 
Example #11
Source File: RegistrationActivity.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostExecute(Void result) {
    super.onPostExecute(result);
    RegistrationActivity activity = activityWeakReference.get();
    if (activity!=null && !TextUtils.isEmpty(oauth2url)) {
        new AlertDialog.Builder(activity)
                .setTitle(R.string.login_info_oauth2_title)
                .setMessage(R.string.login_info_oauth2_text)
                .setNegativeButton(R.string.cancel, (dialog, which)->{
                    activity.oauth2DeclinedByUser = true;
                    oauth2started.set(false);
                })
                .setPositiveButton(R.string.perm_continue, (dialog, which)-> {
                    // pass control to browser, we'll be back in business at (**)
                    activity.oauth2Requested = System.currentTimeMillis();
                    IntentUtils.showBrowserIntent(activity, oauth2url);
                    oauth2started.set(true);
                })
                .setCancelable(false)
                .show();
    } else {
        oauth2started.set(false);
    }
}
 
Example #12
Source File: OpenChatFragment.java    From SendBird-Android with MIT License 6 votes vote down vote up
private void showUploadConfirmDialog(final Uri uri) {
    new AlertDialog.Builder(getActivity())
            .setMessage("Upload file?")
            .setPositiveButton(R.string.upload, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (which == DialogInterface.BUTTON_POSITIVE) {

                        // Specify two dimensions of thumbnails to generate
                        List<FileMessage.ThumbnailSize> thumbnailSizes = new ArrayList<>();
                        thumbnailSizes.add(new FileMessage.ThumbnailSize(240, 240));
                        thumbnailSizes.add(new FileMessage.ThumbnailSize(320, 320));

                        sendImageWithThumbnail(uri, thumbnailSizes);
                    }
                }
            })
            .setNegativeButton(R.string.cancel, null).show();
}
 
Example #13
Source File: LinkingDeviceActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
private void showLEDColor(final OnSelectedListener listener) {
    byte[] illumination = mDevice.getIllumination();
    if (illumination == null) {
        Toast.makeText(getApplicationContext(), getString(R.string.activity_device_not_support_led), Toast.LENGTH_SHORT).show();
        return;
    }

    try {
        final IlluminationData data = new IlluminationData(illumination);

        AlertDialog.Builder builder = new AlertDialog.Builder(LinkingDeviceActivity.this);
        final String[] items = new String[data.getColor().getChildren().length];
        for (int i = 0; i < data.getColor().getChildren().length; i++) {
            items[i] = data.getColor().getChild(i).getName(0).getName();
        }
        builder.setTitle(getString(R.string.activity_device_color_list)).setItems(items, (dialog, which) -> {
            Setting selectedColor = data.getColor().getChild(which);
            if (listener != null) {
                listener.onSelected(selectedColor.getName(0).getName(), selectedColor.getId() & 0xFF);
            }
        });
        builder.create().show();
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), getString(R.string.activity_device_not_support_led), Toast.LENGTH_SHORT).show();
    }
}
 
Example #14
Source File: ReloadProfileDialogFragment.java    From SecondScreen with Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_reload_profile_title)
    .setMessage(R.string.editing_current_profile)
    .setPositiveButton(R.string.action_save_reload, (dialog, id) -> {
        if(getArguments() != null)
            listener.onReloadDialogPositiveClick(getArguments().getString("filename"),
                getArguments().getBoolean("is-edit"),
                getArguments().getBoolean("return-to-list"));
        else
            listener.onReloadDialogPositiveClick(null, false, false);
    })
    .setNegativeButton(R.string.action_save_only, (dialog, id) -> {
        if(getArguments() != null)
            listener.onReloadDialogNegativeClick(getArguments().getString("filename"),
                    getArguments().getBoolean("is-edit"),
                    getArguments().getBoolean("return-to-list"));
        else
            listener.onReloadDialogNegativeClick(null, false, false);
    });

    // Create the AlertDialog object and return it
    return builder.create();
}
 
Example #15
Source File: MainActivity.java    From blinkreceipt-android with MIT License 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected (MenuItem item ) {
    switch( item.getItemId() ) {
        case R.id.sdk_version:
            new AlertDialog.Builder( this )
                    .setTitle( R.string.sdk_version_dialog_title )
                    .setMessage( BlinkReceiptSdk.versionName( this ) )
                    .setPositiveButton(android.R.string.ok, (dialog, which) -> dialog.dismiss())
                    .create()
                    .show();

            return true;
        case R.id.camera:
            if ( EasyPermissions.hasPermissions( this, requestPermissions ) ) {
                startCameraScanForResult();
            } else {
                EasyPermissions.requestPermissions(this, getString( R.string.permissions_rationale ),
                        PERMISSIONS_REQUEST_CODE, requestPermissions );
            }

            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example #16
Source File: FieldAdapter.java    From Field-Book with GNU General Public License v2.0 6 votes vote down vote up
private PopupMenu.OnMenuItemClickListener makeSelectMenuListener(final int position) {
    return new PopupMenu.OnMenuItemClickListener() {
        // Do it when selecting Delete or Statistics
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            final Activity thisActivity = FieldEditorActivity.thisActivity;
            final String strDel = thisActivity.getString(R.string.fields_delete);

            if (item.getTitle().equals(strDel)) {
                AlertDialog alert = createDeleteItemAlertDialog(position);
                alert.show();
                DialogUtils.styleDialogs(alert);
            }

            return false;
        }
    };
}
 
Example #17
Source File: WebRtcAudioOutputToggleButton.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private void showPicker(@NonNull List<WebRtcAudioOutput> availableModes) {
  RecyclerView       rv      = new RecyclerView(getContext());
  AudioOutputAdapter adapter = new AudioOutputAdapter(audioOutput -> {
                                                        setAudioOutput(audioOutput, true);
                                                        hidePicker();
                                                      },
                                                      availableModes);

  adapter.setSelectedOutput(OUTPUT_MODES.get(outputIndex));

  rv.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
  rv.setAdapter(adapter);

  picker = new AlertDialog.Builder(getContext())
                          .setTitle(R.string.WebRtcAudioOutputToggle__audio_output)
                          .setView(rv)
                          .setCancelable(true)
                          .show();
}
 
Example #18
Source File: FieldSelector.java    From android-places-demos with Apache License 2.0 6 votes vote down vote up
/**
 * Shows dialog to allow user to select {@link Field} values they want.
 */
public void showDialog(Context context) {
  ListView listView = new ListView(context);
  PlaceFieldArrayAdapter adapter = new PlaceFieldArrayAdapter(context, fieldStates.values());
  listView.setAdapter(adapter);
  listView.setOnItemClickListener(adapter);

  new AlertDialog.Builder(context)
          .setTitle("Select Place Fields")
          .setPositiveButton(
                  "Done",
                  (dialog, which) -> {
                    outputView.setText(getSelectedString());
                  })
          .setView(listView)
          .show();
}
 
Example #19
Source File: DebugFragment.java    From zephyr with MIT License 6 votes vote down vote up
@OnClick(R.id.debug_theme)
public void onClickTheme(@NonNull TextView view) {
    if (getActivity() == null) {
        return;
    }

    Resources resources = getActivity().getResources();
    final CharSequence[] themeChoices = {
            resources.getString(R.string.menu_debug_theme_system),
            resources.getString(R.string.menu_debug_theme_light),
            resources.getString(R.string.menu_debug_theme_dark)};

    AlertDialog alertDialog = new MaterialAlertDialogBuilder(getActivity())
            .setTitle(R.string.menu_debug_theme_title)
            .setSingleChoiceItems(themeChoices, themeManager.getCurrentThemeSetting(), (dialog, which) -> {
                themeManager.setCurrentThemeSetting(which);
                updateThemeText();
                dialog.dismiss();
            }).create();
    alertDialog.show();
}
 
Example #20
Source File: DeleteImageDialogFragment.java    From cloudinary_android with MIT License 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Resource resource = (Resource) getArguments().getSerializable("resource");
    final boolean recent = getArguments().getBoolean("recent");
    final String message = recent ? getString(R.string.delete_resource_everywhere_message, resource.getResourceType()) :
            getString(R.string.delete_resource_locally_message, resource.getResourceType());

    return new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.delete_single_resource_title, resource.getResourceType()))
            .setMessage(message)
            .setNegativeButton(R.string.delete_single_resource_no, null)
            .setPositiveButton(R.string.delete_single_resource_yes, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (recent) {
                        ((DeleteRequestsCallback) getActivity()).onDeleteResourceEverywhere(resource);
                    } else {
                        ((DeleteRequestsCallback) getActivity()).onDeleteResourceLocally(resource);
                    }
                }
            }).create();
}
 
Example #21
Source File: ListPreferenceData.java    From Status with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    selectedPreference = getListPreference(preference);
    if (selectedPreference == null) return;

    CharSequence[] array = new CharSequence[items.size()];
    for (int i = 0; i < items.size(); i++) {
        array[i] = items.get(i).name;
    }

    new AlertDialog.Builder(getContext())
            .setTitle(getIdentifier().getTitle())
            .setSingleChoiceItems(array, items.indexOf(selectedPreference), (dialog, which) -> selectedPreference = items.get(which))
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                if (selectedPreference != null) {
                    ListPreferenceData.this.preference = selectedPreference.id;

                    getIdentifier().setPreferenceValue(getContext(), selectedPreference.id);
                    onPreferenceChange(selectedPreference.id);
                    selectedPreference = null;
                }
            })
            .setNegativeButton(android.R.string.cancel, (dialog, which) -> selectedPreference = null)
            .create()
            .show();
}
 
Example #22
Source File: MapActivity.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
private boolean handlePoiLongClick(LatLng point) {
    final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
    List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, mapDataManager.getMarkerLayers());
    for (Feature feature : features) {
        if (feature.getBooleanProperty(IS_POI)) {
            new AlertDialog.Builder(MapActivity.this)
                    .setMessage(getString(R.string.menu_delete_location))
                    .setPositiveButton(R.string.yes, (dialog, which) -> {
                        int messageId = feature.getNumberProperty(MESSAGE_ID).intValue();
                        int[] messages = new int[1];
                        messages[0] = messageId;
                        ApplicationContext.getInstance(MapActivity.this).dcContext.deleteMsgs(messages);
                    })
                    .setNegativeButton(R.string.no, null)
                    .show();
            return true;
        }
    }
    return false;
}
 
Example #23
Source File: AdvancedPreferenceFragment.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(final Preference preference, Object newValue) {
  if (((CheckBoxPreference)preference).isChecked()) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setIconAttribute(R.attr.dialog_info_icon);
    builder.setTitle(R.string.ApplicationPreferencesActivity_disable_signal_messages_and_calls);
    builder.setMessage(R.string.ApplicationPreferencesActivity_disable_signal_messages_and_calls_by_unregistering);
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        new DisablePushMessagesTask((CheckBoxPreference)preference).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
      }
    });
    builder.show();
  } else {
    startActivity(RegistrationNavigationActivity.newIntentForReRegistration(requireContext()));
  }

  return false;
}
 
Example #24
Source File: CollectActivity.java    From Field-Book with GNU General Public License v2.0 6 votes vote down vote up
private void showSummary() {
    LayoutInflater inflater = this.getLayoutInflater();
    View layout = inflater.inflate(R.layout.dialog_summary, null);
    TextView summaryText = layout.findViewById(R.id.field_name);
    summaryText.setText(traitBox.createSummaryText(rangeBox.getPlotID()));

    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppAlertDialog);
    builder.setTitle(R.string.preferences_appearance_toolbar_customize_summary)
            .setCancelable(true)
            .setView(layout);

    builder.setNegativeButton(getString(R.string.dialog_close), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            dialog.dismiss();
        }
    });

    final AlertDialog summaryDialog = builder.create();
    summaryDialog.show();
    DialogUtils.styleDialogs(summaryDialog);

    android.view.WindowManager.LayoutParams params2 = summaryDialog.getWindow().getAttributes();
    params2.width = LayoutParams.MATCH_PARENT;
    summaryDialog.getWindow().setAttributes(params2);
}
 
Example #25
Source File: LogcatActivity.java    From matlog with GNU General Public License v3.0 6 votes vote down vote up
private void showLogLevelDialog() {
    String[] logLevels = getResources().getStringArray(R.array.log_levels);

    // put the word "default" after whatever the default log level is
    String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this));
    int index = ArrayUtil.indexOf(getResources().getStringArray(R.array.log_levels_values), defaultLogLevel);

    logLevels[index] = logLevels[index] + " " + getString(R.string.default_in_parens);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle(R.string.log_level)
            .setCancelable(true)
            .setSingleChoiceItems(logLevels, mLogListAdapter.getLogLevelLimit(), (dialog, which) -> {
                mLogListAdapter.setLogLevelLimit(which);
                logLevelChanged();
                dialog.dismiss();

            });

    builder.show();
}
 
Example #26
Source File: AddDeviceActivity.java    From esp-idf-provisioning-android with Apache License 2.0 5 votes vote down vote up
private void alertForWiFi() {

        AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogTheme);
        builder.setCancelable(false);
        builder.setMessage(R.string.error_wifi_off);

        // Set up the buttons
        builder.setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
                espDevice = null;
                hideLoading();
                if (codeScanner != null) {
                    codeScanner.releaseResources();
                    codeScanner.startPreview();
                    if (ActivityCompat.checkSelfPermission(AddDeviceActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                            && ActivityCompat.checkSelfPermission(AddDeviceActivity.this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
                        provisionManager.scanQRCode(codeScanner, qrCodeScanListener);
                    } else {
                        Log.e(TAG, "Permissions are not granted");
                    }
                }
            }
        });

        builder.show();
    }
 
Example #27
Source File: KeyNameDialogFragment.java    From nRF-Logger-API with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
	final AlertDialog.Builder builder = new AlertDialog.Builder(requireContext())
			.setTitle(R.string.dialog_title)
			.setNegativeButton(android.R.string.no, null)
			.setPositiveButton(android.R.string.ok, this);

	final View view = LayoutInflater.from(requireContext())
			.inflate(R.layout.fragment_dialog_key_name, null);
	mKeyView = view.findViewById(R.id.key);
	mNameView = view.findViewById(R.id.name);
	builder.setView(view);
	return builder.create();
}
 
Example #28
Source File: AdapterGroup.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    Group group = groups.get(getAdapterPosition());
    switch (view.getId()) {
        case R.id.ivException:
            StringBuilder sb = new StringBuilder();
            for (XAssignment assignment : app.getAssignments(group.name))
                if (assignment.hook.getGroup().equals(group.name))
                    if (assignment.exception != null) {
                        sb.append("<b>");
                        sb.append(Html.escapeHtml(assignment.hook.getId()));
                        sb.append("</b><br><br>");
                        for (String line : assignment.exception.split("\n")) {
                            sb.append(Html.escapeHtml(line));
                            sb.append("<br>");
                        }
                        sb.append("<br><br>");
                    }

            LayoutInflater inflater = LayoutInflater.from(view.getContext());
            View alert = inflater.inflate(R.layout.exception, null, false);
            TextView tvException = alert.findViewById(R.id.tvException);
            tvException.setText(Html.fromHtml(sb.toString()));

            new AlertDialog.Builder(view.getContext())
                    .setView(alert)
                    .create()
                    .show();
            break;

        case R.id.tvGroup:
            cbAssigned.setChecked(!cbAssigned.isChecked());
            break;
    }
}
 
Example #29
Source File: MainActivity.java    From quickstart-android with Apache License 2.0 5 votes vote down vote up
private void validateAppCode() {
    String uriPrefix = getString(R.string.dynamic_links_uri_prefix);
    if (uriPrefix.contains("YOUR_APP")) {
        new AlertDialog.Builder(this)
                .setTitle("Invalid Configuration")
                .setMessage("Please set your Dynamic Links domain in app/build.gradle")
                .setPositiveButton(android.R.string.ok, null)
                .create().show();
    }
}
 
Example #30
Source File: Utils.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
public static void changelogDialog(Context context) {

        String versionName = appVersion();

        AlertDialog.Builder alert = new AlertDialog.Builder(context);
        alert.setTitle(String.format(context.getString(R.string.changelog), versionName ));
        alert.setMessage(context.getString(R.string.changelog_message));
        alert.setPositiveButton(context.getString(R.string.close), (dialog, id) -> {
            AppSettings.saveBoolean("show_changelog", false, context);
        });

        alert.show();
    }