show outdated server warning for server <NC12

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2018-06-19 14:49:56 +02:00
parent 0bc7924232
commit 6af04fc424
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
5 changed files with 36 additions and 1 deletions

View file

@ -1418,6 +1418,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
// 4. we got the authentication method required by the server
mServerInfo = (GetServerInfoOperation.ServerInfo) (result.getData().get(0));
// show outdated warning
if (mServerInfo.mVersion.compareTo(OwnCloudVersion.nextcloud_12) < 0) {
DisplayUtils.showServerOutdatedSnackbar(this);
}
webViewLoginMethod = mServerInfo.mVersion.isWebLoginSupported() && !forceOldLoginMethod;
if (webViewUser != null && !webViewUser.isEmpty() &&

View file

@ -69,6 +69,7 @@ import android.widget.ImageView;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.VirtualFolderType;
@ -85,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.OwnCloudVersion;
import com.owncloud.android.media.MediaService;
import com.owncloud.android.media.MediaServiceBinder;
import com.owncloud.android.operations.CopyFileOperation;
@ -301,6 +303,7 @@ public class FileDisplayActivity extends HookActivity
// always AFTER setContentView(...) in onCreate(); to work around bug in its implementation
upgradeNotificationForInstantUpload();
checkOutdatedServer();
}
private Activity getActivity() {
@ -353,6 +356,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 (MainApp.getVersionCode() > lastSeenVersion) {
OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this);
if (serverVersion.compareTo(OwnCloudVersion.nextcloud_12) < 0) {
DisplayUtils.showServerOutdatedSnackbar(this);
}
arbitraryDataProvider.storeOrUpdateKeyValue(account.name, WhatsNewActivity.KEY_LAST_SEEN_VERSION_CODE,
String.valueOf(MainApp.getVersionCode()));
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) {

View file

@ -182,7 +182,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
editor.apply();
}
static private int getLastSeenVersionCode() {
static public int getLastSeenVersionCode() {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(MainApp.getAppContext());
return pref.getInt(KEY_LAST_SEEN_VERSION_CODE, 0);
}

View file

@ -767,4 +767,11 @@ public class DisplayUtils {
}
}
static public void showServerOutdatedSnackbar(Activity activity) {
Snackbar.make(activity.findViewById(android.R.id.content),
R.string.outdated_server, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.dismiss, v -> {
})
.show();
}
}

View file

@ -801,4 +801,6 @@
<string name="new_version_was_created">New version was created</string>
<string name="file_version_restored_successfully">Successfully restored file version.</string>
<string name="file_version_restored_error">Error restoring file version!</string>
<string name="outdated_server">The server has reached end of life, please upgrade!</string>
<string name="dismiss">Dismiss</string>
</resources>