• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.homepage.contextualcards;
18 
19 import android.annotation.Nullable;
20 
21 import com.android.settings.intelligence.ContextualCardProto.ContextualCard;
22 import com.android.settings.intelligence.ContextualCardProto.ContextualCardList;
23 import com.android.settings.slices.CustomSliceRegistry;
24 
25 import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardProvider;
26 
27 /** Provides dynamic card for SettingsIntelligence. */
28 public class SettingsContextualCardProvider extends ContextualCardProvider {
29 
30     public static final String CARD_AUTHORITY = "com.android.settings.homepage.contextualcards";
31 
32     @Override
33     @Nullable
getContextualCards()34     public ContextualCardList getContextualCards() {
35         final ContextualCard wifiCard =
36                 ContextualCard.newBuilder()
37                         .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())
38                         .setCardName(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())
39                         .setCardCategory(ContextualCard.Category.IMPORTANT)
40                         .build();
41         final ContextualCard connectedDeviceCard =
42                 ContextualCard.newBuilder()
43                         .setSliceUri(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI.toString())
44                         .setCardName(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI.toString())
45                         .setCardCategory(ContextualCard.Category.IMPORTANT)
46                         .build();
47         final ContextualCard lowStorageCard =
48                 ContextualCard.newBuilder()
49                         .setSliceUri(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString())
50                         .setCardName(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString())
51                         .setCardCategory(ContextualCard.Category.IMPORTANT)
52                         .build();
53         final ContextualCard batteryFixCard =
54                 ContextualCard.newBuilder()
55                         .setSliceUri(CustomSliceRegistry.BATTERY_FIX_SLICE_URI.toString())
56                         .setCardName(CustomSliceRegistry.BATTERY_FIX_SLICE_URI.toString())
57                         .setCardCategory(ContextualCard.Category.IMPORTANT)
58                         .build();
59         final String contextualNotificationChannelSliceUri =
60                 CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI.toString();
61         final ContextualCard notificationChannelCard =
62                 ContextualCard.newBuilder()
63                         .setSliceUri(contextualNotificationChannelSliceUri)
64                         .setCardName(contextualNotificationChannelSliceUri)
65                         .setCardCategory(ContextualCard.Category.POSSIBLE)
66                         .build();
67         final ContextualCardList cards = ContextualCardList.newBuilder()
68                 .addCard(wifiCard)
69                 .addCard(connectedDeviceCard)
70                 .addCard(lowStorageCard)
71                 .addCard(batteryFixCard)
72                 .addCard(notificationChannelCard)
73                 .build();
74 
75         return cards;
76     }
77 }
78