-
Notifications
You must be signed in to change notification settings - Fork 215
/
SettingsStore.java
711 lines (584 loc) · 26.9 KB
/
SettingsStore.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
package org.mozilla.vrbrowser.browser;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModelProvider;
import org.json.JSONArray;
import org.json.JSONObject;
import org.mozilla.geckoview.ContentBlocking;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.telemetry.TelemetryHolder;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.VRBrowserActivity;
import org.mozilla.vrbrowser.VRBrowserApplication;
import org.mozilla.vrbrowser.telemetry.GleanMetricsService;
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
import org.mozilla.vrbrowser.ui.viewmodel.SettingsViewModel;
import org.mozilla.vrbrowser.utils.DeviceType;
import org.mozilla.vrbrowser.utils.StringUtils;
import org.mozilla.vrbrowser.utils.SystemUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import static org.mozilla.vrbrowser.utils.ServoUtils.isServoAvailable;
public class SettingsStore {
private static final String LOGTAG = SystemUtils.createLogtag(SettingsStore.class);
private static SettingsStore mSettingsInstance;
public static synchronized @NonNull
SettingsStore getInstance(final @NonNull Context aContext) {
if (mSettingsInstance == null) {
mSettingsInstance = new SettingsStore(aContext);
}
return mSettingsInstance;
}
private Context mContext;
private SharedPreferences mPrefs;
private SettingsViewModel mSettingsViewModel;
// Developer options default values
public final static boolean REMOTE_DEBUGGING_DEFAULT = false;
public final static boolean CONSOLE_LOGS_DEFAULT = false;
public final static boolean ENV_OVERRIDE_DEFAULT = false;
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = true;
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT_WAVEVR = false;
public final static boolean PERFORMANCE_MONITOR_DEFAULT = true;
public final static boolean DRM_PLAYBACK_DEFAULT = false;
public final static int TRACKING_DEFAULT = ContentBlocking.EtpLevel.DEFAULT;
public final static boolean NOTIFICATIONS_DEFAULT = true;
public final static boolean SPEECH_DATA_COLLECTION_DEFAULT = false;
public final static boolean SPEECH_DATA_COLLECTION_REVIEWED_DEFAULT = false;
public final static boolean SERVO_DEFAULT = false;
public final static int UA_MODE_DEFAULT = GeckoSessionSettings.USER_AGENT_MODE_VR;
public final static int INPUT_MODE_DEFAULT = 1;
public final static float DISPLAY_DENSITY_DEFAULT = 1.0f;
public final static int WINDOW_WIDTH_DEFAULT = 800;
public final static int WINDOW_HEIGHT_DEFAULT = 450;
public final static int DISPLAY_DPI_DEFAULT = 96;
public final static int MAX_WINDOW_WIDTH_DEFAULT = 1200;
public final static int MAX_WINDOW_HEIGHT_DEFAULT = 1200;
public final static int POINTER_COLOR_DEFAULT_DEFAULT = Color.parseColor("#FFFFFF");
public final static int SCROLL_DIRECTION_DEFAULT = 0;
public final static String ENV_DEFAULT = "offworld";
public final static int MSAA_DEFAULT_LEVEL = 1;
public final static boolean AUDIO_ENABLED = false;
public final static float CYLINDER_DENSITY_ENABLED_DEFAULT = 4680.0f;
private final static long CRASH_RESTART_DELTA = 2000;
public final static boolean AUTOPLAY_ENABLED = false;
public final static boolean DEBUG_LOGGING_DEFAULT = false;
public final static boolean POP_UPS_BLOCKING_DEFAULT = true;
public final static boolean WEBXR_ENABLED_DEFAULT = true;
public final static boolean TELEMETRY_STATUS_UPDATE_SENT_DEFAULT = false;
public final static boolean BOOKMARKS_SYNC_DEFAULT = true;
public final static boolean HISTORY_SYNC_DEFAULT = true;
public final static boolean WHATS_NEW_DISPLAYED = false;
public final static long FXA_LAST_SYNC_NEVER = 0;
public final static boolean RESTORE_TABS_ENABLED = true;
public final static boolean BYPASS_CACHE_ON_RELOAD = false;
public final static boolean MULTI_E10S = false;
// Enable telemetry by default (opt-out).
public final static boolean CRASH_REPORTING_DEFAULT = false;
public final static boolean TELEMETRY_DEFAULT = true;
private int mCachedScrollDirection = -1;
private boolean mDisableLayers = false;
public void setDisableLayers(final boolean aDisableLayers) {
mDisableLayers = aDisableLayers;
}
public SettingsStore(Context aContext) {
mContext = aContext;
mPrefs = PreferenceManager.getDefaultSharedPreferences(aContext);
}
public void initModel(@NonNull Context context) {
mSettingsViewModel = new ViewModelProvider(
(VRBrowserActivity)context,
ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) context).getApplication()))
.get(SettingsViewModel.class);
mSettingsViewModel.refresh();
}
public boolean isCrashReportingEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_crash), CRASH_REPORTING_DEFAULT);
}
public void setCrashReportingEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_crash), isEnabled);
editor.commit();
}
public boolean isTelemetryEnabled() {
// The first access to shared preferences will require a disk read.
final StrictMode.ThreadPolicy threadPolicy = StrictMode.allowThreadDiskReads();
try {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_telemetry), TELEMETRY_DEFAULT);
} finally {
StrictMode.setThreadPolicy(threadPolicy);
}
}
public void setTelemetryEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_telemetry), isEnabled);
editor.commit();
// We send before disabling in case of opting-out
if (!isEnabled) {
TelemetryWrapper.telemetryStatus(false);
}
// If the state of Telemetry is not the same, we reinitialize it.
final boolean hasEnabled = isTelemetryEnabled();
if (hasEnabled != isEnabled) {
TelemetryWrapper.init(mContext);
}
TelemetryHolder.get().getConfiguration().setUploadEnabled(isEnabled);
TelemetryHolder.get().getConfiguration().setCollectionEnabled(isEnabled);
// We send after enabling in case of opting-in
if (isEnabled) {
TelemetryWrapper.telemetryStatus(true);
GleanMetricsService.start();
} else {
GleanMetricsService.stop();
}
// Update the status sent flag
setTelemetryPingUpdateSent(true);
}
public boolean telemetryStatusSaved() {
return mPrefs.contains(mContext.getString(R.string.settings_key_telemetry));
}
public boolean isTelemetryPingUpdateSent() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_telemetry_status_update_sent), TELEMETRY_STATUS_UPDATE_SENT_DEFAULT);
}
public void setTelemetryPingUpdateSent(boolean isSent) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_telemetry_status_update_sent), isSent);
editor.commit();
}
public void setGeolocationData(String aGeolocationData) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_geolocation_data), aGeolocationData);
editor.commit();
}
public String getGeolocationData() {
return mPrefs.getString(mContext.getString(R.string.settings_key_geolocation_data), "");
}
public boolean isRemoteDebuggingEnabled() {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_remote_debugging), REMOTE_DEBUGGING_DEFAULT);
}
public void setRemoteDebuggingEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_remote_debugging), isEnabled);
editor.commit();
}
public boolean isConsoleLogsEnabled() {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_console_logs), CONSOLE_LOGS_DEFAULT);
}
public void setConsoleLogsEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_console_logs), isEnabled);
editor.commit();
}
public boolean isDrmContentPlaybackEnabled() {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_drm_playback), DRM_PLAYBACK_DEFAULT);
}
public void setDrmContentPlaybackEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_drm_playback), isEnabled);
editor.commit();
}
public int getTrackingProtectionLevel() {
return mPrefs.getInt(
mContext.getString(R.string.settings_key_tracking_protection_level), TRACKING_DEFAULT);
}
public void setTrackingProtectionLevel(int level) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_tracking_protection_level), level);
editor.commit();
mSettingsViewModel.setIsTrackingProtectionEnabled(level != ContentBlocking.EtpLevel.NONE);
}
public boolean isEnvironmentOverrideEnabled() {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_environment_override), ENV_OVERRIDE_DEFAULT);
}
public void setEnvironmentOverrideEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_environment_override), isEnabled);
editor.commit();
}
public boolean isUIHardwareAccelerationEnabled() {
boolean defaultValue = UI_HARDWARE_ACCELERATION_DEFAULT;
if (DeviceType.isWaveBuild()) {
defaultValue = UI_HARDWARE_ACCELERATION_DEFAULT_WAVEVR;
}
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_ui_hardware_acceleration), defaultValue);
}
public void setUIHardwareAccelerationEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_ui_hardware_acceleration), isEnabled);
editor.commit();
}
public boolean isPerformanceMonitorEnabled() {
// Disabling Performance Monitor until it can properly handle multi-window
return false; // mPrefs.getBoolean(mContext.getString(R.string.settings_key_performance_monitor), PERFORMANCE_MONITOR_DEFAULT);
}
public void setPerformanceMonitorEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_performance_monitor), isEnabled);
editor.commit();
}
public boolean isServoEnabled() {
return isServoAvailable() && mPrefs.getBoolean(mContext.getString(R.string.settings_key_servo), SERVO_DEFAULT);
}
public void setServoEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_servo), isEnabled);
editor.commit();
}
public int getUaMode() {
return mPrefs.getInt(
mContext.getString(R.string.settings_key_user_agent_version), UA_MODE_DEFAULT);
}
public void setUaMode(int mode) {
int checkedMode = mode;
if ((mode != GeckoSessionSettings.USER_AGENT_MODE_VR) && (mode != GeckoSessionSettings.USER_AGENT_MODE_MOBILE)) {
Log.e(LOGTAG, "User agent mode: " + mode + " is not supported.");
checkedMode = UA_MODE_DEFAULT;
}
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_user_agent_version), checkedMode);
editor.commit();
}
public int getInputMode() {
return mPrefs.getInt(
mContext.getString(R.string.settings_key_input_mode), INPUT_MODE_DEFAULT);
}
public void setInputMode(int aTouchMode) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_input_mode), aTouchMode);
editor.commit();
}
public String getHomepage() {
return mPrefs.getString(
mContext.getString(R.string.settings_key_homepage),
mContext.getString(R.string.homepage_url));
}
public void setHomepage(String aHomepage) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_homepage), aHomepage);
editor.commit();
}
public float getDisplayDensity() {
return mPrefs.getFloat(
mContext.getString(R.string.settings_key_display_density), DISPLAY_DENSITY_DEFAULT);
}
public void setDisplayDensity(float aDensity) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putFloat(mContext.getString(R.string.settings_key_display_density), aDensity);
editor.commit();
}
public int getWindowWidth() {
return WINDOW_WIDTH_DEFAULT;
}
public int getWindowHeight() {
return WINDOW_HEIGHT_DEFAULT;
}
public float getWindowAspect() {
return (float)getWindowWidth() / (float)getWindowHeight();
}
public int getDisplayDpi() {
return mPrefs.getInt(
mContext.getString(R.string.settings_key_display_dpi), DISPLAY_DPI_DEFAULT);
}
public void setDisplayDpi(int aDpi) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_display_dpi), aDpi);
editor.commit();
}
public int getMaxWindowWidth() {
return MAX_WINDOW_WIDTH_DEFAULT;
}
public int getMaxWindowHeight() {
return MAX_WINDOW_HEIGHT_DEFAULT;
}
public String getEnvironment() {
return mPrefs.getString(mContext.getString(R.string.settings_key_env), ENV_DEFAULT);
}
public void setEnvironment(String aEnv) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_env), aEnv);
editor.commit();
}
public int getPointerColor() {
return mPrefs.getInt(
mContext.getString(R.string.settings_key_pointer_color), POINTER_COLOR_DEFAULT_DEFAULT);
}
public void setPointerColor(int color) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_pointer_color), color);
editor.commit();
}
public int getScrollDirection() {
if (mCachedScrollDirection < 0) {
mCachedScrollDirection = mPrefs.getInt(mContext.getString(R.string.settings_key_scroll_direction), SCROLL_DIRECTION_DEFAULT);
}
return mCachedScrollDirection;
}
public void setScrollDirection(int aScrollDirection) {
mCachedScrollDirection = aScrollDirection;
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_scroll_direction), aScrollDirection);
editor.commit();
}
public int getMSAALevel() {
return mPrefs.getInt(
mContext.getString(R.string.settings_key_msaa), MSAA_DEFAULT_LEVEL);
}
public void setMSAALevel(int level) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_msaa), level);
editor.commit();
}
public boolean getLayersEnabled() {
if (DeviceType.isOculusBuild() && !mDisableLayers) {
Log.i(LOGTAG, "Layers are enabled");
return true;
}
Log.i(LOGTAG, "Layers are not supported");
return false;
}
public int getTransparentBorderWidth() {
return 1;
}
public boolean isAudioEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_audio), AUDIO_ENABLED);
}
public void setAudioEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_audio), isEnabled);
editor.commit();
}
public String getVoiceSearchLocale() {
String language = mPrefs.getString(
mContext.getString(R.string.settings_key_voice_search_language), null);
return language;
}
public void setVoiceSearchLocale(String language) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_voice_search_language), language);
editor.commit();
}
public String getDisplayLocale() {
String language = mPrefs.getString(
mContext.getString(R.string.settings_key_display_language), null);
return language;
}
public void setDisplayLocale(String language) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_display_language), language);
editor.commit();
}
public ArrayList<String> getContentLocales() {
ArrayList<String> result = new ArrayList<>();
String json = mPrefs.getString(
mContext.getString(R.string.settings_key_content_languages),
null);
try {
JSONArray jsonArray = new JSONArray(json);
for (int i=0; i<jsonArray.length(); i++) {
result.add(jsonArray.getString(i));
}
return result;
} catch (Exception e) {
return null;
}
}
public void setContentLocales(List<String> languages) {
JSONArray json = new JSONArray(languages);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_content_languages), json.toString());
editor.commit();
}
public float getCylinderDensity() {
return mPrefs.getFloat(mContext.getString(R.string.settings_key_cylinder_density), 0);
}
public void setCylinderDensity(float aDensity) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putFloat(mContext.getString(R.string.settings_key_cylinder_density), aDensity);
editor.commit();
}
public boolean isCurvedModeEnabled() {
return getCylinderDensity() > 0;
}
public void setSelectedKeyboard(Locale aLocale) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_keyboard_locale), aLocale.toLanguageTag());
editor.commit();
}
public Locale getKeyboardLocale() {
String value = mPrefs.getString(mContext.getString(R.string.settings_key_keyboard_locale), null);
if (StringUtils.isEmpty(value)) {
return null;
}
return Locale.forLanguageTag(value);
}
public synchronized long getCrashRestartCount() {
long count = mPrefs.getLong(mContext.getString(R.string.settings_key_crash_restart_count), 0);
if (count > 0) {
final long timestamp = mPrefs.getLong(mContext.getString(R.string.settings_key_crash_restart_count_timestamp), -1);
if (System.currentTimeMillis() - timestamp > CRASH_RESTART_DELTA) {
count = 0;
SharedPreferences.Editor editor = mPrefs.edit();
editor.putLong(mContext.getString(R.string.settings_key_crash_restart_count), count);
editor.putLong(mContext.getString(R.string.settings_key_crash_restart_count_timestamp), -1);
editor.commit();
}
}
return count;
}
public synchronized void incrementCrashRestartCount() {
SharedPreferences.Editor editor = mPrefs.edit();
long count = mPrefs.getLong(mContext.getString(R.string.settings_key_crash_restart_count), 0);
count++;
editor.putLong(mContext.getString(R.string.settings_key_crash_restart_count), count);
editor.putLong(mContext.getString(R.string.settings_key_crash_restart_count_timestamp), System.currentTimeMillis());
editor.commit();
}
public synchronized void resetCrashRestartCount() {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putLong(mContext.getString(R.string.settings_key_crash_restart_count), 0);
editor.commit();
}
public boolean isSpeechDataCollectionEnabled() {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_speech_data_collection), SPEECH_DATA_COLLECTION_DEFAULT);
}
public void setSpeechDataCollectionEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_speech_data_collection), isEnabled);
editor.commit();
}
public boolean isNotificationsEnabled() {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_notifications), NOTIFICATIONS_DEFAULT);
}
public void setNotificationsEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_notifications), isEnabled);
editor.commit();
}
public boolean isSpeechDataCollectionReviewed() {
return mPrefs.getBoolean(
mContext.getString(R.string.settings_key_speech_data_collection_reviewed), SPEECH_DATA_COLLECTION_REVIEWED_DEFAULT);
}
public void setSpeechDataCollectionReviewed(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_speech_data_collection_reviewed), isEnabled);
editor.commit();
}
public boolean isDebugLoggingEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_debug_logging), DEBUG_LOGGING_DEFAULT);
}
public void setDebugLoggingEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_debug_logging), isEnabled);
editor.commit();
}
public boolean isAutoplayEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_autoplay), AUTOPLAY_ENABLED);
}
public void setAutoplayEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_autoplay), isEnabled);
editor.commit();
}
public void setPid(int aPid) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_pid), aPid);
editor.commit();
}
public int getPid() {
return mPrefs.getInt(mContext.getString(R.string.settings_key_pid), 0);
}
public boolean isPopUpsBlockingEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_pop_up_blocking), POP_UPS_BLOCKING_DEFAULT);
}
public void setPopUpsBlockingEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_pop_up_blocking), isEnabled);
editor.commit();
}
public boolean isWebXREnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_webxr), WEBXR_ENABLED_DEFAULT);
}
public void setWebXREnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_webxr), isEnabled);
editor.commit();
}
public void setWhatsNewDisplayed(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_whats_new_displayed), isEnabled);
editor.commit();
}
public boolean isWhatsNewDisplayed() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_whats_new_displayed), WHATS_NEW_DISPLAYED);
}
public void setFxALastSync(@NonNull String email, long timestamp) {
String json = mPrefs.getString(
mContext.getString(R.string.settings_key_fxa_last_sync),
new JSONObject().toString());
try {
JSONObject jsonObject = new JSONObject(json);
jsonObject.put(email, timestamp);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_fxa_last_sync), jsonObject.toString());
editor.commit();
} catch (Exception e) {
Log.d(LOGTAG, e.getMessage());
}
}
public long getFxALastSync(@NonNull String email) {
String json = mPrefs.getString(
mContext.getString(R.string.settings_key_fxa_last_sync),
null);
try {
JSONObject jsonObject = new JSONObject(json);
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
if (key.equals(email)) {
return jsonObject.getLong(key);
}
}
return FXA_LAST_SYNC_NEVER;
} catch (Exception e) {
return FXA_LAST_SYNC_NEVER;
}
}
public void setRestoreTabsEnabled(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_restore_tabs), isEnabled);
editor.commit();
}
public boolean isRestoreTabsEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_restore_tabs), RESTORE_TABS_ENABLED);
}
public void setBypassCacheOnReload(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload), isEnabled);
editor.commit();
}
public boolean isBypassCacheOnReloadEnabled() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_bypass_cache_on_reload), BYPASS_CACHE_ON_RELOAD);
}
public void setMultiE10s(boolean isEnabled) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(mContext.getString(R.string.settings_key_multi_e10s), isEnabled);
editor.commit();
}
public boolean isMultiE10s() {
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_multi_e10s), MULTI_E10S);
}
}