Search in sources :

Example 91 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by owncloud.

the class AccountUtils method getServerVersion.

/**
 * Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
 *
 * @param   account     ownCloud account
 * @return Version of the OC server corresponding to account, according to the data saved
 *                      in the system AccountManager
 */
@Nullable
public static OwnCloudVersion getServerVersion(Account account) {
    OwnCloudVersion serverVersion = null;
    if (account != null) {
        // capabilities are now the preferred source for version info
        FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(MainApp.Companion.getAppContext(), account, MainApp.Companion.getAppContext().getContentResolver());
        OCCapability capability = fileDataStorageManager.getCapability(account.name);
        if (capability != null) {
            serverVersion = new OwnCloudVersion(capability.getVersionString());
        } else {
            // legacy: AccountManager as source of version info
            AccountManager accountMgr = AccountManager.get(MainApp.Companion.getAppContext());
            String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);
            if (serverVersionStr != null) {
                serverVersion = new OwnCloudVersion(serverVersionStr);
            }
        }
    }
    return serverVersion;
}
Also used : OCCapability(com.owncloud.android.domain.capabilities.model.OCCapability) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) AccountManager(android.accounts.AccountManager) OwnCloudVersion(com.owncloud.android.lib.resources.status.OwnCloudVersion) Nullable(androidx.annotation.Nullable)

Aggregations

FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)91 OCFile (com.owncloud.android.datamodel.OCFile)43 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)21 Account (android.accounts.Account)19 User (com.nextcloud.client.account.User)16 Intent (android.content.Intent)12 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)12 Context (android.content.Context)9 File (java.io.File)9 ArrayList (java.util.ArrayList)9 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)8 Test (org.junit.Test)8 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)7 OCUpload (com.owncloud.android.db.OCUpload)6 AccountManager (android.accounts.AccountManager)5 OperationCancelledException (com.owncloud.android.lib.common.operations.OperationCancelledException)5 UploadFileOperation (com.owncloud.android.operations.UploadFileOperation)5 DialogFragment (androidx.fragment.app.DialogFragment)4 IOException (java.io.IOException)4 AccountsException (android.accounts.AccountsException)3