Merge "Exposing drag methods with user info." into ub-launcher3-burnaby
This commit is contained in:
@@ -4490,42 +4490,63 @@ public class Launcher extends Activity
|
|||||||
if (mSearchDropTargetBar != null) mSearchDropTargetBar.hideSearchBar(false);
|
if (mSearchDropTargetBar != null) mSearchDropTargetBar.hideSearchBar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: These method should be a part of LauncherSearchCallback
|
||||||
public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
|
public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
|
||||||
// Called from search suggestion, not supported in other profiles.
|
// Called from search suggestion
|
||||||
final UserHandleCompat myUser = UserHandleCompat.myUserHandle();
|
return createAppDragInfo(appLaunchIntent, UserHandleCompat.myUserHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This method should be a part of LauncherSearchCallback
|
||||||
|
public ItemInfo createAppDragInfo(Intent appLaunchIntent, 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);
|
LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this);
|
||||||
LauncherActivityInfoCompat activityInfo = launcherApps.resolveActivity(appLaunchIntent,
|
LauncherActivityInfoCompat activityInfo = launcherApps.resolveActivity(appLaunchIntent,
|
||||||
myUser);
|
user);
|
||||||
if (activityInfo == null) {
|
if (activityInfo == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new AppInfo(this, activityInfo, myUser, mIconCache);
|
return new AppInfo(this, activityInfo, user, mIconCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This method should be a part of LauncherSearchCallback
|
||||||
public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption,
|
public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption,
|
||||||
Bitmap icon) {
|
Bitmap icon) {
|
||||||
// Called from search suggestion, not supported in other profiles.
|
// Called from search suggestion
|
||||||
return createShortcutDragInfo(shortcutIntent, caption, icon,
|
return createShortcutDragInfo(shortcutIntent, caption, icon,
|
||||||
UserHandleCompat.myUserHandle());
|
UserHandleCompat.myUserHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This method should be a part of LauncherSearchCallback
|
||||||
public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption,
|
public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption,
|
||||||
Bitmap icon, UserHandleCompat user) {
|
Bitmap icon, UserHandleCompat user) {
|
||||||
|
if (user == null) {
|
||||||
|
user = UserHandleCompat.myUserHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called from search suggestion
|
||||||
UserManagerCompat userManager = UserManagerCompat.getInstance(this);
|
UserManagerCompat userManager = UserManagerCompat.getInstance(this);
|
||||||
CharSequence contentDescription = userManager.getBadgedLabelForUser(caption, user);
|
CharSequence contentDescription = userManager.getBadgedLabelForUser(caption, user);
|
||||||
return new ShortcutInfo(shortcutIntent, caption, contentDescription, icon, user);
|
return new ShortcutInfo(shortcutIntent, caption, contentDescription, icon, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveWorkspaceToDefaultScreen() {
|
// TODO: This method should be a part of LauncherSearchCallback
|
||||||
mWorkspace.moveToDefaultScreen(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startDrag(View dragView, ItemInfo dragInfo, DragSource source) {
|
public void startDrag(View dragView, ItemInfo dragInfo, DragSource source) {
|
||||||
dragView.setTag(dragInfo);
|
dragView.setTag(dragInfo);
|
||||||
mWorkspace.onExternalDragStartedWithItem(dragView);
|
mWorkspace.onExternalDragStartedWithItem(dragView);
|
||||||
mWorkspace.beginExternalDragShared(dragView, source);
|
mWorkspace.beginExternalDragShared(dragView, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void moveWorkspaceToDefaultScreen() {
|
||||||
|
mWorkspace.moveToDefaultScreen(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSwitch(View newPage, int newPageIndex) {
|
public void onPageSwitch(View newPage, int newPageIndex) {
|
||||||
if (mLauncherCallbacks != null) {
|
if (mLauncherCallbacks != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user