Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f95f1529 authored by thiruram's avatar thiruram
Browse files

Add LAUNCHER_FOLDER_LABEL_CHANGED events for folder label updates.

Sample Logs for all update combinations: https://docs.google.com/document/d/1CBP2yTcXdFhPdNG5ZmWFKSgd8mDbMevY-akVlUXPLDo/edit#bookmark=id.7y1p8n2dz8ge

Bug: 155410872
Bug: 152978018
Change-Id: I296b124b16aa07878f2cf7b74ab91f13b8e6cfbf
parent 77f5efe1
Loading
Loading
Loading
Loading
+32 −24
Original line number Diff line number Diff line
@@ -99,13 +99,14 @@ message FolderIcon {
  optional int32 cardinality = 1;

  // State of the folder label before the event.
  optional FromState from_state = 2;
  optional FromState from_label_state = 2;

  // State of the folder label after the event.
  optional ToState to_state = 3;
  optional ToState to_label_state = 3;

  // Populated only when folder label was suggested.
  optional string label = 4;
  // Details about actual folder label.
  // Populated when folder label is not a PII.
  optional string label_info = 4;
}

//////////////////////////////////////////////
@@ -131,70 +132,77 @@ message FolderContainer {
  }
}

// Represents state of FolderLabel before editing.
// Represents state of EditText field before update.
enum FromState {
  // Default value.
  // Used when a FromState is not applicable, for example, during folder creation.
  FROM_STATE_UNSPECIFIED = 0;

  // FolderLabel was empty.
  // EditText was empty.
  // Eg: When a folder label is updated from empty string.
  FROM_EMPTY = 1;

  // FolderLabel was non-empty and manually entered by the user.
  // EditText was non-empty and manually entered by the user.
  // Eg: When a folder label is updated from a user-entered value.
  FROM_CUSTOM = 2;

  // FolderLabel was non-empty and one of the suggestions.
  // EditText was non-empty and one of the suggestions.
  // Eg: When a folder label is updated from a suggested value.
  FROM_SUGGESTED = 3;
}

// Represents state of FolderLabel after editing.
// Represents state of EditText field after update.
enum ToState {
  // Default value.
  // Used when ToState is not applicable, for example, when folder label is updated to a different
  // value when folder label suggestion feature is disabled.
  TO_STATE_UNSPECIFIED = 0;
  // User attempted to change the folder label, but was not changed.

  // User attempted to change the EditText, but was not changed.
  UNCHANGED = 1;

  // New label matches with primary(aka top) suggestion.
  TO_SUGGESTION0 = 2;

  // New label matches with second top suggestion even though the top suggestion was non-empty.
  // New value matches with second top suggestion even though the top suggestion was non-empty.
  TO_SUGGESTION1_WITH_VALID_PRIMARY = 3;

  // New label matches with second top suggestion given that top suggestion was empty.
  // New value matches with second top suggestion given that top suggestion was empty.
  TO_SUGGESTION1_WITH_EMPTY_PRIMARY = 4;

  // New label matches with third top suggestion even though the top suggestion was non-empty.
  // New value matches with third top suggestion even though the top suggestion was non-empty.
  TO_SUGGESTION2_WITH_VALID_PRIMARY = 5;

  // New label matches with third top suggestion given that top suggestion was empty.
  // New value matches with third top suggestion given that top suggestion was empty.
  TO_SUGGESTION2_WITH_EMPTY_PRIMARY = 6;

  // New label matches with 4th top suggestion even though the top suggestion was non-empty.
  // New value matches with 4th top suggestion even though the top suggestion was non-empty.
  TO_SUGGESTION3_WITH_VALID_PRIMARY = 7;

  // New label matches with 4th top suggestion given that top suggestion was empty.
  // New value matches with 4th top suggestion given that top suggestion was empty.
  TO_SUGGESTION3_WITH_EMPTY_PRIMARY = 8;

  // New label is empty even though the top suggestion was non-empty.
  // New value is empty even though the top suggestion was non-empty.
  TO_EMPTY_WITH_VALID_PRIMARY = 9;

  // New label is empty given that top suggestion was empty.
  // New value is empty given that top suggestion was empty.
  TO_EMPTY_WITH_VALID_SUGGESTIONS_AND_EMPTY_PRIMARY = 10;

  // New label is empty given that no suggestions were provided.
  // New value is empty given that no suggestions were provided.
  TO_EMPTY_WITH_EMPTY_SUGGESTIONS = 11;

  // New label is empty given that suggestions feature was disabled.
  // New value is empty given that suggestions feature was disabled.
  TO_EMPTY_WITH_SUGGESTIONS_DISABLED = 12;

  // New label is non-empty and does not match with any of the suggestions even though the top suggestion was non-empty.
  // New value is non-empty and does not match with any of the suggestions even though the top suggestion was non-empty.
  TO_CUSTOM_WITH_VALID_PRIMARY = 13;

  // New label is non-empty and not match with any suggestions given that top suggestion was empty.
  // New value is non-empty and not match with any suggestions given that top suggestion was empty.
  TO_CUSTOM_WITH_VALID_SUGGESTIONS_AND_EMPTY_PRIMARY = 14;

  // New label is non-empty and also no suggestions were provided.
  // New value is non-empty and also no suggestions were provided.
  TO_CUSTOM_WITH_EMPTY_SUGGESTIONS = 15;

