use of android.Manifest.permission.READ_EXTERNAL_STORAGE in project MaxLock by Maxr1998.
the class MaxLockPreferenceFragment method onLockscreenDismissed.
public void onLockscreenDismissed() {
// Show changelog and rating dialog
int lastVersionNumber = prefs.getInt(Common.LAST_VERSION_NUMBER, -1);
if (BuildConfig.VERSION_CODE > lastVersionNumber) {
// Don't show updated dialog on first start
if (lastVersionNumber > 0)
showUpdatedMessage();
prefs.edit().putInt(Common.LAST_VERSION_NUMBER, BuildConfig.VERSION_CODE).apply();
} else {
if (isFirstPane() && allowRatingDialog()) {
prefs.edit().putInt(Common.RATING_DIALOG_APP_OPENING_COUNTER, 0).putLong(Common.RATING_DIALOG_LAST_SHOWN, System.currentTimeMillis()).apply();
@SuppressLint("InflateParams") View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_like_app, null);
if (prefs.getBoolean(Common.DONATED, false)) {
TextView dialogText = dialogView.findViewById(R.id.dialog_like_app_text);
dialogText.setText(R.string.dialog_like_app_text_pro);
}
@SuppressWarnings("ResourceType") final CheckBox checkBox = dialogView.findViewById(R.id.dialog_cb_never_again);
DialogInterface.OnClickListener onClickListener = (dialogInterface, i) -> {
if (checkBox.isChecked()) {
prefs.edit().putBoolean(Common.RATING_DIALOG_SHOW_NEVER, true).apply();
}
switch(i) {
case BUTTON_NEUTRAL:
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + BuildConfig.APPLICATION_ID)));
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID)));
}
break;
case BUTTON_POSITIVE:
startActivity(new Intent(getActivity(), DonateActivity.class));
break;
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(R.string.dialog_like_app).setView(dialogView);
if (!prefs.getBoolean(Common.DONATED, false))
builder.setPositiveButton(R.string.dialog_button_donate, onClickListener);
builder.setNeutralButton(R.string.dialog_button_rate, onClickListener).setNegativeButton(android.R.string.cancel, onClickListener).create().show();
}
}
if (SDK_INT > Build.VERSION_CODES.O && ContextCompat.checkSelfPermission(getContext(), READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
new AlertDialog.Builder(getActivity()).setMessage(R.string.dialog_need_storage_permission_oreo).setPositiveButton(android.R.string.ok, (dialog, which) -> ActivityCompat.requestPermissions(getActivity(), new String[] { READ_EXTERNAL_STORAGE }, 0)).setNegativeButton(android.R.string.cancel, null).show();
}
}
Aggregations