diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-03-21 11:59:04 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-03-22 16:47:21 -0700 |
commit | 778634c81870ae2013907950a98bb7793802e6c7 (patch) | |
tree | 541bc8177418b23c59753bf095dd67d001bcaba5 /src/com/android/launcher3/dragndrop | |
parent | aeb60bffc9a5a9a45bac59b189f9d448b1c63320 (diff) | |
download | android_packages_apps_Trebuchet-778634c81870ae2013907950a98bb7793802e6c7.tar.gz android_packages_apps_Trebuchet-778634c81870ae2013907950a98bb7793802e6c7.tar.bz2 android_packages_apps_Trebuchet-778634c81870ae2013907950a98bb7793802e6c7.zip |
Adding logging for various interaction in PinItemRequest UI
Bug: 34766840
Change-Id: Ib29d7d4b53ab99cdf3ff253976ef55345729487b
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
3 files changed, 46 insertions, 3 deletions
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java index c2a4820c8..6b27a9992 100644 --- a/src/com/android/launcher3/dragndrop/AddItemActivity.java +++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java @@ -16,6 +16,11 @@ package com.android.launcher3.dragndrop; +import static com.android.launcher3.logging.LoggerUtils.newCommandAction; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; +import static com.android.launcher3.logging.LoggerUtils.newItemTarget; +import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent; + import android.annotation.TargetApi; import android.app.ActivityOptions; import android.appwidget.AppWidgetHost; @@ -31,7 +36,9 @@ import android.os.Build; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; -import android.view.View.*; +import android.view.View.DragShadowBuilder; +import android.view.View.OnLongClickListener; +import android.view.View.OnTouchListener; import com.android.launcher3.BaseActivity; import com.android.launcher3.InstallShortcutReceiver; @@ -44,6 +51,9 @@ import com.android.launcher3.compat.AppWidgetManagerCompat; import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.model.WidgetItem; import com.android.launcher3.shortcuts.ShortcutInfoCompat; +import com.android.launcher3.userevent.nano.LauncherLogProto.Action; +import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; +import com.android.launcher3.widget.PendingAddShortcutInfo; import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.WidgetHostViewLoader; import com.android.launcher3.widget.WidgetImageView; @@ -102,6 +112,12 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener mWidgetCell.setOnTouchListener(this); mWidgetCell.setOnLongClickListener(this); + + // savedInstanceState is null when the activity is created the first time (i.e., avoids + // duplicate logging during rotation) + if (savedInstanceState == null) { + logCommand(Action.Command.ENTRY); + } } @Override @@ -154,7 +170,10 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener } private void setupShortcut() { - WidgetItem item = new WidgetItem(new PinShortcutRequestActivityInfo(mRequest, this)); + PinShortcutRequestActivityInfo shortcutInfo = + new PinShortcutRequestActivityInfo(mRequest, this); + WidgetItem item = new WidgetItem(shortcutInfo); + mWidgetCell.getWidgetView().setTag(new PendingAddShortcutInfo(shortcutInfo)); mWidgetCell.applyFromCellItem(item, mApp.getWidgetCache()); mWidgetCell.ensurePreview(); } @@ -177,6 +196,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener mWidgetOptions = WidgetHostViewLoader.getDefaultOptionsForWidget(this, mPendingWidgetInfo); WidgetItem item = new WidgetItem(widgetInfo, getPackageManager(), mIdp); + mWidgetCell.getWidgetView().setTag(mPendingWidgetInfo); mWidgetCell.applyFromCellItem(item, mApp.getWidgetCache()); mWidgetCell.ensurePreview(); return true; @@ -186,6 +206,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener * Called when the cancel button is clicked. */ public void onCancelClick(View v) { + logCommand(Action.Command.CANCEL); finish(); } @@ -196,6 +217,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) { InstallShortcutReceiver.queueShortcut( new ShortcutInfoCompat(mRequest.getShortcutInfo()), this); + logCommand(Action.Command.CONFIRM); mRequest.accept(); finish(); return; @@ -223,10 +245,17 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener InstallShortcutReceiver.queueWidget(mRequest.getAppWidgetProviderInfo(this), widgetId, this); mWidgetOptions.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId); mRequest.accept(mWidgetOptions); + logCommand(Action.Command.CONFIRM); finish(); } @Override + public void onBackPressed() { + logCommand(Action.Command.BACK); + super.onBackPressed(); + } + + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_BIND_APPWIDGET) { int widgetId = data != null @@ -256,4 +285,11 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener mPendingBindWidgetId = savedInstanceState .getInt(STATE_EXTRA_WIDGET_ID, mPendingBindWidgetId); } + + private void logCommand(int command) { + getUserEventDispatcher().dispatchUserEvent(newLauncherEvent( + newCommandAction(command), + newItemTarget(mWidgetCell.getWidgetView()), + newContainerTarget(ContainerType.PINITEM)), null); + } } diff --git a/src/com/android/launcher3/dragndrop/PinItemDragListener.java b/src/com/android/launcher3/dragndrop/PinItemDragListener.java index fd252a26a..dfc65660e 100644 --- a/src/com/android/launcher3/dragndrop/PinItemDragListener.java +++ b/src/com/android/launcher3/dragndrop/PinItemDragListener.java @@ -42,6 +42,7 @@ import com.android.launcher3.R; import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.folder.Folder; import com.android.launcher3.userevent.nano.LauncherLogProto; +import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.widget.PendingAddShortcutInfo; import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.PendingItemDragHelper; @@ -240,7 +241,7 @@ public class PinItemDragListener @Override public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, LauncherLogProto.Target targetParent) { - // TODO: We should probably log something + targetParent.containerType = ContainerType.PINITEM; } private void postCleanup() { diff --git a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java index 6a8c19f4b..26460d776 100644 --- a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java +++ b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java @@ -27,6 +27,7 @@ import android.os.Build; import com.android.launcher3.IconCache; import com.android.launcher3.LauncherAppState; +import com.android.launcher3.LauncherSettings; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.compat.ShortcutConfigActivityInfo; @@ -55,6 +56,11 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo { } @Override + public int getItemType() { + return LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; + } + + @Override public CharSequence getLabel() { return mInfo.getShortLabel(); } |