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.panel; 18 19 import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI; 20 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_ALARM_URI; 21 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_CALL_URI; 22 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI; 23 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_REMOTE_MEDIA_URI; 24 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_RINGER_URI; 25 26 import android.app.settings.SettingsEnums; 27 import android.content.Context; 28 import android.content.Intent; 29 import android.net.Uri; 30 import android.provider.Settings; 31 32 import com.android.settings.R; 33 import com.android.settings.notification.RemoteVolumePreferenceController; 34 35 import java.util.ArrayList; 36 import java.util.List; 37 38 public class VolumePanel implements PanelContent { 39 40 private final Context mContext; 41 create(Context context)42 public static VolumePanel create(Context context) { 43 return new VolumePanel(context); 44 } 45 VolumePanel(Context context)46 private VolumePanel(Context context) { 47 mContext = context.getApplicationContext(); 48 } 49 50 @Override getTitle()51 public CharSequence getTitle() { 52 return mContext.getText(R.string.volume_connectivity_panel_title); 53 } 54 55 @Override getSlices()56 public List<Uri> getSlices() { 57 final List<Uri> uris = new ArrayList<>(); 58 if (RemoteVolumePreferenceController.getActiveRemoteToken(mContext) != null) { 59 uris.add(VOLUME_REMOTE_MEDIA_URI); 60 } 61 uris.add(VOLUME_MEDIA_URI); 62 uris.add(MEDIA_OUTPUT_INDICATOR_SLICE_URI); 63 uris.add(VOLUME_CALL_URI); 64 uris.add(VOLUME_RINGER_URI); 65 uris.add(VOLUME_ALARM_URI); 66 return uris; 67 } 68 69 @Override getSeeMoreIntent()70 public Intent getSeeMoreIntent() { 71 return new Intent(Settings.ACTION_SOUND_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 72 } 73 74 @Override getMetricsCategory()75 public int getMetricsCategory() { 76 return SettingsEnums.PANEL_VOLUME; 77 } 78 }