summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2017-02-07 19:05:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-02-07 19:05:40 +0000
commit00002d02f5147e8c2943f6d19e65f99d07ba3709 (patch)
tree69f9d8ac55778064172b672b3689e1dbf0bfe9c8 /src/com/android/launcher3
parentd097f475e8c2e7b7af8403ef89f25c373808bc51 (diff)
parentc6b79e307f59e936ee380da07b0bd6fafe0a490c (diff)
downloadandroid_packages_apps_Trebuchet-00002d02f5147e8c2943f6d19e65f99d07ba3709.tar.gz
android_packages_apps_Trebuchet-00002d02f5147e8c2943f6d19e65f99d07ba3709.tar.bz2
android_packages_apps_Trebuchet-00002d02f5147e8c2943f6d19e65f99d07ba3709.zip
Merge "Add logging for notifications." into ub-launcher3-master
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java2
-rw-r--r--src/com/android/launcher3/logging/UserEventDispatcher.java27
-rw-r--r--src/com/android/launcher3/notification/NotificationInfo.java1
-rw-r--r--src/com/android/launcher3/notification/NotificationItemView.java16
-rw-r--r--src/com/android/launcher3/notification/NotificationMainView.java12
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java2
-rw-r--r--src/com/android/launcher3/popup/PopupPopulator.java1
7 files changed, 48 insertions, 13 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index e31c8ffdd..7410ae6c9 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -582,8 +582,8 @@ public class DragController implements DragDriver.EventListener, TouchController
}
}
final View dropTargetAsView = dropTarget instanceof View ? (View) dropTarget : null;
- mLauncher.getUserEventDispatcher().logDragNDrop(mDragObject, dropTargetAsView);
if (!mIsInPreDrag) {
+ mLauncher.getUserEventDispatcher().logDragNDrop(mDragObject, dropTargetAsView);
mDragObject.dragSource.onDropCompleted(
dropTargetAsView, mDragObject, flingAnimation != null, accepted);
}
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 8ab33dc57..b4b62a864 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -16,6 +16,7 @@
package com.android.launcher3.logging;
+import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Intent;
import android.os.SystemClock;
@@ -112,7 +113,7 @@ public class UserEventDispatcher {
// intentHash required
// --------------------------------------------------------------
- protected LauncherEvent createLauncherEvent(View v, Intent intent) {
+ protected LauncherEvent createLauncherEvent(View v, int intentHashCode, ComponentName cn) {
LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP),
newItemTarget(v), newTarget(Target.Type.CONTAINER));
@@ -120,8 +121,7 @@ public class UserEventDispatcher {
int idx = 0;
if (fillInLogContainerData(event, v)) {
ItemInfo itemInfo = (ItemInfo) v.getTag();
- event.srcTarget[idx].intentHash = intent.hashCode();
- ComponentName cn = intent.getComponent();
+ event.srcTarget[idx].intentHash = intentHashCode;
if (cn != null) {
event.srcTarget[idx].packageNameHash = cn.getPackageName().hashCode();
event.srcTarget[idx].componentHash = cn.hashCode();
@@ -146,13 +146,22 @@ public class UserEventDispatcher {
}
public void logAppLaunch(View v, Intent intent) {
- LauncherEvent ev = createLauncherEvent(v, intent);
+ LauncherEvent ev = createLauncherEvent(v, intent.hashCode(), intent.getComponent());
if (ev == null) {
return;
}
dispatchUserEvent(ev, intent);
}
+ public void logNotificationLaunch(View v, PendingIntent intent) {
+ ComponentName dummyComponent = new ComponentName(intent.getCreatorPackage(), "--dummy--");
+ LauncherEvent ev = createLauncherEvent(v, intent.hashCode(), dummyComponent);
+ if (ev == null) {
+ return;
+ }
+ dispatchUserEvent(ev, null);
+ }
+
public void logActionCommand(int command, int containerType) {
logActionCommand(command, containerType, 0);
}
@@ -199,9 +208,17 @@ public class UserEventDispatcher {
dispatchUserEvent(event, null);
}
+ public void logActionOnItem(int action, int dir, int itemType) {
+ Target itemTarget = newTarget(Target.Type.ITEM);
+ itemTarget.itemType = itemType;
+ LauncherEvent event = newLauncherEvent(newTouchAction(action), itemTarget);
+ event.action.dir = dir;
+ dispatchUserEvent(event, null);
+ }
+
public void logDeepShortcutsOpen(View icon) {
LogContainerProvider provider = getLaunchProviderRecursive(icon);
- if (icon == null && !(icon.getTag() instanceof ItemInfo)) {
+ if (icon == null || !(icon.getTag() instanceof ItemInfo)) {
return;
}
ItemInfo info = (ItemInfo) icon.getTag();
diff --git a/src/com/android/launcher3/notification/NotificationInfo.java b/src/com/android/launcher3/notification/NotificationInfo.java
index 73cba28df..77a18c732 100644
--- a/src/com/android/launcher3/notification/NotificationInfo.java
+++ b/src/com/android/launcher3/notification/NotificationInfo.java
@@ -94,6 +94,7 @@ public class NotificationInfo implements View.OnClickListener {
view, 0, 0, view.getWidth(), view.getHeight()).toBundle();
try {
intent.send(null, 0, null, null, null, null, activityOptions);
+ launcher.getUserEventDispatcher().logNotificationLaunch(view, intent);
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
diff --git a/src/com/android/launcher3/notification/NotificationItemView.java b/src/com/android/launcher3/notification/NotificationItemView.java
index 422722d8c..639447dc3 100644
--- a/src/com/android/launcher3/notification/NotificationItemView.java
+++ b/src/com/android/launcher3/notification/NotificationItemView.java
@@ -29,15 +29,16 @@ import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.TextView;
+import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
import com.android.launcher3.graphics.IconPalette;
+import com.android.launcher3.logging.UserEventDispatcher.LogContainerProvider;
import com.android.launcher3.popup.PopupItemView;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import static com.android.launcher3.LauncherAnimUtils.animateViewHeight;
@@ -47,7 +48,7 @@ import static com.android.launcher3.LauncherAnimUtils.animateViewHeight;
* The footer contains: A list of just the icons of all the notifications past the first one.
* @see NotificationFooterLayout
*/
-public class NotificationItemView extends PopupItemView {
+public class NotificationItemView extends PopupItemView implements LogContainerProvider {
private static final Rect sTempRect = new Rect();
@@ -57,7 +58,6 @@ public class NotificationItemView extends PopupItemView {
private NotificationFooterLayout mFooter;
private SwipeHelper mSwipeHelper;
private boolean mAnimatingNextIcon;
- private IconPalette mIconPalette;
public NotificationItemView(Context context) {
this(context, null, 0);
@@ -114,7 +114,6 @@ public class NotificationItemView extends PopupItemView {
}
public void applyColors(IconPalette iconPalette) {
- mIconPalette = iconPalette;
setBackgroundTintList(ColorStateList.valueOf(iconPalette.secondaryColor));
mHeader.setBackgroundTintList(ColorStateList.valueOf(iconPalette.backgroundColor));
mHeader.setTextColor(ColorStateList.valueOf(iconPalette.textColor));
@@ -174,4 +173,11 @@ public class NotificationItemView extends PopupItemView {
animation.playSequentially(removeMainView, removeRest);
return animation;
}
+
+ @Override
+ public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target,
+ LauncherLogProto.Target targetParent) {
+ target.itemType = LauncherLogProto.ItemType.NOTIFICATION;
+ targetParent.containerType = LauncherLogProto.ContainerType.DEEPSHORTCUTS;
+ }
}
diff --git a/src/com/android/launcher3/notification/NotificationMainView.java b/src/com/android/launcher3/notification/NotificationMainView.java
index 7fed608fe..6677c2fa2 100644
--- a/src/com/android/launcher3/notification/NotificationMainView.java
+++ b/src/com/android/launcher3/notification/NotificationMainView.java
@@ -26,11 +26,13 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
+import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.LauncherViewPropertyAnimator;
import com.android.launcher3.R;
import com.android.launcher3.graphics.IconPalette;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
/**
* A {@link LinearLayout} that contains a single notification, e.g. icon + title + text.
@@ -88,6 +90,9 @@ public class NotificationMainView extends LinearLayout implements SwipeHelper.Ca
getContext(), mIconPalette.backgroundColor));
setOnClickListener(mNotificationInfo);
setTranslationX(0);
+ // Add a dummy ItemInfo so that logging populates the correct container and item types
+ // instead of DEFAULT_CONTAINERTYPE and DEFAULT_ITEMTYPE, respectively.
+ setTag(new ItemInfo());
if (animate) {
AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
Animator textFade = new LauncherViewPropertyAnimator(mTextView).alpha(1);
@@ -134,8 +139,13 @@ public class NotificationMainView extends LinearLayout implements SwipeHelper.Ca
@Override
public void onChildDismissed(View v) {
- Launcher.getLauncher(getContext()).getPopupDataProvider().cancelNotification(
+ Launcher launcher = Launcher.getLauncher(getContext());
+ launcher.getPopupDataProvider().cancelNotification(
mNotificationInfo.notificationKey);
+ launcher.getUserEventDispatcher().logActionOnItem(
+ LauncherLogProto.Action.Touch.SWIPE,
+ LauncherLogProto.Action.Direction.RIGHT, // Assume all swipes are right for logging.
+ LauncherLogProto.ItemType.NOTIFICATION);
}
@Override
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index af1bd9b34..b8e2dc8a8 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -696,7 +696,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView
@Override
public void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent) {
target.itemType = ItemType.DEEPSHORTCUT;
- // TODO: add target.rank
+ target.rank = info.rank;
targetParent.containerType = ContainerType.DEEPSHORTCUTS;
}
diff --git a/src/com/android/launcher3/popup/PopupPopulator.java b/src/com/android/launcher3/popup/PopupPopulator.java
index f990fa2d8..d2814ee7b 100644
--- a/src/com/android/launcher3/popup/PopupPopulator.java
+++ b/src/com/android/launcher3/popup/PopupPopulator.java
@@ -171,6 +171,7 @@ public class PopupPopulator {
// Use unbadged icon for the menu.
si.iconBitmap = LauncherIcons.createShortcutIcon(
shortcut, launcher, false /* badged */);
+ si.rank = i;
uiHandler.post(new UpdateShortcutChild(container, shortcutViews.get(i),
si, shortcut));
}