android.support.v7.preference.PreferenceManager Java Examples
The following examples show how to use
android.support.v7.preference.PreferenceManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EarthquakeListFragment.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Retrieve the Earthquake View Model for the parent Activity. earthquakeViewModel = ViewModelProviders.of(getActivity()) .get(EarthquakeViewModel.class); // Get the data from the View Model, and observe any changes. earthquakeViewModel.getEarthquakes() .observe(this, new Observer<List<Earthquake>>() { @Override public void onChanged(@Nullable List<Earthquake> earthquakes) { // When the View Model changes, update the List if (earthquakes != null) setEarthquakes(earthquakes); } }); // Register an OnSharedPreferenceChangeListener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(mPrefListener); }
Example #2
Source File: BookPageFragment.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); bookId = args.getInt(BooksInformationDBContract.BooksAuthors.COLUMN_NAME_BOOK_ID, 0); pageId = args.getInt(BookDatabaseContract.TitlesEntry.COLUMN_NAME_PAGE_ID, 0); mPagerPosition = args.getInt(KEY_PAGER_POSITION, 0); userDataDBHelper = UserDataDBHelper.getInstance(getContext(), bookId); try { BookDatabaseHelper bookDatabaseHelperInstance = BookDatabaseHelper.getInstance(getContext(), bookId); mSharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); page_content = bookDatabaseHelperInstance.getPageContentByPageId(pageId); mPageCitation = bookDatabaseHelperInstance.getCitationInformation(pageId); mPageCitation.setResources(getResources()); pageInfo = mPageCitation.pageInfo; bookInfo = bookDatabaseHelperInstance.getBookInfo(); setHasOptionsMenu(false); } catch (BookDatabaseException bookDatabaseException) { Timber.e(bookDatabaseException); } }
Example #3
Source File: PreferencesTest.java From fdroidclient with GNU General Public License v3.0 | 6 votes |
/** * Manually read the {@code preferences.xml} defaults to a separate * instance. Clear the preference state before each test so that each * test starts as if it was a first time install. */ @Before public void setup() { ShadowLog.stream = System.out; String sharedPreferencesName = CONTEXT.getPackageName() + "_preferences_defaults"; PreferenceManager pm = new PreferenceManager(CONTEXT); pm.setSharedPreferencesName(sharedPreferencesName); pm.setSharedPreferencesMode(Context.MODE_PRIVATE); pm.inflateFromResource(CONTEXT, R.xml.preferences, null); defaults = pm.getSharedPreferences(); assertTrue(defaults.getAll().size() > 0); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(CONTEXT); Log.d(TAG, "Clearing DefaultSharedPreferences containing: " + sharedPreferences.getAll().size()); sharedPreferences.edit().clear().commit(); assertEquals(0, sharedPreferences.getAll().size()); SharedPreferences defaultValueSp = CONTEXT.getSharedPreferences(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, Context.MODE_PRIVATE); defaultValueSp.edit().remove(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES).commit(); }
Example #4
Source File: FragmentSettings.java From fingen with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_CODE_ENABLE: Toast.makeText(getActivity(), getString(R.string.toast_pin_enabled), Toast.LENGTH_SHORT).show(); break; case REQUEST_CODE_DISABLE: Toast.makeText(getActivity(), getString(R.string.toast_pin_disabled), Toast.LENGTH_SHORT).show(); break; case REQUEST_CODE_SELECT_MODEL: if (resultCode == RESULT_OK && data != null) { IAbstractModel model = data.getParcelableExtra("model"); PreferenceManager.getDefaultSharedPreferences(getContext()).edit().putString(FgConst.PREF_DEFAULT_DEPARTMENT, String.valueOf(model.getID())).apply(); } break; } }
Example #5
Source File: FragmentSettings.java From fingen with Apache License 2.0 | 6 votes |
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference. * * @see #sBindPreferenceSummaryToValueListener */ private void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. if (preference instanceof MultiSelectListPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, convertValuesToSummary((MultiSelectListPreference) preference)); } else { sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); } }
Example #6
Source File: FragmentTimeBarChart.java From fingen with Apache License 2.0 | 6 votes |
private Pair<Date, Date> getPairDates(Date date) { int dateRange = PreferenceManager.getDefaultSharedPreferences(Objects.requireNonNull(getActivity())).getInt("report_date_range", 0); Calendar c = Calendar.getInstance(); c.setTime(date); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); switch (dateRange) { case ReportBuilder.DATE_RANGE_Day: break; case ReportBuilder.DATE_RANGE_Month: c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH)); break; case ReportBuilder.DATE_RANGE_YEAR: c.set(Calendar.MONTH, c.getActualMaximum(Calendar.MONTH)); c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH)); break; } return new Pair<>(date, c.getTime()); }
Example #7
Source File: SettingsActivity.java From ActivityDiary with GNU General Public License v3.0 | 6 votes |
private void updateLocationDist() { String def = getResources().getString(R.string.pref_location_dist_default); String value = PreferenceManager .getDefaultSharedPreferences(ActivityDiaryApplication.getAppContext()) .getString(KEY_PREF_LOCATION_DIST, def); int v = Integer.parseInt(value.replaceAll("\\D","")); if(v < 5){ v = 5; } String nvalue = Integer.toString(v); if(!value.equals(nvalue)){ SharedPreferences.Editor editor = PreferenceManager .getDefaultSharedPreferences(ActivityDiaryApplication.getAppContext()).edit(); editor.putString(KEY_PREF_LOCATION_DIST, nvalue); editor.apply(); value = PreferenceManager .getDefaultSharedPreferences(ActivityDiaryApplication.getAppContext()) .getString(KEY_PREF_LOCATION_DIST, def); } locationDistPref.setSummary(getResources().getString(R.string.pref_location_dist, value)); }
Example #8
Source File: WalletTabFragment.java From android-wallet-app with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onEvent(GetAccountDataResponse gad) { if (transfers == null) { transfers = new ArrayList<>(); } transfers = gad.getTransfers(); isConnected = true; updateFab(); walletBalanceIota = 0; walletBalanceIota = walletBalanceIota + gad.getBalance(); String balanceText = IotaUnitConverter.convertRawIotaAmountToDisplayText(walletBalanceIota, false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); prefs.edit().putLong(Constants.PREFERENCES_CURRENT_IOTA_BALANCE, walletBalanceIota).apply(); if (!TextUtils.isEmpty(balanceText)) { balanceTextView.setText(balanceText); } else { balanceTextView.setText(R.string.account_balance_default); } updateAlternateBalance(); }
Example #9
Source File: GPSActivity.java From GPSLogger with GNU General Public License v3.0 | 6 votes |
@Override public void onRestart(){ Log.w("myApp", "[#] " + this + " - onRestart()"); if (Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("prefColorTheme", "2")) != theme) { Log.w("myApp", "[#] GPSActivity.java - it needs to be recreated (Theme changed)"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Normal behaviour for Android 5 + this.recreate(); } else { // Workaround to a bug on Android 4.4.X platform (google won't fix because Android 4.4 is obsolete) // Android 4.4.X: taskAffinity & launchmode='singleTask' violating Activity's lifecycle // https://issuetracker.google.com/issues/36998700 finish(); startActivity(new Intent(this, getClass())); } overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } super.onRestart(); }
Example #10
Source File: EarthquakeListFragment.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Retrieve the Earthquake View Model for the parent Activity. earthquakeViewModel = ViewModelProviders.of(getActivity()) .get(EarthquakeViewModel.class); // Get the data from the View Model, and observe any changes. earthquakeViewModel.getEarthquakes() .observe(this, new Observer<List<Earthquake>>() { @Override public void onChanged(@Nullable List<Earthquake> earthquakes) { // When the View Model changes, update the List if (earthquakes != null) setEarthquakes(earthquakes); } }); // Register an OnSharedPreferenceChangeListener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(mPrefListener); }
Example #11
Source File: TangleExplorerTransactionsFragment.java From android-wallet-app with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { if (transactions == null) { transactions = new ArrayList<>(); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); String jsonPreferences = prefs.getString(TRANSACTIONS_LIST, ""); Type type = new TypeToken<List<Transaction>>() { }.getType(); transactions = new Gson().fromJson(jsonPreferences, type); prefs.edit().remove(TRANSACTIONS_LIST).apply(); if (savedSearchText != null) savedSearchText = savedInstanceState.getString(SEARCH_TEXT); if (savedSearchText != null && !savedSearchText.isEmpty()) if (searchView != null) searchView.setQuery(savedInstanceState.getString(SEARCH_TEXT), false); } setAdapter(); }
Example #12
Source File: SettingsActivity.java From ActivityDiary with GNU General Public License v3.0 | 6 votes |
private void updateDurationFormat() { String value = PreferenceManager .getDefaultSharedPreferences(ActivityDiaryApplication.getAppContext()) .getString(KEY_PREF_DURATION_FORMAT, "dynamic"); if(value.equals("dynamic")){ durationFormatPref.setSummary(getResources().getString(R.string.setting_duration_format_summary_dynamic)); }else if(value.equals("nodays")){ durationFormatPref.setSummary(getResources().getString(R.string.setting_duration_format_summary_nodays)); }else if(value.equals("precise")){ durationFormatPref.setSummary(getResources().getString(R.string.setting_duration_format_summary_precise)); }else if(value.equals("hour_min")){ durationFormatPref.setSummary(getResources().getString(R.string.setting_duration_format_summary_hour_min)); } }
Example #13
Source File: SettingsFragment.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 6 votes |
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference. * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(@NonNull Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. final String key = preference.getKey(); if (preference instanceof MultiSelectListPreference) { Set<String> summary = SharedPreferencesCompat.getStringSet( PreferenceManager.getDefaultSharedPreferences(preference.getContext()), key, new HashSet<>()); sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, summary); } else if (preference instanceof ColorPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, ((ColorPreference) preference).getColor()); } else if (preference instanceof SeekBarPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, ((SeekBarPreference) preference).getValue()); } else { String value = PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(key, ""); sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, value); } }
Example #14
Source File: PreferencesManager.java From RememBirthday with GNU General Public License v3.0 | 6 votes |
/** * Get default days in preferences * @param context Context to call * @return Array of days */ public static int[] getDefaultDays(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String prefNotificationsDay = prefs.getString(context.getString(R.string.pref_reminders_days_key), context.getString(R.string.pref_reminders_days_default)); Pattern p = Pattern.compile(PATTERN_REMINDER_PREF); int[] days; Matcher m = p.matcher(prefNotificationsDay); if(m.matches()) { String[] splitString = prefNotificationsDay.split("#"); days = new int[splitString.length]; for(int i=0; i<splitString.length; i++) { days[i] = Integer.parseInt(splitString[i]); } return days; } // 0 if preference can't match days = new int[1]; days[0] = 0; return days; }
Example #15
Source File: MainActivity.java From mua with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); // get default shared preferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); // Setting language by shared preferences settingLanguage(); // open file list fragment getSupportFragmentManager().beginTransaction().replace( R.id.fragment_container, new FileListFragment()).commit(); }
Example #16
Source File: VisualizerActivity.java From android-dev-challenge with Apache License 2.0 | 6 votes |
private void setupSharedPreferences() { // Get all of the values from shared preferences to set it up SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mVisualizerView.setShowBass(sharedPreferences.getBoolean(getString(R.string.pref_show_bass_key), getResources().getBoolean(R.bool.pref_show_bass_default))); mVisualizerView.setShowMid(sharedPreferences.getBoolean(getString(R.string.pref_show_mid_range_key), getResources().getBoolean(R.bool.pref_show_mid_range_default))); mVisualizerView.setShowTreble(sharedPreferences.getBoolean(getString(R.string.pref_show_treble_key), getResources().getBoolean(R.bool.pref_show_treble_default))); mVisualizerView.setMinSizeScale(Float.parseFloat( sharedPreferences.getString(getString(R.string.pref_size_key), getString(R.string.pref_size_default)))); loadColorFromPreferences(sharedPreferences); // Register the listener sharedPreferences.registerOnSharedPreferenceChangeListener(this); }
Example #17
Source File: SplashActivity.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent(); if (intent.getBooleanExtra(SettingsActivity.KEY_KILL_APP, false)) { finish(); System.exit(0); } PreferenceManager.setDefaultValues(this, R.xml.pref_general, false); ((IslamicLibraryApplication) getApplication()).refreshLocale(this, false); super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); mProgressBar = findViewById(R.id.progressBar1); mTextView = findViewById(R.id.progressTextView); mProgressValue = findViewById(R.id.progressValueTextView); checkStorage(); }
Example #18
Source File: EarthquakeListFragment.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Retrieve the Earthquake View Model for the parent Activity. earthquakeViewModel = ViewModelProviders.of(getActivity()) .get(EarthquakeViewModel.class); // Get the data from the View Model, and observe any changes. earthquakeViewModel.getEarthquakes() .observe(this, new Observer<List<Earthquake>>() { @Override public void onChanged(@Nullable List<Earthquake> earthquakes) { // When the View Model changes, update the List if (earthquakes != null) setEarthquakes(earthquakes); } }); // Register an OnSharedPreferenceChangeListener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(mPrefListener); }
Example #19
Source File: EarthquakeListFragment.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Retrieve the Earthquake View Model for the parent Activity. earthquakeViewModel = ViewModelProviders.of(getActivity()) .get(EarthquakeViewModel.class); // Get the data from the View Model, and observe any changes. earthquakeViewModel.getEarthquakes() .observe(this, new Observer<List<Earthquake>>() { @Override public void onChanged(@Nullable List<Earthquake> earthquakes) { // When the View Model changes, update the List if (earthquakes != null) setEarthquakes(earthquakes); } }); // Register an OnSharedPreferenceChangeListener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(mPrefListener); }
Example #20
Source File: EarthquakeUpdateJobService.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
private void scheduleNextUpdate(Context context, JobParameters job) { if (job.getTag().equals(UPDATE_JOB_TAG)) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int updateFreq = Integer.parseInt( prefs.getString(PreferencesActivity.PREF_UPDATE_FREQ, "60")); boolean autoUpdateChecked = prefs.getBoolean(PreferencesActivity.PREF_AUTO_UPDATE, false); if (autoUpdateChecked) { FirebaseJobDispatcher jobDispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context)); jobDispatcher.schedule(jobDispatcher.newJobBuilder() .setTag(PERIODIC_JOB_TAG) .setService(EarthquakeUpdateJobService.class) .setConstraints(Constraint.ON_ANY_NETWORK) .setReplaceCurrent(true) .setRecurring(true) .setTrigger(Trigger.executionWindow( updateFreq*60 / 2, updateFreq*60)) .setLifetime(Lifetime.FOREVER) .build()); } } }
Example #21
Source File: EarthquakeMapFragment.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Register an OnSharedPreferenceChangeListener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(mPListener); }
Example #22
Source File: EarthquakeMapFragment.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Register an OnSharedPreferenceChangeListener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(mPListener); }
Example #23
Source File: VisualizerActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
private void setupSharedPreferences() { // Get all of the values from shared preferences to set it up SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mVisualizerView.setShowBass(sharedPreferences.getBoolean(getString(R.string.pref_show_bass_key), getResources().getBoolean(R.bool.pref_show_bass_default))); mVisualizerView.setShowMid(true); mVisualizerView.setShowTreble(true); mVisualizerView.setMinSizeScale(1); mVisualizerView.setColor(getString(R.string.pref_color_red_value)); // COMPLETED (3) Register the listener sharedPreferences.registerOnSharedPreferenceChangeListener(this); }
Example #24
Source File: VisualizerActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
@Override protected void onDestroy() { super.onDestroy(); // Unregister VisualizerActivity as an OnPreferenceChangedListener to avoid any memory leaks. PreferenceManager.getDefaultSharedPreferences(this) .unregisterOnSharedPreferenceChangeListener(this); }
Example #25
Source File: ReadingActivity.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
@Override public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean navigate = defaultSharedPreferences. getBoolean(SettingsFragment.PREF_USE_VOLUME_KEY_NAV, false); boolean b = false; if (navigate && keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { mTurnPageByVolumeDownKey = true; b = true; } else if (navigate && keyCode == KeyEvent.KEYCODE_VOLUME_UP) { mTurnPageByVolumeUpKey = true; b = true; } return b || super.onKeyUp(keyCode, event); }
Example #26
Source File: VisualizerActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
private void setupSharedPreferences() { // Get all of the values from shared preferences to set it up SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mVisualizerView.setShowBass(sharedPreferences.getBoolean(getString(R.string.pref_show_bass_key), getResources().getBoolean(R.bool.pref_show_bass_default))); mVisualizerView.setShowMid(sharedPreferences.getBoolean(getString(R.string.pref_show_mid_range_key), getResources().getBoolean(R.bool.pref_show_mid_range_default))); mVisualizerView.setShowTreble(sharedPreferences.getBoolean(getString(R.string.pref_show_treble_key), getResources().getBoolean(R.bool.pref_show_treble_default))); mVisualizerView.setMinSizeScale(1); mVisualizerView.setColor(sharedPreferences.getString(getString(R.string.pref_color_key), getString(R.string.pref_color_red_value))); // Register the listener sharedPreferences.registerOnSharedPreferenceChangeListener(this); }
Example #27
Source File: ReadingActivity.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
@Override public void setThemeNightMode(boolean isDesiredThemeLight) { SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); DisplayPreferenceUtilities.setDisplayPreference(SettingsFragment.KEY_IS_THEME_NIGHT_MODE, isDesiredThemeLight, defaultSharedPreferences, mUserDataDBHelper); restartOnThemeChange(); }
Example #28
Source File: VisualizerActivity.java From android-dev-challenge with Apache License 2.0 | 5 votes |
private void setupSharedPreferences() { // Get all of the values from shared preferences to set it up SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mVisualizerView.setShowBass(sharedPreferences.getBoolean(getString(R.string.pref_show_bass_key), getResources().getBoolean(R.bool.pref_show_bass_default))); mVisualizerView.setShowMid(sharedPreferences.getBoolean(getString(R.string.pref_show_mid_range_key), getResources().getBoolean(R.bool.pref_show_mid_range_default))); mVisualizerView.setShowTreble(sharedPreferences.getBoolean(getString(R.string.pref_show_treble_key), getResources().getBoolean(R.bool.pref_show_treble_default))); mVisualizerView.setMinSizeScale(1); loadColorFromPreferences(sharedPreferences); // Register the listener sharedPreferences.registerOnSharedPreferenceChangeListener(this); }
Example #29
Source File: SettingsActivity.java From ActivityDiary with GNU General Public License v3.0 | 5 votes |
private void updateTagImageSummary() { if(PreferenceManager .getDefaultSharedPreferences(ActivityDiaryApplication.getAppContext()) .getBoolean(KEY_PREF_TAG_IMAGES, true)){ tagImagesPref.setSummary(getResources().getString(R.string.setting_tag_yes)); }else{ tagImagesPref.setSummary(getResources().getString(R.string.setting_tag_no)); } }
Example #30
Source File: FragmentSettings.java From GPSLogger with GNU General Public License v3.0 | 5 votes |
public void PrefEGM96SetToFalse() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor1 = settings.edit(); editor1.putBoolean("prefEGM96AltitudeCorrection", false); editor1.commit(); SwitchPreferenceCompat EGM96 = (SwitchPreferenceCompat) super.findPreference("prefEGM96AltitudeCorrection"); EGM96.setChecked(false); }