From f592845cca50c0c89ce18366a53e66d9f9ac3853 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Wed, 20 Jun 2018 09:52:44 +0200 Subject: [PATCH] - fix one NPE - outdated server warning toggable for brander Signed-off-by: tobiasKaminsky --- .../authentication/AuthenticatorActivity.java | 3 ++- .../ui/activity/FileDisplayActivity.java | 22 +++++++++++-------- src/main/res/values/setup.xml | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java index 9ec1e478f6..5bcdeaba57 100644 --- a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -1419,7 +1419,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mServerInfo = (GetServerInfoOperation.ServerInfo) (result.getData().get(0)); // show outdated warning - if (mServerInfo.mVersion.compareTo(MainApp.OUTDATED_SERVER_VERSION) < 0) { + if (getResources().getBoolean(R.bool.show_outdated_server_warning) && + mServerInfo.mVersion.compareTo(MainApp.OUTDATED_SERVER_VERSION) < 0) { DisplayUtils.showServerOutdatedSnackbar(this); } diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index a0418f0f7b..bf6a84ac96 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -357,20 +357,24 @@ public class FileDisplayActivity extends HookActivity } private void checkOutdatedServer() { - ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver()); Account account = getAccount(); - int lastSeenVersion = arbitraryDataProvider.getIntegerValue(account, WhatsNewActivity.KEY_LAST_SEEN_VERSION_CODE); + if (getResources().getBoolean(R.bool.show_outdated_server_warning) && account != null) { + ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver()); - if (MainApp.getVersionCode() > lastSeenVersion) { - OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this); + int lastSeenVersion = arbitraryDataProvider.getIntegerValue(account, + WhatsNewActivity.KEY_LAST_SEEN_VERSION_CODE); - if (serverVersion.compareTo(MainApp.OUTDATED_SERVER_VERSION) < 0) { - DisplayUtils.showServerOutdatedSnackbar(this); + if (MainApp.getVersionCode() > lastSeenVersion) { + OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this); + + if (serverVersion.compareTo(MainApp.OUTDATED_SERVER_VERSION) < 0) { + DisplayUtils.showServerOutdatedSnackbar(this); + } + + arbitraryDataProvider.storeOrUpdateKeyValue(account.name, WhatsNewActivity.KEY_LAST_SEEN_VERSION_CODE, + String.valueOf(MainApp.getVersionCode())); } - - arbitraryDataProvider.storeOrUpdateKeyValue(account.name, WhatsNewActivity.KEY_LAST_SEEN_VERSION_CODE, - String.valueOf(MainApp.getVersionCode())); } } diff --git a/src/main/res/values/setup.xml b/src/main/res/values/setup.xml index 0161e6c747..019c91fccb 100644 --- a/src/main/res/values/setup.xml +++ b/src/main/res/values/setup.xml @@ -39,6 +39,7 @@ true true true + true true