mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Merge "Fixes missing LauncherEvent for TAP action on FOLDER_ICON" into ub-launcher3-qt-future-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9d9c42ef38
@@ -74,7 +74,10 @@ import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.logging.LoggerUtils;
|
||||
import com.android.launcher3.pageindicators.PageIndicatorDots;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.views.ClipPathView;
|
||||
@@ -559,7 +562,11 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
mState = STATE_OPEN;
|
||||
announceAccessibilityChanges();
|
||||
|
||||
mLauncher.getUserEventDispatcher().resetElapsedContainerMillis("folder opened");
|
||||
mLauncher.getUserEventDispatcher().logActionOnItem(
|
||||
Touch.TAP,
|
||||
Direction.NONE,
|
||||
ItemType.FOLDER_ICON, mInfo.cellX, mInfo.cellY);
|
||||
|
||||
mContent.setFocusOnFirstChild();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ public class LoggerUtils {
|
||||
}
|
||||
|
||||
public static String getTargetStr(Target t) {
|
||||
if (t == null){
|
||||
if (t == null) {
|
||||
return "";
|
||||
}
|
||||
String str = "";
|
||||
@@ -138,17 +138,16 @@ public class LoggerUtils {
|
||||
if (t.intentHash != 0) {
|
||||
typeStr += ", intentHash=" + t.intentHash;
|
||||
}
|
||||
if ((t.packageNameHash != 0 || t.componentHash != 0 || t.intentHash != 0) &&
|
||||
t.itemType != ItemType.TASK) {
|
||||
if (t.itemType == ItemType.FOLDER_ICON) {
|
||||
typeStr += ", grid(" + t.gridX + "," + t.gridY + ")";
|
||||
} else if ((t.packageNameHash != 0 || t.componentHash != 0 || t.intentHash != 0)
|
||||
&& t.itemType != ItemType.TASK) {
|
||||
typeStr += ", predictiveRank=" + t.predictedRank + ", grid(" + t.gridX + "," + t.gridY
|
||||
+ "), span(" + t.spanX + "," + t.spanY
|
||||
+ "), pageIdx=" + t.pageIndex;
|
||||
|
||||
+ "), span(" + t.spanX + "," + t.spanY + "), pageIdx=" + t.pageIndex;
|
||||
}
|
||||
if (t.searchQueryLength != 0) {
|
||||
typeStr += ", searchQueryLength=" + t.searchQueryLength;
|
||||
}
|
||||
|
||||
if (t.itemType == ItemType.TASK) {
|
||||
typeStr += ", pageIdx=" + t.pageIndex;
|
||||
}
|
||||
@@ -172,7 +171,7 @@ public class LoggerUtils {
|
||||
switch (info.itemType) {
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
|
||||
t.itemType = (instantAppResolver != null && info instanceof AppInfo
|
||||
&& instantAppResolver.isInstantApp(((AppInfo) info)) )
|
||||
&& instantAppResolver.isInstantApp(((AppInfo) info)))
|
||||
? ItemType.WEB_APP
|
||||
: ItemType.APP_ICON;
|
||||
t.predictedRank = DEFAULT_PREDICTED_RANK;
|
||||
|
||||
@@ -26,6 +26,8 @@ import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent;
|
||||
import static com.android.launcher3.logging.LoggerUtils.newTarget;
|
||||
import static com.android.launcher3.logging.LoggerUtils.newTouchAction;
|
||||
|
||||
import static java.util.Optional.ofNullable;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -59,7 +61,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* Manages the creation of {@link LauncherEvent}.
|
||||
* To debug this class, execute following command before side loading a new apk.
|
||||
*
|
||||
* <p>
|
||||
* $ adb shell setprop log.tag.UserEvent VERBOSE
|
||||
*/
|
||||
public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
@@ -95,6 +97,7 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
|
||||
/**
|
||||
* Fills in the container data on the given event if the given view is not null.
|
||||
*
|
||||
* @return whether container data was added.
|
||||
*/
|
||||
public boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) {
|
||||
@@ -146,7 +149,11 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
mAppOrTaskLaunch = true;
|
||||
}
|
||||
|
||||
public void logActionTip(int actionType, int viewType) { }
|
||||
/**
|
||||
* Dummy method.
|
||||
*/
|
||||
public void logActionTip(int actionType, int viewType) {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void logTaskLaunchOrDismiss(int action, int direction, int taskIndex,
|
||||
@@ -191,15 +198,15 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
|
||||
public void logActionCommand(int command, int srcContainerType, int dstContainerType) {
|
||||
logActionCommand(command, newContainerTarget(srcContainerType),
|
||||
dstContainerType >=0 ? newContainerTarget(dstContainerType) : null);
|
||||
dstContainerType >= 0 ? newContainerTarget(dstContainerType) : null);
|
||||
}
|
||||
|
||||
public void logActionCommand(int command, int srcContainerType, int dstContainerType,
|
||||
int pageIndex) {
|
||||
int pageIndex) {
|
||||
Target srcTarget = newContainerTarget(srcContainerType);
|
||||
srcTarget.pageIndex = pageIndex;
|
||||
logActionCommand(command, srcTarget,
|
||||
dstContainerType >=0 ? newContainerTarget(dstContainerType) : null);
|
||||
dstContainerType >= 0 ? newContainerTarget(dstContainerType) : null);
|
||||
}
|
||||
|
||||
public void logActionCommand(int command, Target srcTarget, Target dstTarget) {
|
||||
@@ -248,7 +255,7 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
}
|
||||
|
||||
public void logActionOnControl(int action, int controlType, int parentContainer,
|
||||
int grandParentContainer){
|
||||
int grandParentContainer) {
|
||||
LauncherEvent event = newLauncherEvent(newTouchAction(action),
|
||||
newControlTarget(controlType),
|
||||
newContainerTarget(parentContainer),
|
||||
@@ -257,11 +264,11 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
}
|
||||
|
||||
public void logActionOnControl(int action, int controlType, @Nullable View controlInContainer,
|
||||
int parentContainerType) {
|
||||
int parentContainerType) {
|
||||
final LauncherEvent event = (controlInContainer == null && parentContainerType < 0)
|
||||
? newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL))
|
||||
: newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL),
|
||||
newTarget(Target.Type.CONTAINER));
|
||||
newTarget(Target.Type.CONTAINER));
|
||||
event.srcTarget[0].controlType = controlType;
|
||||
if (controlInContainer != null) {
|
||||
fillInLogContainerData(event, controlInContainer);
|
||||
@@ -308,9 +315,9 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
* (1) WORKSPACE: if the launcher is the foreground activity
|
||||
* (2) APP: if another app was the foreground activity
|
||||
*/
|
||||
public void logStateChangeAction(int action, int dir, int downX, int downY, int srcChildTargetType,
|
||||
int srcParentContainerType, int dstContainerType,
|
||||
int pageIndex) {
|
||||
public void logStateChangeAction(int action, int dir, int downX, int downY,
|
||||
int srcChildTargetType, int srcParentContainerType, int dstContainerType,
|
||||
int pageIndex) {
|
||||
LauncherEvent event;
|
||||
if (srcChildTargetType == LauncherLogProto.ItemType.TASK) {
|
||||
event = newLauncherEvent(newTouchAction(action),
|
||||
@@ -333,9 +340,25 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
}
|
||||
|
||||
public void logActionOnItem(int action, int dir, int itemType) {
|
||||
logActionOnItem(action, dir, itemType, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new {@link LauncherEvent} of ITEM target type with input arguments and dispatches it.
|
||||
*
|
||||
* @param touchAction ENUM value of {@link LauncherLogProto.Action.Touch} Action
|
||||
* @param dir ENUM value of {@link LauncherLogProto.Action.Direction} Action
|
||||
* @param itemType ENUM value of {@link LauncherLogProto.ItemType}
|
||||
* @param gridX Nullable X coordinate of item's position on the workspace grid
|
||||
* @param gridY Nullable Y coordinate of item's position on the workspace grid
|
||||
*/
|
||||
public void logActionOnItem(int touchAction, int dir, int itemType,
|
||||
@Nullable Integer gridX, @Nullable Integer gridY) {
|
||||
Target itemTarget = newTarget(Target.Type.ITEM);
|
||||
itemTarget.itemType = itemType;
|
||||
LauncherEvent event = newLauncherEvent(newTouchAction(action), itemTarget);
|
||||
ofNullable(gridX).ifPresent(value -> itemTarget.gridX = value);
|
||||
ofNullable(gridY).ifPresent(value -> itemTarget.gridY = value);
|
||||
LauncherEvent event = newLauncherEvent(newTouchAction(touchAction), itemTarget);
|
||||
event.action.dir = dir;
|
||||
dispatchUserEvent(event, null);
|
||||
}
|
||||
@@ -358,7 +381,7 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP),
|
||||
newItemTarget(dragObj.originalDragInfo, mInstantAppResolver),
|
||||
newTarget(Target.Type.CONTAINER));
|
||||
event.destTarget = new Target[] {
|
||||
event.destTarget = new Target[]{
|
||||
newItemTarget(dragObj.originalDragInfo, mInstantAppResolver),
|
||||
newDropTarget(dropTargetAsView)
|
||||
};
|
||||
@@ -380,14 +403,10 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
int actionTouch = isButton ? Action.Touch.TAP : Action.Touch.SWIPE;
|
||||
Action action = newCommandAction(actionTouch);
|
||||
action.command = Action.Command.BACK;
|
||||
action.dir = isButton
|
||||
? Action.Direction.NONE
|
||||
: gestureSwipeLeft
|
||||
? Action.Direction.LEFT
|
||||
: Action.Direction.RIGHT;
|
||||
Target target = newControlTarget(isButton
|
||||
? LauncherLogProto.ControlType.BACK_BUTTON
|
||||
: LauncherLogProto.ControlType.BACK_GESTURE);
|
||||
action.dir = isButton ? Action.Direction.NONE :
|
||||
gestureSwipeLeft ? Action.Direction.LEFT : Action.Direction.RIGHT;
|
||||
Target target = newControlTarget(isButton ? LauncherLogProto.ControlType.BACK_BUTTON :
|
||||
LauncherLogProto.ControlType.BACK_GESTURE);
|
||||
target.spanX = downX;
|
||||
target.spanY = downY;
|
||||
target.cardinality = completed ? 1 : 0;
|
||||
@@ -398,6 +417,7 @@ public class UserEventDispatcher implements ResourceBasedOverride {
|
||||
|
||||
/**
|
||||
* Currently logs following containers: workspace, allapps, widget tray.
|
||||
*
|
||||
* @param reason
|
||||
*/
|
||||
public final void resetElapsedContainerMillis(String reason) {
|
||||
|
||||
Reference in New Issue
Block a user