List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:com.freshplanet.googleplaygames.ExtensionContext.java
public boolean isSignedIn() { init();// w w w . ja v a2 s.c o m SharedPreferences preferences = getActivity().getPreferences(0); return preferences.getBoolean("AneGoogleServicesIsSignedIn", false); }
From source file:de.ub0r.android.websms.connector.sipgate.ConnectorSipgate.java
/** * {@inheritDoc}/* w ww .j ava2 s. co m*/ */ @Override public final ConnectorSpec updateSpec(final Context context, final ConnectorSpec connectorSpec) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (p.getBoolean(Preferences.PREFS_ENABLE_SIPGATE, false)) { if (p.getString(Preferences.PREFS_USER_SIPGATE, "").length() > 0 && p.getString(Preferences.PREFS_PASSWORD_SIPGATE, "") // . .length() > 0) { connectorSpec.setReady(); } else { connectorSpec.setStatus(ConnectorSpec.STATUS_ENABLED); } } else { connectorSpec.setStatus(ConnectorSpec.STATUS_INACTIVE); } return connectorSpec; }
From source file:com.liato.bankdroid.banking.banks.Coop.java
@Override public Urllib login() throws LoginException, BankException { try {/* ww w .j a v a2s . co m*/ LoginPackage lp = preLogin(); response = urlopen.open(lp.getLoginTarget(), lp.getPostData()); if (response.contains("forfarande logga in med ditt personnummer")) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getBoolean("debug_mode", false) && prefs.getBoolean("debug_coop_sendmail", false)) { Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("plain/text"); i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "android@nullbyte.eu" }); i.putExtra(android.content.Intent.EXTRA_SUBJECT, "Bankdroid - Coop Error"); i.putExtra(android.content.Intent.EXTRA_TEXT, response); context.startActivity(i); } throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } return urlopen; }
From source file:com.android.mms.MmsConfig.java
public static boolean getInitQuickText() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MmsApp.getApplication()); boolean isFristInit = sp.getBoolean("InitQuickText", true); return isFristInit; }
From source file:de.dekies.android.websms.connector.smsglobal.ConnectorSmsGlobal.java
/** * {@inheritDoc}/* www . j ava2s . c o m*/ */ @Override public final ConnectorSpec updateSpec(final Context context, final ConnectorSpec connectorSpec) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (p.getBoolean(Preferences.PREFS_ENABLED, false)) { if (p.getString(Preferences.PREFS_USER, "").length() > 0 && p.getString(Preferences.PREFS_PASSWORD, "")// . .length() > 0) { connectorSpec.setReady(); } else { connectorSpec.setStatus(ConnectorSpec.STATUS_ENABLED); } } else { connectorSpec.setStatus(ConnectorSpec.STATUS_INACTIVE); } return connectorSpec; }
From source file:de.ub0r.android.websms.connector.sipgate.ConnectorSipgate.java
/** * Sets up and instance of {@link XMLRPCClient}. * // w w w .ja v a 2 s.c o m * @param context * {@link Context} * @return the initialized {@link XMLRPCClient} * @throws XMLRPCException * XMLRPCException */ private XMLRPCClient init(final Context context) throws XMLRPCException { Log.d(TAG, "init()"); final String version = context.getString(R.string.app_version); final String vendor = context.getString(R.string.connector_sipgate_author); XMLRPCClient client = null; final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (p.getBoolean(Preferences.PREFS_ENABLE_SIPGATE_TEAM, false)) { client = new XMLRPCClient(SIPGATE_TEAM_URL); } else { client = new XMLRPCClient(SIPGATE_URL); } client.setBasicAuthentication(p.getString(Preferences.PREFS_USER_SIPGATE, ""), p.getString(Preferences.PREFS_PASSWORD_SIPGATE, "")); Object back; try { Hashtable<String, String> ident = new Hashtable<String, String>(); ident.put("ClientName", TAG); ident.put("ClientVersion", version); ident.put("ClientVendor", vendor); back = client.call("samurai.ClientIdentify", ident); Log.d(TAG, back.toString()); return client; } catch (XMLRPCException e) { Log.e(TAG, "XMLRPCExceptin in init()", e); throw e; } }
From source file:com.zen.bodybuildingdiet.IntroScreen.java
private void loadPrefs() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); restarted = sp.getBoolean("RESTARTED", false); }
From source file:com.google.samples.apps.iosched.feedback.FeedbackHelper.java
/** * Whether a feedback notification has already been fired for a particular {@code sessionId}. * * @return true if feedback notification has been fired. *//*from w w w. j a va2s. co m*/ public boolean isFeedbackNotificationFiredForSession(String sessionId) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); final String key = createKeyForNotification(sessionId); return sp.getBoolean(key, false); }
From source file:at.florian_lentsch.expirysync.RegistrationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_registration); final SharedPreferences sharedPref = this.getApplicationContext().getSharedPreferences("main", Context.MODE_PRIVATE); Boolean serverChosen = sharedPref.getBoolean(SettingsActivity.KEY_SERVER_CHOSEN, false); if (!serverChosen) { AlternateServerChoiceDialog.showChoice(this); }//from ww w . j a v a2 s. c o m }
From source file:com.farmerbb.secondscreen.util.U.java
public static String generateBlurb(Activity a, String key, String value, boolean isNotification) { String blurb = " "; if (a instanceof TaskerQuickActionsActivity) { blurb = a.getResources().getStringArray(R.array.pref_notification_action_list)[1]; // If this blurb is being generated for the notification, and the value is "Toggle", // set value to the actual "On" or "Off" state if (isNotification && value.equals("Toggle")) { SharedPreferences prefCurrent = getPrefCurrent(a); switch (key) { case "temp_backlight_off": if (prefCurrent.getBoolean("backlight_off", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; break; case "temp_chrome": if (prefCurrent.getBoolean("chrome", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; case "temp_immersive": case "temp_immersive_new": if (key.equals("temp_immersive_new")) key = "temp_immersive"; switch (prefCurrent.getString("immersive_new", "fallback")) { case "immersive-mode": value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; break; default: value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; }/*from www . j av a 2 s . co m*/ break; case "temp_overscan": if (prefCurrent.getBoolean("overscan", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; case "temp_vibration_off": if (prefCurrent.getBoolean("vibration_off", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; break; case "temp_freeform": if (prefCurrent.getBoolean("freeform", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; case "temp_hdmi_rotation": switch (prefCurrent.getString("hdmi_rotation", "landscape")) { case "portrait": value = a.getResources().getStringArray(R.array.pref_hdmi_rotation_list)[1]; break; case "landscape": value = a.getResources().getStringArray(R.array.pref_hdmi_rotation_list)[0]; break; } break; } } // Modifications for non-English locales if (value.equals(a.getResources().getStringArray(R.array.pref_quick_actions_values)[0])) value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; else if (value.equals(a.getResources().getStringArray(R.array.pref_quick_actions_values)[1])) { if (key.equals("temp_overscan")) value = a.getResources().getStringArray(R.array.pref_quick_actions_overscan)[0]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; } } switch (key) { case "turn_off": blurb = a.getResources().getString(R.string.quick_turn_off); break; case "lock_device": blurb = a.getResources().getStringArray(R.array.pref_notification_action_list)[2]; break; case "temp_backlight_off": blurb = a.getResources().getString(R.string.quick_backlight) + " " + value; break; case "temp_chrome": blurb = a.getResources().getString(R.string.quick_chrome) + " " + value; break; case "temp_immersive": blurb = a.getResources().getString(R.string.quick_immersive) + " " + value; break; case "temp_immersive_new": switch (value) { case "do-nothing": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[0]; break; case "status-only": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[1]; break; case "immersive-mode": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[2]; break; case "Toggle": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[3]; break; } break; case "density": case "temp_density": switch (value) { case "reset": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[0]; break; case "120": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[1]; break; case "160": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[2]; break; case "213": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[3]; break; case "240": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[4]; break; case "320": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[6]; break; case "480": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[8]; break; case "640": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[10]; break; default: blurb = value + a.getResources().getString(R.string.dpi); break; } break; case "temp_overscan": blurb = a.getResources().getString(R.string.quick_overscan) + " " + value; break; case "size": case "temp_size": SharedPreferences prefMain = getPrefMain(a); if (value.equals("reset")) blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[0]; else if (prefMain.getBoolean("landscape", false)) { switch (value) { case "1920x1080": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[1]; break; case "1280x720": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[2]; break; case "854x480": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[3]; break; default: blurb = value; break; } } else { switch (value) { case "1080x1920": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[1]; break; case "720x1280": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[2]; break; case "480x854": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[3]; break; default: Scanner scanner = new Scanner(value); scanner.useDelimiter("x"); int height = scanner.nextInt(); int width = scanner.nextInt(); scanner.close(); blurb = Integer.toString(width) + "x" + Integer.toString(height); break; } } break; case "temp_rotation_lock_new": switch (value) { case "do-nothing": blurb = a.getResources().getStringArray(R.array.pref_rotation_list)[0]; break; case "auto-rotate": blurb = a.getResources().getStringArray(R.array.pref_rotation_list)[1]; break; case "landscape": blurb = a.getResources().getStringArray(R.array.pref_rotation_list)[2]; break; } break; case "temp_vibration_off": blurb = a.getResources().getString(R.string.quick_vibration) + " " + value; break; case "temp_freeform": blurb = a.getResources().getString(R.string.quick_freeform) + " " + value; break; case "temp_hdmi_rotation": blurb = a.getResources().getString(R.string.quick_hdmi_rotation) + " " + value; break; } return blurb; }