diff options
author | Arne Schwabe <arne@rfc2549.org> | 2016-12-17 13:45:51 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2016-12-17 13:45:51 +0100 |
commit | 7939e5af2252f47ab79dff80682388bdbced1fa5 (patch) | |
tree | 20cb53cf7002975f6e3b43b574e418146629d205 /main/src | |
parent | 6b3e6cd5f45c6e8421540af6691637f3ac54c9a4 (diff) |
Fix crash on phones with less than 4 profiles
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java | 12 |
1 files 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<ShortcutInfo> newShortcuts = new LinkedList<>(); + LinkedList<ShortcutInfo> updateShortcuts = new LinkedList<>(); + LinkedList<String> removeShortcuts = new LinkedList<>(); LinkedList<String> disableShortcuts = new LinkedList<>(); @@ -186,6 +188,7 @@ public class VPNProfileList extends ListFragment implements OnClickListener, Vpn sortedProfilesLRU.addAll(profileManager.getProfiles()); LinkedList<VpnProfile> 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()) |