List of usage examples for android.content SharedPreferences getStringSet
@Nullable Set<String> getStringSet(String key, @Nullable Set<String> defValues);
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
/** * Updates TickerStorage with new tickers *//*from ww w . j a v a 2 s . c om*/ private void updateStorageWithTickers() { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); Set<String> pairs = preferences.getStringSet("PairsToDisplay", new HashSet<String>()); if (pairs.size() == 0) { //cleanup storage TickersStorage.loadLatestData().clear(); TickersStorage.loadPreviousData().clear(); return; } //checking for added tickers for (String pair : pairs) { if (!TickersStorage.loadLatestData().containsKey(pair.replace("/", "_").toLowerCase(Locale.US))) { Ticker ticker = new Ticker(pair); TickersStorage.addNewTicker(ticker); } } //checking for deleted tickers for (Iterator<String> iterator = TickersStorage.loadLatestData().keySet().<String>iterator(); iterator .hasNext();) { String key = iterator.next(); if (!pairs.contains(key)) { iterator.remove(); } } }
From source file:org.xbmc.kore.ui.AddonDetailsFragment.java
@OnClick(R.id.pin_unpin) public void onPinClicked(View v) { final boolean isBookmarked = (v.getTag() == null) ? true : !(Boolean) v.getTag(); String name = mediaTitle.getText().toString(); String path = addonId;//from w ww . j a v a 2s. c o m SharedPreferences prefs = getActivity().getSharedPreferences("addons", Context.MODE_PRIVATE); Set<String> bookmarks = new HashSet<>(prefs.getStringSet("bookmarked", Collections.<String>emptySet())); if (isBookmarked) bookmarks.add(path); else bookmarks.remove(path); prefs.edit().putStringSet("bookmarked", bookmarks).putString("name_" + path, name).apply(); Toast.makeText(getActivity(), isBookmarked ? R.string.addon_pinned : R.string.addon_unpinned, Toast.LENGTH_SHORT).show(); setupPinButton(isBookmarked); }
From source file:com.example.milos.msattackczm.ui.ProcedureDetailFragment.java
private void load(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String mItemString = String.valueOf(mItem); Set<String> defaultStringSet = new TreeSet<String>(); Set<String> codeNumbersChecked = prefs.getStringSet(mItemString, defaultStringSet); }
From source file:gowtham.com.desknote.MyListener.java
@Override public void onNotificationPosted(StatusBarNotification sbn) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); // If user has disabled notifications, then skip if (!pref.getBoolean("send_notifications", false)) return;/*from w w w. j a v a 2 s . c o m*/ // Look for our device Set<String> emptySet = new HashSet<String>(); Collection<String> addresses = pref.getStringSet("desktop_address", emptySet); Log.i(MainActivity.TAG, "Connected devices " + connectedDevices); Collection<String> connectedAddresses = getConnectedAddresses(addresses, connectedDevices); Notification mNotification = sbn.getNotification(); // Can't do much if we get a null! if (mNotification == null) return; Bundle extras = mNotification.extras; String packageName = sbn.getPackageName(); String title = extras.getString(Notification.EXTRA_TITLE); String text = extras.getString(Notification.EXTRA_TEXT); String subText = extras.getString(Notification.EXTRA_SUB_TEXT); Integer smallIconID = extras.getInt(Notification.EXTRA_SMALL_ICON); String icon = "null"; if (pref.getBoolean("include_images", false)) { if (extras.getParcelable(Notification.EXTRA_LARGE_ICON) != null) { Bitmap b = Bitmap.class.cast(extras.getParcelable(Notification.EXTRA_LARGE_ICON)); icon = bitmap2Base64(b); } else { icon = getIcon(packageName, smallIconID); } } Map<String, String> extrasMap = new HashMap<String, String>(); for (String key : extras.keySet()) { extrasMap.put(key, String.valueOf(extras.get(key))); } Log.e(MainActivity.TAG, "Got a new notification " + title + " " + mNotification.hashCode()); Message msg = new Message(title, text, subText, icon, mNotification.toString(), extrasMap, packageName); NotificationTransmitter tx = new NotificationTransmitter(); Log.e(MainActivity.TAG, "Sending bluetooth message"); tx.transmit(connectedAddresses, msg); }
From source file:org.epstudios.epcoding.ProcedureDetailFragment.java
private void load(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String mItemString = String.valueOf(mItem); Set<String> defaultStringSet = new TreeSet<String>(); Set<String> codeNumbersChecked = prefs.getStringSet(mItemString, defaultStringSet); // String numbers = codeNumbersChecked.toString(); for (Map.Entry<String, CodeCheckBox> entry : secondaryCheckBoxMap.entrySet()) { if (codeNumbersChecked.contains(entry.getValue().getCodeNumber())) entry.getValue().setChecked(true); }/*from w w w . ja v a 2 s .co m*/ }
From source file:com.wab.lernapp.LerntestActivity.java
private void firstTime() { SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); HashSet<String> defaultTypes = new HashSet<>(); defaultTypes.add("leer"); defaultTypes.add("leer"); Set<String> didacticTypes = SP.getStringSet("preference_didactic_type", defaultTypes); if (didacticTypes.contains("leer")) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(LerntestActivity.this); // set title alertDialogBuilder.setTitle("Dein Lerntyp"); // set dialog message alertDialogBuilder/* ww w . j a v a 2 s .c o m*/ .setMessage( "Um die Inhalte auf dich zuzuschneiden mchten wir einen Lerntypentest durchfhren.") .setCancelable(false).setPositiveButton("Los geht's", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setNegativeButton("berspringen", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { LerntestActivity.this.finish(); HashSet<String> didacticTypes = new HashSet<>(); didacticTypes.add("visuell"); didacticTypes.add("auditiv"); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); SharedPreferences.Editor mEditor = SP.edit(); mEditor.putStringSet("preference_didactic_type", didacticTypes).commit(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } else { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(LerntestActivity.this); // set title alertDialogBuilder.setTitle("Dein Lerntyp"); // set dialog message alertDialogBuilder .setMessage("Mchtest du den Test nochmal machen und den aktuellen Lerntyp berschreiben?") .setCancelable(false).setPositiveButton("Klar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setNegativeButton("Lieber nicht", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { LerntestActivity.this.finish(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } }
From source file:mx.com.adolfogarcia.popularmovies.data.RestfulServiceConfiguration.java
/** * Returns the set of available image sizes for the movie posters. The * sizes are specified by the code names used in * <a href="https://www.themoviedb.org/">themoviedb.org</a>'s RESTful API * (usually the width in pixels, prefixed by the character 'w'). * * @return the set of available image sizes for the movie posters as * previously saved, or the default values. *///from w ww . j av a2 s .co m public Set<String> getPosterSizes() { requireNonNullContext(); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mWeakContext.get()); return settings.getStringSet(PREFERENCES_KEY_POSTER_SIZES, getDefaultSetValue(PROPERTIES_KEY_DEFAULT_POSTER_SIZES)); }
From source file:mx.com.adolfogarcia.popularmovies.data.RestfulServiceConfiguration.java
/** * Returns the set of available image sizes for the movie backdrops. The * sizes are specified by the code names used in * <a href="https://www.themoviedb.org/">themoviedb.org</a>'s RESTful API * (usually the width in pixels, prefixed by the character 'w'). * * @return the set of available image sizes for the movie backdrops as * previously saved, or the default values. */// w w w .j av a 2 s. c o m public Set<String> getBackdropSizes() { requireNonNullContext(); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mWeakContext.get()); return settings.getStringSet(PREFERENCES_KEY_BACKDROP_SIZES, getDefaultSetValue(PROPERTIES_KEY_DEFAULT_BACKDROP_SIZES)); }
From source file:com.quarterfull.newsAndroid.NewsDetailActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.news_detail, menu); menuItem_Starred = menu.findItem(R.id.action_starred); menuItem_Read = menu.findItem(R.id.action_read); menuItem_PlayPodcast = menu.findItem(R.id.action_playPodcast); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); Set<String> selections = preferences.getStringSet("sp_news_detail_actionbar_icons", new HashSet<String>()); String[] selected = selections.toArray(new String[] {}); for (String selection : selected) { switch (selection) { case "open_in_browser": menu.findItem(R.id.action_openInBrowser).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); break; case "share": menu.findItem(R.id.action_ShareItem).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); break; case "podcast": menu.findItem(R.id.action_playPodcast).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); break; //case "tts": // menu.findItem(R.id.action_tts).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // break; }// ww w .ja v a2s. c om } UpdateActionBarIcons(); return true; }
From source file:com.fusionx.lightirc.util.SharedPreferencesUtils.java
private static ServerConfiguration.Builder convertPrefsToBuilder(final Context context, final String filename) { final SharedPreferences serverSettings = context.getSharedPreferences(filename, MODE_PRIVATE); final ServerConfiguration.Builder builder = new ServerConfiguration.Builder(); // Server connection builder.setTitle(serverSettings.getString(PreferenceConstants.PREF_TITLE, "")); builder.setUrl(serverSettings.getString(PreferenceConstants.PREF_URL, "").trim()); builder.setPort(Integer.parseInt(serverSettings.getString(PreferenceConstants.PREF_PORT, "6667"))); // SSL/*from www .java 2s .c o m*/ builder.setSsl(serverSettings.getBoolean(PreferenceConstants.PREF_SSL, false)); builder.setSslAcceptAllCertificates( serverSettings.getBoolean(PreferenceConstants.PREF_SSL_ACCEPT_ALL_CONNECTIONS, false)); // User settings final String firstChoice = serverSettings.getString(PreferenceConstants.PREF_NICK, "HoloIRCUser"); final String secondChoice = serverSettings.getString(PreferenceConstants.PREF_SECOND_NICK, ""); final String thirdChoice = serverSettings.getString(PreferenceConstants.PREF_THIRD_NICK, ""); final NickStorage nickStorage = new NickStorage(firstChoice, secondChoice, thirdChoice); builder.setNickStorage(nickStorage); builder.setRealName(serverSettings.getString(PreferenceConstants.PREF_REALNAME, "HoloIRC")); builder.setNickChangeable(serverSettings.getBoolean(PreferenceConstants.PREF_AUTO_NICK, true)); // Autojoin channels final ArrayList<String> auto = new ArrayList<String>( serverSettings.getStringSet(PreferenceConstants.PREF_AUTOJOIN, new HashSet<String>())); for (final String channel : auto) { builder.getAutoJoinChannels().add(channel); } // Server authorisation builder.setServerUserName(serverSettings.getString(PreferenceConstants.PREF_LOGIN_USERNAME, "holoirc")); builder.setServerPassword(serverSettings.getString(PreferenceConstants.PREF_LOGIN_PASSWORD, "")); // SASL authorisation builder.setSaslUsername(serverSettings.getString(PreferenceConstants.PREF_SASL_USERNAME, "")); builder.setSaslPassword(serverSettings.getString(PreferenceConstants.PREF_SASL_PASSWORD, "")); // NickServ authorisation builder.setNickservPassword(serverSettings.getString(PreferenceConstants.PREF_NICKSERV_PASSWORD, "")); return builder; }