Adding logging for various interaction in PinItemRequest UI
Bug: 34766840 Change-Id: Ib29d7d4b53ab99cdf3ff253976ef55345729487b
This commit is contained in:
parent
aeb60bffc9
commit
778634c818
|
@ -79,6 +79,7 @@ enum ContainerType {
|
||||||
PREDICTION = 7;
|
PREDICTION = 7;
|
||||||
SEARCHRESULT = 8;
|
SEARCHRESULT = 8;
|
||||||
DEEPSHORTCUTS = 9;
|
DEEPSHORTCUTS = 9;
|
||||||
|
PINITEM = 10; // confirmation screen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to define what type of control a Target would represent.
|
// Used to define what type of control a Target would represent.
|
||||||
|
@ -124,6 +125,10 @@ message Action {
|
||||||
enum Command {
|
enum Command {
|
||||||
HOME_INTENT = 0;
|
HOME_INTENT = 0;
|
||||||
BACK = 1;
|
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 Type type = 1;
|
||||||
optional Touch touch = 2;
|
optional Touch touch = 2;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.launcher3.IconCache;
|
import com.android.launcher3.IconCache;
|
||||||
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutInfo;
|
import com.android.launcher3.ShortcutInfo;
|
||||||
|
|
||||||
|
@ -61,6 +62,10 @@ public abstract class ShortcutConfigActivityInfo {
|
||||||
return mUser;
|
return mUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getItemType() {
|
||||||
|
return LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract CharSequence getLabel();
|
public abstract CharSequence getLabel();
|
||||||
|
|
||||||
public abstract Drawable getFullResIcon(IconCache cache);
|
public abstract Drawable getFullResIcon(IconCache cache);
|
||||||
|
|
|
@ -16,6 +16,11 @@
|
||||||
|
|
||||||
package com.android.launcher3.dragndrop;
|
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.annotation.TargetApi;
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.appwidget.AppWidgetHost;
|
import android.appwidget.AppWidgetHost;
|
||||||
|
@ -31,7 +36,9 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
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.BaseActivity;
|
||||||
import com.android.launcher3.InstallShortcutReceiver;
|
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.compat.PinItemRequestCompat;
|
||||||
import com.android.launcher3.model.WidgetItem;
|
import com.android.launcher3.model.WidgetItem;
|
||||||
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
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.PendingAddWidgetInfo;
|
||||||
import com.android.launcher3.widget.WidgetHostViewLoader;
|
import com.android.launcher3.widget.WidgetHostViewLoader;
|
||||||
import com.android.launcher3.widget.WidgetImageView;
|
import com.android.launcher3.widget.WidgetImageView;
|
||||||
|
@ -102,6 +112,12 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
|
||||||
|
|
||||||
mWidgetCell.setOnTouchListener(this);
|
mWidgetCell.setOnTouchListener(this);
|
||||||
mWidgetCell.setOnLongClickListener(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
|
@Override
|
||||||
|
@ -154,7 +170,10 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupShortcut() {
|
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.applyFromCellItem(item, mApp.getWidgetCache());
|
||||||
mWidgetCell.ensurePreview();
|
mWidgetCell.ensurePreview();
|
||||||
}
|
}
|
||||||
|
@ -177,6 +196,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
|
||||||
mWidgetOptions = WidgetHostViewLoader.getDefaultOptionsForWidget(this, mPendingWidgetInfo);
|
mWidgetOptions = WidgetHostViewLoader.getDefaultOptionsForWidget(this, mPendingWidgetInfo);
|
||||||
|
|
||||||
WidgetItem item = new WidgetItem(widgetInfo, getPackageManager(), mIdp);
|
WidgetItem item = new WidgetItem(widgetInfo, getPackageManager(), mIdp);
|
||||||
|
mWidgetCell.getWidgetView().setTag(mPendingWidgetInfo);
|
||||||
mWidgetCell.applyFromCellItem(item, mApp.getWidgetCache());
|
mWidgetCell.applyFromCellItem(item, mApp.getWidgetCache());
|
||||||
mWidgetCell.ensurePreview();
|
mWidgetCell.ensurePreview();
|
||||||
return true;
|
return true;
|
||||||
|
@ -186,6 +206,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
|
||||||
* Called when the cancel button is clicked.
|
* Called when the cancel button is clicked.
|
||||||
*/
|
*/
|
||||||
public void onCancelClick(View v) {
|
public void onCancelClick(View v) {
|
||||||
|
logCommand(Action.Command.CANCEL);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +217,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
|
||||||
if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) {
|
if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) {
|
||||||
InstallShortcutReceiver.queueShortcut(
|
InstallShortcutReceiver.queueShortcut(
|
||||||
new ShortcutInfoCompat(mRequest.getShortcutInfo()), this);
|
new ShortcutInfoCompat(mRequest.getShortcutInfo()), this);
|
||||||
|
logCommand(Action.Command.CONFIRM);
|
||||||
mRequest.accept();
|
mRequest.accept();
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
@ -223,9 +245,16 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
|
||||||
InstallShortcutReceiver.queueWidget(mRequest.getAppWidgetProviderInfo(this), widgetId, this);
|
InstallShortcutReceiver.queueWidget(mRequest.getAppWidgetProviderInfo(this), widgetId, this);
|
||||||
mWidgetOptions.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
|
mWidgetOptions.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
|
||||||
mRequest.accept(mWidgetOptions);
|
mRequest.accept(mWidgetOptions);
|
||||||
|
logCommand(Action.Command.CONFIRM);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
logCommand(Action.Command.BACK);
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == REQUEST_BIND_APPWIDGET) {
|
if (requestCode == REQUEST_BIND_APPWIDGET) {
|
||||||
|
@ -256,4 +285,11 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
|
||||||
mPendingBindWidgetId = savedInstanceState
|
mPendingBindWidgetId = savedInstanceState
|
||||||
.getInt(STATE_EXTRA_WIDGET_ID, mPendingBindWidgetId);
|
.getInt(STATE_EXTRA_WIDGET_ID, mPendingBindWidgetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logCommand(int command) {
|
||||||
|
getUserEventDispatcher().dispatchUserEvent(newLauncherEvent(
|
||||||
|
newCommandAction(command),
|
||||||
|
newItemTarget(mWidgetCell.getWidgetView()),
|
||||||
|
newContainerTarget(ContainerType.PINITEM)), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import com.android.launcher3.R;
|
||||||
import com.android.launcher3.compat.PinItemRequestCompat;
|
import com.android.launcher3.compat.PinItemRequestCompat;
|
||||||
import com.android.launcher3.folder.Folder;
|
import com.android.launcher3.folder.Folder;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
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.PendingAddShortcutInfo;
|
||||||
import com.android.launcher3.widget.PendingAddWidgetInfo;
|
import com.android.launcher3.widget.PendingAddWidgetInfo;
|
||||||
import com.android.launcher3.widget.PendingItemDragHelper;
|
import com.android.launcher3.widget.PendingItemDragHelper;
|
||||||
|
@ -240,7 +241,7 @@ public class PinItemDragListener
|
||||||
@Override
|
@Override
|
||||||
public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target,
|
public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target,
|
||||||
LauncherLogProto.Target targetParent) {
|
LauncherLogProto.Target targetParent) {
|
||||||
// TODO: We should probably log something
|
targetParent.containerType = ContainerType.PINITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postCleanup() {
|
private void postCleanup() {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import android.os.Build;
|
||||||
|
|
||||||
import com.android.launcher3.IconCache;
|
import com.android.launcher3.IconCache;
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
|
import com.android.launcher3.LauncherSettings;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
import com.android.launcher3.compat.PinItemRequestCompat;
|
import com.android.launcher3.compat.PinItemRequestCompat;
|
||||||
import com.android.launcher3.compat.ShortcutConfigActivityInfo;
|
import com.android.launcher3.compat.ShortcutConfigActivityInfo;
|
||||||
|
@ -54,6 +55,11 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemType() {
|
||||||
|
return LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getLabel() {
|
public CharSequence getLabel() {
|
||||||
return mInfo.getShortLabel();
|
return mInfo.getShortLabel();
|
||||||
|
|
|
@ -32,6 +32,6 @@ public class PendingAddShortcutInfo extends PendingAddItemInfo {
|
||||||
this.activityInfo = activityInfo;
|
this.activityInfo = activityInfo;
|
||||||
componentName = activityInfo.getComponent();
|
componentName = activityInfo.getComponent();
|
||||||
user = activityInfo.getUser();
|
user = activityInfo.getUser();
|
||||||
itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
|
itemType = activityInfo.getItemType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue