[Libreoffice-commits] online.git: android/app
kaishu-sahu (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 14 18:34:44 UTC 2019
android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java | 45 ++++++++++
android/app/src/main/res/values/strings.xml | 7 +
2 files changed, 52 insertions(+)
New commits:
commit 743f2e7bdb98fb695ec23a52e53a95a7e3a8a5ad
Author: kaishu-sahu <kaishusahu101 at gmail.com>
AuthorDate: Tue May 28 02:15:33 2019 +0530
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri Jun 14 20:34:00 2019 +0200
android: add rationale dialog for permission denial with "Don't ask again".
If the user denies the permission with "Don't ask again" ticked
in the permission dialog then the only way to allow the permission
is through android os settings.
Change-Id: I8f51ae7390a9565011d6172bcbd08b3666bd60e4
Reviewed-on: https://gerrit.libreoffice.org/73071
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
index 0d9c65b46..3c462fe52 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
@@ -26,9 +26,11 @@ import android.graphics.drawable.Icon;
import android.hardware.usb.UsbManager;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
+import android.provider.Settings;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
@@ -1316,6 +1318,49 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
setEditFABVisibility(View.VISIBLE);
} else {
setEditFABVisibility(View.INVISIBLE);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ boolean showRationale = shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE);
+ androidx.appcompat.app.AlertDialog.Builder rationaleDialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(this)
+ .setCancelable(false)
+ .setTitle(getString(R.string.title_permission_required))
+ .setMessage(getString(R.string.reason_required_to_read_documents));
+ if (showRationale) {
+ rationaleDialogBuilder.setPositiveButton(getString(R.string.positive_ok), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ ActivityCompat.requestPermissions(LibreOfficeUIActivity.this,
+ new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
+ PERMISSION_WRITE_EXTERNAL_STORAGE);
+ }
+ })
+ .setNegativeButton(getString(R.string.negative_im_sure), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ LibreOfficeUIActivity.this.finish();
+ }
+ })
+ .create()
+ .show();
+ } else {
+ rationaleDialogBuilder.setPositiveButton(getString(R.string.positive_ok), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+ Uri uri = Uri.fromParts("package", getPackageName(), null);
+ intent.setData(uri);
+ startActivity(intent);
+ }
+ })
+ .setNegativeButton(R.string.negative_cancel, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ LibreOfficeUIActivity.this.finish();
+ }
+ })
+ .create()
+ .show();
+ }
+ }
}
break;
default:
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 41dc85ad6..7e893df46 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -109,6 +109,13 @@
<string name="bad_directory">Invalid directory path</string>
<string name="current_dir">Current Directory: %1$s</string>
+ <!-- Permission rationale alert dialog strings -->
+ <string name="title_permission_required">Permission Required</string>
+ <string name="reason_required_to_read_documents">Storage permission is required for reading your documents.</string>
+ <string name="positive_ok">OKAY</string>
+ <string name="negative_im_sure">I\'M SURE</string>
+ <string name="negative_cancel">CANCEL</string>
+
<!-- Save Alert dialog strings -->
<string name="action_cancel">Cancel</string>
More information about the Libreoffice-commits
mailing list