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);
}
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();
}
}
Aggregations