Эх сурвалжийг харах

Merge pull request #3705 from nextcloud/preferences

change Preferences to SettingsActivity
Andy Scherzinger 6 жил өмнө
parent
commit
ce14d3116c

+ 1 - 1
src/main/AndroidManifest.xml

@@ -142,7 +142,7 @@
             </intent-filter>
         </activity>
         <activity
-            android:name=".ui.activity.Preferences"
+            android:name=".ui.activity.SettingsActivity"
             android:theme="@style/Theme.ownCloud" >
         </activity>
         <activity

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

@@ -28,7 +28,7 @@ import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.ui.activity.ComponentsGetter;
-import com.owncloud.android.ui.activity.Preferences;
+import com.owncloud.android.ui.activity.SettingsActivity;
 import com.owncloud.android.utils.FileSortOrder;
 
 import static com.owncloud.android.ui.fragment.OCFileListFragment.FOLDER_LAYOUT_LIST;
@@ -228,7 +228,7 @@ public final class PreferenceManager implements AppPreferences {
      * @return lock     lock preference value.
      */
     public static String getLockPreference(Context context) {
-        return getDefaultSharedPreferences(context).getString(Preferences.PREFERENCE_LOCK, "");
+        return getDefaultSharedPreferences(context).getString(SettingsActivity.PREFERENCE_LOCK, "");
     }
 
     /**
@@ -238,7 +238,7 @@ public final class PreferenceManager implements AppPreferences {
      * @return useFingerprint     is lock via fingerprint preference.
      */
     public static boolean isUseFingerprint(Context context) {
-        return getDefaultSharedPreferences(context).getBoolean(Preferences.PREFERENCE_USE_FINGERPRINT, false);
+        return getDefaultSharedPreferences(context).getBoolean(SettingsActivity.PREFERENCE_USE_FINGERPRINT, false);
     }
 
     /**

+ 14 - 14
src/main/java/com/owncloud/android/MainApp.java

@@ -40,6 +40,8 @@ import android.view.WindowManager;
 
 import com.evernote.android.job.JobManager;
 import com.evernote.android.job.JobRequest;
+import com.nextcloud.client.preferences.AppPreferences;
+import com.nextcloud.client.preferences.PreferenceManager;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.authentication.PassCodeManager;
 import com.owncloud.android.datamodel.ArbitraryDataProvider;
@@ -51,8 +53,6 @@ import com.owncloud.android.datamodel.SyncedFolderProvider;
 import com.owncloud.android.datamodel.ThumbnailsCacheManager;
 import com.owncloud.android.datastorage.DataStorageProvider;
 import com.owncloud.android.datastorage.StoragePoint;
-import com.nextcloud.client.preferences.AppPreferences;
-import com.nextcloud.client.preferences.PreferenceManager;
 import com.owncloud.android.jobs.MediaFoldersDetectionJob;
 import com.owncloud.android.jobs.NCJobCreator;
 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
@@ -60,7 +60,7 @@ import com.owncloud.android.lib.common.OwnCloudClientManagerFactory.Policy;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
-import com.owncloud.android.ui.activity.Preferences;
+import com.owncloud.android.ui.activity.SettingsActivity;
 import com.owncloud.android.ui.activity.SyncedFoldersActivity;
 import com.owncloud.android.ui.activity.WhatsNewActivity;
 import com.owncloud.android.ui.notifications.NotificationUtils;
@@ -132,8 +132,8 @@ public class MainApp extends MultiDexApplication {
 
         fixStoragePath();
 
-        MainApp.storagePath = appPrefs.getString(Preferences.PreferenceKeys.STORAGE_PATH,
-                getApplicationContext().getFilesDir().getAbsolutePath());
+        MainApp.storagePath = appPrefs.getString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
+                                                 getApplicationContext().getFilesDir().getAbsolutePath());
 
         boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
 
@@ -243,12 +243,12 @@ public class MainApp extends MultiDexApplication {
         if (!PreferenceManager.getStoragePathFix(this)) {
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                 StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints();
-                String storagePath = appPrefs.getString(Preferences.PreferenceKeys.STORAGE_PATH, "");
+                String storagePath = appPrefs.getString(SettingsActivity.PreferenceKeys.STORAGE_PATH, "");
                 if (TextUtils.isEmpty(storagePath)) {
                     if (PreferenceManager.getLastSeenVersionCode(this) != 0) {
                         // We already used the app, but no storage is set - fix that!
-                        appPrefs.edit().putString(Preferences.PreferenceKeys.STORAGE_PATH,
-                                Environment.getExternalStorageDirectory().getAbsolutePath()).commit();
+                        appPrefs.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
+                                                  Environment.getExternalStorageDirectory().getAbsolutePath()).commit();
                         appPrefs.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
                     } else {
                         // find internal storage path that's indexable
@@ -256,8 +256,8 @@ public class MainApp extends MultiDexApplication {
                         for (StoragePoint storagePoint : storagePoints) {
                             if (storagePoint.getStorageType().equals(StoragePoint.StorageType.INTERNAL) &&
                                     storagePoint.getPrivacyType().equals(StoragePoint.PrivacyType.PUBLIC)) {
-                                appPrefs.edit().putString(Preferences.PreferenceKeys.STORAGE_PATH,
-                                        storagePoint.getPath()).commit();
+                                appPrefs.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
+                                                          storagePoint.getPath()).commit();
                                 appPrefs.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
                                 set = true;
                                 break;
@@ -267,8 +267,8 @@ public class MainApp extends MultiDexApplication {
                         if (!set) {
                             for (StoragePoint storagePoint : storagePoints) {
                                 if (storagePoint.getPrivacyType().equals(StoragePoint.PrivacyType.PUBLIC)) {
-                                    appPrefs.edit().putString(Preferences.PreferenceKeys.STORAGE_PATH,
-                                            storagePoint.getPath()).commit();
+                                    appPrefs.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
+                                                              storagePoint.getPath()).commit();
                                     appPrefs.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
                                     set = true;
                                     break;
@@ -284,8 +284,8 @@ public class MainApp extends MultiDexApplication {
                 }
             } else {
                 if (TextUtils.isEmpty(storagePath)) {
-                    appPrefs.edit().putString(Preferences.PreferenceKeys.STORAGE_PATH,
-                            Environment.getExternalStorageDirectory().getAbsolutePath()).commit();
+                    appPrefs.edit().putString(SettingsActivity.PreferenceKeys.STORAGE_PATH,
+                                              Environment.getExternalStorageDirectory().getAbsolutePath()).commit();
                 }
                 appPrefs.edit().remove(PreferenceManager.PREF__KEYS_MIGRATION).commit();
                 PreferenceManager.setStoragePathFix(this, true);

+ 4 - 4
src/main/java/com/owncloud/android/authentication/PassCodeManager.java

@@ -27,11 +27,11 @@ import android.os.PowerManager;
 import android.view.Window;
 import android.view.WindowManager;
 
-import com.owncloud.android.MainApp;
 import com.nextcloud.client.preferences.PreferenceManager;
+import com.owncloud.android.MainApp;
 import com.owncloud.android.ui.activity.PassCodeActivity;
-import com.owncloud.android.ui.activity.Preferences;
 import com.owncloud.android.ui.activity.RequestCredentialsActivity;
+import com.owncloud.android.ui.activity.SettingsActivity;
 import com.owncloud.android.utils.DeviceCredentialUtils;
 
 import java.util.HashSet;
@@ -119,7 +119,7 @@ public final class PassCodeManager {
     }
 
     private boolean passCodeIsEnabled() {
-        return Preferences.LOCK_PASSCODE.equals(PreferenceManager.getLockPreference(MainApp.getAppContext()));
+        return SettingsActivity.LOCK_PASSCODE.equals(PreferenceManager.getLockPreference(MainApp.getAppContext()));
     }
 
     private boolean deviceCredentialsShouldBeRequested(Long timestamp, Activity activity) {
@@ -128,7 +128,7 @@ public final class PassCodeManager {
     }
 
     private boolean deviceCredentialsAreEnabled(Activity activity) {
-        return Preferences.LOCK_DEVICE_CREDENTIALS.equals(PreferenceManager.getLockPreference(MainApp.getAppContext()))
+        return SettingsActivity.LOCK_DEVICE_CREDENTIALS.equals(PreferenceManager.getLockPreference(MainApp.getAppContext()))
                 || Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
                         (PreferenceManager.isUseFingerprint(MainApp.getAppContext())
                                 && DeviceCredentialUtils.areCredentialsAvailable(activity));

+ 2 - 2
src/main/java/com/owncloud/android/jobs/FilesSyncJob.java

@@ -42,7 +42,7 @@ import com.owncloud.android.datamodel.SyncedFolderProvider;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.operations.UploadFileOperation;
-import com.owncloud.android.ui.activity.Preferences;
+import com.owncloud.android.ui.activity.SettingsActivity;
 import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.utils.FilesSyncHelper;
 import com.owncloud.android.utils.MimeType;
@@ -152,7 +152,7 @@ public class FilesSyncJob extends Job {
             if (lightVersion) {
                 needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging);
                 needsWifi = account == null || arbitraryDataProvider.getBooleanValue(account.name,
-                        Preferences.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
+                                                                                     SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
                 String uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour);
                 uploadAction = getUploadAction(uploadActionString);
 

+ 3 - 3
src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java

@@ -67,7 +67,7 @@ import com.owncloud.android.operations.RenameFileOperation;
 import com.owncloud.android.operations.SynchronizeFileOperation;
 import com.owncloud.android.operations.UploadFileOperation;
 import com.owncloud.android.ui.activity.ConflictsResolveActivity;
-import com.owncloud.android.ui.activity.Preferences;
+import com.owncloud.android.ui.activity.SettingsActivity;
 import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.utils.UriUtils;
 
@@ -95,8 +95,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
     public Cursor queryRoots(String[] projection) throws FileNotFoundException {
 
         SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(MainApp.getAppContext());
-        if (Preferences.LOCK_PASSCODE.equals(appPrefs.getString(Preferences.PREFERENCE_LOCK, "")) ||
-            Preferences.LOCK_DEVICE_CREDENTIALS.equals(appPrefs.getString(Preferences.PREFERENCE_LOCK, ""))) {
+        if (SettingsActivity.LOCK_PASSCODE.equals(appPrefs.getString(SettingsActivity.PREFERENCE_LOCK, "")) ||
+            SettingsActivity.LOCK_DEVICE_CREDENTIALS.equals(appPrefs.getString(SettingsActivity.PREFERENCE_LOCK, ""))) {
             return new FileCursor();
         }
 

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

@@ -54,6 +54,7 @@ import com.bumptech.glide.Glide;
 import com.bumptech.glide.request.animation.GlideAnimation;
 import com.bumptech.glide.request.target.SimpleTarget;
 import com.google.android.material.navigation.NavigationView;
+import com.nextcloud.client.preferences.PreferenceManager;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountUtils;
@@ -62,7 +63,6 @@ import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.ExternalLinksProvider;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
-import com.nextcloud.client.preferences.PreferenceManager;
 import com.owncloud.android.lib.common.ExternalLink;
 import com.owncloud.android.lib.common.ExternalLinkType;
 import com.owncloud.android.lib.common.OwnCloudAccount;
@@ -383,7 +383,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
                 showFiles(false);
                 break;
             case R.id.nav_bar_settings:
-                Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class);
+                Intent settingsIntent = new Intent(getApplicationContext(), SettingsActivity.class);
                 startActivity(settingsIntent);
                 break;
             default:
@@ -446,7 +446,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
                 startActivity(contactsIntent);
                 break;
             case R.id.nav_settings:
-                Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class);
+                Intent settingsIntent = new Intent(getApplicationContext(), SettingsActivity.class);
                 startActivity(settingsIntent);
                 break;
             case R.id.nav_participate:

+ 5 - 5
src/main/java/com/owncloud/android/ui/activity/ManageSpaceActivity.java

@@ -1,4 +1,4 @@
-/**
+/*
  *   ownCloud Android client application
  *
  *   @author masensio
@@ -92,9 +92,9 @@ public class ManageSpaceActivity extends AppCompatActivity {
             SharedPreferences appPrefs = PreferenceManager
                     .getDefaultSharedPreferences(getApplicationContext());
 
-            String lockPref = appPrefs.getString(Preferences.PREFERENCE_LOCK, Preferences.LOCK_NONE);
-            boolean passCodeEnable = Preferences.LOCK_PASSCODE.equals(
-                    appPrefs.getString(Preferences.PREFERENCE_LOCK, ""));
+            String lockPref = appPrefs.getString(SettingsActivity.PREFERENCE_LOCK, SettingsActivity.LOCK_NONE);
+            boolean passCodeEnable = SettingsActivity.LOCK_PASSCODE.equals(
+                appPrefs.getString(SettingsActivity.PREFERENCE_LOCK, ""));
 
             String passCodeDigits[] = new String[4];
             if (passCodeEnable) {
@@ -121,7 +121,7 @@ public class ManageSpaceActivity extends AppCompatActivity {
                 appPrefsEditor.putString(PassCodeActivity.PREFERENCE_PASSCODE_D4, passCodeDigits[3]);
             }
 
-            appPrefsEditor.putString(Preferences.PREFERENCE_LOCK, lockPref);
+            appPrefsEditor.putString(SettingsActivity.PREFERENCE_LOCK, lockPref);
             result = result && appPrefsEditor.commit();
 
             return result;

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

@@ -131,10 +131,10 @@ public class    PassCodeActivity extends AppCompatActivity {
                 mPassCodeDigits = savedInstanceState.getStringArray(PassCodeActivity.KEY_PASSCODE_DIGITS);
             }
             if(mConfirmingPassCode){
-                //the app was in the passcodeconfirmation
+                // the app was in the passcodeconfirmation
                 requestPassCodeConfirmation();
             }else{
-                /// pass code preference has just been activated in Preferences;
+                // pass code preference has just been activated in SettingsActivity;
                 // will receive and confirm pass code value
                 mPassCodeHdr.setText(R.string.pass_code_configure_your_pass_code);
 
@@ -143,7 +143,7 @@ public class    PassCodeActivity extends AppCompatActivity {
             }
 
         } else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
-            /// pass code preference has just been disabled in Preferences;
+            // pass code preference has just been disabled in SettingsActivity;
             // will confirm user knows pass code, then remove it
             mPassCodeHdr.setText(R.string.pass_code_remove_your_pass_code);
             mPassCodeHdrExplanation.setVisibility(View.INVISIBLE);

+ 2 - 2
src/main/java/com/owncloud/android/ui/activity/Preferences.java → src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java

@@ -84,10 +84,10 @@ import androidx.core.content.res.ResourcesCompat;
  *
  * It proxies the necessary calls via {@link androidx.appcompat.app.AppCompatDelegate} to be used with AppCompat.
  */
-public class Preferences extends PreferenceActivity
+public class SettingsActivity extends PreferenceActivity
         implements StorageMigration.StorageMigrationProgressListener, LoadingVersionNumberTask.VersionDevInterface {
 
-    private static final String TAG = Preferences.class.getSimpleName();
+    private static final String TAG = SettingsActivity.class.getSimpleName();
 
     public static final String PREFERENCE_LOCK= "lock";
 

+ 1 - 1
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -471,7 +471,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                         openDrawer();
                     }
                 } else {
-                    Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class);
+                    Intent settingsIntent = new Intent(getApplicationContext(), SettingsActivity.class);
                     startActivity(settingsIntent);
                 }
                 break;

