From 71aa88f3702aa293b35832956f9d38481deff47c Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 3 Aug 2018 23:00:06 +0200 Subject: some changes in Updater --- .../de/pixart/messenger/ui/UpdaterActivity.java | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/main/java/de/pixart/messenger/ui/UpdaterActivity.java') diff --git a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java index 4832dc466..0c59b06c6 100644 --- a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java +++ b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java @@ -37,13 +37,15 @@ import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.utils.WakeLockHelper; import static de.pixart.messenger.http.HttpConnectionManager.getProxy; +import static de.pixart.messenger.services.XmppConnectionService.FDroid; +import static de.pixart.messenger.services.XmppConnectionService.PlayStore; public class UpdaterActivity extends XmppActivity { static final private String FileName = "update.apk"; String appURI = ""; String changelog = ""; Integer filesize = 0; - boolean playstore = false; + String store; ProgressDialog mProgressDialog; DownloadTask downloadTask; XmppConnectionService mXmppConnectionService; @@ -104,9 +106,9 @@ public class UpdaterActivity extends XmppActivity { UpdaterActivity.this.finish(); } try { - playstore = getIntent().getBooleanExtra("playstore", false); + store = getIntent().getStringExtra("store"); } catch (Exception e) { - playstore = false; + store = null; } //delete old downloaded localVersion files File dir = new File(FileBackend.getConversationsDirectory("Update", false)); @@ -129,7 +131,7 @@ public class UpdaterActivity extends XmppActivity { //ask for permissions on devices >= SDK 23 if (isStoragePermissionGranted() && isNetworkAvailable(getApplicationContext())) { //start downloading the file using the download manager - if (playstore) { + if (store.equals(PlayStore)) { Uri uri = Uri.parse("market://details?id=de.pixart.messenger"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, uri); PackageManager manager = getApplicationContext().getPackageManager(); @@ -143,6 +145,20 @@ public class UpdaterActivity extends XmppActivity { startActivity(browserIntent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } + } else if (store.equals(FDroid)) { + Uri uri = Uri.parse("https://f-droid.org/de/packages/de.pixart.messenger/"); + Intent marketIntent = new Intent(Intent.ACTION_VIEW, uri); + PackageManager manager = getApplicationContext().getPackageManager(); + List infos = manager.queryIntentActivities(marketIntent, 0); + if (infos.size() > 0) { + startActivity(marketIntent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + } else { + uri = Uri.parse("https://f-droid.org/de/packages/de.pixart.messenger/"); + Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(browserIntent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + } } else { Toast.makeText(getApplicationContext(), getText(R.string.download_started), Toast.LENGTH_LONG).show(); downloadTask = new DownloadTask(UpdaterActivity.this) { -- cgit v1.2.3