Adding logging for various interaction in PinItemRequest UI

Bug: 34766840
Change-Id: Ib29d7d4b53ab99cdf3ff253976ef55345729487b
This commit is contained in:
Sunny Goyal 2017-03-21 11:59:04 -07:00
parent aeb60bffc9
commit 778634c818
6 changed files with 57 additions and 4 deletions

View File

@ -79,6 +79,7 @@ enum ContainerType {
PREDICTION = 7;
SEARCHRESULT = 8;
DEEPSHORTCUTS = 9;
PINITEM = 10; // confirmation screen
}
// Used to define what type of control a Target would represent.
@ -124,6 +125,10 @@ message Action {
enum Command {
HOME_INTENT = 0;
BACK = 1;
ENTRY = 2; // Indicates entry to one of Launcher container type target
// not using the HOME_INTENT
CANCEL = 3; // Indicates that a confirmation screen was cancelled
CONFIRM = 4; // Indicates thata confirmation screen was accepted
}
optional Type type = 1;
optional Touch touch = 2;

View File

@ -33,6 +33,7 @@ import android.util.Log;
import android.widget.Toast;
import com.android.launcher3.IconCache;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
@ -61,6 +62,10 @@ public abstract class ShortcutConfigActivityInfo {
return mUser;
}
public int getItemType() {
return LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
}
public abstract CharSequence getLabel();
public abstract Drawable getFullResIcon(IconCache cache);

View File

@ -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,9 +245,16 @@ 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) {
@ -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);
}
}

View File

@ -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() {

View File

@ -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;
@ -54,6 +55,11 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
mContext = context;
}
@Override
public int getItemType() {
return LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
}
@Override
public CharSequence getLabel() {
return mInfo.getShortLabel();

View File

@ -32,6 +32,6 @@ public class PendingAddShortcutInfo extends PendingAddItemInfo {
this.activityInfo = activityInfo;
componentName = activityInfo.getComponent();
user = activityInfo.getUser();
itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
itemType = activityInfo.getItemType();
}
}