Browse Source

combine sharedPreferences in MainApp

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 6 years ago
parent
commit
1b2c41b7e4

+ 6 - 0
src/main/java/com/nextcloud/client/preferences/AppPreferences.java

@@ -274,4 +274,10 @@ public interface AppPreferences {
      * @implNote this clears only shared preferences, not preferences kept in account manager
      * @implNote this clears only shared preferences, not preferences kept in account manager
      */
      */
     void clear();
     void clear();
+
+    String getStoragePath(String defaultPath);
+
+    void setStoragePath(String path);
+
+    void removeKeysMigrationPreference();
 }
 }

+ 36 - 5
src/main/java/com/nextcloud/client/preferences/PreferenceManager.java

@@ -20,9 +20,9 @@
 package com.nextcloud.client.preferences;
 package com.nextcloud.client.preferences;
 
 
 import android.accounts.Account;
 import android.accounts.Account;
+import android.annotation.SuppressLint;
 import android.content.Context;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences;
-
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -41,6 +41,8 @@ public final class PreferenceManager implements AppPreferences {
      * Constant to access value of last path selected by the user to upload a file shared from other app.
      * Constant to access value of last path selected by the user to upload a file shared from other app.
      * Value handled by the app without direct access in the UI.
      * Value handled by the app without direct access in the UI.
      */
      */
+    public static final String AUTO_PREF__LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
+    public static final String STORAGE_PATH = "storage_path";
     private static final String AUTO_PREF__LAST_UPLOAD_PATH = "last_upload_path";
     private static final String AUTO_PREF__LAST_UPLOAD_PATH = "last_upload_path";
     private static final String AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH = "upload_from_local_last_path";
     private static final String AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH = "upload_from_local_last_path";
     private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_MAP_URL = "prefs_upload_file_extension_map_url";
     private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_MAP_URL = "prefs_upload_file_extension_map_url";
@@ -48,12 +50,11 @@ public final class PreferenceManager implements AppPreferences {
     private static final String AUTO_PREF__UPLOADER_BEHAVIOR = "prefs_uploader_behaviour";
     private static final String AUTO_PREF__UPLOADER_BEHAVIOR = "prefs_uploader_behaviour";
     private static final String AUTO_PREF__GRID_COLUMNS = "grid_columns";
     private static final String AUTO_PREF__GRID_COLUMNS = "grid_columns";
     private static final String AUTO_PREF__SHOW_DETAILED_TIMESTAMP = "detailed_timestamp";
     private static final String AUTO_PREF__SHOW_DETAILED_TIMESTAMP = "detailed_timestamp";
-    public static final String AUTO_PREF__LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
     private static final String PREF__INSTANT_UPLOADING = "instant_uploading";
     private static final String PREF__INSTANT_UPLOADING = "instant_uploading";
     private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading";
     private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading";
     private static final String PREF__SHOW_HIDDEN_FILES = "show_hidden_files_pref";
     private static final String PREF__SHOW_HIDDEN_FILES = "show_hidden_files_pref";
     private static final String PREF__LEGACY_CLEAN = "legacyClean";
     private static final String PREF__LEGACY_CLEAN = "legacyClean";
-    public static final String PREF__KEYS_MIGRATION = "keysMigration";
+    private static final String PREF__KEYS_MIGRATION = "keysMigration";
     private static final String PREF__FIX_STORAGE_PATH = "storagePathFix";
     private static final String PREF__FIX_STORAGE_PATH = "storagePathFix";
     private static final String PREF__KEYS_REINIT = "keysReinit";
     private static final String PREF__KEYS_REINIT = "keysReinit";
     private static final String PREF__AUTO_UPLOAD_UPDATE_PATH = "autoUploadPathUpdate";
     private static final String PREF__AUTO_UPLOAD_UPDATE_PATH = "autoUploadPathUpdate";
@@ -62,7 +63,7 @@ public final class PreferenceManager implements AppPreferences {
     private static final String PREF__AUTO_UPLOAD_INIT = "autoUploadInit";
     private static final String PREF__AUTO_UPLOAD_INIT = "autoUploadInit";
     private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
     private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
     private static final String PREF__FOLDER_LAYOUT = "folder_layout";
     private static final String PREF__FOLDER_LAYOUT = "folder_layout";
-    public static final String PREF__LOCK_TIMESTAMP = "lock_timestamp";
+    private static final String PREF__LOCK_TIMESTAMP = "lock_timestamp";
     private static final String PREF__SHOW_MEDIA_SCAN_NOTIFICATIONS = "show_media_scan_notifications";
     private static final String PREF__SHOW_MEDIA_SCAN_NOTIFICATIONS = "show_media_scan_notifications";
     private static final String PREF__LOCK = SettingsActivity.PREFERENCE_LOCK;
     private static final String PREF__LOCK = SettingsActivity.PREFERENCE_LOCK;
 
 
@@ -76,7 +77,7 @@ public final class PreferenceManager implements AppPreferences {
         return new PreferenceManager(appContext, prefs);
         return new PreferenceManager(appContext, prefs);
     }
     }
 
 
-    public static SharedPreferences getDefaultSharedPreferences(Context context) {
+    private static SharedPreferences getDefaultSharedPreferences(Context context) {
         return android.preference.PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
         return android.preference.PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
     }
     }
 
 
@@ -245,6 +246,11 @@ public final class PreferenceManager implements AppPreferences {
     @Override
     @Override
     public void setSortOrder(FileSortOrder.Type type, FileSortOrder sortOrder) {
     public void setSortOrder(FileSortOrder.Type type, FileSortOrder sortOrder) {
         Account account = AccountUtils.getCurrentOwnCloudAccount(context);
         Account account = AccountUtils.getCurrentOwnCloudAccount(context);
+
+        if (account == null) {
+            throw new IllegalArgumentException("Account may not be null!");
+        }
+
         ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
         ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
         dataProvider.storeOrUpdateKeyValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
         dataProvider.storeOrUpdateKeyValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
     }
     }
@@ -402,6 +408,26 @@ public final class PreferenceManager implements AppPreferences {
         preferences.edit().clear().apply();
         preferences.edit().clear().apply();
     }
     }
 
 
+    @Override
+    public String getStoragePath(String defaultPath) {
+        return preferences.getString(STORAGE_PATH, defaultPath);
+    }
+
+    @SuppressLint("ApplySharedPref")
+    @Override
+    public void setStoragePath(String path) {
+        preferences.edit().putString(STORAGE_PATH, path).commit();  // commit synchronously
+    }
+
+    /**
+     * Removes keys migration key from shared preferences.
+     */
+    @SuppressLint("ApplySharedPref")
+    @Override
+    public void removeKeysMigrationPreference() {
+        preferences.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit(); // commit synchronously
+    }
+
     /**
     /**
      * Get preference value for a folder.
      * Get preference value for a folder.
      * If folder is not set itself, it finds an ancestor that is set.
      * If folder is not set itself, it finds an ancestor that is set.
@@ -441,6 +467,11 @@ public final class PreferenceManager implements AppPreferences {
      */
      */
     private static void setFolderPreference(Context context, String preferenceName, OCFile folder, String value) {
     private static void setFolderPreference(Context context, String preferenceName, OCFile folder, String value) {
         Account account = AccountUtils.getCurrentOwnCloudAccount(context);
         Account account = AccountUtils.getCurrentOwnCloudAccount(context);
+
+        if (account == null) {
+            throw new IllegalArgumentException("Account may not be null!");
+        }
+
         ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
         ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
         dataProvider.storeOrUpdateKeyValue(account.name, getKeyFromFolder(preferenceName, folder), value);
         dataProvider.storeOrUpdateKeyValue(account.name, getKeyFromFolder(preferenceName, folder), value);
     }
     }

+ 28 - 34
src/main/java/com/owncloud/android/MainApp.java

@@ -29,7 +29,6 @@ import android.app.Service;
 import android.content.ContentResolver;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Context;
 import android.content.Intent;
 import android.content.Intent;
-import android.content.SharedPreferences;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager;
 import android.os.Build;
 import android.os.Build;
@@ -38,12 +37,7 @@ import android.os.Environment;
 import android.os.StrictMode;
 import android.os.StrictMode;
 import android.text.TextUtils;
 import android.text.TextUtils;
 import android.view.WindowManager;
 import android.view.WindowManager;
-import androidx.annotation.RequiresApi;
-import androidx.annotation.StringRes;
-import androidx.appcompat.app.AlertDialog;
-import androidx.core.util.Pair;
-import androidx.fragment.app.Fragment;
-import androidx.multidex.MultiDexApplication;
+
 import com.evernote.android.job.JobManager;
 import com.evernote.android.job.JobManager;
 import com.evernote.android.job.JobRequest;
 import com.evernote.android.job.JobRequest;
 import com.nextcloud.client.di.ActivityInjector;
 import com.nextcloud.client.di.ActivityInjector;
@@ -68,7 +62,6 @@ import com.owncloud.android.lib.common.OwnCloudClientManagerFactory.Policy;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
 import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
-import com.owncloud.android.ui.activity.SettingsActivity;
 import com.owncloud.android.ui.activity.SyncedFoldersActivity;
 import com.owncloud.android.ui.activity.SyncedFoldersActivity;
 import com.owncloud.android.ui.activity.WhatsNewActivity;
 import com.owncloud.android.ui.activity.WhatsNewActivity;
 import com.owncloud.android.ui.notifications.NotificationUtils;
 import com.owncloud.android.ui.notifications.NotificationUtils;
@@ -77,14 +70,7 @@ import com.owncloud.android.utils.FilesSyncHelper;
 import com.owncloud.android.utils.PermissionUtil;
 import com.owncloud.android.utils.PermissionUtil;
 import com.owncloud.android.utils.ReceiversHelper;
 import com.owncloud.android.utils.ReceiversHelper;
 import com.owncloud.android.utils.SecurityUtils;
 import com.owncloud.android.utils.SecurityUtils;
-import dagger.android.AndroidInjector;
-import dagger.android.DispatchingAndroidInjector;
-import dagger.android.HasActivityInjector;
-import dagger.android.HasServiceInjector;
-import dagger.android.support.HasSupportFragmentInjector;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 
-import javax.inject.Inject;
 import java.lang.reflect.Method;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -92,6 +78,21 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
+import javax.inject.Inject;
+
+import androidx.annotation.RequiresApi;
+import androidx.annotation.StringRes;
+import androidx.appcompat.app.AlertDialog;
+import androidx.core.util.Pair;
+import androidx.fragment.app.Fragment;
+import androidx.multidex.MultiDexApplication;
+import dagger.android.AndroidInjector;
+import dagger.android.DispatchingAndroidInjector;
+import dagger.android.HasActivityInjector;
+import dagger.android.HasServiceInjector;
+import dagger.android.support.HasSupportFragmentInjector;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP;
 import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP;
 
 
 
 
@@ -124,8 +125,6 @@ public class MainApp extends MultiDexApplication implements
 
 
     private static boolean mOnlyOnDevice;
     private static boolean mOnlyOnDevice;
 
 
-    private SharedPreferences sharedPreferences;
-
     @Inject
     @Inject
     AppPreferences preferences;
     AppPreferences preferences;
 
 
@@ -161,12 +160,10 @@ public class MainApp extends MultiDexApplication implements
         new SecurityUtils();
         new SecurityUtils();
         DisplayUtils.useCompatVectorIfNeeded();
         DisplayUtils.useCompatVectorIfNeeded();
 
 
-        sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
         fixStoragePath();
         fixStoragePath();
         passCodeManager = new PassCodeManager(preferences);
         passCodeManager = new PassCodeManager(preferences);
 
 
-        MainApp.storagePath = sharedPreferences.getString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
-                                                 getApplicationContext().getFilesDir().getAbsolutePath());
+        MainApp.storagePath = preferences.getStoragePath(getApplicationContext().getFilesDir().getAbsolutePath());
 
 
         boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
         boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
 
 
@@ -276,22 +273,21 @@ public class MainApp extends MultiDexApplication implements
         if (!preferences.isStoragePathFixEnabled()) {
         if (!preferences.isStoragePathFixEnabled()) {
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                 StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints();
                 StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints();
-                String storagePath = sharedPreferences.getString(SettingsActivity.PreferenceKeys.STORAGE_PATH, "");
+                String storagePath = preferences.getStoragePath("");
+
                 if (TextUtils.isEmpty(storagePath)) {
                 if (TextUtils.isEmpty(storagePath)) {
                     if (preferences.getLastSeenVersionCode() != 0) {
                     if (preferences.getLastSeenVersionCode() != 0) {
                         // We already used the app, but no storage is set - fix that!
                         // We already used the app, but no storage is set - fix that!
-                        sharedPreferences.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
-                                                  Environment.getExternalStorageDirectory().getAbsolutePath()).commit();
-                        sharedPreferences.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
+                        preferences.setStoragePath(Environment.getExternalStorageDirectory().getAbsolutePath());
+                        preferences.removeKeysMigrationPreference();
                     } else {
                     } else {
                         // find internal storage path that's indexable
                         // find internal storage path that's indexable
                         boolean set = false;
                         boolean set = false;
                         for (StoragePoint storagePoint : storagePoints) {
                         for (StoragePoint storagePoint : storagePoints) {
                             if (storagePoint.getStorageType().equals(StoragePoint.StorageType.INTERNAL) &&
                             if (storagePoint.getStorageType().equals(StoragePoint.StorageType.INTERNAL) &&
                                     storagePoint.getPrivacyType().equals(StoragePoint.PrivacyType.PUBLIC)) {
                                     storagePoint.getPrivacyType().equals(StoragePoint.PrivacyType.PUBLIC)) {
-                                sharedPreferences.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
-                                                          storagePoint.getPath()).commit();
-                                sharedPreferences.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
+                                preferences.setStoragePath(storagePoint.getPath());
+                                preferences.removeKeysMigrationPreference();
                                 set = true;
                                 set = true;
                                 break;
                                 break;
                             }
                             }
@@ -300,9 +296,8 @@ public class MainApp extends MultiDexApplication implements
                         if (!set) {
                         if (!set) {
                             for (StoragePoint storagePoint : storagePoints) {
                             for (StoragePoint storagePoint : storagePoints) {
                                 if (storagePoint.getPrivacyType().equals(StoragePoint.PrivacyType.PUBLIC)) {
                                 if (storagePoint.getPrivacyType().equals(StoragePoint.PrivacyType.PUBLIC)) {
-                                    sharedPreferences.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
-                                                              storagePoint.getPath()).commit();
-                                    sharedPreferences.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
+                                    preferences.setStoragePath(storagePoint.getPath());
+                                    preferences.removeKeysMigrationPreference();
                                     set = true;
                                     set = true;
                                     break;
                                     break;
                                 }
                                 }
@@ -312,15 +307,14 @@ public class MainApp extends MultiDexApplication implements
                     }
                     }
                     preferences.setStoragePathFixEnabled(true);
                     preferences.setStoragePathFixEnabled(true);
                 } else {
                 } else {
-                    sharedPreferences.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
+                    preferences.removeKeysMigrationPreference();
                     preferences.setStoragePathFixEnabled(true);
                     preferences.setStoragePathFixEnabled(true);
                 }
                 }
             } else {
             } else {
                 if (TextUtils.isEmpty(storagePath)) {
                 if (TextUtils.isEmpty(storagePath)) {
-                    sharedPreferences.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
-                                              Environment.getExternalStorageDirectory().getAbsolutePath()).commit();
+                    preferences.setStoragePath(Environment.getExternalStorageDirectory().getAbsolutePath());
                 }
                 }
-                sharedPreferences.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
+                preferences.removeKeysMigrationPreference();
                 preferences.setStoragePathFixEnabled(true);
                 preferences.setStoragePathFixEnabled(true);
             }
             }
         }
         }

+ 11 - 19
src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java

@@ -48,7 +48,12 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewGroup;
 import android.view.Window;
 import android.view.Window;
 import android.webkit.URLUtil;
 import android.webkit.URLUtil;
-
+import androidx.annotation.LayoutRes;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatDelegate;
+import androidx.core.content.res.ResourcesCompat;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.owncloud.android.BuildConfig;
 import com.owncloud.android.BuildConfig;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.MainApp;
@@ -73,13 +78,6 @@ import com.owncloud.android.utils.ThemeUtils;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
-import androidx.annotation.LayoutRes;
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.ActionBar;
-import androidx.appcompat.app.AlertDialog;
-import androidx.appcompat.app.AppCompatDelegate;
-import androidx.core.content.res.ResourcesCompat;
-
 /**
 /**
  * An Activity that allows the user to change the application's settings.
  * An Activity that allows the user to change the application's settings.
  *
  *
@@ -122,10 +120,6 @@ public class SettingsActivity extends PreferenceActivity
     private ArbitraryDataProvider arbitraryDataProvider;
     private ArbitraryDataProvider arbitraryDataProvider;
     private AppPreferences preferences;
     private AppPreferences preferences;
 
 
-    public static class PreferenceKeys {
-        public static final String STORAGE_PATH = "storage_path";
-    }
-
     @SuppressWarnings("deprecation")
     @SuppressWarnings("deprecation")
     @Override
     @Override
     public void onCreate(Bundle savedInstanceState) {
     public void onCreate(Bundle savedInstanceState) {
@@ -666,7 +660,7 @@ public class SettingsActivity extends PreferenceActivity
         preferenceCategoryGeneral.setTitle(ThemeUtils.getColoredTitle(getString(R.string.prefs_category_general),
         preferenceCategoryGeneral.setTitle(ThemeUtils.getColoredTitle(getString(R.string.prefs_category_general),
                 accentColor));
                 accentColor));
 
 
-        prefStoragePath = (ListPreference) findPreference(PreferenceKeys.STORAGE_PATH);
+        prefStoragePath = (ListPreference) findPreference(com.nextcloud.client.preferences.PreferenceManager.STORAGE_PATH);
         if (prefStoragePath != null) {
         if (prefStoragePath != null) {
             StoragePoint[] storageOptions = DataStorageProvider.getInstance().getAvailableStoragePoints();
             StoragePoint[] storageOptions = DataStorageProvider.getInstance().getAvailableStoragePoints();
             String[] entries = new String[storageOptions.length];
             String[] entries = new String[storageOptions.length];
@@ -966,12 +960,11 @@ public class SettingsActivity extends PreferenceActivity
      * Save storage path
      * Save storage path
      */
      */
     private void saveStoragePath(String newStoragePath) {
     private void saveStoragePath(String newStoragePath) {
-        SharedPreferences appPrefs =
-                PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+        SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
         storagePath = newStoragePath;
         storagePath = newStoragePath;
         MainApp.setStoragePath(storagePath);
         MainApp.setStoragePath(storagePath);
         SharedPreferences.Editor editor = appPrefs.edit();
         SharedPreferences.Editor editor = appPrefs.edit();
-        editor.putString(PreferenceKeys.STORAGE_PATH, storagePath);
+        editor.putString(com.nextcloud.client.preferences.PreferenceManager.STORAGE_PATH, storagePath);
         editor.apply();
         editor.apply();
         String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(storagePath);
         String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(storagePath);
         prefStoragePath.setSummary(storageDescription);
         prefStoragePath.setSummary(storageDescription);
@@ -982,10 +975,9 @@ public class SettingsActivity extends PreferenceActivity
      * Load storage path set on preferences
      * Load storage path set on preferences
      */
      */
     private void loadStoragePath() {
     private void loadStoragePath() {
-        SharedPreferences appPrefs =
-                PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+        SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
         // Load storage path from shared preferences. Use private internal storage by default.
         // Load storage path from shared preferences. Use private internal storage by default.
-        storagePath = appPrefs.getString(PreferenceKeys.STORAGE_PATH,
+        storagePath = appPrefs.getString(com.nextcloud.client.preferences.PreferenceManager.STORAGE_PATH,
                 getApplicationContext().getFilesDir().getAbsolutePath());
                 getApplicationContext().getFilesDir().getAbsolutePath());
         String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(storagePath);
         String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(storagePath);
         prefStoragePath.setSummary(storageDescription);
         prefStoragePath.setSummary(storageDescription);