Search in sources :

Example 11 with Tile

use of com.android.settingslib.drawer.Tile in project android_frameworks_base by ResurrectionRemix.

the class SuggestionParser method readSuggestions.

private void readSuggestions(SuggestionCategory category, List<Tile> suggestions) {
    int countBefore = suggestions.size();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(category.category);
    if (category.pkg != null) {
        intent.setPackage(category.pkg);
    }
    TileUtils.getTilesForIntent(mContext, new UserHandle(UserHandle.myUserId()), intent, addCache, null, suggestions, true, false);
    for (int i = countBefore; i < suggestions.size(); i++) {
        if (!isAvailable(suggestions.get(i)) || !isSupported(suggestions.get(i)) || !satisfiesRequiredAccount(suggestions.get(i)) || isDismissed(suggestions.get(i))) {
            suggestions.remove(i--);
        }
    }
    if (!category.multiple && suggestions.size() > (countBefore + 1)) {
        // If there are too many, remove them all and only re-add the one with the highest
        // priority.
        Tile item = suggestions.remove(suggestions.size() - 1);
        while (suggestions.size() > countBefore) {
            Tile last = suggestions.remove(suggestions.size() - 1);
            if (last.priority > item.priority) {
                item = last;
            }
        }
        // If category is marked as done, do not add any item.
        if (!isCategoryDone(category.category)) {
            suggestions.add(item);
        }
    }
}
Also used : UserHandle(android.os.UserHandle) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent)

Example 12 with Tile

use of com.android.settingslib.drawer.Tile in project android_frameworks_base by DirtyUnicorns.

the class SuggestionParser method readSuggestions.

private void readSuggestions(SuggestionCategory category, List<Tile> suggestions) {
    int countBefore = suggestions.size();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(category.category);
    if (category.pkg != null) {
        intent.setPackage(category.pkg);
    }
    TileUtils.getTilesForIntent(mContext, new UserHandle(UserHandle.myUserId()), intent, addCache, null, suggestions, true, false);
    for (int i = countBefore; i < suggestions.size(); i++) {
        if (!isAvailable(suggestions.get(i)) || !isSupported(suggestions.get(i)) || !satisfiesRequiredAccount(suggestions.get(i)) || isDismissed(suggestions.get(i))) {
            suggestions.remove(i--);
        }
    }
    if (!category.multiple && suggestions.size() > (countBefore + 1)) {
        // If there are too many, remove them all and only re-add the one with the highest
        // priority.
        Tile item = suggestions.remove(suggestions.size() - 1);
        while (suggestions.size() > countBefore) {
            Tile last = suggestions.remove(suggestions.size() - 1);
            if (last.priority > item.priority) {
                item = last;
            }
        }
        // If category is marked as done, do not add any item.
        if (!isCategoryDone(category.category)) {
            suggestions.add(item);
        }
    }
}
Also used : UserHandle(android.os.UserHandle) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent)

Example 13 with Tile

use of com.android.settingslib.drawer.Tile in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DashboardAdapter method recountItems.

private void recountItems() {
    reset();
    boolean hasConditions = false;
    for (int i = 0; mConditions != null && i < mConditions.size(); i++) {
        boolean shouldShow = mConditions.get(i).shouldShow();
        hasConditions |= shouldShow;
        countItem(mConditions.get(i), R.layout.condition_card, shouldShow, NS_CONDITION);
    }
    boolean hasSuggestions = mSuggestions != null && mSuggestions.size() != 0;
    countItem(null, R.layout.dashboard_spacer, hasConditions && hasSuggestions, NS_SPACER);
    countItem(null, R.layout.suggestion_header, hasSuggestions, NS_SPACER);
    resetCount();
    if (mSuggestions != null) {
        int maxSuggestions = getDisplayableSuggestionCount();
        for (int i = 0; i < mSuggestions.size(); i++) {
            countItem(mSuggestions.get(i), R.layout.suggestion_tile, i < maxSuggestions, NS_SUGGESTION);
        }
    }
    resetCount();
    for (int i = 0; mCategories != null && i < mCategories.size(); i++) {
        DashboardCategory category = mCategories.get(i);
        countItem(category, R.layout.dashboard_category, mIsShowingAll, NS_ITEMS);
        for (int j = 0; j < category.tiles.size(); j++) {
            Tile tile = category.tiles.get(j);
            countItem(tile, R.layout.dashboard_tile, mIsShowingAll || ArrayUtils.contains(DashboardSummary.INITIAL_ITEMS, tile.intent.getComponent().getClassName()), NS_ITEMS);
        }
    }
    notifyDataSetChanged();
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Tile(com.android.settingslib.drawer.Tile)

Aggregations

Tile (com.android.settingslib.drawer.Tile)13 Intent (android.content.Intent)6 UserHandle (android.os.UserHandle)5 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)3 SettingsDrawerActivity (com.android.settingslib.drawer.SettingsDrawerActivity)3 ComponentName (android.content.ComponentName)2 Condition (com.android.settings.dashboard.conditional.Condition)2 PackageManager (android.content.pm.PackageManager)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 ResolveInfo (android.content.pm.ResolveInfo)1 NfcAdapter (android.nfc.NfcAdapter)1 UserManager (android.os.UserManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 AccessibilitySettings (com.android.settings.accessibility.AccessibilitySettings)1 AccountSettings (com.android.settings.accounts.AccountSettings)1 AccountSyncSettings (com.android.settings.accounts.AccountSyncSettings)1