List of usage examples for android.content SharedPreferences getStringSet
@Nullable Set<String> getStringSet(String key, @Nullable Set<String> defValues);
From source file:com.marlonjones.voidlauncher.InstallShortcutReceiver.java
public static void removeFromInstallQueue(Context context, HashSet<String> packageNames, UserHandleCompat user) {//from ww w . j av a 2 s.c o m if (packageNames.isEmpty()) { return; } SharedPreferences sp = Utilities.getPrefs(context); synchronized (sLock) { Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); } if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String encoded = newStringsIter.next(); PendingInstallShortcutInfo info = decode(encoded, context); if (info == null || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) { newStringsIter.remove(); } } sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).apply(); } } }
From source file:com.android.launcher3.InstallShortcutReceiver.java
public static void removeFromInstallQueue(Context context, ArrayList<String> packageNames, UserHandleCompat user) {/*from w ww. j a va 2 s . co m*/ if (packageNames.isEmpty()) { return; } String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); synchronized (sLock) { Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); } if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String encoded = newStringsIter.next(); PendingInstallShortcutInfo info = decode(encoded, context); if (info == null || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) { newStringsIter.remove(); } } sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).commit(); } } }
From source file:com.android.launcher4.InstallShortcutReceiver.java
public static void removeFromInstallQueue(SharedPreferences sharedPrefs, ArrayList<String> packageNames) { if (packageNames.isEmpty()) { return;//from w w w. j a v a 2 s .c om } synchronized (sLock) { Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); } if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String json = newStringsIter.next(); try { JSONObject object = (JSONObject) new JSONTokener(json).nextValue(); Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); String pn = launchIntent.getPackage(); if (pn == null) { pn = launchIntent.getComponent().getPackageName(); } if (packageNames.contains(pn)) { newStringsIter.remove(); } } catch (org.json.JSONException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } catch (java.net.URISyntaxException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } } sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>(newStrings)).commit(); } } }
From source file:com.marlonjones.voidlauncher.InstallShortcutReceiver.java
private static ArrayList<PendingInstallShortcutInfo> getAndClearInstallQueue(SharedPreferences sharedPrefs, Context context) {//from w ww .ja v a 2 s .c o m synchronized (sLock) { Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) Log.d(TAG, "Getting and clearing APPS_PENDING_INSTALL: " + strings); if (strings == null) { return new ArrayList<PendingInstallShortcutInfo>(); } ArrayList<PendingInstallShortcutInfo> infos = new ArrayList<PendingInstallShortcutInfo>(); for (String encoded : strings) { PendingInstallShortcutInfo info = decode(encoded, context); if (info != null) { infos.add(info); } } sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).apply(); return infos; } }
From source file:com.stv.launcher.receiver.InstallShortcutReceiver.java
public static void removeFromInstallQueue(Context context, ArrayList<String> packageNames, UserHandleCompat user) {//from ww w .j a v a 2 s . c o m if (packageNames.isEmpty()) { return; } String spKey = LauncherState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); synchronized (sLock) { Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); } if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String encoded = newStringsIter.next(); PendingInstallShortcutInfo info = decode(encoded, context); if (info == null || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) { newStringsIter.remove(); } } sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).commit(); } } }
From source file:com.android.launcher3.InstallShortcutReceiver.java
private static void addToInstallQueue(SharedPreferences sharedPrefs, PendingInstallShortcutInfo info) { synchronized (sLock) { String encoded = info.encodeToString(); if (encoded != null) { Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); if (strings == null) { strings = new HashSet<String>(1); } else { strings = new HashSet<String>(strings); }//from w w w . j a v a 2s.c om strings.add(encoded); sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, strings).commit(); } } }
From source file:com.marlonjones.voidlauncher.InstallShortcutReceiver.java
private static void addToInstallQueue(SharedPreferences sharedPrefs, PendingInstallShortcutInfo info) { synchronized (sLock) { String encoded = info.encodeToString(); if (encoded != null) { Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); if (strings == null) { strings = new HashSet<String>(1); } else { strings = new HashSet<String>(strings); }/*from w w w . j a va2 s. c o m*/ strings.add(encoded); sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, strings).apply(); } } }
From source file:fyc.framework.util.PrefsUtils.java
/** * @param context/* w w w. j a va 2 s. c om*/ * @param name * @param key * @param defValues * @param mode * @return */ @TargetApi(11) public static Set<String> getStringSet(Context context, String name, String key, Set<String> defValues, int mode, boolean[] keyValueEncrypt) { SharedPreferences preferences = null; if (TextUtils.isEmpty(name)) { preferences = PreferenceManager.getDefaultSharedPreferences(context); } else { preferences = context.getSharedPreferences(name, mode); } Set<String> valueSet = preferences.getStringSet(keyValueEncrypt[0] ? SecurityUtils.MD5(key) : key, defValues); Set<String> tempValueSet = new HashSet<String>(); for (String s : valueSet) { tempValueSet.add(SecurityUtils.DESdecrypt(s, SECURITY_KEY)); } return tempValueSet; }
From source file:org.xbmc.kore.ui.AddonListContainerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // We're not being shown or there's nothing to show return null; }// www. jav a 2 s . c om ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_default_view_pager, container, false); ButterKnife.inject(this, root); tabsAdapter = new TabsAdapter(getActivity(), getChildFragmentManager()); SharedPreferences prefs = getActivity().getSharedPreferences("addons", Context.MODE_PRIVATE); Set<String> bookmarked = prefs.getStringSet("bookmarked", Collections.<String>emptySet()); long baseFragmentId = 70 + bookmarked.size() * 100; tabsAdapter.addTab(AddonListFragment.class, new Bundle(), R.string.addons, baseFragmentId); for (String path : bookmarked) { String name = prefs.getString("name_" + path, "Content"); Bundle addon = new Bundle(); addon.putString(AddonDetailsFragment.BUNDLE_KEY_NAME, name); addon.putParcelable(MediaFileListFragment.ROOT_PATH, new MediaFileListFragment.FileLocation(name, "plugin://" + path, true)); tabsAdapter.addTab(MediaFileListFragment.class, addon, name, ++baseFragmentId); } viewPager.setAdapter(tabsAdapter); pagerTabStrip.setViewPager(viewPager); return root; }
From source file:com.agateau.equiv.ui.Kernel.java
private void readFavorites(SharedPreferences prefs) { Set<String> stringSet = prefs.getStringSet("favorites", null); if (stringSet == null) { return;/* ww w. ja v a 2 s .c om*/ } Set<UUID> favorites = new HashSet<>(); for (String str : stringSet) { favorites.add(UUID.fromString(str)); } mProductStore.setFavoriteUuids(favorites); }