Browse Source

Re-try to get file management permission if user does not enable it, and show toast.

Does not allow any usage of the app if permission is not granted.

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 years ago
parent
commit
7966fa7923

+ 17 - 3
src/main/java/com/owncloud/android/ui/activity/FileActivity.java

@@ -39,6 +39,7 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.text.TextUtils;
+import android.widget.Toast;
 
 import com.google.android.material.snackbar.Snackbar;
 import com.nextcloud.client.account.UserAccountManager;
@@ -91,6 +92,7 @@ import com.owncloud.android.utils.ClipboardUtil;
 import com.owncloud.android.utils.DisplayUtils;
 import com.owncloud.android.utils.ErrorMessageAdapter;
 import com.owncloud.android.utils.FilesSyncHelper;
+import com.owncloud.android.utils.PermissionUtil;
 import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
 import com.owncloud.android.utils.theme.ThemeToolbarUtils;
 
@@ -919,9 +921,21 @@ public abstract class FileActivity extends DrawerActivity
      */
     @Override
     public void onShareProcessClosed() {
-        Fragment fragment  = getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_LIST_OF_FILES);
-        if (fragment!=null){
-            ((FileDetailFragment)fragment).showHideFragmentView(false);
+        Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_LIST_OF_FILES);
+        if (fragment != null) {
+            ((FileDetailFragment) fragment).showHideFragmentView(false);
+        }
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) {
+            // if the user denies manage storage, ask it again
+            Toast.makeText(this, R.string.file_management_permission_denied, Toast.LENGTH_SHORT).show();
+            if (!PermissionUtil.checkExternalStoragePermission(this)) {
+                PermissionUtil.requestExternalStoragePermission(this);
+            }
         }
     }
 }

+ 1 - 0
src/main/res/values/strings.xml

@@ -1005,4 +1005,5 @@
     <string name="whats_new_storage_sdk30_title">Changes in storage access from Android 11</string>
     <string name="whats_new_storage_sdk30_content">From Android 11 onwards, strict storage access control is enforced.\n\nAs a consequence, Nextcloud will no longer be able to write or delete files on external storage, or read files in private folders owned by other apps.</string>
     <string name="whats_new_storage_sdk30_content_page2">Please check your auto upload items and verify that Nextcloud still has read access to the local folder.\n\nAdditionally, other applications will not be able to read Nextcloud\'s downloaded files directly from the external storage.</string>
+    <string name="file_management_permission_denied">File management permission is required to use Nextcloud. Please enable it to continue.</string>
 </resources>