Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Displayed the context menu when double clicking on the URL bar (#2110)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and bluemarvin committed Nov 1, 2019
1 parent a0ec4bd commit 0500080
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -138,6 +137,9 @@ private void initialize(Context aContext) {
mBinding.setIsUrlEmpty(isUrlEmpty);
if (!focused) {
hideSelectionMenu();

} else {
mBinding.urlEditText.setSelection(mBinding.urlEditText.length(), 0);
}
});

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

Expand All @@ -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);
Expand Down Expand Up @@ -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<String> actions = new ArrayList<>();
if (mBinding.urlEditText.getSelectionEnd() > mBinding.urlEditText.getSelectionStart()) {
actions.add(GeckoSession.SelectionActionDelegate.ACTION_CUT);
Expand Down Expand Up @@ -598,7 +601,7 @@ public void onAction(String action) {
}
} else if (action.equals(GeckoSession.SelectionActionDelegate.ACTION_SELECT_ALL)) {
mBinding.urlEditText.selectAll();
handleLongPress();
showSelectionMenu();
return;

}
Expand Down

0 comments on commit 0500080

Please sign in to comment.