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

Commit 03f27013 authored by Tony Wickham's avatar Tony Wickham
Browse files

Log undo button click

Also fix a bug where we logged workspace swipe upon clicking undo, since
rebinding the pages causes us to reset mCurrentPage = 0 followed by
setCurrentPage(pageBoundFirst). Since the page isn't actually visibly
changing, we shouldn't log in that case.

Bug: 118758133
Change-Id: Ie87164a8c7c278680f67dee75657210bd33408a4
parent 1e4a43ac
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.launcher3;

import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP;
import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType.UNDO;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -121,8 +124,12 @@ public class DeleteDropTarget extends ButtonDropTarget {
            int itemPage = mLauncher.getWorkspace().getCurrentPage();
            onAccessibilityDrop(null, item);
            ModelWriter modelWriter = mLauncher.getModelWriter();
            Runnable onUndoClicked = () -> {
                modelWriter.abortDelete(itemPage);
                mLauncher.getUserEventDispatcher().logActionOnControl(TAP, UNDO);
            };
            Snackbar.show(mLauncher, R.string.item_removed, R.string.undo,
                    modelWriter::commitDelete, () -> modelWriter.abortDelete(itemPage));
                    modelWriter::commitDelete, onUndoClicked);
        }
    }

+5 −4
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.animation.OvershootInterpolator;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.allapps.AllAppsContainerView;
@@ -150,9 +152,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.function.Predicate;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;

/**
 * Default launcher application.
 */
@@ -2198,7 +2197,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
                InstallShortcutReceiver.FLAG_LOADER_RUNNING, this);

        // When undoing the removal of the last item on a page, return to that page.
        mWorkspace.setCurrentPage(pageBoundFirst);
        // Since we are just resetting the current page without user interaction,
        // override the previous page so we don't log the page switch.
        mWorkspace.setCurrentPage(pageBoundFirst, pageBoundFirst /* overridePrevPage */);

        TraceHelper.endSection("finishBindingItems");
    }
+6 −2
Original line number Diff line number Diff line
@@ -300,10 +300,14 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        return page;
    }

    public void setCurrentPage(int currentPage) {
        setCurrentPage(currentPage, INVALID_PAGE);
    }

    /**
     * Sets the current page.
     */
    public void setCurrentPage(int currentPage) {
    public void setCurrentPage(int currentPage, int overridePrevPage) {
        if (!mScroller.isFinished()) {
            abortScrollerAnimation(true);
        }
@@ -312,7 +316,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        if (getChildCount() == 0) {
            return;
        }
        int prevPage = mCurrentPage;
        int prevPage = overridePrevPage != INVALID_PAGE ? overridePrevPage : mCurrentPage;
        mCurrentPage = validateNewPage(currentPage);
        updateCurrentPageScroll();
        notifyPageSwitchListener(prevPage);