Home | History | Annotate | Download | only in conditional
      1 /*
      2  * Copyright (C) 2018 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.dashboard.conditional;
     18 
     19 import android.graphics.drawable.Drawable;
     20 import android.media.AudioManager;
     21 
     22 import com.android.internal.logging.nano.MetricsProto;
     23 import com.android.settings.R;
     24 
     25 public class RingerVibrateCondition extends AbnormalRingerConditionBase {
     26 
     27     RingerVibrateCondition(ConditionManager manager) {
     28         super(manager);
     29     }
     30 
     31     @Override
     32     public void refreshState() {
     33         setActive(mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_VIBRATE);
     34     }
     35 
     36     @Override
     37     public int getMetricsConstant() {
     38         return MetricsProto.MetricsEvent.SETTINGS_CONDITION_DEVICE_VIBRATE;
     39     }
     40 
     41     @Override
     42     public Drawable getIcon() {
     43         return mManager.getContext().getDrawable(R.drawable.ic_volume_ringer_vibrate);
     44     }
     45 
     46     @Override
     47     public CharSequence getTitle() {
     48         return mManager.getContext().getText(R.string.condition_device_vibrate_title);
     49     }
     50 
     51     @Override
     52     public CharSequence getSummary() {
     53         return mManager.getContext().getText(R.string.condition_device_vibrate_summary);
     54     }
     55 }
     56