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 15 matching lines...) Expand all Loading... | |
26 private static final String PROMOS_SKIPPED_ON_FIRST_START = "promos_skipped_ on_first_start"; | 26 private static final String PROMOS_SKIPPED_ON_FIRST_START = "promos_skipped_ on_first_start"; |
27 private static final String SIGNIN_PROMO_LAST_SHOWN = "signin_promo_last_tim estamp_key"; | 27 private static final String SIGNIN_PROMO_LAST_SHOWN = "signin_promo_last_tim estamp_key"; |
28 private static final String SHOW_SIGNIN_PROMO = "show_signin_promo"; | 28 private static final String SHOW_SIGNIN_PROMO = "show_signin_promo"; |
29 private static final String ALLOW_LOW_END_DEVICE_UI = "allow_low_end_device_ ui"; | 29 private static final String ALLOW_LOW_END_DEVICE_UI = "allow_low_end_device_ ui"; |
30 private static final String PREF_WEBSITE_SETTINGS_FILTER = "website_settings _filter"; | 30 private static final String PREF_WEBSITE_SETTINGS_FILTER = "website_settings _filter"; |
31 private static final String CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT = | 31 private static final String CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT = |
32 "contextual_search_promo_open_count"; | 32 "contextual_search_promo_open_count"; |
33 private static final String CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT = | 33 private static final String CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_COUNT = |
34 "contextual_search_tap_triggered_promo_count"; | 34 "contextual_search_tap_triggered_promo_count"; |
35 private static final String CONTEXTUAL_SEARCH_TAP_COUNT = "contextual_search _tap_count"; | 35 private static final String CONTEXTUAL_SEARCH_TAP_COUNT = "contextual_search _tap_count"; |
36 private static final String CONTEXTUAL_SEARCH_LAST_ANIMATION_ON_TAP_TIME = | |
newt (away)
2015/09/25 01:21:27
I'd rename these to be consistent with the method
Theresa
2015/09/25 01:52:08
Done.
| |
37 "contextual_search_last_animation_on_tap_time"; | |
36 private static final String ENABLE_CUSTOM_TABS = "enable_custom_tabs"; | 38 private static final String ENABLE_CUSTOM_TABS = "enable_custom_tabs"; |
37 | 39 |
38 private static final int SIGNIN_PROMO_CYCLE_IN_DAYS = 120; | 40 private static final int SIGNIN_PROMO_CYCLE_IN_DAYS = 120; |
39 private static final long MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24; | 41 private static final long MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24; |
40 | 42 |
41 private static ChromePreferenceManager sPrefs; | 43 private static ChromePreferenceManager sPrefs; |
42 | 44 |
43 private final SharedPreferences mSharedPreferences; | 45 private final SharedPreferences mSharedPreferences; |
44 private final Context mContext; | 46 private final Context mContext; |
45 | 47 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 | 229 |
228 /** | 230 /** |
229 * Sets the number of times the panel was opened with the promo visible. | 231 * Sets the number of times the panel was opened with the promo visible. |
230 * @param count Number of times the panel was opened with a promo visible. | 232 * @param count Number of times the panel was opened with a promo visible. |
231 */ | 233 */ |
232 public void setContextualSearchPromoOpenCount(int count) { | 234 public void setContextualSearchPromoOpenCount(int count) { |
233 writeInt(CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT, count); | 235 writeInt(CONTEXTUAL_SEARCH_PROMO_OPEN_COUNT, count); |
234 } | 236 } |
235 | 237 |
236 /** | 238 /** |
239 * @return The last time the search provider icon was animated on tap. | |
240 */ | |
241 public long getContextualSearchLastAnimationTime() { | |
242 return mSharedPreferences.getLong(CONTEXTUAL_SEARCH_LAST_ANIMATION_ON_TA P_TIME, 0); | |
243 } | |
244 | |
245 /** | |
246 * Sets the last time the search provider icon was animated on tap. | |
247 * @param time The last time the search provider icon was animated on tap. | |
248 */ | |
249 public void setContextualSearchLastAnimationTime(long time) { | |
250 SharedPreferences.Editor ed = mSharedPreferences.edit(); | |
251 ed.putLong(CONTEXTUAL_SEARCH_LAST_ANIMATION_ON_TAP_TIME, time); | |
252 ed.apply(); | |
253 } | |
254 | |
255 /** | |
237 * @return Number of times the promo was triggered to peek by a tap gesture, or a negative value | 256 * @return Number of times the promo was triggered to peek by a tap gesture, or a negative value |
238 * if in the disabled state. | 257 * if in the disabled state. |
239 */ | 258 */ |
240 public int getContextualSearchTapTriggeredPromoCount() { | 259 public int getContextualSearchTapTriggeredPromoCount() { |
241 return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_C OUNT, 0); | 260 return mSharedPreferences.getInt(CONTEXTUAL_SEARCH_TAP_TRIGGERED_PROMO_C OUNT, 0); |
242 } | 261 } |
243 | 262 |
244 /** | 263 /** |
245 * Sets the number of times the promo was triggered to peek by a tap gesture . | 264 * Sets the number of times the promo was triggered to peek by a tap gesture . |
246 * Use a negative value to record that the counter has been disabled. | 265 * Use a negative value to record that the counter has been disabled. |
(...skipping 24 matching lines...) Expand all Loading... | |
271 * | 290 * |
272 * @param key The name of the preference to modify. | 291 * @param key The name of the preference to modify. |
273 * @param value The new value for the preference. | 292 * @param value The new value for the preference. |
274 */ | 293 */ |
275 private void writeInt(String key, int value) { | 294 private void writeInt(String key, int value) { |
276 SharedPreferences.Editor ed = mSharedPreferences.edit(); | 295 SharedPreferences.Editor ed = mSharedPreferences.edit(); |
277 ed.putInt(key, value); | 296 ed.putInt(key, value); |
278 ed.apply(); | 297 ed.apply(); |
279 } | 298 } |
280 } | 299 } |
OLD | NEW |