mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
hide outdated version warning if extended support is enabled
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
6f70ebd3a1
commit
b649ec38c4
7 changed files with 62 additions and 50 deletions
|
@ -1249,8 +1249,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
|
||||
// show outdated warning
|
||||
if (getResources().getBoolean(R.bool.show_outdated_server_warning) &&
|
||||
MainApp.OUTDATED_SERVER_VERSION.compareTo(mServerInfo.mVersion) >= 0) {
|
||||
DisplayUtils.showServerOutdatedSnackbar(this);
|
||||
MainApp.OUTDATED_SERVER_VERSION.compareTo(mServerInfo.mVersion) >= 0 &&
|
||||
!mServerInfo.hasExtendedSupport) {
|
||||
DisplayUtils.showServerOutdatedSnackbar(this, Snackbar.LENGTH_INDEFINITE);
|
||||
}
|
||||
|
||||
webViewLoginMethod = mServerInfo.mVersion.isWebLoginSupported() && !forceOldLoginMethod;
|
||||
|
|
|
@ -1917,6 +1917,7 @@ public class FileDataStorageManager {
|
|||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MICRO, capability.getVersionMicro());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_STRING, capability.getVersionString());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, capability.getVersionEdition());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT, capability.getExtendedSupport().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollInterval());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED, capability.getFilesSharingApiEnabled().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED,
|
||||
|
@ -2072,6 +2073,8 @@ public class FileDataStorageManager {
|
|||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_STRING)));
|
||||
capability.setVersionEdition(c.getString(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_EDITION)));
|
||||
capability.setExtendedSupport(CapabilityBooleanType.fromValue(c.getInt(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT))));
|
||||
capability.setCorePollInterval(c.getInt(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL)));
|
||||
capability.setFilesSharingApiEnabled(CapabilityBooleanType.fromValue(c.getInt(c
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
|
|||
*/
|
||||
public class ProviderMeta {
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 48;
|
||||
public static final int DB_VERSION = 49;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
|
@ -151,6 +151,7 @@ public class ProviderMeta {
|
|||
public static final String CAPABILITIES_VERSION_MICRO = "version_micro";
|
||||
public static final String CAPABILITIES_VERSION_STRING = "version_string";
|
||||
public static final String CAPABILITIES_VERSION_EDITION = "version_edition";
|
||||
public static final String CAPABILITIES_EXTENDED_SUPPORT = "extended_support";
|
||||
public static final String CAPABILITIES_CORE_POLLINTERVAL = "core_pollinterval";
|
||||
public static final String CAPABILITIES_SHARING_API_ENABLED = "sharing_api_enabled";
|
||||
public static final String CAPABILITIES_SHARING_PUBLIC_ENABLED = "sharing_public_enabled";
|
||||
|
|
|
@ -67,7 +67,7 @@ public class GetServerInfoOperation extends RemoteOperation {
|
|||
/**
|
||||
* Performs the operation
|
||||
*
|
||||
* @return Result of the operation. If successful, includes an instance of
|
||||
* @return Result of the operation. If successful, includes an instance of
|
||||
* {@link ServerInfo} with the information retrieved from the server.
|
||||
* Call {@link RemoteOperationResult#getData()}.get(0) to get it.
|
||||
*/
|
||||
|
@ -81,15 +81,15 @@ public class GetServerInfoOperation extends RemoteOperation {
|
|||
|
||||
if (result.isSuccess()) {
|
||||
// second: get authentication method required by the server
|
||||
mResultData.mVersion = (OwnCloudVersion)(result.getData().get(0));
|
||||
mResultData.mVersion = (OwnCloudVersion) result.getData().get(0);
|
||||
mResultData.hasExtendedSupport = (boolean) result.getData().get(1);
|
||||
mResultData.mIsSslConn = result.getCode() == ResultCode.OK_SSL;
|
||||
mResultData.mBaseUrl = normalizeProtocolPrefix(mUrl, mResultData.mIsSslConn);
|
||||
RemoteOperationResult detectAuthResult = detectAuthorizationMethod(client);
|
||||
|
||||
// third: merge results
|
||||
if (detectAuthResult.isSuccess()) {
|
||||
mResultData.mAuthMethod =
|
||||
(AuthenticationMethod)detectAuthResult.getData().get(0);
|
||||
mResultData.mAuthMethod = (AuthenticationMethod) detectAuthResult.getData().get(0);
|
||||
ArrayList<Object> data = new ArrayList<Object>();
|
||||
data.add(mResultData);
|
||||
result.setData(data);
|
||||
|
@ -141,6 +141,7 @@ public class GetServerInfoOperation extends RemoteOperation {
|
|||
|
||||
public static class ServerInfo {
|
||||
public OwnCloudVersion mVersion;
|
||||
public boolean hasExtendedSupport;
|
||||
public String mBaseUrl = "";
|
||||
public AuthenticationMethod mAuthMethod = AuthenticationMethod.UNKNOWN;
|
||||
public boolean mIsSslConn;
|
||||
|
|
|
@ -738,6 +738,7 @@ public class FileContentProvider extends ContentProvider {
|
|||
+ ProviderTableMeta.CAPABILITIES_VERSION_MICRO + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_VERSION_STRING + TEXT
|
||||
+ ProviderTableMeta.CAPABILITIES_VERSION_EDITION + TEXT
|
||||
+ ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED + INTEGER // boolean
|
||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED + INTEGER // boolean
|
||||
|
@ -1985,6 +1986,24 @@ public class FileContentProvider extends ContentProvider {
|
|||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 49 && newVersion >= 49) {
|
||||
Log_OC.i(SQL, "Entering in the #49 add extended support to capabilities table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT + " INTEGER ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,11 +63,8 @@ import com.nextcloud.client.appinfo.AppInfo;
|
|||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.owncloud.android.BuildConfig;
|
||||
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;
|
||||
|
@ -373,27 +370,17 @@ public class FileDisplayActivity extends FileActivity
|
|||
Account account = getAccount();
|
||||
|
||||
if (getResources().getBoolean(R.bool.show_outdated_server_warning) && account != null) {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this);
|
||||
|
||||
int lastSeenVersion = arbitraryDataProvider.getIntegerValue(account,
|
||||
AppPreferencesImpl.AUTO_PREF__LAST_SEEN_VERSION_CODE);
|
||||
if (serverVersion == null) {
|
||||
serverVersion = getCapabilities().getVersion();
|
||||
}
|
||||
|
||||
if (BuildConfig.VERSION_CODE > lastSeenVersion) {
|
||||
OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this);
|
||||
|
||||
if (serverVersion == null) {
|
||||
serverVersion = getCapabilities().getVersion();
|
||||
}
|
||||
|
||||
if (MainApp.OUTDATED_SERVER_VERSION.compareTo(serverVersion) >= 0) {
|
||||
DisplayUtils.showServerOutdatedSnackbar(this);
|
||||
}
|
||||
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(
|
||||
account.name,
|
||||
AppPreferencesImpl.AUTO_PREF__LAST_SEEN_VERSION_CODE,
|
||||
appInfo.getFormattedVersionCode()
|
||||
);
|
||||
// show outdated warning
|
||||
if (getResources().getBoolean(R.bool.show_outdated_server_warning) &&
|
||||
MainApp.OUTDATED_SERVER_VERSION.compareTo(serverVersion) >= 0 &&
|
||||
getCapabilities().getExtendedSupport().isFalse()) {
|
||||
DisplayUtils.showServerOutdatedSnackbar(this, Snackbar.LENGTH_LONG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -783,9 +783,9 @@ public final class DisplayUtils {
|
|||
return (int) (dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT));
|
||||
}
|
||||
|
||||
static public void showServerOutdatedSnackbar(Activity activity) {
|
||||
static public void showServerOutdatedSnackbar(Activity activity, int length) {
|
||||
Snackbar.make(activity.findViewById(android.R.id.content),
|
||||
R.string.outdated_server, Snackbar.LENGTH_INDEFINITE)
|
||||
R.string.outdated_server, length)
|
||||
.setAction(R.string.dismiss, v -> {
|
||||
})
|
||||
.show();
|
||||
|
|
Loading…
Reference in a new issue