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

use result code to determinate if old login

tobiaskaminsky 7 жил өмнө
parent
commit
0aa2aaaab1

+ 1 - 1
build.gradle

@@ -184,7 +184,7 @@ dependencies {
     /// dependencies for app building
     implementation name: 'touch-image-view'
     implementation 'com.android.support:multidex:1.0.2'
-    compile 'com.github.nextcloud:android-library:1.0.30'
+    compile 'com.github.nextcloud:android-library:pushWarning-SNAPSHOT'
     implementation "com.android.support:support-v4:${supportLibraryVersion}"
     implementation "com.android.support:design:${supportLibraryVersion}"
     implementation 'com.jakewharton:disklrucache:2.0.2'

+ 4 - 0
src/gplay/java/com/owncloud/android/utils/PushUtils.java

@@ -247,6 +247,10 @@ public class PushUtils {
                                     arbitraryDataProvider.storeOrUpdateKeyValue(account.name, KEY_PUSH,
                                             gson.toJson(pushArbitraryData));
                                 }
+                            } else if (remoteOperationResult.getCode() ==
+                                    RemoteOperationResult.ResultCode.ACCOUNT_USES_OLD_LOGIN) {
+                                arbitraryDataProvider.storeOrUpdateKeyValue(account.name,
+                                        AccountUtils.ACCOUNT_USES_OLD_LOGIN, "true");
                             }
                         } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
                             Log_OC.d(TAG, "Failed to find an account");

+ 1 - 0
src/main/java/com/owncloud/android/authentication/AccountUtils.java

@@ -52,6 +52,7 @@ public class AccountUtils {
 
     public static final int ACCOUNT_VERSION = 1;
     public static final int ACCOUNT_VERSION_WITH_PROPER_ID = 2;
+    public static final String ACCOUNT_USES_OLD_LOGIN = "ACCOUNT_USES_OLD_LOGIN";
 
     /**
      * Can be used to get the currently selected ownCloud {@link Account} in the

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

@@ -152,11 +152,20 @@ public class NotificationsActivity extends FileActivity {
         } else {
             Account account = AccountUtils.getCurrentOwnCloudAccount(context);
             ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
-            String pushValue = arbitraryDataProvider.getValue(account.name, PushUtils.KEY_PUSH);
 
-            if (pushValue == null || pushValue.isEmpty()) {
+            boolean usesOldLogin = arbitraryDataProvider.getBooleanValue(account.name,
+                    AccountUtils.ACCOUNT_USES_OLD_LOGIN);
+
+            if (usesOldLogin) {
                 Snackbar.make(emptyContentContainer, R.string.push_notifications_old_login,
                         Snackbar.LENGTH_INDEFINITE).show();
+            } else {
+                String pushValue = arbitraryDataProvider.getValue(account.name, PushUtils.KEY_PUSH);
+
+                if (pushValue == null || pushValue.isEmpty()) {
+                    Snackbar.make(emptyContentContainer, R.string.push_notifications_temp_error,
+                            Snackbar.LENGTH_INDEFINITE).show();
+                }
             }
         }
 

+ 1 - 0
src/main/res/values/strings.xml

@@ -708,4 +708,5 @@
     <string name="prefs_gpl_v2" translatable="false">GNU General Public License, version 2</string>
     <string name="push_notifications_not_implemented">Push notifications disabled due to dependencies on proprietary Google Play services.</string>
     <string name="push_notifications_old_login">No push notifications due to outdated login session. Please consider re-adding your account.</string>
+    <string name="push_notifications_temp_error">Push notifications currently not available.</string>
 </resources>