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 androidx.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 connectedDeviceCard = 36 ContextualCard.newBuilder() 37 .setSliceUri(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI.toString()) 38 .setCardName(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI.toString()) 39 .setCardCategory(ContextualCard.Category.IMPORTANT) 40 .build(); 41 final ContextualCard lowStorageCard = 42 ContextualCard.newBuilder() 43 .setSliceUri(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString()) 44 .setCardName(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString()) 45 .setCardCategory(ContextualCard.Category.IMPORTANT) 46 .build(); 47 final String contextualAdaptiveSleepSliceUri = 48 CustomSliceRegistry.CONTEXTUAL_ADAPTIVE_SLEEP_URI.toString(); 49 final ContextualCard contextualAdaptiveSleepCard = 50 ContextualCard.newBuilder() 51 .setSliceUri(contextualAdaptiveSleepSliceUri) 52 .setCardName(contextualAdaptiveSleepSliceUri) 53 .setCardCategory(ContextualCard.Category.DEFAULT) 54 .build(); 55 final ContextualCard contextualFaceSettingsCard = 56 ContextualCard.newBuilder() 57 .setSliceUri(CustomSliceRegistry.FACE_ENROLL_SLICE_URI.toString()) 58 .setCardName(CustomSliceRegistry.FACE_ENROLL_SLICE_URI.toString()) 59 .setCardCategory(ContextualCard.Category.DEFAULT) 60 .build(); 61 final ContextualCard darkThemeCard = 62 ContextualCard.newBuilder() 63 .setSliceUri(CustomSliceRegistry.DARK_THEME_SLICE_URI.toString()) 64 .setCardName(CustomSliceRegistry.DARK_THEME_SLICE_URI.toString()) 65 .setCardCategory(ContextualCard.Category.IMPORTANT) 66 .build(); 67 final ContextualCardList cards = ContextualCardList.newBuilder() 68 .addCard(connectedDeviceCard) 69 .addCard(lowStorageCard) 70 .addCard(contextualAdaptiveSleepCard) 71 .addCard(contextualFaceSettingsCard) 72 .addCard(darkThemeCard) 73 .build(); 74 75 return cards; 76 } 77 } 78