From 7939e5af2252f47ab79dff80682388bdbced1fa5 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sat, 17 Dec 2016 13:45:51 +0100 Subject: Fix crash on phones with less than 4 profiles --- .../java/de/blinkt/openvpn/fragments/VPNProfileList.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 3c79a278..109ecf9f 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java @@ -175,6 +175,8 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn .build(); LinkedList newShortcuts = new LinkedList<>(); + LinkedList updateShortcuts = new LinkedList<>(); + LinkedList removeShortcuts = new LinkedList<>(); LinkedList disableShortcuts = new LinkedList<>(); @@ -186,6 +188,7 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn sortedProfilesLRU.addAll(profileManager.getProfiles()); LinkedList LRUProfiles = new LinkedList<>(); + maxvpn = Math.min(maxvpn, sortedProfilesLRU.size()); for (int i = 0; i < maxvpn; i++) { LRUProfiles.add(sortedProfilesLRU.pollFirst()); @@ -209,8 +212,10 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn LRUProfiles.remove(p); else removeShortcuts.add(p.getUUIDString()); - //} - // XXX: Update Shortcut + + if (!p.getName().equals(shortcut.getShortLabel())) + updateShortcuts.add(createShortcut(p)); + } } @@ -221,6 +226,8 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn for (VpnProfile p : LRUProfiles) newShortcuts.add(createShortcut(p)); + if (updateShortcuts.size() > 0) + shortcutManager.updateShortcuts(updateShortcuts); if (removeShortcuts.size() > 0) shortcutManager.removeDynamicShortcuts(removeShortcuts); if (newShortcuts.size() > 0) @@ -235,6 +242,7 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn shortcutIntent.setClass(getActivity(), LaunchVPN.class); shortcutIntent.putExtra(LaunchVPN.EXTRA_KEY, profile.getUUID().toString()); shortcutIntent.setAction(Intent.ACTION_MAIN); + shortcutIntent.putExtra("EXTRA_HIDELOG", true); return new ShortcutInfo.Builder(getContext(), profile.getUUIDString()) .setShortLabel(profile.getName()) -- cgit v1.2.3