OSDN Git Service

Improve permission string & cleanup code
authorMichael Bestas <mikeioannina@cyanogenmod.org>
Sun, 24 Jan 2016 20:30:47 +0000 (22:30 +0200)
committerMichael Bestas <mikeioannina@cyanogenmod.org>
Sun, 24 Jan 2016 20:30:47 +0000 (22:30 +0200)
Change-Id: Id0e4be70019fd03c165d4f95f1b5f6323e2802ea

res/values/strings.xml
src/com/cyanogenmod/filemanager/activities/NavigationActivity.java

index b71fd52..4199502 100644 (file)
     <string name="welcome_msg">Welcome to the CyanogenMod file manager.\n\nThis app allows you to explore the file system and do operations that could break your device. To prevent damage, the app will start in a safe, low-privileged mode.\n\nYou can access the advanced, full-privileged mode via Settings. It\'s your responsibility to ensure that an operation doesn\'t break your system.\n\nThe CyanogenMod Team</string>
 
     <string name="activity_not_found_exception">Couldn\'t find an app to open this file</string>
-    <string name="storage_permissions_denied">Storage permissions denied!</string>
+
+    <string name="storage_permissions_denied">The app cannot run without permission to write to external storage.</string>
 
 </resources>
index 6ad7a48..bf663b6 100755 (executable)
@@ -32,6 +32,7 @@ import android.content.res.XmlResourceParser;
 import android.database.Cursor;
 import android.graphics.Color;
 import android.graphics.drawable.Drawable;
+import android.Manifest;
 import android.net.Uri;
 import android.nfc.NfcAdapter;
 import android.nfc.NfcEvent;
@@ -495,14 +496,13 @@ public class NavigationActivity extends Activity
 
     private static final int REQUEST_CODE_STORAGE_PERMS = 321;
     private boolean hasPermissions() {
-        String permission = "android.permission.WRITE_EXTERNAL_STORAGE";
-        int res = checkCallingOrSelfPermission(permission);
+        int res = checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
         return (res == PackageManager.PERMISSION_GRANTED);
     }
 
     private void requestNecessaryPermissions() {
         String[] permissions = new String[] {
-                "android.permission.WRITE_EXTERNAL_STORAGE"
+                Manifest.permission.WRITE_EXTERNAL_STORAGE,
         };
         requestPermissions(permissions, REQUEST_CODE_STORAGE_PERMS);
     }