summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/logging/LoggerUtils.java
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-09-01 12:47:12 -0700
committerHyunyoung Song <hyunyoungs@google.com>2016-09-01 12:47:12 -0700
commit59a238095e82fd02355f4cb53abe01655a50b051 (patch)
tree59aed70bde91588fff3a51c2940c42fb814d6d07 /src/com/android/launcher3/logging/LoggerUtils.java
parent4a4b49ff3482cbe7f8192807cdc99437810fe518 (diff)
downloadandroid_packages_apps_Trebuchet-59a238095e82fd02355f4cb53abe01655a50b051.tar.gz
android_packages_apps_Trebuchet-59a238095e82fd02355f4cb53abe01655a50b051.tar.bz2
android_packages_apps_Trebuchet-59a238095e82fd02355f4cb53abe01655a50b051.zip
Support user event logging for drag and drop
b/30039490 Supported in this CL: - DnD: drag from container [WORKSPACE|HOTSEAT|FOLDER|ALLAPPS|WIDGETS|DEEPSHORTCUTS] drag to container [HOTSEAT,WORKSPACE,FOLDER,DROPTARGETS] - Source and target can be [FOLDER_ICON, ICON, DEEPSHORTCUT, WIDGET] - $ adb shell setprop log.tag.UserEvent DEBUG will turn on debugging Change-Id: I0b8b879b80e6dce85bbde6e7794f9e0677832603
Diffstat (limited to 'src/com/android/launcher3/logging/LoggerUtils.java')
-rw-r--r--src/com/android/launcher3/logging/LoggerUtils.java63
1 files changed, 57 insertions, 6 deletions
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java
index dc045977d..845dbc2bc 100644
--- a/src/com/android/launcher3/logging/LoggerUtils.java
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -2,8 +2,12 @@ package com.android.launcher3.logging;
import android.view.View;
+import com.android.launcher3.ButtonDropTarget;
+import com.android.launcher3.DeleteDropTarget;
+import com.android.launcher3.InfoDropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
+import com.android.launcher3.UninstallDropTarget;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -164,14 +168,35 @@ public class LoggerUtils {
return event;
}
- private static Target initTarget(View v) {
+ /**
+ * Used for drag and drop interaction.
+ */
+ public static LauncherLogProto.LauncherEvent initLauncherEvent(
+ int actionType,
+ View v,
+ ItemInfo info,
+ int parentSrcTargetType,
+ View parentDestTargetType){
+ LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent();
+
+ event.srcTarget = new LauncherLogProto.Target[2];
+ event.srcTarget[0] = initTarget(v, info);
+ event.srcTarget[1] = new LauncherLogProto.Target();
+ event.srcTarget[1].type = parentSrcTargetType;
+
+ event.destTarget = new LauncherLogProto.Target[2];
+ event.destTarget[0] = initTarget(v, info);
+ event.destTarget[1] = initDropTarget(parentDestTargetType);
+
+ event.action = new LauncherLogProto.Action();
+ event.action.type = actionType;
+ return event;
+ }
+
+ private static Target initTarget(View v, ItemInfo info) {
Target t = new LauncherLogProto.Target();
t.type = Target.ITEM;
- if (!(v.getTag() instanceof ItemInfo)) {
- return t;
- }
- ItemInfo itemInfo = (ItemInfo) v.getTag();
- switch (itemInfo.itemType) {
+ switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
t.itemType = LauncherLogProto.APP_ICON;
break;
@@ -190,4 +215,30 @@ public class LoggerUtils {
}
return t;
}
+
+ private static Target initDropTarget(View v) {
+ Target t = new LauncherLogProto.Target();
+ t.type = (v instanceof ButtonDropTarget)? Target.CONTROL : Target.CONTAINER;
+ if (t.type == Target.CONTAINER) {
+ return t;
+ }
+
+ if (v instanceof InfoDropTarget) {
+ t.controlType = LauncherLogProto.APPINFO_TARGET;
+ } else if (v instanceof UninstallDropTarget) {
+ t.controlType = LauncherLogProto.UNINSTALL_TARGET;
+ } else if (v instanceof DeleteDropTarget) {
+ t.controlType = LauncherLogProto.REMOVE_TARGET;
+ }
+ return t;
+ }
+
+ private static Target initTarget(View v) {
+ Target t = new LauncherLogProto.Target();
+ t.type = Target.ITEM;
+ if (!(v.getTag() instanceof ItemInfo)) {
+ return t;
+ }
+ return initTarget(v, (ItemInfo) v.getTag());
+ }
}