+ 2 - 2
src/main/java/com/owncloud/android/ui/activity/UploadPathActivity.java

@@ -1,4 +1,4 @@
-/**
+/*
  *   ownCloud Android client application
  *
  *   Copyright (C) 2015 ownCloud Inc.
@@ -38,7 +38,7 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag
 
         String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
 
-        // The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
+        // The caller activity (SettingsActivity) is not a FileActivity, so it has no OCFile, only a path.
         OCFile folder = new OCFile(instantUploadPath);
 
         setFile(folder);

+ 6 - 4
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java

@@ -49,12 +49,14 @@ import com.owncloud.android.jobs.ContactsBackupJob;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.operations.RefreshFolderOperation;
 import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
-import com.owncloud.android.ui.activity.Preferences;
+import com.owncloud.android.ui.activity.SettingsActivity;
 import com.owncloud.android.ui.fragment.FileFragment;
 import com.owncloud.android.utils.DisplayUtils;
 import com.owncloud.android.utils.PermissionUtil;
 import com.owncloud.android.utils.ThemeUtils;
 
+import org.jetbrains.annotations.NotNull;
+
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Comparator;
@@ -106,7 +108,7 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
 
 
     @Override
-    public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+    public View onCreateView(@NotNull final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
         // use grey as fallback for elements where custom theming is not available
         if (ThemeUtils.themingEnabled(getContext())) {
@@ -271,7 +273,7 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
                         contactsPreferenceActivity.openDrawer();
                     }
                 } else {
-                    Intent settingsIntent = new Intent(getContext(), Preferences.class);
+                    Intent settingsIntent = new Intent(getContext(), SettingsActivity.class);
                     startActivity(settingsIntent);
                 }
                 retval = true;
@@ -463,7 +465,7 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
     }
 
     @Override
-    public void onSaveInstanceState(Bundle outState) {
+    public void onSaveInstanceState(@NotNull Bundle outState) {
         super.onSaveInstanceState(outState);
         if (datePickerDialog != null) {
             outState.putBoolean(KEY_CALENDAR_PICKER_OPEN, datePickerDialog.isShowing());