From 70971661cb04a1f6ce6beb8140c2af86119918a2 Mon Sep 17 00:00:00 2001 From: Christian S Date: Fri, 6 May 2016 21:42:30 +0200 Subject: Ask to uninstall the plugins because the features are directly integrated --- .../conversations/ui/ConversationActivity.java | 73 +++++++++++++++++++++- src/main/res/values-de/strings.xml | 3 + src/main/res/values/strings.xml | 2 + 3 files changed, 75 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index b336d98e2..5b84446ec 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -13,6 +13,8 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.IntentSender.SendIntentException; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; @@ -203,8 +205,6 @@ public class ConversationActivity extends XmppActivity } } - AppUpdate(); - setContentView(R.layout.fragment_conversations_overview); this.mConversationFragment = new ConversationFragment(); @@ -345,11 +345,78 @@ public class ConversationActivity extends XmppActivity } } - protected void AppUpdate() { + public boolean isPackageInstalled(String targetPackage){ + List packages; + PackageManager pm; + pm = getPackageManager(); + packages = pm.getInstalledApplications(0); + for (ApplicationInfo packageInfo : packages) { + if(packageInfo.packageName.equals(targetPackage)) return true; + } + return false; + } + + protected void AppUpdate() { String PREFS_NAME = "UpdateTimeStamp"; SharedPreferences UpdateTimeStamp = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); long lastUpdateTime = UpdateTimeStamp.getLong("lastUpdateTime", 0); + //detect installed plugins and deinstall them + PackageInfo pInfo = null; + try { + pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + //get the app version Name for display + final int versionCode = pInfo.versionCode; + // delete voice recorder and location plugin for versions >= 142 (1.12.1) + if (versionCode >= 142) { + Log.d(Config.LOGTAG, "New Features - Uninstall plugins"); + if (isPackageInstalled("eu.siacs.conversations.voicerecorder") || isPackageInstalled("eu.siacs.conversations.sharelocation") || isPackageInstalled("com.samwhited.opensharelocationplugin")) { + AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this); + builder.setMessage(R.string.uninstall_plugins) + .setPositiveButton(R.string.uninstall, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialogInterface, int i) { + //start the deinstallation of voice recorder + if (isPackageInstalled("eu.siacs.conversations.voicerecorder")) { + Uri packageURI_VR = Uri.parse("package:eu.siacs.conversations.voicerecorder"); + Intent uninstallIntent_VR = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI_VR); + if (uninstallIntent_VR.resolveActivity(getPackageManager()) != null) { + Log.d(Config.LOGTAG, "New Features - Uninstall voice recorder"); + startActivity(uninstallIntent_VR); + } + } + //start the deinstallation of share location + if (isPackageInstalled("eu.siacs.conversations.sharelocation")) { + Uri packageURI_SL = Uri.parse("package:eu.siacs.conversations.sharelocation"); + Intent uninstallIntent_SL = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI_SL); + if (uninstallIntent_SL.resolveActivity(getPackageManager()) != null) { + Log.d(Config.LOGTAG, "New Features - Uninstall share location"); + startActivity(uninstallIntent_SL); + } + } + //start the deinstallation of open share location + if (isPackageInstalled("com.samwhited.opensharelocationplugin")) { + Uri packageURI_SL = Uri.parse("package:com.samwhited.opensharelocationplugin"); + Intent uninstallIntent_SL = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI_SL); + if (uninstallIntent_SL.resolveActivity(getPackageManager()) != null) { + Log.d(Config.LOGTAG, "New Features - Uninstall open share location"); + startActivity(uninstallIntent_SL); + } + } + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialogInterface, int i) { + Log.d(Config.LOGTAG, "New Features - Uninstall cancled"); + + } + }); + builder.create().show(); + } + } + Log.d(Config.LOGTAG, "AppUpdater - LastUpdateTime: " + lastUpdateTime); if ((lastUpdateTime + (Config.UPDATE_CHECK_TIMER * 1000)) < System.currentTimeMillis()) { diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 117dd0993..16cdc192f 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -642,4 +642,7 @@ Deine öffentliche OpenPGP Schlüssel müssen veröffentlicht werden! Teilen Standort teilen + Bindungsfehler + Deinstallieren + Wir haben den VoiceRecorder und das ShareLocation Plugin direkt integriert. Die Plugins sind nicht länger erforderlich und sollten deinstalliert werden. diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index a5190236b..0d7edfcd5 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -678,5 +678,7 @@ Location sharing is disabled in settings Locating… Captcha Text + We have integrated the VoiceRecorder and ShareLocation plugin directly into the messenger. You should uninstall the plugins. + Uninstall -- cgit v1.2.3