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