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 String contextualAdaptiveSleepSliceUri = 68 CustomSliceRegistry.CONTEXTUAL_ADAPTIVE_SLEEP_URI.toString(); 69 final ContextualCard contextualAdaptiveSleepCard = 70 ContextualCard.newBuilder() 71 .setSliceUri(contextualAdaptiveSleepSliceUri) 72 .setCardName(contextualAdaptiveSleepSliceUri) 73 .setCardCategory(ContextualCard.Category.DEFAULT) 74 .build(); 75 final ContextualCard contextualFaceSettingsCard = 76 ContextualCard.newBuilder() 77 .setSliceUri(CustomSliceRegistry.FACE_ENROLL_SLICE_URI.toString()) 78 .setCardName(CustomSliceRegistry.FACE_ENROLL_SLICE_URI.toString()) 79 .setCardCategory(ContextualCard.Category.DEFAULT) 80 .build(); 81 final ContextualCard darkThemeCard = 82 ContextualCard.newBuilder() 83 .setSliceUri(CustomSliceRegistry.DARK_THEME_SLICE_URI.toString()) 84 .setCardName(CustomSliceRegistry.DARK_THEME_SLICE_URI.toString()) 85 .setCardCategory(ContextualCard.Category.IMPORTANT) 86 .build(); 87 final ContextualCardList cards = ContextualCardList.newBuilder() 88 .addCard(wifiCard) 89 .addCard(connectedDeviceCard) 90 .addCard(lowStorageCard) 91 .addCard(batteryFixCard) 92 .addCard(notificationChannelCard) 93 .addCard(contextualAdaptiveSleepCard) 94 .addCard(contextualFaceSettingsCard) 95 .addCard(darkThemeCard) 96 .build(); 97 98 return cards; 99 } 100 } 101