diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationsActivity.java | 17 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/UpdaterActivity.java | 24 |
2 files changed, 28 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index 67618dc65..f2e4dc2b6 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -93,6 +93,7 @@ import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xmpp.OnUpdateBlocklist; import de.pixart.messenger.xmpp.chatstate.ChatState; +import static de.pixart.messenger.services.XmppConnectionService.PlayStore; import static de.pixart.messenger.ui.ConversationFragment.REQUEST_DECRYPT_PGP; import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS; @@ -193,9 +194,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio if (xmppConnectionService.getAccounts().size() != 0) { if (xmppConnectionService.hasInternetConnection()) { if (xmppConnectionService.isWIFI() || (xmppConnectionService.isMobile() && !xmppConnectionService.isMobileRoaming())) { - if (!xmppConnectionService.installedFromFDroid()) { - AppUpdate(xmppConnectionService.installedFromPlayStore()); - } + AppUpdate(xmppConnectionService.installedFrom()); } } } @@ -559,10 +558,10 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio return true; case R.id.action_check_updates: if (xmppConnectionService.hasInternetConnection()) { - if (!installFromUnknownSourceAllowed() && !xmppConnectionService.installedFromPlayStore()) { + if (!installFromUnknownSourceAllowed() && !xmppConnectionService.installedFrom().equals(PlayStore)) { openInstallFromUnknownSourcesDialogIfNeeded(); } else { - UpdateService task = new UpdateService(this, xmppConnectionService.installedFromPlayStore(), xmppConnectionService); + UpdateService task = new UpdateService(this, xmppConnectionService.installedFrom(), xmppConnectionService); task.executeOnExecutor(UpdateService.THREAD_POOL_EXECUTOR, "true"); Log.d(Config.LOGTAG, "AppUpdater started"); } @@ -940,8 +939,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio runOnUiThread(() -> Toast.makeText(this, resId, Toast.LENGTH_SHORT).show()); } - protected void AppUpdate(boolean PlayStore) { - if (PlayStore) { + protected void AppUpdate(String Store) { + if (Store == null) { return; } String PREFS_NAME = "UpdateTimeStamp"; @@ -954,10 +953,10 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio editor.putLong("lastUpdateTime", lastUpdateTime); editor.apply(); Log.d(Config.LOGTAG, "AppUpdater: CurrentTime: " + lastUpdateTime); - if (!installFromUnknownSourceAllowed() && !PlayStore) { + if (!installFromUnknownSourceAllowed() && !Store.equals(PlayStore)) { openInstallFromUnknownSourcesDialogIfNeeded(); } else { - UpdateService task = new UpdateService(this, PlayStore, xmppConnectionService); + UpdateService task = new UpdateService(this, Store, xmppConnectionService); task.executeOnExecutor(UpdateService.THREAD_POOL_EXECUTOR, "false"); Log.d(Config.LOGTAG, "AppUpdater started"); } 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<ResolveInfo> 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) { |