diff options
Diffstat (limited to '')
3 files changed, 43 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 6378fcb03..6143ab02e 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -9,6 +9,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.database.ContentObserver; import android.graphics.Bitmap; import android.media.AudioManager; @@ -70,6 +71,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import de.duenndns.ssl.MemorizingTrustManager; +import de.pixart.messenger.BuildConfig; import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.crypto.PgpDecryptionService; @@ -4254,6 +4256,22 @@ public class XmppConnectionService extends Service { } } + public boolean installedFromFDroid() { + final PackageManager packageManager = this.getPackageManager(); + final String packageID = BuildConfig.APPLICATION_ID; + final String installedFrom = packageManager.getInstallerPackageName(packageID); + Log.d(Config.LOGTAG, "Messenger installed from " + installedFrom); + return installedFrom != null && installedFrom.contains("org.fdroid.fdroid"); + } + + public boolean installedFromPlayStore() { + final PackageManager packageManager = this.getPackageManager(); + final String packageID = BuildConfig.APPLICATION_ID; + final String installedFrom = packageManager.getInstallerPackageName(packageID); + Log.d(Config.LOGTAG, "Messenger installed from " + installedFrom); + return installedFrom != null && installedFrom.contains("com.android.venedig"); + } + public ShortcutService getShortcutService() { return mShortcutService; } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index b7018b58c..274b51d8a 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -483,7 +483,7 @@ public class ConversationActivity extends XmppActivity menuInviteContact.setVisible(false); menuAttach.setVisible(false); menuClearHistory.setVisible(false); - if (installedFromFDroid()) { + if (xmppConnectionService.installedFromFDroid()) { menuUpdater.setVisible(false); } else { menuUpdater.setVisible(true); @@ -523,14 +523,6 @@ public class ConversationActivity extends XmppActivity return super.onCreateOptionsMenu(menu); } - private boolean installedFromFDroid() { - final PackageManager packageManager = this.getPackageManager(); - final String packageID = BuildConfig.APPLICATION_ID; - final String installedFrom = packageManager.getInstallerPackageName(packageID); - Log.d(Config.LOGTAG, "Messenger installed from " + installedFrom); - return installedFrom != null && installedFrom.contains("fdroid"); - } - private Runnable addOmemoDebuggerRunnable = new Runnable() { @Override public void run() { @@ -1386,7 +1378,7 @@ public class ConversationActivity extends XmppActivity if (xmppConnectionService.getAccounts().size() != 0) { if (xmppConnectionService.hasInternetConnection()) { if (xmppConnectionService.isWIFI() || (xmppConnectionService.isMobile() && !xmppConnectionService.isMobileRoaming())) { - if (!installedFromFDroid()) { + if (!xmppConnectionService.installedFromFDroid()) { AppUpdate(); } } @@ -1432,10 +1424,11 @@ public class ConversationActivity extends XmppActivity if (!ExceptionHelper.checkForCrash(this, this.xmppConnectionService) && !mRedirected.get()) { openBatteryOptimizationDialogIfNeeded(); + if (!xmppConnectionService.installedFromFDroid() && !xmppConnectionService.installedFromPlayStore()) { + openInstallFromUnknownSourcesDialogIfNeeded(); + } } - if (!installedFromFDroid()) { - openInstallFromUnknownSourcesDialogIfNeeded(); - } + if (isConversationsOverviewVisable() && isConversationsOverviewHideable()) { xmppConnectionService.getNotificationService().setOpenConversation(null); } else { diff --git a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java index 37497ee6a..670e24406 100644 --- a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java +++ b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; @@ -33,9 +34,11 @@ import java.util.List; import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.persistance.FileBackend; +import de.pixart.messenger.services.XmppConnectionService; public class UpdaterActivity extends Activity { + XmppConnectionService xmppConnectionService; static final private String FileName = "update.apk"; String appURI = ""; String changelog = ""; @@ -88,8 +91,22 @@ public class UpdaterActivity extends Activity { //ask for permissions on devices >= SDK 23 if (isStoragePermissionGranted() && isNetworkAvailable(getApplicationContext())) { //start downloading the file using the download manager - DownloadFromUrl(appURI, FileName); - Toast.makeText(getApplicationContext(), getText(R.string.download_started), Toast.LENGTH_LONG).show(); + if (xmppConnectionService.installedFromPlayStore()) { + Uri uri = Uri.parse("market://details?id=de.pixart.openmessenger"); + 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); + } else { + uri = Uri.parse("https://jabber.pix-art.de/"); + Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(browserIntent); + } + } else { + DownloadFromUrl(appURI, FileName); + Toast.makeText(getApplicationContext(), getText(R.string.download_started), Toast.LENGTH_LONG).show(); + } } else { Log.d(Config.LOGTAG, "AppUpdater: failed - has storage permissions " + isStoragePermissionGranted() + " and internet " + isNetworkAvailable(getApplicationContext())); } |