Search in sources :

Example 91 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class SummaryLoaderTest method testUpdateSummaryToCache_hasCache_shouldUpdate.

@Test
public void testUpdateSummaryToCache_hasCache_shouldUpdate() {
    final String testSummary = "test_summary";
    final DashboardCategory category = new DashboardCategory();
    final Tile tile = new Tile();
    tile.key = "123";
    tile.intent = new Intent();
    category.addTile(tile);
    when(mFeatureFactory.dashboardFeatureProvider.getDashboardKeyForTile(tile)).thenReturn(tile.key);
    mSummaryLoader.updateSummaryIfNeeded(tile, testSummary);
    tile.summary = null;
    mSummaryLoader.updateSummaryToCache(category);
    assertThat(tile.summary).isEqualTo(testSummary);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) Test(org.junit.Test)

Example 92 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class SuggestionAdapterTest method makeSuggestions.

private List<Tile> makeSuggestions(String... pkgNames) {
    final List<Tile> suggestions = new ArrayList<>();
    for (String pkgName : pkgNames) {
        Tile suggestion = new Tile();
        suggestion.intent = new Intent("action");
        suggestion.intent.setComponent(new ComponentName(pkgName, "cls"));
        suggestions.add(suggestion);
        suggestion.icon = mock(Icon.class);
    }
    return suggestions;
}
Also used : ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Icon(android.graphics.drawable.Icon)

Example 93 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_NoAccountType_shouldNotDisplay.

@Test
public void refreshDashboardTiles_NoAccountType_shouldNotDisplay() {
    final Tile tile = new Tile();
    final Bundle metaData = new Bundle();
    metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
    tile.metaData = metaData;
    assertThat(mFragment.displayTile(tile)).isFalse();
}
Also used : Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 94 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by SudaMod.

the class SiteMapManagerTest method buildBreadCrumb_fromSiteMapDbAndDashboardProvider_breadcrumbShouldLinkUp.

@Test
public void buildBreadCrumb_fromSiteMapDbAndDashboardProvider_breadcrumbShouldLinkUp() {
    final String iaClass = SystemDashboardFragment.class.getName();
    final String iaTitle = "ia_title";
    ContentValues index = new ContentValues();
    index.put(IndexDatabaseHelper.IndexColumns.CLASS_NAME, iaClass);
    index.put(IndexDatabaseHelper.IndexColumns.SCREEN_TITLE, iaTitle);
    mDb.replaceOrThrow(IndexDatabaseHelper.Tables.TABLE_PREFS_INDEX, null, index);
    final DashboardCategory category = new DashboardCategory();
    category.key = CategoryKey.CATEGORY_SYSTEM;
    category.tiles.add(new Tile());
    category.tiles.get(0).title = TITLE_PREFIX + STATIC_DB_DEPTH;
    category.tiles.get(0).metaData = new Bundle();
    category.tiles.get(0).metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, CLASS_PREFIX + STATIC_DB_DEPTH);
    when(mFeatureFactory.dashboardFeatureProvider.getAllCategories()).thenReturn(Arrays.asList(category));
    final List<String> breadcrumb = mSiteMapManager.buildBreadCrumb(mContext, CLASS_PREFIX + 0, TITLE_PREFIX + 0);
    assertThat(breadcrumb.size()).isEqualTo(STATIC_DB_DEPTH + 2);
    assertThat(breadcrumb.get(0)).isEqualTo(iaTitle);
}
Also used : ContentValues(android.content.ContentValues) DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 95 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by SudaMod.

the class DashboardAdapter method logSuggestions.

private void logSuggestions() {
    final List<Tile> suggestions = mDashboardData.getSuggestions();
    if (suggestions == null) {
        return;
    }
    for (Tile suggestion : suggestions) {
        final String suggestionId = mSuggestionFeatureProvider.getSuggestionIdentifier(mContext, suggestion);
        if (!mSuggestionsShownLogged.contains(suggestionId)) {
            mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, suggestionId, getSuggestionTaggedData());
            mSuggestionsShownLogged.add(suggestionId);
        }
    }
}
Also used : Tile(com.android.settingslib.drawer.Tile)

Aggregations

Tile (com.android.settingslib.drawer.Tile)506 Test (org.junit.Test)345 Intent (android.content.Intent)160 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)117 Bundle (android.os.Bundle)108 Preference (android.support.v7.preference.Preference)98 ComponentName (android.content.ComponentName)93 ArrayList (java.util.ArrayList)87 Context (android.content.Context)70 ActivityTile (com.android.settingslib.drawer.ActivityTile)50 ProviderTile (com.android.settingslib.drawer.ProviderTile)45 UserHandle (android.os.UserHandle)39 Preference (androidx.preference.Preference)39 RecyclerView (android.support.v7.widget.RecyclerView)31 View (android.view.View)31 Icon (android.graphics.drawable.Icon)30 Activity (android.app.Activity)29 VisibleForTesting (android.support.annotation.VisibleForTesting)29 PackageManager (android.content.pm.PackageManager)25 ViewGroup (android.view.ViewGroup)24