  // New label is non-empty and also suggestions feature was disable.
  // New value is non-empty and also suggestions feature was disable.
  TO_CUSTOM_WITH_SUGGESTIONS_DISABLED = 16;
}
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class HotseatEduController {
        if (!putIntoFolder.isEmpty()) {
            ItemInfo firstItem = putIntoFolder.get(0);
            FolderInfo folderInfo = new FolderInfo();
            folderInfo.title = "";
            folderInfo.setTitle("");
            mLauncher.getModelWriter().addItemToDatabase(folderInfo, firstItem.container,
                    firstItem.screenId, firstItem.cellX, firstItem.cellY);
            folderInfo.contents.addAll(putIntoFolder);
+22 −6
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
import static com.android.launcher3.config.FeatureFlags.ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_LABEL_UPDATED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED;
import static com.android.launcher3.model.data.FolderInfo.FLAG_MANUAL_FOLDER_NAME;

import static java.util.Arrays.asList;
@@ -196,6 +198,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
    @Thunk int mScrollHintDir = SCROLL_NONE;
    @Thunk int mCurrentScrollDir = SCROLL_NONE;

    private StatsLogManager mStatsLogManager;

    /**
     * Used to inflate the Workspace from XML.
@@ -208,10 +211,12 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        setAlwaysDrawnWithCacheEnabled(false);

        mLauncher = Launcher.getLauncher(context);
        mStatsLogManager = StatsLogManager.newInstance(context);
        // We need this view to be focusable in touch mode so that when text editing of the folder
        // name is complete, we have something to focus on, thus hiding the cursor and giving
        // reliable behavior when clicking the text field (since it will always gain focus on click).
        setFocusableInTouchMode(true);

    }

    @Override
@@ -329,8 +334,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        if (DEBUG) {
            Log.d(TAG, "onBackKey newTitle=" + newTitle);
        }
        mInfo.previousTitle = mInfo.title;
        mInfo.title = newTitle;
        mInfo.setTitle(newTitle);
        mInfo.fromCustom = mInfo.hasOption(FLAG_MANUAL_FOLDER_NAME);
        mInfo.setOption(FLAG_MANUAL_FOLDER_NAME, !mInfo.getAcceptedSuggestionIndex().isPresent(),
                mLauncher.getModelWriter());
        mFolderIcon.onTitleChanged(newTitle);
@@ -1326,10 +1331,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        if (d.stateAnnouncer != null) {
            d.stateAnnouncer.completeAction(R.string.item_moved);
        }
        StatsLogManager.newInstance(getContext())
                .log(StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
                    d.logInstanceId,
                    d.dragInfo.buildProto(mInfo));
        mStatsLogManager
                .log(LAUNCHER_ITEM_DROP_COMPLETED, d.logInstanceId, d.dragInfo.buildProto(mInfo));
    }

    // This is used so the item doesn't immediately appear in the folder when added. In one case
@@ -1434,6 +1437,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
            if (hasFocus) {
                startEditingFolderName();
            } else {
                mStatsLogManager.log(LAUNCHER_FOLDER_LABEL_UPDATED, mInfo.buildProto());
                logFolderLabelState();
                mFolderName.dispatchBackKey();
            }
        }
@@ -1631,4 +1636,15 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
    public FolderPagedView getContent() {
        return mContent;
    }

    /**
     * Logs current folder label info.
     *
     * @deprecated This method is only used for log validation and soon will be removed.
     */
    @Deprecated
    public void logFolderLabelState() {
        mLauncher.getUserEventDispatcher()
                .logLauncherEvent(mInfo.getFolderLabelStateLauncherEvent());
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -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.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_LABEL_CHANGED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_LABEL_UPDATED;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -429,6 +429,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
            mPreviewItemManager.hidePreviewItem(finalIndex, false);
            mFolder.showItem(item);
            setLabelSuggestion(nameInfos, instanceId);
            mFolder.logFolderLabelState();
            invalidate();
        }, DROP_IN_ANIMATION_DURATION);
    }
@@ -447,10 +448,9 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
        if (nameInfos == null || nameInfos[0] == null || isEmpty(nameInfos[0].getLabel())) {
            return;
        }
        mInfo.previousTitle = mInfo.title;
        mInfo.title = nameInfos[0].getLabel();
        mInfo.setTitle(nameInfos[0].getLabel());
        StatsLogManager.newInstance(getContext())
                .log(LAUNCHER_FOLDER_LABEL_CHANGED, instanceId, mInfo.getFolderIconAtom());
                .log(LAUNCHER_FOLDER_LABEL_UPDATED, instanceId, mInfo.buildProto());
        onTitleChanged(mInfo.title);
        mFolder.mFolderName.setText(mInfo.title);
        mFolder.mLauncher.getModelWriter().updateItemInDatabase(mInfo);
+3 −3
Original line number Diff line number Diff line
@@ -57,9 +57,9 @@ public class StatsLogManager implements ResourceBasedOverride {
                + "resulting in a new folder creation")
        LAUNCHER_ITEM_DROP_FOLDER_CREATED(386),

        @LauncherUiEvent(doc = "A dragged launcher item is successfully dropped on another item "
                + "resulting in new folder creation")
        LAUNCHER_FOLDER_LABEL_CHANGED(460),
        @LauncherUiEvent(doc = "User action resulted in or manually updated the folder label to "
                + "new/same value.")
        LAUNCHER_FOLDER_LABEL_UPDATED(460),

        @LauncherUiEvent(doc = "A dragged item is dropped on 'Remove' button in the target bar")
        LAUNCHER_ITEM_DROPPED_ON_REMOVE(465),
Loading