From a1d1bf3119f7b1aab1d394af6cb21c2c4100d458 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 26 Jun 2015 13:24:53 -0700 Subject: Allowing UserHandle to be passed in the intent when creating AppInfo > Removing createShortcut with userHandle, as shortcuts can only be for the primary user. Bug: 22070517 Change-Id: Ifc58a76d0f1e0ab8f1943b46588cc19dd88bdda1 --- src/com/android/launcher3/Launcher.java | 35 +++++++++++++-------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'src/com/android/launcher3') diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index a995f0813..98aae8f1a 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -64,6 +64,7 @@ import android.os.Handler; import android.os.Message; import android.os.StrictMode; import android.os.SystemClock; +import android.os.UserHandle; import android.text.Selection; import android.text.SpannableStringBuilder; import android.text.TextUtils; @@ -93,6 +94,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; + import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.PagedView.PageSwitchListener; import com.android.launcher3.allapps.AllAppsContainerView; @@ -4493,24 +4495,29 @@ public class Launcher extends Activity } // TODO: These method should be a part of LauncherSearchCallback + @TargetApi(Build.VERSION_CODES.LOLLIPOP) public ItemInfo createAppDragInfo(Intent appLaunchIntent) { // Called from search suggestion - return createAppDragInfo(appLaunchIntent, UserHandleCompat.myUserHandle()); + UserHandleCompat user = null; + if (Utilities.isLmpOrAbove()) { + UserHandle userHandle = appLaunchIntent.getParcelableExtra(Intent.EXTRA_USER); + if (userHandle != null) { + user = UserHandleCompat.fromUser(userHandle); + } + } + return createAppDragInfo(appLaunchIntent, user); } // TODO: This method should be a part of LauncherSearchCallback - public ItemInfo createAppDragInfo(Intent appLaunchIntent, UserHandleCompat user) { + public ItemInfo createAppDragInfo(Intent intent, UserHandleCompat user) { if (user == null) { user = UserHandleCompat.myUserHandle(); } // Called from search suggestion, add the profile extra to the intent to ensure that we // can launch it correctly - long serialNumber = UserManagerCompat.getInstance(this).getSerialNumberForUser(user); - appLaunchIntent.putExtra(AppInfo.EXTRA_PROFILE, serialNumber); LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this); - LauncherActivityInfoCompat activityInfo = launcherApps.resolveActivity(appLaunchIntent, - user); + LauncherActivityInfoCompat activityInfo = launcherApps.resolveActivity(intent, user); if (activityInfo == null) { return null; } @@ -4520,24 +4527,10 @@ public class Launcher extends Activity // TODO: This method should be a part of LauncherSearchCallback public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption, Bitmap icon) { - // Called from search suggestion - return createShortcutDragInfo(shortcutIntent, caption, icon, + return new ShortcutInfo(shortcutIntent, caption, caption, icon, UserHandleCompat.myUserHandle()); } - // TODO: This method should be a part of LauncherSearchCallback - public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption, - Bitmap icon, UserHandleCompat user) { - if (user == null) { - user = UserHandleCompat.myUserHandle(); - } - - // Called from search suggestion - UserManagerCompat userManager = UserManagerCompat.getInstance(this); - CharSequence contentDescription = userManager.getBadgedLabelForUser(caption, user); - return new ShortcutInfo(shortcutIntent, caption, contentDescription, icon, user); - } - // TODO: This method should be a part of LauncherSearchCallback public void startDrag(View dragView, ItemInfo dragInfo, DragSource source) { dragView.setTag(dragInfo); -- cgit v1.2.3