1 /* 2 * Copyright (C) 2016 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 package com.android.settings.dashboard; 17 18 import android.app.Activity; 19 import android.content.Context; 20 import android.support.v7.preference.Preference; 21 22 import com.android.settingslib.drawer.DashboardCategory; 23 import com.android.settingslib.drawer.Tile; 24 25 import java.util.List; 26 27 /** 28 * FeatureProvider for dashboard (aka settings homepage). 29 */ 30 public interface DashboardFeatureProvider { 31 32 /** 33 * Get tiles (wrapped in {@link DashboardCategory}) for key defined in CategoryKey. 34 */ getTilesForCategory(String key)35 DashboardCategory getTilesForCategory(String key); 36 37 /** 38 * Get tiles (wrapped as a list of Preference) for key defined in CategoryKey. 39 * 40 * @param activity Activity hosting the preference 41 * @param context UI context to inflate preference 42 * @param sourceMetricsCategory The context (source) from which an action is performed 43 * @param key Value from CategoryKey 44 * @deprecated Pages implementing {@code DashboardFragment} should use 45 * {@link #getTilesForCategory(String)} instead. Using this method will not get the benefit 46 * of auto-ordering, progressive disclosure, auto-refreshing summary text etc. 47 */ 48 @Deprecated getPreferencesForCategory(Activity activity, Context context, int sourceMetricsCategory, String key)49 List<Preference> getPreferencesForCategory(Activity activity, Context context, 50 int sourceMetricsCategory, String key); 51 52 /** 53 * Get all tiles, grouped by category. 54 */ getAllCategories()55 List<DashboardCategory> getAllCategories(); 56 57 /** 58 * Whether or not we should tint icons in setting pages. 59 * @deprecated in favor of color icons in homepage 60 */ 61 @Deprecated shouldTintIcon()62 boolean shouldTintIcon(); 63 64 /** 65 * Returns an unique string key for the tile. 66 */ getDashboardKeyForTile(Tile tile)67 String getDashboardKeyForTile(Tile tile); 68 69 /** 70 * Binds preference to data provided by tile. 71 * 72 * @param activity If tile contains intent to launch, it will be launched from this activity 73 * @param sourceMetricsCategory The context (source) from which an action is performed 74 * @param pref The preference to bind data 75 * @param tile The binding data 76 * @param key They key for preference. If null, we will generate one from tile data 77 * @param baseOrder The order offset value. When binding, pref's order is determined by 78 * both this value and tile's own priority. 79 */ bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref, Tile tile, String key, int baseOrder)80 void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref, 81 Tile tile, String key, int baseOrder); 82 83 /** 84 * Returns additional intent filter action for dashboard tiles 85 */ getExtraIntentAction()86 String getExtraIntentAction(); 87 88 /** 89 * Opens a tile to its destination intent. 90 */ openTileIntent(Activity activity, Tile tile)91 void openTileIntent(Activity activity, Tile tile); 92 93 } 94