1 /*
2  * Copyright (C) 2019 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.media.MediaOutputSlice.MEDIA_PACKAGE_NAME;
20 import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
21 
22 import android.app.settings.SettingsEnums;
23 import android.content.Context;
24 import android.content.Intent;
25 import android.net.Uri;
26 
27 import com.android.settings.R;
28 
29 import java.util.ArrayList;
30 import java.util.List;
31 
32 /**
33  * Represents the Media output Panel.
34  *
35  * <p>
36  * Displays Media output item
37  * </p>
38  */
39 public class MediaOutputPanel implements PanelContent {
40 
41     private final Context mContext;
42     private final String mPackageName;
43 
create(Context context, String packageName)44     public static MediaOutputPanel create(Context context, String packageName) {
45         return new MediaOutputPanel(context, packageName);
46     }
47 
MediaOutputPanel(Context context, String packageName)48     private MediaOutputPanel(Context context, String packageName) {
49         mContext = context.getApplicationContext();
50         mPackageName = packageName;
51     }
52 
53     @Override
getTitle()54     public CharSequence getTitle() {
55         return mContext.getText(R.string.media_output_panel_title);
56     }
57 
58     @Override
getSlices()59     public List<Uri> getSlices() {
60         final List<Uri> uris = new ArrayList<>();
61         MEDIA_OUTPUT_SLICE_URI =
62                 MEDIA_OUTPUT_SLICE_URI
63                         .buildUpon()
64                         .clearQuery()
65                         .appendQueryParameter(MEDIA_PACKAGE_NAME, mPackageName)
66                         .build();
67         uris.add(MEDIA_OUTPUT_SLICE_URI);
68         return uris;
69     }
70 
71     @Override
getSeeMoreIntent()72     public Intent getSeeMoreIntent() {
73         return null;
74     }
75 
76     @Override
getMetricsCategory()77     public int getMetricsCategory() {
78         return SettingsEnums.PANEL_MEDIA_OUTPUT;
79     }
80 }
81