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.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
20 import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT_GROUP;
21 
22 import android.content.Context;
23 import android.os.Bundle;
24 import android.provider.Settings;
25 
26 public class PanelFeatureProviderImpl implements PanelFeatureProvider {
27 
28     @Override
getPanel(Context context, Bundle bundle)29     public PanelContent getPanel(Context context, Bundle bundle) {
30         if (context == null) {
31             return null;
32         }
33 
34         final String panelType =
35                 bundle.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
36         final String mediaPackageName =
37                 bundle.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
38 
39         switch (panelType) {
40             case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
41                 return InternetConnectivityPanel.create(context);
42             case ACTION_MEDIA_OUTPUT:
43                 return MediaOutputPanel.create(context, mediaPackageName);
44             case Settings.Panel.ACTION_NFC:
45                 return NfcPanel.create(context);
46             case Settings.Panel.ACTION_WIFI:
47                 return WifiPanel.create(context);
48             case Settings.Panel.ACTION_VOLUME:
49                 return VolumePanel.create(context);
50             case ACTION_MEDIA_OUTPUT_GROUP:
51                 return MediaOutputGroupPanel.create(context, mediaPackageName);
52         }
53 
54         throw new IllegalStateException("No matching panel for: "  + panelType);
55     }
56 }
57