package android.service.chooser {
public final class ChooserTarget implements android.os.Parcelable {
- ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.app.PendingIntent);
- ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.content.IntentSender);
+ ctor public ChooserTarget(java.lang.CharSequence, android.graphics.drawable.Icon, float, android.app.PendingIntent);
+ ctor public ChooserTarget(java.lang.CharSequence, android.graphics.drawable.Icon, float, android.content.IntentSender);
method public int describeContents();
- method public android.graphics.Bitmap getIcon();
+ method public android.graphics.drawable.Icon getIcon();
method public android.content.IntentSender getIntentSender();
method public float getScore();
method public java.lang.CharSequence getTitle();
package android.service.chooser {
public final class ChooserTarget implements android.os.Parcelable {
- ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.app.PendingIntent);
- ctor public ChooserTarget(java.lang.CharSequence, android.graphics.Bitmap, float, android.content.IntentSender);
+ ctor public ChooserTarget(java.lang.CharSequence, android.graphics.drawable.Icon, float, android.app.PendingIntent);
+ ctor public ChooserTarget(java.lang.CharSequence, android.graphics.drawable.Icon, float, android.content.IntentSender);
method public int describeContents();
- method public android.graphics.Bitmap getIcon();
+ method public android.graphics.drawable.Icon getIcon();
method public android.content.IntentSender getIntentSender();
method public float getScore();
method public java.lang.CharSequence getTitle();
import android.content.IntentFilter;
import android.content.IntentSender;
import android.graphics.Bitmap;
+import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
/**
* A ChooserTarget represents a deep-link into an application as returned by a
* {@link android.service.chooser.ChooserTargetService}.
+ *
+ * <p>A chooser target represents a specific deep link target into an application exposed
+ * for selection by the user. This might be a frequently emailed contact, a recently active
+ * group messaging conversation, a folder in a cloud storage app, a collection of related
+ * items published on a social media service or any other contextually relevant grouping
+ * of target app + relevant metadata.</p>
+ *
+ * <p>Creators of chooser targets should consult the relevant design guidelines for the type
+ * of target they are presenting. For example, targets involving people should be presented
+ * with a circular icon.</p>
*/
public final class ChooserTarget implements Parcelable {
private static final String TAG = "ChooserTarget";
* The icon that will be shown to the user to represent this target.
* The system may resize this icon as appropriate.
*/
- private Bitmap mIcon;
+ private Icon mIcon;
/**
* The IntentSender that will be used to deliver the intent to the target.
* @param score ranking score for this target between 0.0f and 1.0f, inclusive
* @param pendingIntent PendingIntent to fill in and send if the user chooses this target
*/
- public ChooserTarget(CharSequence title, Bitmap icon, float score,
+ public ChooserTarget(CharSequence title, Icon icon, float score,
PendingIntent pendingIntent) {
this(title, icon, score, pendingIntent.getIntentSender());
}
* @param score ranking score for this target between 0.0f and 1.0f, inclusive
* @param intentSender IntentSender to fill in and send if the user chooses this target
*/
- public ChooserTarget(CharSequence title, Bitmap icon, float score, IntentSender intentSender) {
+ public ChooserTarget(CharSequence title, Icon icon, float score, IntentSender intentSender) {
mTitle = title;
mIcon = icon;
if (score > 1.f || score < 0.f) {
ChooserTarget(Parcel in) {
mTitle = in.readCharSequence();
if (in.readInt() != 0) {
- mIcon = Bitmap.CREATOR.createFromParcel(in);
+ mIcon = Icon.CREATOR.createFromParcel(in);
} else {
mIcon = null;
}
*
* @return the icon representing this target, intended to be shown to a user
*/
- public Bitmap getIcon() {
+ public Icon getIcon() {
return mIcon;
}
* <p>The returned list should be sorted such that the most relevant targets appear first.
* Any PendingIntents used to construct the resulting ChooserTargets should always be prepared
* to have the relevant data fields filled in by the sender. See
- * {@link ChooserTarget#ChooserTarget(CharSequence, android.graphics.Bitmap, float, android.app.PendingIntent) ChooserTarget}.</p>
+ * {@link ChooserTarget#ChooserTarget(CharSequence, android.graphics.drawable.Icon, float, android.app.PendingIntent) ChooserTarget}.</p>
*
* <p><em>Important:</em> Calls to this method from other applications will occur on
* a binder thread, not on your app's main thread. Make sure that access to relevant data
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.database.DataSetObserver;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
-import android.widget.LinearLayout;
import android.widget.ListView;
import com.android.internal.R;
private IntentSender mRefinementIntentSender;
private RefinementResultReceiver mRefinementResultReceiver;
+ private Intent mReferrerFillInIntent;
+
private ChooserListAdapter mChooserListAdapter;
private final List<ChooserTargetServiceConnection> mServiceConnections = new ArrayList<>();
private static final int CHOOSER_TARGET_SERVICE_RESULT = 1;
private static final int CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT = 2;
- private Handler mTargetResultHandler = new Handler() {
+ private final Handler mChooserHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
}
}
+ mReferrerFillInIntent = new Intent().putExtra(Intent.EXTRA_REFERRER, getReferrer());
+
mChosenComponentSender = intent.getParcelableExtra(
Intent.EXTRA_CHOSEN_COMPONENT_INTENT_SENDER);
mRefinementIntentSender = intent.getParcelableExtra(
if (!mServiceConnections.isEmpty()) {
if (DEBUG) Log.d(TAG, "queryTargets setting watchdog timer for "
+ WATCHDOG_TIMEOUT_MILLIS + "ms");
- mTargetResultHandler.sendEmptyMessageDelayed(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT,
+ mChooserHandler.sendEmptyMessageDelayed(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT,
WATCHDOG_TIMEOUT_MILLIS);
}
}
unbindService(conn);
}
mServiceConnections.clear();
- mTargetResultHandler.removeMessages(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT);
+ mChooserHandler.removeMessages(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT);
}
void onRefinementResult(TargetInfo selectedTarget, Intent matchingIntent) {
private final ResolveInfo mBackupResolveInfo;
private final ChooserTarget mChooserTarget;
private Drawable mBadgeIcon = null;
- private final Drawable mDisplayIcon;
+ private Drawable mDisplayIcon;
private final Intent mFillInIntent;
private final int mFillInFlags;
}
}
}
- mDisplayIcon = new BitmapDrawable(getResources(), chooserTarget.getIcon());
+ final Icon icon = chooserTarget.getIcon();
+ // TODO do this in the background
+ mDisplayIcon = icon != null ? icon.loadDrawable(ChooserActivity.this) : null;
if (sourceInfo != null) {
mBackupResolveInfo = null;
? mSourceInfo.getResolvedIntent() : getTargetIntent();
if (result == null) {
Log.e(TAG, "ChooserTargetInfo#getFillInIntent: no fillIn intent available");
- } else if (mFillInIntent != null) {
+ } else {
result = new Intent(result);
- result.fillIn(mFillInIntent, mFillInFlags);
+ if (mFillInIntent != null) {
+ result.fillIn(mFillInIntent, mFillInFlags);
+ }
+ result.fillIn(mReferrerFillInIntent, 0);
}
return result;
}
msg.what = CHOOSER_TARGET_SERVICE_RESULT;
msg.obj = new ServiceResultInfo(mOriginalTarget, targets,
ChooserTargetServiceConnection.this);
- mTargetResultHandler.sendMessage(msg);
+ mChooserHandler.sendMessage(msg);
}
};