Search in sources :

Example 1 with LoadingVersionNumberTask

use of com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask in project android by nextcloud.

the class FileActivity method checkForNewDevVersion.

public static void checkForNewDevVersion(LoadingVersionNumberTask.VersionDevInterface callback, Context context) {
    String url = context.getString(R.string.dev_latest);
    LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask(callback);
    loadTask.execute(url);
}
Also used : LoadingVersionNumberTask(com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask)

Example 2 with LoadingVersionNumberTask

use of com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask in project android by nextcloud.

the class FileActivity method checkForNewDevVersion.

public static void checkForNewDevVersion(View view, Context context, boolean openDirectly) {
    Integer latestVersion = -1;
    Integer currentVersion = -1;
    try {
        currentVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
        String url = context.getString(R.string.dev_latest);
        LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask();
        loadTask.execute(url);
        latestVersion = loadTask.get();
    } catch (InterruptedException | ExecutionException | PackageManager.NameNotFoundException e) {
        Log_OC.e(TAG, "Error detecting app version", e);
    }
    if (latestVersion == -1 || currentVersion == -1) {
        Snackbar.make(view, R.string.dev_version_no_information_available, Snackbar.LENGTH_LONG).show();
    }
    if (latestVersion > currentVersion) {
        if (openDirectly) {
            String devApkLink = (String) context.getText(R.string.dev_link) + latestVersion + ".apk";
            Uri uriUrl = Uri.parse(devApkLink);
            Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
            context.startActivity(intent);
        } else {
            Integer finalLatestVersion = latestVersion;
            Snackbar.make(view, R.string.dev_version_new_version_available, Snackbar.LENGTH_LONG).setAction(context.getString(R.string.version_dev_download), v -> {
                String devApkLink = (String) context.getText(R.string.dev_link) + finalLatestVersion + ".apk";
                Uri uriUrl = Uri.parse(devApkLink);
                Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
                context.startActivity(intent);
            }).show();
        }
    } else {
        Snackbar.make(view, R.string.dev_version_no_new_version_available, Snackbar.LENGTH_LONG).show();
    }
}
Also used : UpdateShareViaLinkOperation(com.owncloud.android.operations.UpdateShareViaLinkOperation) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) Uri(android.net.Uri) OCFile(com.owncloud.android.datamodel.OCFile) IBinder(android.os.IBinder) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) Handler(android.os.Handler) LoadingDialog(com.owncloud.android.ui.dialog.LoadingDialog) FileOperationsHelper(com.owncloud.android.ui.helpers.FileOperationsHelper) ServiceConnection(android.content.ServiceConnection) View(android.view.View) OnRemoteOperationListener(com.owncloud.android.lib.common.operations.OnRemoteOperationListener) ConfirmationDialogFragment(com.owncloud.android.ui.dialog.ConfirmationDialogFragment) DisplayUtils(com.owncloud.android.utils.DisplayUtils) OwnCloudCredentials(com.owncloud.android.lib.common.OwnCloudCredentials) OwnCloudClient(com.owncloud.android.lib.common.OwnCloudClient) AccountManager(android.accounts.AccountManager) FileDownloaderBinder(com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder) FileUploaderBinder(com.owncloud.android.files.services.FileUploader.FileUploaderBinder) Account(android.accounts.Account) Fragment(android.support.v4.app.Fragment) FilesSyncHelper(com.owncloud.android.utils.FilesSyncHelper) Log_OC(com.owncloud.android.lib.common.utils.Log_OC) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) MainApp(com.owncloud.android.MainApp) FileUploader(com.owncloud.android.files.services.FileUploader) Snackbar(android.support.design.widget.Snackbar) R(com.owncloud.android.R) Context(android.content.Context) GetSharesForFileOperation(com.owncloud.android.operations.GetSharesForFileOperation) CertificateCombinedException(com.owncloud.android.lib.common.network.CertificateCombinedException) SynchronizeFileOperation(com.owncloud.android.operations.SynchronizeFileOperation) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) ResultCode(com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode) Intent(android.content.Intent) OwnCloudClientManagerFactory(com.owncloud.android.lib.common.OwnCloudClientManagerFactory) AuthenticatorException(android.accounts.AuthenticatorException) FileDownloader(com.owncloud.android.files.services.FileDownloader) SynchronizeFolderOperation(com.owncloud.android.operations.SynchronizeFolderOperation) Toast(android.widget.Toast) UnshareOperation(com.owncloud.android.operations.UnshareOperation) SslUntrustedCertDialog(com.owncloud.android.ui.dialog.SslUntrustedCertDialog) AuthenticatorActivity(com.owncloud.android.authentication.AuthenticatorActivity) ComponentName(android.content.ComponentName) CreateShareWithShareeOperation(com.owncloud.android.operations.CreateShareWithShareeOperation) RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) LoadingVersionNumberTask(com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask) ExecutionException(java.util.concurrent.ExecutionException) OperationsService(com.owncloud.android.services.OperationsService) FragmentManager(android.support.v4.app.FragmentManager) ErrorMessageAdapter(com.owncloud.android.utils.ErrorMessageAdapter) OperationsServiceBinder(com.owncloud.android.services.OperationsService.OperationsServiceBinder) FragmentTransaction(android.support.v4.app.FragmentTransaction) UpdateSharePermissionsOperation(com.owncloud.android.operations.UpdateSharePermissionsOperation) LoadingVersionNumberTask(com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask) Intent(android.content.Intent) ExecutionException(java.util.concurrent.ExecutionException) Uri(android.net.Uri)

Aggregations

Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 AuthenticatorException (android.accounts.AuthenticatorException)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ServiceConnection (android.content.ServiceConnection)1 PackageManager (android.content.pm.PackageManager)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 IBinder (android.os.IBinder)1 Snackbar (android.support.design.widget.Snackbar)1 Fragment (android.support.v4.app.Fragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 View (android.view.View)1 Toast (android.widget.Toast)1 MainApp (com.owncloud.android.MainApp)1 R (com.owncloud.android.R)1