summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2017-01-26 17:39:22 +0100
committerArne Schwabe <arne@rfc2549.org>2017-01-26 17:39:22 +0100
commitea4dc52451a33fedacd7109582630a27d004de92 (patch)
tree08309ce3fdd470c75fffa695be3466dedd71a1a4
parent23095590c96b88330a2ca5c889d4301f79e0c569 (diff)
Ensure that the launcher shortcuts are updated when something aside from the name changes (symbol in this case)
-rw-r--r--build.gradle2
-rw-r--r--gradle/wrapper/gradle-wrapper.properties4
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java21
3 files changed, 22 insertions, 5 deletions
diff --git a/build.gradle b/build.gradle
index c51071af..e1ab1d1e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.0-beta1'
+ classpath 'com.android.tools.build:gradle:2.3.0-beta3'
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 4d7436fe..0b49e0b5 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Dec 14 15:14:57 CET 2016
+#Thu Jan 26 17:27:33 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java b/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
index 4130d218..5a786afd 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
@@ -20,7 +20,7 @@ import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
-import android.preference.PreferenceManager;
+import android.os.PersistableBundle;
import android.support.annotation.RequiresApi;
import android.text.Html;
import android.text.Html.ImageGetter;
@@ -157,8 +157,13 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn
}
+ // Shortcut version is increased to refresh all shortcuts
+ final static int SHORTCUT_VERSION = 1;
+
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
void updateDynamicShortcuts() {
+ PersistableBundle versionExtras = new PersistableBundle();
+ versionExtras.putInt("version", SHORTCUT_VERSION);
ShortcutManager shortcutManager = getContext().getSystemService(ShortcutManager.class);
if (shortcutManager.isRateLimitingActive())
@@ -173,6 +178,7 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn
.setLongLabel("Disconnect VPN")
.setIntent(new Intent(getContext(), DisconnectVPN.class).setAction(DISCONNECT_VPN))
.setIcon(Icon.createWithResource(getContext(), R.drawable.ic_shortcut_cancel))
+ .setExtras(versionExtras)
.build();
LinkedList<ShortcutInfo> newShortcuts = new LinkedList<>();
@@ -198,6 +204,10 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn
for (ShortcutInfo shortcut : shortcuts) {
if (shortcut.getId().equals("disconnectVPN")) {
addDisconnect = false;
+ if (shortcut.getExtras() == null
+ || shortcut.getExtras().getInt("version") != SHORTCUT_VERSION)
+ updateShortcuts.add(disconnectShortcut);
+
} else {
VpnProfile p = ProfileManager.get(getContext(), shortcut.getId());
if (p == null || p.profileDeleted) {
@@ -214,9 +224,12 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn
else
removeShortcuts.add(p.getUUIDString());
- if (!p.getName().equals(shortcut.getShortLabel()))
+ if (!p.getName().equals(shortcut.getShortLabel())
+ || shortcut.getExtras() == null
+ || shortcut.getExtras().getInt("version") != SHORTCUT_VERSION)
updateShortcuts.add(createShortcut(p));
+
}
}
@@ -245,11 +258,15 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn
shortcutIntent.setAction(Intent.ACTION_MAIN);
shortcutIntent.putExtra("EXTRA_HIDELOG", true);
+ PersistableBundle versionExtras = new PersistableBundle();
+ versionExtras.putInt("version", SHORTCUT_VERSION);
+
return new ShortcutInfo.Builder(getContext(), profile.getUUIDString())
.setShortLabel(profile.getName())
.setLongLabel(getString(R.string.qs_connect, profile.getName()))
.setIcon(Icon.createWithResource(getContext(), R.drawable.ic_shortcut_vpn_key))
.setIntent(shortcutIntent)
+ .setExtras(versionExtras)
.build();
}