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 boolean DEFAULT_SHOW_HEADERS = false; 47 public static final boolean DEFAULT_ENABLE_AUTOMUTE = true; 48 public static final boolean DEFAULT_ENABLE_SILENT_MODE = true; 49 unregisterCallbacks(Context c, OnSharedPreferenceChangeListener listener)50 public static void unregisterCallbacks(Context c, OnSharedPreferenceChangeListener listener) { 51 prefs(c).unregisterOnSharedPreferenceChangeListener(listener); 52 } 53 registerCallbacks(Context c, OnSharedPreferenceChangeListener listener)54 public static void registerCallbacks(Context c, OnSharedPreferenceChangeListener listener) { 55 prefs(c).registerOnSharedPreferenceChangeListener(listener); 56 } 57 prefs(Context context)58 private static SharedPreferences prefs(Context context) { 59 return PreferenceManager.getDefaultSharedPreferences(context); 60 } 61 get(Context context, String key, boolean def)62 public static boolean get(Context context, String key, boolean def) { 63 return prefs(context).getBoolean(key, def); 64 } 65 } 66