Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82869360 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Bind icon and remote views for Suggestion"

parents 42f5c71e e7337b3e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -601,6 +601,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
        }

        public Drawable getIcon(Icon icon) {
            if (icon == null) {
                return null;
            }
            Drawable drawable = mMap.get(icon);
            if (drawable == null) {
                drawable = icon.loadDrawable(mContext);
+1 −2
Original line number Diff line number Diff line
@@ -96,8 +96,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
        //                  itemView));
        //        } else
        {
            // TODO: Add icon field in Suggestion, and enable this.
            //            holder.icon.setImageDrawable(mCache.getIcon(suggestion.icon));
            holder.icon.setImageDrawable(mCache.getIcon(suggestion.getIcon()));
            holder.title.setText(suggestion.getTitle());
            final CharSequence summary = suggestion.getSummary();
            if (!TextUtils.isEmpty(summary)) {
+20 −7
Original line number Diff line number Diff line
@@ -17,13 +17,16 @@
package android.service.settings.suggestions;

import android.app.PendingIntent;
import android.graphics.drawable.Icon;
import android.os.Parcel;
import android.text.TextUtils;
import android.widget.RemoteViews;

public class Suggestion {
    private final String mId;
    private final CharSequence mTitle;
    private final CharSequence mSummary;
    private final Icon mIcon;
    private final PendingIntent mPendingIntent;

    /**
@@ -47,6 +50,13 @@ public class Suggestion {
        return mSummary;
    }

    /**
     * Optional icon for this suggestion.
     */
    public Icon getIcon() {
        return mIcon;
    }

    /**
     * The Intent to launch when the suggestion is activated.
     */
@@ -57,17 +67,11 @@ public class Suggestion {
    private Suggestion(Builder builder) {
        mTitle = builder.mTitle;
        mSummary = builder.mSummary;
        mIcon = builder.mIcon;
        mPendingIntent = builder.mPendingIntent;
        mId = builder.mId;
    }

    private Suggestion(Parcel in) {
        mId = in.readString();
        mTitle = in.readCharSequence();
        mSummary = in.readCharSequence();
        mPendingIntent = in.readParcelable(PendingIntent.class.getClassLoader());
    }

    /**
     * Builder class for {@link Suggestion}.
     */
@@ -75,6 +79,7 @@ public class Suggestion {
        private final String mId;
        private CharSequence mTitle;
        private CharSequence mSummary;
        private Icon mIcon;
        private PendingIntent mPendingIntent;

        public Builder(String id) {
@@ -101,6 +106,14 @@ public class Suggestion {
            return this;
        }

        /**
         * Sets icon for the suggestion.
         */
        public Builder setIcon(Icon icon) {
            mIcon = icon;
            return this;
        }

        /**
         * Sets suggestion intent
         */