use of com.android.settingslib.drawer.DashboardCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SummaryLoader method getTileFromCategory.
private Tile getTileFromCategory(List<DashboardCategory> categories, ComponentName component) {
if (categories == null) {
if (DEBUG) {
Log.d(TAG, "Category is null, can't find tile");
}
return null;
}
final int categorySize = categories.size();
for (int i = 0; i < categorySize; i++) {
final DashboardCategory category = categories.get(i);
final int tileCount = category.tiles.size();
for (int j = 0; j < tileCount; j++) {
final Tile tile = category.tiles.get(j);
if (component.equals(tile.intent.getComponent())) {
return tile;
}
}
}
return null;
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class DashboardAdapter method onSaveInstanceState.
void onSaveInstanceState(Bundle outState) {
final List<Tile> suggestions = mDashboardData.getSuggestions();
final DashboardCategory category = mDashboardData.getCategory();
if (suggestions != null) {
outState.putParcelableArrayList(STATE_SUGGESTION_LIST, new ArrayList<>(suggestions));
}
if (category != null) {
outState.putParcelable(STATE_CATEGORY_LIST, category);
}
outState.putStringArrayList(STATE_SUGGESTIONS_SHOWN_LOGGED, mSuggestionsShownLogged);
outState.putInt(STATE_SUGGESTION_CONDITION_MODE, mDashboardData.getSuggestionConditionMode());
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class DashboardFeatureProviderImpl method getPreferencesForCategory.
@Override
public List<Preference> getPreferencesForCategory(Activity activity, Context context, int sourceMetricsCategory, String key) {
final DashboardCategory category = getTilesForCategory(key);
if (category == null) {
Log.d(TAG, "NO dashboard tiles for " + TAG);
return null;
}
final List<Tile> tiles = category.tiles;
if (tiles == null || tiles.isEmpty()) {
Log.d(TAG, "tile list is empty, skipping category " + category.title);
return null;
}
final List<Preference> preferences = new ArrayList<>();
for (Tile tile : tiles) {
final Preference pref = new Preference(context);
bindPreferenceToTile(activity, sourceMetricsCategory, pref, tile, null, /* key */
Preference.DEFAULT_ORDER);
preferences.add(pref);
}
return preferences;
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class DashboardFragment method onCategoriesChanged.
@Override
public void onCategoriesChanged() {
final DashboardCategory category = mDashboardFeatureProvider.getTilesForCategory(getCategoryKey());
if (category == null) {
return;
}
refreshDashboardTiles(getLogTag());
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class SiteMapManager method init.
/**
* Initialize a list of {@link SiteMapPair}s. Each pair knows about a single parent-child
* page relationship.
*
* We get the knowledge of such mPairs from 2 sources:
* 1. Static indexing time: we know which page(s) a parent can open by parsing its pref xml.
* 2. IA: We know from {@link DashboardFeatureProvider} which page can be dynamically
* injected to where.
*/
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
@WorkerThread
synchronized void init(Context context) {
if (mInitialized) {
// Make sure only init once.
return;
}
final long startTime = System.currentTimeMillis();
// First load site map from static index table.
final Context appContext = context.getApplicationContext();
final SQLiteDatabase db = IndexDatabaseHelper.getInstance(appContext).getReadableDatabase();
Cursor sitemap = db.query(IndexDatabaseHelper.Tables.TABLE_SITE_MAP, SITE_MAP_COLUMNS, null, null, null, null, null);
while (sitemap.moveToNext()) {
final SiteMapPair pair = new SiteMapPair(sitemap.getString(sitemap.getColumnIndex(SiteMapColumns.PARENT_CLASS)), sitemap.getString(sitemap.getColumnIndex(SiteMapColumns.PARENT_TITLE)), sitemap.getString(sitemap.getColumnIndex(SiteMapColumns.CHILD_CLASS)), sitemap.getString(sitemap.getColumnIndex(SiteMapColumns.CHILD_TITLE)));
mPairs.add(pair);
}
sitemap.close();
// Then prepare a local map that contains class name -> screen title mapping. This is needed
// to figure out the display name for any fragment if it's injected dynamically through IA.
final Map<String, String> classToTitleMap = new HashMap<>();
final Cursor titleQuery = db.query(IndexDatabaseHelper.Tables.TABLE_PREFS_INDEX, CLASS_TO_SCREEN_TITLE_COLUMNS, null, null, null, null, null);
while (titleQuery.moveToNext()) {
classToTitleMap.put(titleQuery.getString(titleQuery.getColumnIndex(IndexColumns.CLASS_NAME)), titleQuery.getString(titleQuery.getColumnIndex(IndexColumns.SCREEN_TITLE)));
}
titleQuery.close();
// Loop through all IA categories and pages and build additional SiteMapPairs
List<DashboardCategory> categories = FeatureFactory.getFactory(context).getDashboardFeatureProvider(context).getAllCategories();
for (DashboardCategory category : categories) {
// Find the category key first.
final String parentClass = CATEGORY_KEY_TO_PARENT_MAP.get(category.key);
if (parentClass == null) {
continue;
}
// Use the key to look up parent (which page hosts this key)
final String parentName = classToTitleMap.get(parentClass);
if (parentName == null) {
continue;
}
// Build parent-child mPairs for all children listed under this key.
for (Tile tile : category.tiles) {
final String childTitle = tile.title.toString();
String childClass = null;
if (tile.metaData != null) {
childClass = tile.metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS);
}
if (childClass == null) {
continue;
}
mPairs.add(new SiteMapPair(parentClass, parentName, childClass, childTitle));
}
}
// Done.
mInitialized = true;
if (DEBUG_TIMING) {
Log.d(TAG, "Init timing: " + (System.currentTimeMillis() - startTime));
}
}
Aggregations