Home | History | Annotate | Download | only in notification
      1 /*
      2  * Copyright (C) 2017 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.settings.notification;
     18 
     19 import static com.android.settings.notification.SettingPref.TYPE_GLOBAL;
     20 
     21 import android.content.Context;
     22 
     23 import android.content.res.Resources;
     24 import android.provider.Settings.Global;
     25 import android.telephony.TelephonyManager;
     26 import com.android.settings.SettingsPreferenceFragment;
     27 import com.android.settingslib.core.lifecycle.Lifecycle;
     28 
     29 public class DockAudioMediaPreferenceController extends SettingPrefController {
     30 
     31     private static final String KEY_DOCK_AUDIO_MEDIA = "dock_audio_media";
     32 
     33     private static final int DOCK_AUDIO_MEDIA_DISABLED = 0;
     34     private static final int DOCK_AUDIO_MEDIA_ENABLED = 1;
     35     private static final int DEFAULT_DOCK_AUDIO_MEDIA = DOCK_AUDIO_MEDIA_DISABLED;
     36 
     37     public DockAudioMediaPreferenceController(Context context, SettingsPreferenceFragment parent,
     38             Lifecycle lifecycle) {
     39         super(context, parent, lifecycle);
     40         mPreference = new SettingPref(
     41             TYPE_GLOBAL, KEY_DOCK_AUDIO_MEDIA, Global.DOCK_AUDIO_MEDIA_ENABLED,
     42             DEFAULT_DOCK_AUDIO_MEDIA, DOCK_AUDIO_MEDIA_DISABLED, DOCK_AUDIO_MEDIA_ENABLED) {
     43             @Override
     44             public boolean isApplicable(Context context) {
     45                 return context.getResources().getBoolean(
     46                     com.android.settings.R.bool.has_dock_settings);
     47             }
     48 
     49             @Override
     50             protected String getCaption(Resources res, int value) {
     51                 switch(value) {
     52                     case DOCK_AUDIO_MEDIA_DISABLED:
     53                         return res.getString(
     54                             com.android.settings.R.string.dock_audio_media_disabled);
     55                     case DOCK_AUDIO_MEDIA_ENABLED:
     56                         return res.getString(
     57                             com.android.settings.R.string.dock_audio_media_enabled);
     58                     default:
     59                         throw new IllegalArgumentException();
     60                 }
     61             }
     62         };
     63     }
     64 }
     65