List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:com.fastbootmobile.twofactorauthdemo.MainActivity.java
protected void updateUI() { TextView txt = (TextView) findViewById(R.id.txt); Button regButton = (Button) findViewById(R.id.register); final SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(OwnPushClient.PREF_PUSH, Context.MODE_PRIVATE); if (prefs.getString("device_uid", null) != null) { txt.setText("Device ID : " + prefs.getString("device_uid", null)); }/* w w w . j a v a 2 s . c om*/ if (prefs.getBoolean(OwnPushClient.PREF_REG_DONE, false)) { regButton.setVisibility(View.GONE); } }
From source file:com.ppdl.microphone.MainActivity.java
public void bindParams(Intent intent) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (sp.getBoolean("tips_sound", true)) { intent.putExtra(Constant.EXTRA_SOUND_START, R.raw.bdspeech_recognition_start); intent.putExtra(Constant.EXTRA_SOUND_END, R.raw.bdspeech_speech_end); intent.putExtra(Constant.EXTRA_SOUND_SUCCESS, R.raw.bdspeech_recognition_success); intent.putExtra(Constant.EXTRA_SOUND_ERROR, R.raw.bdspeech_recognition_error); intent.putExtra(Constant.EXTRA_SOUND_CANCEL, R.raw.bdspeech_recognition_cancel); }/*from w w w . java 2 s . co m*/ if (sp.contains(Constant.EXTRA_INFILE)) { String tmp = sp.getString(Constant.EXTRA_INFILE, "").replaceAll(",.*", "").trim(); intent.putExtra(Constant.EXTRA_INFILE, tmp); } if (sp.getBoolean(Constant.EXTRA_OUTFILE, false)) { intent.putExtra(Constant.EXTRA_OUTFILE, "sdcard/outfile.pcm"); } if (sp.contains(Constant.EXTRA_SAMPLE)) { String tmp = sp.getString(Constant.EXTRA_SAMPLE, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_SAMPLE, Integer.parseInt(tmp)); } } if (sp.contains(Constant.EXTRA_LANGUAGE)) { String tmp = sp.getString(Constant.EXTRA_LANGUAGE, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_LANGUAGE, tmp); } } if (sp.contains(Constant.EXTRA_NLU)) { String tmp = sp.getString(Constant.EXTRA_NLU, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_NLU, tmp); } } if (sp.contains(Constant.EXTRA_VAD)) { String tmp = sp.getString(Constant.EXTRA_VAD, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { intent.putExtra(Constant.EXTRA_VAD, tmp); } } String prop = null; if (sp.contains(Constant.EXTRA_PROP)) { String tmp = sp.getString(Constant.EXTRA_PROP, "").replaceAll(",.*", "").trim(); if (null != tmp && !"".equals(tmp)) { Log.i(TAG, "=======$====" + tmp); intent.putExtra(Constant.EXTRA_PROP, Integer.parseInt(tmp)); prop = tmp; } } // offline asr { intent.putExtra("sample", 16000); // ? 16000 intent.putExtra("language", "cmn-Hans-CN"); // ?? intent.putExtra("prop", 20000); Log.i(TAG, "============= " + Environment.getExternalStorageDirectory().getPath()); intent.putExtra(Constant.EXTRA_OFFLINE_ASR_BASE_FILE_PATH, Environment.getExternalStorageDirectory().getPath() + "/s_1"); intent.putExtra(Constant.EXTRA_LICENSE_FILE_PATH, Environment.getExternalStorageDirectory().getPath() + "/temp_license_2016-04-18"); ///if (null != prop) { // int propInt = Integer.parseInt(prop); // if (propInt == 10060) { intent.putExtra(Constant.EXTRA_OFFLINE_LM_RES_FILE_PATH, Environment.getExternalStorageDirectory().getPath() + "/s_2_Navi"); //// } else if (propInt == 20000) { intent.putExtra(Constant.EXTRA_OFFLINE_LM_RES_FILE_PATH, Environment.getExternalStorageDirectory().getPath() + "/s_2_InputMethod"); // } //} intent.putExtra(Constant.EXTRA_OFFLINE_SLOT_DATA, buildTestSlotData()); } }
From source file:blackman.matt.boardlist.BoardListActivity.java
/** * When the activity is created this sets up the activity. * * @param savedInstanceState The saved state if this was created before. *//*from w ww. ja va2 s. c o m*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_board_list); mProgress = (LinearLayout) findViewById(R.id.progress_board_list); mBoardList = (ListView) findViewById(R.id.lv_board_list); initSpinners(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); Boolean ageAccept = preferences.getBoolean("age_guard_accept", false); if (ageAccept && list_db.isEmpty()) { new GetBoardList().execute(); } new Handler().post(new Runnable() { @Override public void run() { Cursor cursor = list_db.getSortedSearch(mCurFilter, DEFAULT_SELECTED_COLUMN, DEFAULT_SORT_ORDER); mAdapter = new BoardListCursorAdapter(BoardListActivity.this, cursor); mAdapter.setListener(BoardListActivity.this); mBoardList.setAdapter(mAdapter); } }); }
From source file:com.ichi2.anki.Reviewer.java
@Override protected SharedPreferences restorePreferences() { super.restorePreferences(); SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = Integer.parseInt(preferences.getString("fullscreenMode", "0")) > 0; return preferences; }
From source file:com.dngames.mobilewebcam.PhotoSettings.java
public static String DumpSettings(Context context, SharedPreferences prefs) { StringBuilder s = new StringBuilder(); Map<String, Object[]> all = new HashMap<String, Object[]>(); for (Field f : PhotoSettings.class.getFields()) { {/*from w ww. java 2 s.c om*/ BooleanPref bp = f.getAnnotation(BooleanPref.class); if (bp != null) { String key = bp.key(); boolean val = prefs.getBoolean(key, bp.val()); all.put(key, new Object[] { val, bp.help() }); if (bp.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getBoolean(key, bp.val()); all.put(key, new Object[] { val, bp.help() }); } } } { StringPref sp = f.getAnnotation(StringPref.class); if (sp != null) { String key = sp.key(); String val = prefs.getString(key, getDefaultString(context, sp)); all.put(key, new Object[] { val, sp.help() }); if (sp.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getString(key, getDefaultString(context, sp)); all.put(key, new Object[] { val, sp.help() }); } } } { EditIntPref ip = f.getAnnotation(EditIntPref.class); if (ip != null) { String key = ip.key(); String val = prefs.getString(key, "" + ip.val()); all.put(ip.key(), new Object[] { val, ip.help() }); if (ip.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getString(key, "" + ip.val()); all.put(key, new Object[] { val, ip.help() }); } } } { IntPref ip = f.getAnnotation(IntPref.class); if (ip != null) { String key = ip.key(); int val = prefs.getInt(key, ip.val()); all.put(ip.key(), new Object[] { val, ip.help() }); if (ip.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getInt(key, ip.val()); all.put(key, new Object[] { val, ip.help() }); } } } { EditFloatPref fp = f.getAnnotation(EditFloatPref.class); if (fp != null) { String key = fp.key(); String val = prefs.getString(key, "" + fp.val()); all.put(fp.key(), new Object[] { val, fp.help() }); if (fp.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getString(key, "" + fp.val()); all.put(key, new Object[] { val, fp.help() }); } } } } for (Map.Entry<String, ?> p : all.entrySet()) { Object[] vals = (Object[]) p.getValue(); if (((String) vals[1]).length() > 0) s.append("// " + vals[1] + "\n"); s.append(p.getKey() + ":" + vals[0] + "\n"); } return s.toString(); }
From source file:com.tassadar.multirommgr.installfragment.UbuntuManifest.java
public boolean downloadAndParse(Device dev) { ByteArrayOutputStream out = new ByteArrayOutputStream(8192); try {/*from w w w.j a v a2 s . c o m*/ final String url = dev.getUbuntuBaseUrl() + CHANNELS_PATH; if (!Utils.downloadFile(url, out, null, true) || out.size() == 0) return false; } catch (IOException e) { e.printStackTrace(); return false; } finally { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } try { Object rawObject = new JSONTokener(out.toString()).nextValue(); if (!(rawObject instanceof JSONObject)) { Log.e(TAG, "Malformed manifest format!"); return false; } JSONObject o = (JSONObject) rawObject; SharedPreferences pref = MgrApp.getPreferences(); Iterator itr = o.keys(); while (itr.hasNext()) { String name = (String) itr.next(); JSONObject c = o.getJSONObject(name); // Skip hidden channels if (c.optBoolean("hidden", false) && !pref.getBoolean(SettingsFragment.UTOUCH_SHOW_HIDDEN, false)) { continue; } addChannel(name, c); } } catch (JSONException e) { e.printStackTrace(); return false; } // Remove channels without the device we're currently running on and load images Iterator<Map.Entry<String, TreeMap<String, UbuntuChannel>>> f_itr = m_flavours.entrySet().iterator(); while (f_itr.hasNext()) { Map<String, UbuntuChannel> channelMap = f_itr.next().getValue(); Iterator<Map.Entry<String, UbuntuChannel>> c_itr = channelMap.entrySet().iterator(); while (c_itr.hasNext()) { UbuntuChannel c = c_itr.next().getValue(); // Devices like deb or tilapia won't be in // Ubuntu Touch manifests, yet the versions // for flo/grouper work fine - select those. String dev_name = dev.getName(); if (!c.hasDevice(dev_name)) { dev_name = dev.getBaseVariantName(); if (!c.hasDevice(dev_name)) { c_itr.remove(); continue; } } try { if (!c.loadDeviceImages(dev_name, dev)) return false; } catch (Exception e) { e.printStackTrace(); return false; } // Remove channels with no images for our device if (!c.hasImages()) { c_itr.remove(); continue; } Log.d(TAG, "Got channel: " + c.getDisplayName()); } if (channelMap.isEmpty()) f_itr.remove(); } return true; }
From source file:com.trellmor.berrymotes.sync.SubredditEmoteDownloader.java
public SubredditEmoteDownloader(Context context, EmoteDownloader emoteDownloader, String subreddit) { mContext = context;//from w ww . j av a 2 s. c o m mEmoteDownloader = emoteDownloader; mSubreddit = subreddit; SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); mDownloadNSFW = settings.getBoolean(SettingsActivity.KEY_SYNC_NSFW, false); mLastModified = new Date(settings.getLong(SettingsActivity.KEY_SYNC_LAST_MODIFIED + mSubreddit, 0)); mBaseDir = mContext.getExternalFilesDir(null); mContentResolver = mContext.getContentResolver(); mSyncResult = new SyncResult(); }
From source file:com.google.wolff.androidhunt.Hunt.java
/** Loads player progress. */ public void restore(Resources res, Context context) { SharedPreferences sharedPref = context.getSharedPreferences(res.getString(R.string.preference_file_key), Context.MODE_PRIVATE); for (String tag : tags.keySet()) { Boolean val = sharedPref.getBoolean(tag, false); tagsFound.put(tag, val); }//from w w w. j a va2s. c om hasSeenIntro = sharedPref.getBoolean(HAS_SEEN_INTRO_KEY, false); }
From source file:com.orange.labs.sdk.session.AuthSession.java
/** * Start authentication. If needed, launch {@code AuthActivity} * allowing an user authentication else wait to check authentication with refresh token * {@link #checkAuthentication(com.orange.labs.sdk.OrangeListener.Success, * com.orange.labs.sdk.OrangeListener.Error)} *//*from www.jav a2 s . c o m*/ public void startAuthentication() { String refreshToken = getRefreshToken(); // If refresh token exists, connect directly else // show web authent inside AuthActivity if (refreshToken == null || refreshToken.length() == 0) { // Start Orange auth activity. Intent intent = new Intent(context, AuthActivity.class); // Check if Oauth has to force user to enter login & password SharedPreferences sharedPref = context.getApplicationContext() .getSharedPreferences(SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE); boolean forceLogin = sharedPref.getBoolean(SHARED_PREFERENCES_FORCE_LOGIN, false); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_FORCE_LOGIN, forceLogin); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_KEY, getAppkey()); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_SCOPE, getScope()); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_REDIRECT_URI, getRedirectUri()); if (!(context instanceof Activity)) { // If starting the intent outside of an Activity, must include // this. See startActivity(). Otherwise, we prefer to stay in // the same task. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } context.startActivity(intent); } }
From source file:com.pseudosudostudios.jdd.activities.GameActivity.java
/** * Creates the view, loads from a rotation and from a relaunch *//* w w w. j a v a 2 s .c om*/ @Override protected void onCreate(Bundle savedInstanceState) { // Remove the ActionBar, same logic as the drama app super.onCreate(savedInstanceState); bg = new Grid(this); setContentView(bg); // if there was a savedInstanceGame, then load that one final SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); boolean hasScreen = prefs.getBoolean(instructionString, false); if (!hasScreen && savedInstanceState == null) { showInstructions(); onCreateStuff(savedInstanceState); } else if (savedInstanceState != null && savedInstanceState.containsKey(onSaveBaseString + 0 + 0)) onCreateStuff(savedInstanceState); else loadGamePrompt(savedInstanceState); scoreNoTime = 0; scorePrev = 0; }