Browse Source

If first version is null, try to get it from capabilities

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

+ 9 - 0
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -86,6 +86,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.shares.OCShare;
 import com.owncloud.android.lib.resources.shares.ShareType;
+import com.owncloud.android.lib.resources.status.OCCapability;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.media.MediaService;
 import com.owncloud.android.media.MediaServiceBinder;
@@ -191,6 +192,8 @@ public class FileDisplayActivity extends HookActivity
 
     public static final String TEXT_PREVIEW = "TEXT_PREVIEW";
 
+    private static final String VERSION_DOT = ".";
+
     private OCFile mWaitingToPreview;
 
     private boolean mSyncInProgress;
@@ -365,6 +368,12 @@ public class FileDisplayActivity extends HookActivity
 
             if (MainApp.getVersionCode() > lastSeenVersion) {
                 OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this);
+                
+                if (serverVersion == null) {
+                    OCCapability capability = getCapabilities();
+                    serverVersion = new OwnCloudVersion(capability.getVersionMayor() + VERSION_DOT +
+                            capability.getVersionMinor() + VERSION_DOT + capability.getVersionMinor());
+                }
 
                 if (MainApp.OUTDATED_SERVER_VERSION.compareTo(serverVersion) >= 0) {
                     DisplayUtils.showServerOutdatedSnackbar(this);