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
This commit is contained in:
parent
1e4a43ac67
commit
03f27013bf
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue