1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.volume;
18 
19 import android.content.Context;
20 import android.content.SharedPreferences;
21 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
22 import android.preference.PreferenceManager;
23 
24 /**
25  *  Configuration for the volume dialog + related policy.
26  */
27 public class VolumePrefs {
28 
29     public static final String PREF_ENABLE_PROTOTYPE = "pref_enable_prototype";  // not persistent
30     public static final String PREF_SHOW_ALARMS = "pref_show_alarms";
31     public static final String PREF_SHOW_SYSTEM = "pref_show_system";
32     public static final String PREF_SHOW_HEADERS = "pref_show_headers";
33     public static final String PREF_SHOW_FAKE_REMOTE_1 = "pref_show_fake_remote_1";
34     public static final String PREF_SHOW_FAKE_REMOTE_2 = "pref_show_fake_remote_2";
35     public static final String PREF_ENABLE_AUTOMUTE = "pref_enable_automute";
36     public static final String PREF_ENABLE_SILENT_MODE = "pref_enable_silent_mode";
37     public static final String PREF_DEBUG_LOGGING = "pref_debug_logging";
38     public static final String PREF_SEND_LOGS = "pref_send_logs";
39     public static final String PREF_ADJUST_SYSTEM = "pref_adjust_system";
40     public static final String PREF_ADJUST_VOICE_CALLS = "pref_adjust_voice_calls";
41     public static final String PREF_ADJUST_BLUETOOTH_SCO = "pref_adjust_bluetooth_sco";
42     public static final String PREF_ADJUST_MEDIA = "pref_adjust_media";
43     public static final String PREF_ADJUST_ALARMS = "pref_adjust_alarms";
44     public static final String PREF_ADJUST_NOTIFICATION = "pref_adjust_notification";
45 
46     public static final int SHOW_RINGER_TOAST_COUNT = 12;
47 
48     public static final boolean DEFAULT_SHOW_HEADERS = true;
49     public static final boolean DEFAULT_ENABLE_AUTOMUTE = true;
50     public static final boolean DEFAULT_ENABLE_SILENT_MODE = true;
51 
unregisterCallbacks(Context c, OnSharedPreferenceChangeListener listener)52     public static void unregisterCallbacks(Context c, OnSharedPreferenceChangeListener listener) {
53         prefs(c).unregisterOnSharedPreferenceChangeListener(listener);
54     }
55 
registerCallbacks(Context c, OnSharedPreferenceChangeListener listener)56     public static void registerCallbacks(Context c, OnSharedPreferenceChangeListener listener) {
57         prefs(c).registerOnSharedPreferenceChangeListener(listener);
58     }
59 
prefs(Context context)60     private static SharedPreferences prefs(Context context) {
61         return PreferenceManager.getDefaultSharedPreferences(context);
62     }
63 
get(Context context, String key, boolean def)64     public static boolean get(Context context, String key, boolean def) {
65         return prefs(context).getBoolean(key, def);
66     }
67 }
68