浏览代码

enhance offline detection

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 6 年之前
父节点
当前提交
1d05ba6526

+ 3 - 3
build.gradle

@@ -210,9 +210,9 @@ dependencies {
     // dependencies for app building
     implementation 'com.android.support:multidex:1.0.3'
 //    implementation project('nextcloud-android-library')
-    genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
-    gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
-    versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
+    genericImplementation "com.github.nextcloud:android-library:offlineSupport-SNAPSHOT"
+    gplayImplementation "com.github.nextcloud:android-library:offlineSupport-SNAPSHOT"
+    versionDevImplementation 'com.github.nextcloud:android-library:offlineSupport-SNAPSHOT' // use always latest master
     implementation "com.android.support:support-v4:${supportLibraryVersion}"
     implementation "com.android.support:design:${supportLibraryVersion}"
     implementation 'com.jakewharton:disklrucache:2.0.2'

+ 4 - 0
src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java

@@ -292,6 +292,10 @@ public class RefreshFolderOperation extends RemoteOperation {
             if (result.getCode() == ResultCode.MAINTENANCE_MODE) {
                 return result;
             }
+            if (result.getCode() == ResultCode.HOST_NOT_AVAILABLE ||
+                    result.getCode() == ResultCode.NO_NETWORK_CONNECTION) {
+                return result;
+            }
             if (result.isException()) {
                 Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
                         result.getLogMessage(), result.getException());

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

@@ -1348,6 +1348,9 @@ public class FileDisplayActivity extends HookActivity
                                     showUntrustedCertDialog(synchResult);
                                 } else if (ResultCode.MAINTENANCE_MODE.equals(synchResult.getCode())) {
                                     showInfoBox(R.string.maintenance_mode);
+                                } else if (ResultCode.NO_NETWORK_CONNECTION.equals(synchResult.getCode()) ||
+                                        ResultCode.HOST_NOT_AVAILABLE.equals(synchResult.getCode())) {
+                                    showInfoBox(R.string.offline_mode);
                                 }
                             }
                         }