use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by omnirom.
the class SuggestionsChecksTest method testFingerprintEnrollmentIntroductionIsCompleteWhenFingerprintNotSupported.
@Test
public void testFingerprintEnrollmentIntroductionIsCompleteWhenFingerprintNotSupported() {
stubFingerprintSupported(false);
Tile tile = createFingerprintTile();
assertThat(mSuggestionsChecks.isSuggestionComplete(tile)).isTrue();
}
use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.
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.Tile in project android_packages_apps_Settings by crdroidandroid.
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));
}
}
use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.
the class SummaryLoader method setSummary.
public void setSummary(SummaryProvider provider, final CharSequence summary) {
final ComponentName component = mSummaryProviderMap.get(provider);
mHandler.post(new Runnable() {
@Override
public void run() {
final Tile tile = getTileFromCategory(mDashboardFeatureProvider.getTilesForCategory(mCategoryKey), component);
if (tile == null) {
if (DEBUG) {
Log.d(TAG, "Can't find tile for " + component);
}
return;
}
if (DEBUG) {
Log.d(TAG, "setSummary " + tile.title + " - " + summary);
}
updateSummaryIfNeeded(tile, summary);
}
});
}
use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.
the class SuggestionAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(DashboardItemHolder holder, int position) {
final Tile suggestion = (Tile) mSuggestions.get(position);
final String suggestionId = mSuggestionFeatureProvider.getSuggestionIdentifier(mContext, suggestion);
// This is for cases when a suggestion is dismissed and the next one comes to view
if (!mSuggestionsShownLogged.contains(suggestionId)) {
mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, suggestionId, getSuggestionTaggedData());
mSuggestionsShownLogged.add(suggestionId);
}
if (suggestion.remoteViews != null) {
final ViewGroup itemView = (ViewGroup) holder.itemView;
itemView.removeAllViews();
itemView.addView(suggestion.remoteViews.apply(itemView.getContext(), itemView));
} else {
holder.icon.setImageDrawable(mCache.getIcon(suggestion.icon));
holder.title.setText(suggestion.title);
if (!TextUtils.isEmpty(suggestion.summary)) {
holder.summary.setText(suggestion.summary);
holder.summary.setVisibility(View.VISIBLE);
} else {
holder.summary.setVisibility(View.GONE);
}
}
final View divider = holder.itemView.findViewById(R.id.divider);
if (divider != null) {
divider.setVisibility(position < mSuggestions.size() - 1 ? View.VISIBLE : View.GONE);
}
View clickHandler = holder.itemView;
// If a view with @android:id/primary is defined, use that as the click handler
// instead.
final View primaryAction = holder.itemView.findViewById(android.R.id.primary);
if (primaryAction != null) {
clickHandler = primaryAction;
}
clickHandler.setOnClickListener(v -> {
mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_SUGGESTION, suggestionId, getSuggestionTaggedData());
((SettingsActivity) mContext).startSuggestion(suggestion.intent);
});
}
Aggregations