mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Refactors in UserEventDispatcher
- LaunchSource -> LogContainer Change-Id: I71bfee992fb1ba7ae80e824d419f7bf8d3020999
This commit is contained in:
@@ -19,12 +19,12 @@ package com.android.launcher3;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.DropTarget.DragObject;
|
||||
import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
|
||||
import com.android.launcher3.logging.UserEventDispatcher.LogContainerProvider;
|
||||
|
||||
/**
|
||||
* Interface defining an object that can originate a drag.
|
||||
*/
|
||||
public interface DragSource extends LaunchSourceProvider {
|
||||
public interface DragSource extends LogContainerProvider {
|
||||
|
||||
/**
|
||||
* @return whether items dragged from this source supports
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
|
||||
public class Hotseat extends FrameLayout
|
||||
implements UserEventDispatcher.LaunchSourceProvider {
|
||||
implements UserEventDispatcher.LogContainerProvider {
|
||||
|
||||
private CellLayout mContent;
|
||||
|
||||
@@ -172,7 +172,7 @@ public class Hotseat extends FrameLayout
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
target.gridX = info.cellX;
|
||||
target.gridY = info.cellY;
|
||||
targetParent.containerType = LauncherLogProto.HOTSEAT;
|
||||
|
||||
@@ -4256,7 +4256,7 @@ public class Workspace extends PagedView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
target.gridX = info.cellX;
|
||||
target.gridY = info.cellY;
|
||||
target.pageIndex = getCurrentPage();
|
||||
|
||||
@@ -586,7 +586,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
targetParent.containerType = mAppsRecyclerView.getContainerType(v);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class AnotherWindowDragSource implements DragSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
// TODO: Probably log something
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1430,7 +1430,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
target.gridX = info.cellX;
|
||||
target.gridY = info.cellY;
|
||||
target.pageIndex = mContent.getCurrentPage();
|
||||
|
||||
@@ -48,13 +48,9 @@ public class UserEventDispatcher {
|
||||
private final boolean mIsVerbose;
|
||||
|
||||
/**
|
||||
* TODO: change the name of this interface to LogContainerProvider
|
||||
* and the method name to fillInLogContainerData. Not changed to minimize CL diff
|
||||
* in this branch.
|
||||
*
|
||||
* Implemented by containers to provide a launch source for a given child.
|
||||
* Implemented by containers to provide a container source for a given child.
|
||||
*/
|
||||
public interface LaunchSourceProvider {
|
||||
public interface LogContainerProvider {
|
||||
|
||||
/**
|
||||
* Copies data from the source to the destination proto.
|
||||
@@ -64,13 +60,13 @@ public class UserEventDispatcher {
|
||||
* @param target dest of the data
|
||||
* @param targetParent dest of the data
|
||||
*/
|
||||
void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent);
|
||||
void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively finds the parent of the given child which implements IconLogInfoProvider
|
||||
*/
|
||||
public static LaunchSourceProvider getLaunchProviderRecursive(View v) {
|
||||
public static LogContainerProvider getLaunchProviderRecursive(View v) {
|
||||
ViewParent parent = null;
|
||||
|
||||
if (v != null) {
|
||||
@@ -82,8 +78,8 @@ public class UserEventDispatcher {
|
||||
// Optimization to only check up to 5 parents.
|
||||
int count = MAXIMUM_VIEW_HIERARCHY_LEVEL;
|
||||
while (parent != null && count-- > 0) {
|
||||
if (parent instanceof LaunchSourceProvider) {
|
||||
return (LaunchSourceProvider) parent;
|
||||
if (parent instanceof LogContainerProvider) {
|
||||
return (LogContainerProvider) parent;
|
||||
} else {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
@@ -123,12 +119,12 @@ public class UserEventDispatcher {
|
||||
// Fill in grid(x,y), pageIndex of the child and container type of the parent
|
||||
// TODO: make this percolate up the view hierarchy if needed.
|
||||
int idx = 0;
|
||||
LaunchSourceProvider provider = getLaunchProviderRecursive(v);
|
||||
LogContainerProvider provider = getLaunchProviderRecursive(v);
|
||||
if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) {
|
||||
return null;
|
||||
}
|
||||
ItemInfo itemInfo = (ItemInfo) v.getTag();
|
||||
provider.fillInLaunchSourceData(v, itemInfo, event.srcTarget[idx], event.srcTarget[idx + 1]);
|
||||
provider.fillInLogContainerData(v, itemInfo, event.srcTarget[idx], event.srcTarget[idx + 1]);
|
||||
|
||||
event.srcTarget[idx].intentHash = intent.hashCode();
|
||||
ComponentName cn = intent.getComponent();
|
||||
@@ -181,12 +177,12 @@ public class UserEventDispatcher {
|
||||
public void logDeepShortcutsOpen(View icon) {
|
||||
LauncherEvent event = LoggerUtils.initLauncherEvent(
|
||||
Action.TOUCH, icon, Target.CONTAINER);
|
||||
LaunchSourceProvider provider = getLaunchProviderRecursive(icon);
|
||||
LogContainerProvider provider = getLaunchProviderRecursive(icon);
|
||||
if (icon == null && !(icon.getTag() instanceof ItemInfo)) {
|
||||
return;
|
||||
}
|
||||
ItemInfo info = (ItemInfo) icon.getTag();
|
||||
provider.fillInLaunchSourceData(icon, info, event.srcTarget[0], event.srcTarget[1]);
|
||||
provider.fillInLogContainerData(icon, info, event.srcTarget[0], event.srcTarget[1]);
|
||||
event.action.touch = Action.LONGPRESS;
|
||||
dispatchUserEvent(event, null);
|
||||
|
||||
@@ -205,11 +201,11 @@ public class UserEventDispatcher {
|
||||
dropTargetAsView);
|
||||
event.action.touch = Action.DRAGDROP;
|
||||
|
||||
dragObj.dragSource.fillInLaunchSourceData(null, dragObj.originalDragInfo,
|
||||
dragObj.dragSource.fillInLogContainerData(null, dragObj.originalDragInfo,
|
||||
event.srcTarget[0], event.srcTarget[1]);
|
||||
|
||||
if (dropTargetAsView instanceof LaunchSourceProvider) {
|
||||
((LaunchSourceProvider) dropTargetAsView).fillInLaunchSourceData(null,
|
||||
if (dropTargetAsView instanceof LogContainerProvider) {
|
||||
((LogContainerProvider) dropTargetAsView).fillInLogContainerData(null,
|
||||
dragObj.dragInfo, event.destTarget[0], event.destTarget[1]);
|
||||
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
target.itemType = LauncherLogProto.DEEPSHORTCUT;
|
||||
// TODO: add target.rank
|
||||
targetParent.containerType = LauncherLogProto.DEEPSHORTCUTS;
|
||||
|
||||
@@ -338,7 +338,7 @@ public class WidgetsContainerView extends BaseContainerView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
|
||||
targetParent.containerType = LauncherLogProto.WIDGETS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user