Skip to content

Commit

Permalink
Dismiss context menu when scrolling (MozillaReality#2271)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and Alexandre Lissy committed Jan 21, 2020
1 parent 9c37fc0 commit 7fa1e4b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ default void onSyncBookmarks(@NonNull View view) {}
default void onFxALogin(@NonNull View view) {}
default void onFxASynSettings(@NonNull View view) {}
default void onShowContextMenu(@NonNull View view, Bookmark item, boolean isLastVisibleItem) {}
default void onHideContextMenu(@NonNull View view) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ default void onSyncHistory(@NonNull View view) {}
default void onFxALogin(@NonNull View view) {}
default void onFxASynSettings(@NonNull View view) {}
default void onShowContextMenu(@NonNull View view, @NonNull VisitInfo item, boolean isLastVisibleItem) {}
default void onHideContextMenu(@NonNull View view) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private void initialize(Context aContext) {
v.requestFocusFromTouch();
return false;
});
mBinding.bookmarksList.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> mBookmarksViewListeners.forEach((listener) -> listener.onHideContextMenu(v)));
mBinding.bookmarksList.setHasFixedSize(true);
mBinding.bookmarksList.setItemViewCacheSize(20);
mBinding.bookmarksList.setDrawingCacheEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private void initialize(Context aContext) {
v.requestFocusFromTouch();
return false;
});
mBinding.historyList.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> mHistoryViewListeners.forEach((listener) -> listener.onHideContextMenu(v)));
mBinding.historyList.setHasFixedSize(true);
mBinding.historyList.setItemViewCacheSize(20);
mBinding.historyList.setDrawingCacheEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,11 @@ public void onShowContextMenu(@NonNull View view, @NotNull Bookmark item, boolea
public void onFxASynSettings(@NonNull View view) {
mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA);
}

@Override
public void onHideContextMenu(@NonNull View view) {
hideContextMenus();
}
};

private HistoryCallback mHistoryListener = new HistoryCallback() {
Expand All @@ -1414,6 +1419,11 @@ public void onShowContextMenu(@NonNull View view, @NonNull VisitInfo item, boole
public void onFxASynSettings(@NonNull View view) {
mWidgetManager.getTray().toggleSettingsDialog(SettingsWidget.SettingDialog.FXA);
}

@Override
public void onHideContextMenu(@NonNull View view) {
hideContextMenus();
}
};

private void hideContextMenus() {
Expand Down

0 comments on commit 7fa1e4b

Please sign in to comment.