Browse Source

move MINIMUM_SUPPORTED_SERVER_VERSION to MainApp

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

+ 9 - 8
src/main/java/com/owncloud/android/MainApp.java

@@ -4,16 +4,16 @@
  * @author masensio
  * @author David A. Velasco
  * Copyright (C) 2015 ownCloud Inc.
- * 
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2,
  * as published by the Free Software Foundation.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -95,6 +95,7 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER
 public class MainApp extends MultiDexApplication {
 
     public static final OwnCloudVersion OUTDATED_SERVER_VERSION = OwnCloudVersion.nextcloud_12;
+    public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_10;
 
     private static final String TAG = MainApp.class.getSimpleName();
 
@@ -387,7 +388,7 @@ public class MainApp extends MultiDexApplication {
             notificationManager.createNotificationChannel(channel);
         }
     }
-    
+
 
     public static Context getAppContext() {
         return MainApp.mContext;
@@ -405,9 +406,9 @@ public class MainApp extends MultiDexApplication {
         MainApp.storagePath = path;
     }
 
-    // Methods to obtain Strings referring app_name 
-    //   From AccountAuthenticator 
-    //   public static final String ACCOUNT_TYPE = "owncloud";    
+    // Methods to obtain Strings referring app_name
+    //   From AccountAuthenticator
+    //   public static final String ACCOUNT_TYPE = "owncloud";
     public static String getAccountType(Context context) {
         return context.getResources().getString(R.string.account_type);
     }
@@ -446,7 +447,7 @@ public class MainApp extends MultiDexApplication {
         return getAppContext().getResources().getString(R.string.authority);
     }
 
-    //  From ProviderMeta 
+    //  From ProviderMeta
     //  public static final String DB_FILE = "owncloud.db";
     public static String getDBFile() {
         return getAppContext().getResources().getString(R.string.db_file);

+ 12 - 9
src/main/java/com/owncloud/android/authentication/AccountUtils.java

@@ -50,10 +50,10 @@ public final class AccountUtils {
     /**
      * Can be used to get the currently selected ownCloud {@link Account} in the
      * application preferences.
-     * 
+     *
      * @param   context     The current application {@link Context}
-     * @return              The ownCloud {@link Account} currently saved in preferences, or the first 
-     *                      {@link Account} available, if valid (still registered in the system as ownCloud 
+     * @return The ownCloud {@link Account} currently saved in preferences, or the first
+     *                      {@link Account} available, if valid (still registered in the system as ownCloud
      *                      account). If none is available and valid, returns null.
      */
     public static @Nullable Account getCurrentOwnCloudAccount(Context context) {
@@ -96,7 +96,7 @@ public final class AccountUtils {
         return accountManager.getAccountsByType(MainApp.getAccountType(context));
     }
 
-    
+
     public static boolean exists(Account account, Context context) {
         Account[] ocAccounts = getAccounts(context);
 
@@ -132,7 +132,7 @@ public final class AccountUtils {
             return null;
         }
     }
-    
+
     /**
      * Returns owncloud account identified by accountName or null if it does not exist.
      * @param context the context
@@ -176,20 +176,23 @@ public final class AccountUtils {
     /**
      * Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
      *
-     * @param   account     ownCloud account
-     * @return              Version of the OC server corresponding to account, according to the data saved
-     *                      in the system AccountManager
+     * @param account ownCloud account
+     * @return Version of the OC server corresponding to account, according to the data saved
+     * in the system AccountManager
      */
     public static @NonNull
     OwnCloudVersion getServerVersion(Account account) {
-        OwnCloudVersion serverVersion = OwnCloudVersion.nextcloud_10;
+        OwnCloudVersion serverVersion = MainApp.MINIMUM_SUPPORTED_SERVER_VERSION;
+
         if (account != null) {
             AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());
             String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);
+
             if (serverVersionStr != null) {
                 serverVersion = new OwnCloudVersion(serverVersionStr);
             }
         }
+
         return serverVersion;
     }