summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/dragndrop
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-03-30 19:02:25 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-30 19:02:25 +0000
commit4f209caed5d174a9d9e4c88fd6e7afcea5e7ea2e (patch)
treea1759e11afa252effcbef063056d96b2dbd19059 /src/com/android/launcher3/dragndrop
parent8ac5a9058e4711997f347f8c9ce499f0640fd5ec (diff)
parentc5c9cae70da1dbf05668258cbd4cbf50a36f0e26 (diff)
downloadandroid_packages_apps_Trebuchet-4f209caed5d174a9d9e4c88fd6e7afcea5e7ea2e.tar.gz
android_packages_apps_Trebuchet-4f209caed5d174a9d9e4c88fd6e7afcea5e7ea2e.tar.bz2
android_packages_apps_Trebuchet-4f209caed5d174a9d9e4c88fd6e7afcea5e7ea2e.zip
Merge "Adding logging for various interaction in PinItemRequest UI" into ub-launcher3-dorval
am: c5c9cae70d Change-Id: I0be49e2a81b9ee284230672c368a03f3aaef7916
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
-rw-r--r--src/com/android/launcher3/dragndrop/AddItemActivity.java36
-rw-r--r--src/com/android/launcher3/dragndrop/PinItemDragListener.java3
-rw-r--r--src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java6
3 files changed, 43 insertions, 2 deletions
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index 187e6d93d..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;
@@ -46,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;
@@ -104,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
@@ -156,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();
}
@@ -179,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;
@@ -188,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();
}
@@ -198,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;
@@ -225,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
@@ -258,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();
}