| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.preferences; | 5 package org.chromium.chrome.browser.preferences; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
| 9 import android.preference.PreferenceManager; | 9 import android.preference.PreferenceManager; |
| 10 | 10 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 * @param prefValue The type to restrict the filter to. | 159 * @param prefValue The type to restrict the filter to. |
| 160 */ | 160 */ |
| 161 public void setWebsiteSettingsFilterPreference(String prefValue) { | 161 public void setWebsiteSettingsFilterPreference(String prefValue) { |
| 162 SharedPreferences.Editor sharedPreferencesEditor = mSharedPreferences.ed
it(); | 162 SharedPreferences.Editor sharedPreferencesEditor = mSharedPreferences.ed
it(); |
| 163 sharedPreferencesEditor.putString( | 163 sharedPreferencesEditor.putString( |
| 164 ChromePreferenceManager.PREF_WEBSITE_SETTINGS_FILTER, prefValue)
; | 164 ChromePreferenceManager.PREF_WEBSITE_SETTINGS_FILTER, prefValue)
; |
| 165 sharedPreferencesEditor.apply(); | 165 sharedPreferencesEditor.apply(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Set shared preference to allow low end device ui. | 169 * This value may have been explicitly set to false when we used to keep exi
sting low-end |
| 170 * devices on the normal UI rather than the simplified UI. We want to keep t
he existing device |
| 171 * settings. For all new low-end devices they should get the simplified UI b
y default. |
| 172 * @return Whether low end device UI was allowed. |
| 170 */ | 173 */ |
| 171 public void setAllowLowEndDeviceUi() { | 174 public boolean getAllowLowEndDeviceUi() { |
| 172 SharedPreferences.Editor sharedPreferencesEditor = mSharedPreferences.ed
it(); | 175 return mSharedPreferences.getBoolean(ALLOW_LOW_END_DEVICE_UI, true); |
| 173 sharedPreferencesEditor.putBoolean(ALLOW_LOW_END_DEVICE_UI, true); | |
| 174 sharedPreferencesEditor.apply(); | |
| 175 } | 176 } |
| 176 | 177 |
| 177 /** | 178 /** |
| 178 * @return Whether low end device ui is allowed. | |
| 179 */ | |
| 180 public boolean getAllowLowEndDeviceUi() { | |
| 181 return mSharedPreferences.getBoolean(ALLOW_LOW_END_DEVICE_UI, false); | |
| 182 } | |
| 183 | |
| 184 /** | |
| 185 * Signin promo could be shown at most once every 12 weeks. This method chec
ks | 179 * Signin promo could be shown at most once every 12 weeks. This method chec
ks |
| 186 * wheter the signin promo has already been shown in the current cycle. | 180 * wheter the signin promo has already been shown in the current cycle. |
| 187 * @return Whether the signin promo has been shown in the current cycle. | 181 * @return Whether the signin promo has been shown in the current cycle. |
| 188 */ | 182 */ |
| 189 public boolean getSigninPromoShown() { | 183 public boolean getSigninPromoShown() { |
| 190 long signinPromoLastShown = mSharedPreferences.getLong(SIGNIN_PROMO_LAST
_SHOWN, 0); | 184 long signinPromoLastShown = mSharedPreferences.getLong(SIGNIN_PROMO_LAST
_SHOWN, 0); |
| 191 long numDaysElapsed = | 185 long numDaysElapsed = |
| 192 (System.currentTimeMillis() - signinPromoLastShown) / MILLISECON
DS_IN_DAY; | 186 (System.currentTimeMillis() - signinPromoLastShown) / MILLISECON
DS_IN_DAY; |
| 193 return numDaysElapsed < SIGNIN_PROMO_CYCLE_IN_DAYS; | 187 return numDaysElapsed < SIGNIN_PROMO_CYCLE_IN_DAYS; |
| 194 } | 188 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 * | 267 * |
| 274 * @param key The name of the preference to modify. | 268 * @param key The name of the preference to modify. |
| 275 * @param value The new value for the preference. | 269 * @param value The new value for the preference. |
| 276 */ | 270 */ |
| 277 private void writeInt(String key, int value) { | 271 private void writeInt(String key, int value) { |
| 278 SharedPreferences.Editor ed = mSharedPreferences.edit(); | 272 SharedPreferences.Editor ed = mSharedPreferences.edit(); |
| 279 ed.putInt(key, value); | 273 ed.putInt(key, value); |
| 280 ed.apply(); | 274 ed.apply(); |
| 281 } | 275 } |
| 282 } | 276 } |
| OLD | NEW |