Fixes folder logging. am: b53764bd4b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/11902346 Change-Id: Ib9b34794311a41e0b54c19d1c0097f6d36680917
This commit is contained in:
commit
7fa1c8a25d
|
@ -34,6 +34,9 @@ import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.logger.LauncherAtom;
|
import com.android.launcher3.logger.LauncherAtom;
|
||||||
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.FolderIcon;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||||
import com.android.launcher3.logging.InstanceId;
|
import com.android.launcher3.logging.InstanceId;
|
||||||
import com.android.launcher3.logging.InstanceIdSequence;
|
import com.android.launcher3.logging.InstanceIdSequence;
|
||||||
import com.android.launcher3.logging.StatsLogManager;
|
import com.android.launcher3.logging.StatsLogManager;
|
||||||
|
@ -174,6 +177,9 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||||
private Optional<ContainerInfo> mContainerInfo = Optional.empty();
|
private Optional<ContainerInfo> mContainerInfo = Optional.empty();
|
||||||
private int mSrcState = LAUNCHER_UICHANGED__SRC_STATE__HOME;
|
private int mSrcState = LAUNCHER_UICHANGED__SRC_STATE__HOME;
|
||||||
private int mDstState = LAUNCHER_UICHANGED__DST_STATE__BACKGROUND;
|
private int mDstState = LAUNCHER_UICHANGED__DST_STATE__BACKGROUND;
|
||||||
|
private Optional<FromState> mFromState = Optional.empty();
|
||||||
|
private Optional<ToState> mToState = Optional.empty();
|
||||||
|
private Optional<String> mEditText = Optional.empty();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatsLogger withItemInfo(ItemInfo itemInfo) {
|
public StatsLogger withItemInfo(ItemInfo itemInfo) {
|
||||||
|
@ -219,26 +225,34 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatsLogger withFromState(FromState fromState) {
|
||||||
|
this.mFromState = Optional.of(fromState);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatsLogger withToState(ToState toState) {
|
||||||
|
this.mToState = Optional.of(toState);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatsLogger withEditText(String editText) {
|
||||||
|
this.mEditText = Optional.of(editText);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(EventEnum event) {
|
public void log(EventEnum event) {
|
||||||
if (!Utilities.ATLEAST_R) {
|
if (!Utilities.ATLEAST_R) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherAtom.ItemInfo.Builder itemInfoBuilder =
|
|
||||||
(LauncherAtom.ItemInfo.Builder) mItemInfo.buildProto().toBuilder();
|
|
||||||
mRank.ifPresent(itemInfoBuilder::setRank);
|
|
||||||
if (mContainerInfo.isPresent()) {
|
|
||||||
// User already provided container info;
|
|
||||||
// default container info from item info will be ignored.
|
|
||||||
itemInfoBuilder.setContainerInfo(mContainerInfo.get());
|
|
||||||
write(event, mInstanceId, itemInfoBuilder.build(), mSrcState, mDstState);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mItemInfo.container < 0) {
|
if (mItemInfo.container < 0) {
|
||||||
// Item is not within a folder. Write to StatsLog in same thread.
|
// Item is not within a folder. Write to StatsLog in same thread.
|
||||||
write(event, mInstanceId, itemInfoBuilder.build(), mSrcState, mDstState);
|
write(event, mInstanceId, applyOverwrites(mItemInfo.buildProto()), mSrcState,
|
||||||
|
mDstState);
|
||||||
} else {
|
} else {
|
||||||
// Item is inside the folder, fetch folder info in a BG thread
|
// Item is inside the folder, fetch folder info in a BG thread
|
||||||
// and then write to StatsLog.
|
// and then write to StatsLog.
|
||||||
|
@ -248,17 +262,33 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||||
public void execute(LauncherAppState app, BgDataModel dataModel,
|
public void execute(LauncherAppState app, BgDataModel dataModel,
|
||||||
AllAppsList apps) {
|
AllAppsList apps) {
|
||||||
FolderInfo folderInfo = dataModel.folders.get(mItemInfo.container);
|
FolderInfo folderInfo = dataModel.folders.get(mItemInfo.container);
|
||||||
LauncherAtom.ItemInfo.Builder atomInfoBuilder =
|
write(event, mInstanceId,
|
||||||
(LauncherAtom.ItemInfo.Builder) mItemInfo
|
applyOverwrites(mItemInfo.buildProto(folderInfo)),
|
||||||
.buildProto(folderInfo).toBuilder();
|
mSrcState, mDstState);
|
||||||
mRank.ifPresent(atomInfoBuilder::setRank);
|
|
||||||
write(event, mInstanceId, atomInfoBuilder.build(), mSrcState,
|
|
||||||
mDstState);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LauncherAtom.ItemInfo applyOverwrites(LauncherAtom.ItemInfo atomInfo) {
|
||||||
|
LauncherAtom.ItemInfo.Builder itemInfoBuilder =
|
||||||
|
(LauncherAtom.ItemInfo.Builder) atomInfo.toBuilder();
|
||||||
|
|
||||||
|
mRank.ifPresent(itemInfoBuilder::setRank);
|
||||||
|
mContainerInfo.ifPresent(itemInfoBuilder::setContainerInfo);
|
||||||
|
|
||||||
|
if (mFromState.isPresent() || mToState.isPresent() || mEditText.isPresent()) {
|
||||||
|
FolderIcon.Builder folderIconBuilder = (FolderIcon.Builder) itemInfoBuilder
|
||||||
|
.getFolderIcon()
|
||||||
|
.toBuilder();
|
||||||
|
mFromState.ifPresent(folderIconBuilder::setFromLabelState);
|
||||||
|
mToState.ifPresent(folderIconBuilder::setToLabelState);
|
||||||
|
mEditText.ifPresent(folderIconBuilder::setLabelInfo);
|
||||||
|
itemInfoBuilder.setFolderIcon(folderIconBuilder);
|
||||||
|
}
|
||||||
|
return itemInfoBuilder.build();
|
||||||
|
}
|
||||||
|
|
||||||
private void write(EventEnum event, InstanceId instanceId, LauncherAtom.ItemInfo atomInfo,
|
private void write(EventEnum event, InstanceId instanceId, LauncherAtom.ItemInfo atomInfo,
|
||||||
int srcState, int dstState) {
|
int srcState, int dstState) {
|
||||||
if (IS_VERBOSE) {
|
if (IS_VERBOSE) {
|
||||||
|
|
|
@ -415,7 +415,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||||
|
|
||||||
// Always enter the spring loaded mode
|
// Always enter the spring loaded mode
|
||||||
mLauncher.getStateManager().goToState(SPRING_LOADED);
|
mLauncher.getStateManager().goToState(SPRING_LOADED);
|
||||||
mStatsLogManager.logger().withItemInfo(dragObject.originalDragInfo)
|
mStatsLogManager.logger().withItemInfo(dragObject.dragInfo)
|
||||||
.withInstanceId(dragObject.logInstanceId)
|
.withInstanceId(dragObject.logInstanceId)
|
||||||
.log(LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
|
.log(LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,10 @@ import com.android.launcher3.dragndrop.DragController;
|
||||||
import com.android.launcher3.dragndrop.DragController.DragListener;
|
import com.android.launcher3.dragndrop.DragController.DragListener;
|
||||||
import com.android.launcher3.dragndrop.DragLayer;
|
import com.android.launcher3.dragndrop.DragLayer;
|
||||||
import com.android.launcher3.dragndrop.DragOptions;
|
import com.android.launcher3.dragndrop.DragOptions;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||||
import com.android.launcher3.logging.StatsLogManager;
|
import com.android.launcher3.logging.StatsLogManager;
|
||||||
|
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
|
||||||
import com.android.launcher3.model.data.AppInfo;
|
import com.android.launcher3.model.data.AppInfo;
|
||||||
import com.android.launcher3.model.data.FolderInfo;
|
import com.android.launcher3.model.data.FolderInfo;
|
||||||
import com.android.launcher3.model.data.FolderInfo.FolderListener;
|
import com.android.launcher3.model.data.FolderInfo.FolderListener;
|
||||||
|
@ -99,6 +102,7 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.StringJoiner;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,6 +113,12 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
View.OnFocusChangeListener, DragListener, ExtendedEditText.OnBackKeyListener {
|
View.OnFocusChangeListener, DragListener, ExtendedEditText.OnBackKeyListener {
|
||||||
private static final String TAG = "Launcher.Folder";
|
private static final String TAG = "Launcher.Folder";
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for separating folder title when logging together.
|
||||||
|
*/
|
||||||
|
private static final CharSequence FOLDER_LABEL_DELIMITER = "~";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We avoid measuring {@link #mContent} with a 0 width or height, as this
|
* We avoid measuring {@link #mContent} with a 0 width or height, as this
|
||||||
* results in CellLayout being measured as UNSPECIFIED, which it does not support.
|
* results in CellLayout being measured as UNSPECIFIED, which it does not support.
|
||||||
|
@ -155,6 +165,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
protected final Launcher mLauncher;
|
protected final Launcher mLauncher;
|
||||||
protected DragController mDragController;
|
protected DragController mDragController;
|
||||||
public FolderInfo mInfo;
|
public FolderInfo mInfo;
|
||||||
|
private CharSequence mFromTitle;
|
||||||
|
private FromState mFromLabelState;
|
||||||
|
|
||||||
@Thunk FolderIcon mFolderIcon;
|
@Thunk FolderIcon mFolderIcon;
|
||||||
|
|
||||||
|
@ -335,7 +347,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
Log.d(TAG, "onBackKey newTitle=" + newTitle);
|
Log.d(TAG, "onBackKey newTitle=" + newTitle);
|
||||||
}
|
}
|
||||||
mInfo.setTitle(newTitle);
|
mInfo.setTitle(newTitle);
|
||||||
mInfo.fromCustom = mInfo.hasOption(FLAG_MANUAL_FOLDER_NAME);
|
|
||||||
mInfo.setOption(FLAG_MANUAL_FOLDER_NAME, !mInfo.getAcceptedSuggestionIndex().isPresent(),
|
mInfo.setOption(FLAG_MANUAL_FOLDER_NAME, !mInfo.getAcceptedSuggestionIndex().isPresent(),
|
||||||
mLauncher.getModelWriter());
|
mLauncher.getModelWriter());
|
||||||
mFolderIcon.onTitleChanged(newTitle);
|
mFolderIcon.onTitleChanged(newTitle);
|
||||||
|
@ -415,6 +426,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
|
|
||||||
void bind(FolderInfo info) {
|
void bind(FolderInfo info) {
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
|
mFromTitle = info.title;
|
||||||
|
mFromLabelState = info.getFromLabelState();
|
||||||
ArrayList<WorkspaceItemInfo> children = info.contents;
|
ArrayList<WorkspaceItemInfo> children = info.contents;
|
||||||
Collections.sort(children, ITEM_POS_COMPARATOR);
|
Collections.sort(children, ITEM_POS_COMPARATOR);
|
||||||
updateItemLocationsInDatabaseBatch(true);
|
updateItemLocationsInDatabaseBatch(true);
|
||||||
|
@ -1442,10 +1455,38 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if (v == mFolderName) {
|
if (v == mFolderName) {
|
||||||
if (hasFocus) {
|
if (hasFocus) {
|
||||||
|
mFromLabelState = mInfo.getFromLabelState();
|
||||||
|
mFromTitle = mInfo.title;
|
||||||
startEditingFolderName();
|
startEditingFolderName();
|
||||||
} else {
|
} else {
|
||||||
mStatsLogManager.logger().withItemInfo(mInfo).log(LAUNCHER_FOLDER_LABEL_UPDATED);
|
StatsLogger statsLogger = mStatsLogManager.logger()
|
||||||
logFolderLabelState();
|
.withItemInfo(mInfo)
|
||||||
|
.withFromState(mFromLabelState);
|
||||||
|
|
||||||
|
// If the folder label is suggested, it is logged to improve prediction model.
|
||||||
|
// When both old and new labels are logged together delimiter is used.
|
||||||
|
StringJoiner labelInfoBuilder = new StringJoiner(FOLDER_LABEL_DELIMITER);
|
||||||
|
if (mFromLabelState.equals(FromState.FROM_SUGGESTED)) {
|
||||||
|
labelInfoBuilder.add(mFromTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
ToState toLabelState;
|
||||||
|
if (mFromTitle != null && mFromTitle.equals(mInfo.title)) {
|
||||||
|
toLabelState = ToState.UNCHANGED;
|
||||||
|
} else {
|
||||||
|
toLabelState = mInfo.getToLabelState();
|
||||||
|
if (toLabelState.toString().startsWith("TO_SUGGESTION")) {
|
||||||
|
labelInfoBuilder.add(mInfo.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statsLogger.withToState(toLabelState);
|
||||||
|
|
||||||
|
if (labelInfoBuilder.length() > 0) {
|
||||||
|
statsLogger.withEditText(labelInfoBuilder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
statsLogger.log(LAUNCHER_FOLDER_LABEL_UPDATED);
|
||||||
|
logFolderLabelState(mFromLabelState, toLabelState);
|
||||||
mFolderName.dispatchBackKey();
|
mFolderName.dispatchBackKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1650,8 +1691,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||||
* @deprecated This method is only used for log validation and soon will be removed.
|
* @deprecated This method is only used for log validation and soon will be removed.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void logFolderLabelState() {
|
public void logFolderLabelState(FromState fromState, ToState toState) {
|
||||||
mLauncher.getUserEventDispatcher()
|
mLauncher.getUserEventDispatcher()
|
||||||
.logLauncherEvent(mInfo.getFolderLabelStateLauncherEvent());
|
.logLauncherEvent(mInfo.getFolderLabelStateLauncherEvent(fromState, toState));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static android.text.TextUtils.isEmpty;
|
||||||
|
|
||||||
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
|
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
|
||||||
import static com.android.launcher3.folder.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION;
|
import static com.android.launcher3.folder.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION;
|
||||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_LABEL_UPDATED;
|
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_AUTO_LABELED;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
@ -63,6 +63,8 @@ import com.android.launcher3.dragndrop.DragLayer;
|
||||||
import com.android.launcher3.dragndrop.DragView;
|
import com.android.launcher3.dragndrop.DragView;
|
||||||
import com.android.launcher3.dragndrop.DraggableView;
|
import com.android.launcher3.dragndrop.DraggableView;
|
||||||
import com.android.launcher3.icons.DotRenderer;
|
import com.android.launcher3.icons.DotRenderer;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||||
import com.android.launcher3.logging.InstanceId;
|
import com.android.launcher3.logging.InstanceId;
|
||||||
import com.android.launcher3.logging.StatsLogManager;
|
import com.android.launcher3.logging.StatsLogManager;
|
||||||
import com.android.launcher3.model.data.AppInfo;
|
import com.android.launcher3.model.data.AppInfo;
|
||||||
|
@ -428,7 +430,6 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||||
mPreviewItemManager.hidePreviewItem(finalIndex, false);
|
mPreviewItemManager.hidePreviewItem(finalIndex, false);
|
||||||
mFolder.showItem(item);
|
mFolder.showItem(item);
|
||||||
setLabelSuggestion(nameInfos, instanceId);
|
setLabelSuggestion(nameInfos, instanceId);
|
||||||
mFolder.logFolderLabelState();
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}, DROP_IN_ANIMATION_DURATION);
|
}, DROP_IN_ANIMATION_DURATION);
|
||||||
}
|
}
|
||||||
|
@ -447,12 +448,25 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||||
if (nameInfos == null || nameInfos[0] == null || isEmpty(nameInfos[0].getLabel())) {
|
if (nameInfos == null || nameInfos[0] == null || isEmpty(nameInfos[0].getLabel())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mInfo.setTitle(nameInfos[0].getLabel());
|
CharSequence newTitle = nameInfos[0].getLabel();
|
||||||
StatsLogManager.newInstance(getContext()).logger().withItemInfo(mInfo)
|
FromState fromState = mInfo.getFromLabelState();
|
||||||
.withInstanceId(instanceId).log(LAUNCHER_FOLDER_LABEL_UPDATED);
|
|
||||||
|
mInfo.setTitle(newTitle);
|
||||||
onTitleChanged(mInfo.title);
|
onTitleChanged(mInfo.title);
|
||||||
mFolder.mFolderName.setText(mInfo.title);
|
mFolder.mFolderName.setText(mInfo.title);
|
||||||
mFolder.mLauncher.getModelWriter().updateItemInDatabase(mInfo);
|
mFolder.mLauncher.getModelWriter().updateItemInDatabase(mInfo);
|
||||||
|
|
||||||
|
// Logging for folder creation flow
|
||||||
|
StatsLogManager.newInstance(getContext()).logger()
|
||||||
|
.withInstanceId(instanceId)
|
||||||
|
.withItemInfo(mInfo)
|
||||||
|
.withFromState(fromState)
|
||||||
|
.withToState(ToState.TO_SUGGESTION0)
|
||||||
|
// When LAUNCHER_FOLDER_LABEL_UPDATED event.edit_text does not have delimiter,
|
||||||
|
// event is assumed to be folder creation on the server side.
|
||||||
|
.withEditText(newTitle.toString())
|
||||||
|
.log(LAUNCHER_FOLDER_AUTO_LABELED);
|
||||||
|
mFolder.logFolderLabelState(fromState, ToState.TO_SUGGESTION0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||||
|
import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||||
import com.android.launcher3.logging.StatsLogUtils.LogStateProvider;
|
import com.android.launcher3.logging.StatsLogUtils.LogStateProvider;
|
||||||
import com.android.launcher3.model.data.ItemInfo;
|
import com.android.launcher3.model.data.ItemInfo;
|
||||||
import com.android.launcher3.util.ResourceBasedOverride;
|
import com.android.launcher3.util.ResourceBasedOverride;
|
||||||
|
@ -66,8 +68,10 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||||
+ "resulting in a new folder creation")
|
+ "resulting in a new folder creation")
|
||||||
LAUNCHER_ITEM_DROP_FOLDER_CREATED(386),
|
LAUNCHER_ITEM_DROP_FOLDER_CREATED(386),
|
||||||
|
|
||||||
@UiEvent(doc = "User action resulted in or manually updated the folder label to "
|
@UiEvent(doc = "Folder's label is automatically assigned.")
|
||||||
+ "new/same value.")
|
LAUNCHER_FOLDER_AUTO_LABELED(591),
|
||||||
|
|
||||||
|
@UiEvent(doc = "User manually updated the folder label.")
|
||||||
LAUNCHER_FOLDER_LABEL_UPDATED(460),
|
LAUNCHER_FOLDER_LABEL_UPDATED(460),
|
||||||
|
|
||||||
@UiEvent(doc = "User long pressed on the workspace empty space.")
|
@UiEvent(doc = "User long pressed on the workspace empty space.")
|
||||||
|
@ -245,6 +249,27 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets FromState field of log message.
|
||||||
|
*/
|
||||||
|
default StatsLogger withFromState(FromState fromState) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets ToState field of log message.
|
||||||
|
*/
|
||||||
|
default StatsLogger withToState(ToState toState) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets editText field of log message.
|
||||||
|
*/
|
||||||
|
default StatsLogger withEditText(String editText) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the final value for container related fields of log message.
|
* Sets the final value for container related fields of log message.
|
||||||
*
|
*
|
||||||
|
|
|
@ -54,7 +54,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.StringJoiner;
|
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,20 +87,6 @@ public class FolderInfo extends ItemInfo {
|
||||||
|
|
||||||
public Intent suggestedFolderNames;
|
public Intent suggestedFolderNames;
|
||||||
|
|
||||||
// Represents the title before current.
|
|
||||||
// Primarily used for logging purpose.
|
|
||||||
private CharSequence mPreviousTitle;
|
|
||||||
|
|
||||||
// True if the title before was manually entered, suggested otherwise.
|
|
||||||
// Primarily used for logging purpose.
|
|
||||||
public boolean fromCustom;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for separating {@link #mPreviousTitle} and {@link #title} when concatenating them
|
|
||||||
* for logging.
|
|
||||||
*/
|
|
||||||
private static final CharSequence FOLDER_LABEL_DELIMITER = "=>";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The apps and shortcuts
|
* The apps and shortcuts
|
||||||
*/
|
*/
|
||||||
|
@ -207,21 +192,16 @@ public class FolderInfo extends ItemInfo {
|
||||||
return getDefaultItemInfoBuilder()
|
return getDefaultItemInfoBuilder()
|
||||||
.setFolderIcon(LauncherAtom.FolderIcon.newBuilder().setCardinality(contents.size()))
|
.setFolderIcon(LauncherAtom.FolderIcon.newBuilder().setCardinality(contents.size()))
|
||||||
.setRank(rank)
|
.setRank(rank)
|
||||||
.setAttribute(fromCustom ? MANUAL_LABEL : SUGGESTED_LABEL)
|
.setAttribute(hasOption(FLAG_MANUAL_FOLDER_NAME) ? MANUAL_LABEL : SUGGESTED_LABEL)
|
||||||
.setContainerInfo(getContainerInfo())
|
.setContainerInfo(getContainerInfo())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(CharSequence title) {
|
public void setTitle(CharSequence title) {
|
||||||
mPreviousTitle = this.title;
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharSequence getPreviousTitle() {
|
|
||||||
return mPreviousTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemInfo makeShallowCopy() {
|
public ItemInfo makeShallowCopy() {
|
||||||
FolderInfo folderInfo = new FolderInfo();
|
FolderInfo folderInfo = new FolderInfo();
|
||||||
|
@ -235,30 +215,7 @@ public class FolderInfo extends ItemInfo {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LauncherAtom.ItemInfo buildProto() {
|
public LauncherAtom.ItemInfo buildProto() {
|
||||||
FromState fromFolderLabelState = getFromFolderLabelState();
|
return buildProto(null);
|
||||||
ToState toFolderLabelState = getToFolderLabelState();
|
|
||||||
LauncherAtom.FolderIcon.Builder folderIconBuilder = LauncherAtom.FolderIcon.newBuilder()
|
|
||||||
.setCardinality(contents.size())
|
|
||||||
.setFromLabelState(fromFolderLabelState)
|
|
||||||
.setToLabelState(toFolderLabelState);
|
|
||||||
|
|
||||||
// If the folder label is suggested, it is logged to improve prediction model.
|
|
||||||
// When both old and new labels are logged together delimiter is used.
|
|
||||||
StringJoiner labelInfoBuilder = new StringJoiner(FOLDER_LABEL_DELIMITER);
|
|
||||||
if (fromFolderLabelState.equals(FromState.FROM_SUGGESTED)) {
|
|
||||||
labelInfoBuilder.add(mPreviousTitle);
|
|
||||||
}
|
|
||||||
if (toFolderLabelState.toString().startsWith("TO_SUGGESTION")) {
|
|
||||||
labelInfoBuilder.add(title);
|
|
||||||
}
|
|
||||||
if (labelInfoBuilder.length() > 0) {
|
|
||||||
folderIconBuilder.setLabelInfo(labelInfoBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDefaultItemInfoBuilder()
|
|
||||||
.setFolderIcon(folderIconBuilder)
|
|
||||||
.setContainerInfo(getContainerInfo())
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,15 +237,27 @@ public class FolderInfo extends ItemInfo {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LauncherAtom.ToState getToFolderLabelState() {
|
/**
|
||||||
|
* Returns {@link FromState} based on current {@link #title}.
|
||||||
|
*/
|
||||||
|
public LauncherAtom.FromState getFromLabelState() {
|
||||||
|
return title == null
|
||||||
|
? LauncherAtom.FromState.FROM_STATE_UNSPECIFIED
|
||||||
|
: title.length() == 0
|
||||||
|
? LauncherAtom.FromState.FROM_EMPTY
|
||||||
|
: hasOption(FLAG_MANUAL_FOLDER_NAME)
|
||||||
|
? LauncherAtom.FromState.FROM_CUSTOM
|
||||||
|
: LauncherAtom.FromState.FROM_SUGGESTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@link ToState} based on current {@link #title}.
|
||||||
|
*/
|
||||||
|
public LauncherAtom.ToState getToLabelState() {
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
return LauncherAtom.ToState.TO_STATE_UNSPECIFIED;
|
return LauncherAtom.ToState.TO_STATE_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title.equals(mPreviousTitle)) {
|
|
||||||
return LauncherAtom.ToState.UNCHANGED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
if (!FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||||
return title.length() > 0
|
return title.length() > 0
|
||||||
? LauncherAtom.ToState.TO_CUSTOM_WITH_SUGGESTIONS_DISABLED
|
? LauncherAtom.ToState.TO_CUSTOM_WITH_SUGGESTIONS_DISABLED
|
||||||
|
@ -335,17 +304,6 @@ public class FolderInfo extends ItemInfo {
|
||||||
// fall through
|
// fall through
|
||||||
}
|
}
|
||||||
return LauncherAtom.ToState.TO_STATE_UNSPECIFIED;
|
return LauncherAtom.ToState.TO_STATE_UNSPECIFIED;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private LauncherAtom.FromState getFromFolderLabelState() {
|
|
||||||
return mPreviousTitle == null
|
|
||||||
? LauncherAtom.FromState.FROM_STATE_UNSPECIFIED
|
|
||||||
: mPreviousTitle.length() == 0
|
|
||||||
? LauncherAtom.FromState.FROM_EMPTY
|
|
||||||
: fromCustom
|
|
||||||
? LauncherAtom.FromState.FROM_CUSTOM
|
|
||||||
: LauncherAtom.FromState.FROM_SUGGESTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<String[]> getSuggestedLabels() {
|
private Optional<String[]> getSuggestedLabels() {
|
||||||
|
@ -368,7 +326,8 @@ public class FolderInfo extends ItemInfo {
|
||||||
* @deprecated This method is used only for validation purpose and soon will be removed.
|
* @deprecated This method is used only for validation purpose and soon will be removed.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public LauncherLogProto.LauncherEvent getFolderLabelStateLauncherEvent() {
|
public LauncherLogProto.LauncherEvent getFolderLabelStateLauncherEvent(FromState fromState,
|
||||||
|
ToState toState) {
|
||||||
return LauncherLogProto.LauncherEvent.newBuilder()
|
return LauncherLogProto.LauncherEvent.newBuilder()
|
||||||
.setAction(LauncherLogProto.Action
|
.setAction(LauncherLogProto.Action
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
|
@ -377,8 +336,8 @@ public class FolderInfo extends ItemInfo {
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.setType(Target.Type.ITEM)
|
.setType(Target.Type.ITEM)
|
||||||
.setItemType(LauncherLogProto.ItemType.EDITTEXT)
|
.setItemType(LauncherLogProto.ItemType.EDITTEXT)
|
||||||
.setFromFolderLabelState(convertFolderLabelState(getFromFolderLabelState()))
|
.setFromFolderLabelState(convertFolderLabelState(fromState))
|
||||||
.setToFolderLabelState(convertFolderLabelState(getToFolderLabelState())))
|
.setToFolderLabelState(convertFolderLabelState(toState)))
|
||||||
.addSrcTarget(Target.newBuilder()
|
.addSrcTarget(Target.newBuilder()
|
||||||
.setType(Target.Type.CONTAINER)
|
.setType(Target.Type.CONTAINER)
|
||||||
.setContainerType(LauncherLogProto.ContainerType.FOLDER)
|
.setContainerType(LauncherLogProto.ContainerType.FOLDER)
|
||||||
|
|
Loading…
Reference in New Issue