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.media.AudioManager; 20 import android.view.View; 21 22 /** 23 * Static helpers for the volume dialog. 24 */ 25 class Util extends com.android.settingslib.volume.Util { 26 logTag(Class<?> c)27 public static String logTag(Class<?> c) { 28 final String tag = "vol." + c.getSimpleName(); 29 return tag.length() < 23 ? tag : tag.substring(0, 23); 30 } 31 ringerModeToString(int ringerMode)32 public static String ringerModeToString(int ringerMode) { 33 switch (ringerMode) { 34 case AudioManager.RINGER_MODE_SILENT: 35 return "RINGER_MODE_SILENT"; 36 case AudioManager.RINGER_MODE_VIBRATE: 37 return "RINGER_MODE_VIBRATE"; 38 case AudioManager.RINGER_MODE_NORMAL: 39 return "RINGER_MODE_NORMAL"; 40 default: 41 return "RINGER_MODE_UNKNOWN_" + ringerMode; 42 } 43 } 44 setVisOrGone(View v, boolean vis)45 public static final void setVisOrGone(View v, boolean vis) { 46 if (v == null || (v.getVisibility() == View.VISIBLE) == vis) return; 47 v.setVisibility(vis ? View.VISIBLE : View.GONE); 48 } 49 } 50