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:
Tony Wickham
2019-04-25 14:22:54 -07:00
parent 1e4a43ac67
commit 03f27013bf
3 changed files with 19 additions and 7 deletions

View File

@@ -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);
}
}