Search in sources :

Example 1 with Tile

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

the class DashboardSummary method onStop.

@Override
public void onStop() {
    super.onStop();
    ((SettingsDrawerActivity) getActivity()).remCategoryListener(this);
    mSummaryLoader.setListening(false);
    for (Condition c : mConditionManager.getConditions()) {
        if (c.shouldShow()) {
            MetricsLogger.hidden(getContext(), c.getMetricsConstant());
        }
    }
    if (mAdapter.getSuggestions() == null) {
        return;
    }
    if (!getActivity().isChangingConfigurations()) {
        for (Tile suggestion : mAdapter.getSuggestions()) {
            String id = DashboardAdapter.getSuggestionIdentifier(getContext(), suggestion);
            if (!mSuggestionsHiddenLogged.contains(id)) {
                mSuggestionsHiddenLogged.add(id);
                MetricsLogger.action(getContext(), MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION, id);
            }
        }
    }
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) Tile(com.android.settingslib.drawer.Tile) SettingsDrawerActivity(com.android.settingslib.drawer.SettingsDrawerActivity)

Example 2 with Tile

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

the class DashboardAdapter method setCategoriesAndSuggestions.

public void setCategoriesAndSuggestions(List<DashboardCategory> categories, List<Tile> suggestions) {
    mCategories = categories;
    if ((Settings.System.getInt(mContext.getContentResolver(), Settings.System.DISABLE_SUGGESTIONS, 0) == 1)) {
        mSuggestions = null;
    } else {
        mSuggestions = suggestions;
    }
    TypedValue tintColorValue = new TypedValue();
    mContext.getResources().getValue(R.color.external_tile_icon_tint_color, tintColorValue, true);
    for (int i = 0; i < categories.size(); i++) {
        for (int j = 0; j < categories.get(i).tiles.size(); j++) {
            Tile tile = categories.get(i).tiles.get(j);
            if (!mContext.getPackageName().equals(tile.intent.getComponent().getPackageName())) {
                // color.
                if (tintColorValue.type == TypedValue.TYPE_ATTRIBUTE) {
                    mContext.getTheme().resolveAttribute(tintColorValue.data, tintColorValue, true);
                }
                tile.icon.setTint(tintColorValue.data).setTintMode(Mode.SRC_ATOP);
            }
        }
    }
    recountItems();
}
Also used : Tile(com.android.settingslib.drawer.Tile) TypedValue(android.util.TypedValue)

Example 3 with Tile

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

the class DashboardAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(DashboardItemHolder holder, int position) {
    switch(mTypes.get(position)) {
        case R.layout.dashboard_category:
            onBindCategory(holder, (DashboardCategory) mItems.get(position));
            break;
        case R.layout.dashboard_tile:
            final Tile tile = (Tile) mItems.get(position);
            onBindTile(holder, tile);
            holder.itemView.setTag(tile);
            holder.itemView.setOnClickListener(this);
            break;
        case R.layout.suggestion_header:
            onBindSuggestionHeader(holder);
            break;
        case R.layout.suggestion_tile:
            final Tile suggestion = (Tile) mItems.get(position);
            onBindTile(holder, suggestion);
            holder.itemView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    MetricsLogger.action(mContext, MetricsEvent.ACTION_SETTINGS_SUGGESTION, DashboardAdapter.getSuggestionIdentifier(mContext, suggestion));
                    ((SettingsActivity) mContext).startSuggestion(suggestion.intent);
                }
            });
            holder.itemView.findViewById(R.id.overflow).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    showRemoveOption(v, suggestion);
                }
            });
            break;
        case R.layout.see_all:
            onBindSeeAll(holder);
            break;
        case R.layout.condition_card:
            ConditionAdapterUtils.bindViews((Condition) mItems.get(position), holder, mItems.get(position) == mExpandedCondition, this, new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    onExpandClick(v);
                }
            });
            break;
    }
}
Also used : Tile(com.android.settingslib.drawer.Tile) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 4 with Tile

use of com.android.settingslib.drawer.Tile 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;
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Tile(com.android.settingslib.drawer.Tile)

Example 5 with Tile

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

the class DashboardSummary method onStart.

@Override
public void onStart() {
    long startTime = System.currentTimeMillis();
    super.onStart();
    ((SettingsDrawerActivity) getActivity()).addCategoryListener(this);
    mSummaryLoader.setListening(true);
    for (Condition c : mConditionManager.getConditions()) {
        if (c.shouldShow()) {
            MetricsLogger.visible(getContext(), c.getMetricsConstant());
        }
    }
    if (mAdapter.getSuggestions() != null) {
        for (Tile suggestion : mAdapter.getSuggestions()) {
            MetricsLogger.action(getContext(), MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, DashboardAdapter.getSuggestionIdentifier(getContext(), suggestion));
        }
    }
    if (DEBUG_TIMING)
        Log.d(TAG, "onStart took " + (System.currentTimeMillis() - startTime) + " ms");
    updateSettings();
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) Tile(com.android.settingslib.drawer.Tile) SettingsDrawerActivity(com.android.settingslib.drawer.SettingsDrawerActivity)

Aggregations

Tile (com.android.settingslib.drawer.Tile)466 Test (org.junit.Test)309 Intent (android.content.Intent)158 Bundle (android.os.Bundle)117 Preference (android.support.v7.preference.Preference)108 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)102 ComponentName (android.content.ComponentName)98 ArrayList (java.util.ArrayList)79 Context (android.content.Context)71 UserHandle (android.os.UserHandle)32 Activity (android.app.Activity)31 RecyclerView (android.support.v7.widget.RecyclerView)31 View (android.view.View)31 Icon (android.graphics.drawable.Icon)30 VisibleForTesting (android.support.annotation.VisibleForTesting)30 PackageManager (android.content.pm.PackageManager)25 TypedArray (android.content.res.TypedArray)24 ViewGroup (android.view.ViewGroup)24 RemoteViews (android.widget.RemoteViews)24 SettingsActivity (com.android.settings.SettingsActivity)24