use result code to determinate if old login

This commit is contained in:
tobiaskaminsky 2017-09-20 11:48:14 +02:00 committed by tobiasKaminsky
parent 46535cdc02
commit 0aa2aaaab1
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
5 changed files with 18 additions and 3 deletions

View file

@ -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'

View file

@ -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");

View file

@ -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

View file

@ -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();
}
}
}

View file

@ -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>