From 050008004523c3707ac9159654ba71cb0de5b6c4 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Fri, 1 Nov 2019 20:08:12 +0100 Subject: [PATCH] Displayed the context menu when double clicking on the URL bar (#2110) --- .../vrbrowser/ui/views/NavigationURLBar.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java index 9122e0279..720535bf8 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java @@ -29,7 +29,6 @@ import androidx.annotation.StringRes; import androidx.databinding.DataBindingUtil; -import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.geckoview.GeckoSession; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.audio.AudioEngine; @@ -138,6 +137,9 @@ private void initialize(Context aContext) { mBinding.setIsUrlEmpty(isUrlEmpty); if (!focused) { hideSelectionMenu(); + + } else { + mBinding.urlEditText.setSelection(mBinding.urlEditText.length(), 0); } }); @@ -187,7 +189,7 @@ private void initialize(Context aContext) { } // Add some delay so selection ranges are ready - ThreadUtils.postDelayedToUiThread(this::handleLongPress, 10); + postDelayed(this::showSelectionMenu, 10); return true; }); @@ -198,7 +200,7 @@ private void initialize(Context aContext) { boolean hasCopy = mSelectionMenu.hasAction(GeckoSession.SelectionActionDelegate.ACTION_COPY); boolean showCopy = end > start; if (hasCopy != showCopy) { - handleLongPress(); + showSelectionMenu(); } else { mDelegate.onLongPress(getSelectionCenterX(), mSelectionMenu); @@ -539,11 +541,12 @@ public boolean onDoubleTap(MotionEvent motionEvent) { @Override public boolean onDoubleTapEvent(MotionEvent motionEvent) { mBinding.urlEditText.selectAll(); + showSelectionMenu(); return true; } }; - private void handleLongPress() { + private void showSelectionMenu() { ArrayList actions = new ArrayList<>(); if (mBinding.urlEditText.getSelectionEnd() > mBinding.urlEditText.getSelectionStart()) { actions.add(GeckoSession.SelectionActionDelegate.ACTION_CUT); @@ -598,7 +601,7 @@ public void onAction(String action) { } } else if (action.equals(GeckoSession.SelectionActionDelegate.ACTION_SELECT_ALL)) { mBinding.urlEditText.selectAll(); - handleLongPress(); + showSelectionMenu(); return; }