Merge "Log when App info or Widgets system shortcuts are tapped" into ub-launcher3-dorval-polish

This commit is contained in:
Tony Wickham
2017-05-25 21:40:15 +00:00
committed by Android (Google) Code Review
2 changed files with 24 additions and 6 deletions
@@ -21,6 +21,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;
@@ -90,7 +91,7 @@ public class UserEventDispatcher {
/**
* Recursively finds the parent of the given child which implements IconLogInfoProvider
*/
public static LogContainerProvider getLaunchProviderRecursive(View v) {
public static LogContainerProvider getLaunchProviderRecursive(@Nullable View v) {
ViewParent parent;
if (v != null) {
parent = v.getParent();
@@ -147,7 +148,11 @@ public class UserEventDispatcher {
return event;
}
public boolean fillInLogContainerData(LauncherEvent event, View v) {
/**
* Fills in the container data on the given event if the given view is not null.
* @return whether container data was added.
*/
private boolean fillInLogContainerData(LauncherEvent event, @Nullable View v) {
// Fill in grid(x,y), pageIndex of the child and container type of the parent
LogContainerProvider provider = getLaunchProviderRecursive(v);
if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) {
@@ -203,9 +208,16 @@ public class UserEventDispatcher {
}
public void logActionOnControl(int action, int controlType) {
LauncherEvent event = newLauncherEvent(
newTouchAction(action), newTarget(Target.Type.CONTROL));
logActionOnControl(action, controlType, null);
}
public void logActionOnControl(int action, int controlType, @Nullable View controlInContainer) {
final LauncherEvent event = controlInContainer == null
? newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL))
: newLauncherEvent(newTouchAction(action), newTarget(Target.Type.CONTROL),
newTarget(Target.Type.CONTAINER));
event.srcTarget[0].controlType = controlType;
fillInLogContainerData(event, controlInContainer);
dispatchUserEvent(event, null);
}
@@ -13,18 +13,20 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.Themes;
import com.android.launcher3.widget.WidgetsBottomSheet;
import java.util.List;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
/**
* Represents a system shortcut for a given app. The shortcut should have a static label and
* icon, and an onClickListener that depends on the item that the shortcut services.
*
* Example system shortcuts, defined as inner classes, include Widgets and AppInfo.
*/
public abstract class SystemShortcut {
public abstract class SystemShortcut extends ItemInfo {
private final int mIconResId;
private final int mLabelResId;
@@ -66,6 +68,8 @@ public abstract class SystemShortcut {
(WidgetsBottomSheet) launcher.getLayoutInflater().inflate(
R.layout.widgets_bottom_sheet, launcher.getDragLayer(), false);
widgetsBottomSheet.populateAndShow(itemInfo);
launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.WIDGETS_BUTTON, view);
}
};
}
@@ -85,6 +89,8 @@ public abstract class SystemShortcut {
Rect sourceBounds = launcher.getViewBounds(view);
Bundle opts = launcher.getActivityLaunchOptions(view);
InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, null, sourceBounds, opts);
launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.APPINFO_TARGET, view);
}
};
}