Load suggestions through SettingsIntelligence.
- Add flag to switch between old/new implementation - Add SuggestionLoader to load using Loader (instead of AsyncTask) - Update DashboardAdapater/SuggestionAdapter to take List<Suggestion> - Marked old getter/setters as @Deprecated and added comment - Update tests to cover suggestionV2 adapter changes. TODO: - Handler for dismissing suggestion not set up yet. - Suggestion data structure is incomplete (missing icon, remote view, etc) - Need to extend Suggestion data strcture to support icon and remote view binding Bug: 65065268 Test: robotests Change-Id: I2378ef4c9edee972d5de93c3868068e2cde23f56
This commit is contained in:
@@ -16,5 +16,104 @@
|
||||
|
||||
package android.service.settings.suggestions;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.os.Parcel;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class Suggestion {
|
||||
private final String mId;
|
||||
private final CharSequence mTitle;
|
||||
private final CharSequence mSummary;
|
||||
private final PendingIntent mPendingIntent;
|
||||
|
||||
/**
|
||||
* Gets the id for the suggestion object.
|
||||
*/
|
||||
public String getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of the suggestion that is shown to the user.
|
||||
*/
|
||||
public CharSequence getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional summary describing what this suggestion controls.
|
||||
*/
|
||||
public CharSequence getSummary() {
|
||||
return mSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Intent to launch when the suggestion is activated.
|
||||
*/
|
||||
public PendingIntent getPendingIntent() {
|
||||
return mPendingIntent;
|
||||
}
|
||||
|
||||
private Suggestion(Builder builder) {
|
||||
mTitle = builder.mTitle;
|
||||
mSummary = builder.mSummary;
|
||||
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}.
|
||||
*/
|
||||
public static class Builder {
|
||||
private final String mId;
|
||||
private CharSequence mTitle;
|
||||
private CharSequence mSummary;
|
||||
private PendingIntent mPendingIntent;
|
||||
|
||||
public Builder(String id) {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
throw new IllegalArgumentException("Suggestion id cannot be empty");
|
||||
}
|
||||
mId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets suggestion title
|
||||
*/
|
||||
|
||||
public Builder setTitle(CharSequence title) {
|
||||
mTitle = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets suggestion summary
|
||||
*/
|
||||
public Builder setSummary(CharSequence summary) {
|
||||
mSummary = summary;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets suggestion intent
|
||||
*/
|
||||
public Builder setPendingIntent(PendingIntent pendingIntent) {
|
||||
mPendingIntent = pendingIntent;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an immutable {@link Suggestion} object.
|
||||
*/
|
||||
public Suggestion build() {
|
||||
return new Suggestion(this /* builder */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user