Bind icon and remote views for Suggestion
Bug: 65065268 Test: robotests Change-Id: I181a9e092c56f4e45addfc1cde166fb7dac7becd
This commit is contained in:
@@ -601,6 +601,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getIcon(Icon icon) {
|
public Drawable getIcon(Icon icon) {
|
||||||
|
if (icon == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Drawable drawable = mMap.get(icon);
|
Drawable drawable = mMap.get(icon);
|
||||||
if (drawable == null) {
|
if (drawable == null) {
|
||||||
drawable = icon.loadDrawable(mContext);
|
drawable = icon.loadDrawable(mContext);
|
||||||
|
@@ -96,8 +96,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
|
|||||||
// itemView));
|
// itemView));
|
||||||
// } else
|
// } else
|
||||||
{
|
{
|
||||||
// TODO: Add icon field in Suggestion, and enable this.
|
holder.icon.setImageDrawable(mCache.getIcon(suggestion.getIcon()));
|
||||||
// holder.icon.setImageDrawable(mCache.getIcon(suggestion.icon));
|
|
||||||
holder.title.setText(suggestion.getTitle());
|
holder.title.setText(suggestion.getTitle());
|
||||||
final CharSequence summary = suggestion.getSummary();
|
final CharSequence summary = suggestion.getSummary();
|
||||||
if (!TextUtils.isEmpty(summary)) {
|
if (!TextUtils.isEmpty(summary)) {
|
||||||
|
@@ -17,13 +17,16 @@
|
|||||||
package android.service.settings.suggestions;
|
package android.service.settings.suggestions;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
public class Suggestion {
|
public class Suggestion {
|
||||||
private final String mId;
|
private final String mId;
|
||||||
private final CharSequence mTitle;
|
private final CharSequence mTitle;
|
||||||
private final CharSequence mSummary;
|
private final CharSequence mSummary;
|
||||||
|
private final Icon mIcon;
|
||||||
private final PendingIntent mPendingIntent;
|
private final PendingIntent mPendingIntent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,6 +50,13 @@ public class Suggestion {
|
|||||||
return mSummary;
|
return mSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional icon for this suggestion.
|
||||||
|
*/
|
||||||
|
public Icon getIcon() {
|
||||||
|
return mIcon;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Intent to launch when the suggestion is activated.
|
* The Intent to launch when the suggestion is activated.
|
||||||
*/
|
*/
|
||||||
@@ -57,17 +67,11 @@ public class Suggestion {
|
|||||||
private Suggestion(Builder builder) {
|
private Suggestion(Builder builder) {
|
||||||
mTitle = builder.mTitle;
|
mTitle = builder.mTitle;
|
||||||
mSummary = builder.mSummary;
|
mSummary = builder.mSummary;
|
||||||
|
mIcon = builder.mIcon;
|
||||||
mPendingIntent = builder.mPendingIntent;
|
mPendingIntent = builder.mPendingIntent;
|
||||||
mId = builder.mId;
|
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}.
|
* Builder class for {@link Suggestion}.
|
||||||
*/
|
*/
|
||||||
@@ -75,6 +79,7 @@ public class Suggestion {
|
|||||||
private final String mId;
|
private final String mId;
|
||||||
private CharSequence mTitle;
|
private CharSequence mTitle;
|
||||||
private CharSequence mSummary;
|
private CharSequence mSummary;
|
||||||
|
private Icon mIcon;
|
||||||
private PendingIntent mPendingIntent;
|
private PendingIntent mPendingIntent;
|
||||||
|
|
||||||
public Builder(String id) {
|
public Builder(String id) {
|
||||||
@@ -101,6 +106,14 @@ public class Suggestion {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets icon for the suggestion.
|
||||||
|
*/
|
||||||
|
public Builder setIcon(Icon icon) {
|
||||||
|
mIcon = icon;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets suggestion intent
|
* Sets suggestion intent
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user