diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java index 2b12b8c45f..73c73dae8e 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/Session.java @@ -24,7 +24,6 @@ import org.mozilla.geckoview.AllowOrDeny; import org.mozilla.geckoview.ContentBlocking; import org.mozilla.geckoview.GeckoDisplay; -import org.mozilla.geckoview.GeckoResponse; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoSession; @@ -1389,10 +1388,10 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin // GeckoSession.SelectionActionDelegate @Override - public void onShowActionRequest(@NonNull GeckoSession aSession, @NonNull Selection selection, @NonNull String[] strings, @NonNull GeckoResponse geckoResponse) { + public void onShowActionRequest(@NonNull GeckoSession aSession, @NonNull Selection selection) { if (mState.mSession == aSession) { for (GeckoSession.SelectionActionDelegate listener : mSelectionActionListeners) { - listener.onShowActionRequest(aSession, selection, strings, geckoResponse); + listener.onShowActionRequest(aSession, selection); } } } 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 00dea33960..217d82d2b4 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 @@ -50,7 +50,8 @@ import java.net.URI; import java.net.URL; import java.net.URLDecoder; -import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; import java.util.concurrent.Executor; import kotlin.Unit; @@ -555,7 +556,7 @@ public boolean onDoubleTapEvent(MotionEvent motionEvent) { }; private void showSelectionMenu() { - ArrayList actions = new ArrayList<>(); + Collection actions = new HashSet<>(); if (mBinding.urlEditText.getSelectionEnd() > mBinding.urlEditText.getSelectionStart()) { actions.add(GeckoSession.SelectionActionDelegate.ACTION_CUT); actions.add(GeckoSession.SelectionActionDelegate.ACTION_COPY); @@ -574,15 +575,14 @@ private void showSelectionMenu() { return; } - String[] actionsArray = actions.toArray(new String[0]); - if (mSelectionMenu != null && !mSelectionMenu.hasSameActions(actionsArray)) { + if (mSelectionMenu != null && !mSelectionMenu.hasSameActions(actions)) { // Release current selection menu to recreate it with different actions. hideSelectionMenu(); } if (mSelectionMenu == null) { mSelectionMenu = new SelectionActionWidget(getContext()); - mSelectionMenu.setActions(actionsArray); + mSelectionMenu.setActions(actions); mSelectionMenu.setDelegate(new SelectionActionWidget.Delegate() { @Override public void onAction(String action) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index d5d7a5c3ea..8a3bdd7d96 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -26,8 +26,6 @@ import androidx.annotation.UiThread; import org.jetbrains.annotations.NotNull; -import org.mozilla.geckoview.GeckoDisplay; -import org.mozilla.geckoview.GeckoResponse; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.PanZoomController; @@ -1631,10 +1629,10 @@ public void onSecurityChange(GeckoSession geckoSession, SecurityInformation secu // GeckoSession.SelectionActionDelegate @Override - public void onShowActionRequest(@NonNull GeckoSession aSession, @NonNull Selection aSelection, @NonNull String[] aActions, @NonNull GeckoResponse aResponse) { - if (aActions.length == 1 && GeckoSession.SelectionActionDelegate.ACTION_HIDE.equals(aActions[0])) { + public void onShowActionRequest(@NonNull GeckoSession aSession, @NonNull Selection aSelection) { + if (aSelection.availableActions.size() == 1 && (aSelection.availableActions.contains(GeckoSession.SelectionActionDelegate.ACTION_HIDE))) { // See: https://github.com/MozillaReality/FirefoxReality/issues/2214 - aResponse.respond(GeckoSession.SelectionActionDelegate.ACTION_HIDE); + aSelection.hide(); return; } TelemetryWrapper.longPressContextMenuEvent(); @@ -1642,7 +1640,7 @@ public void onShowActionRequest(@NonNull GeckoSession aSession, @NonNull Selecti hideContextMenus(); mSelectionMenu = new SelectionActionWidget(getContext()); mSelectionMenu.mWidgetPlacement.parentHandle = getHandle(); - mSelectionMenu.setActions(aActions); + mSelectionMenu.setActions(aSelection.availableActions); Matrix matrix = new Matrix(); aSession.getClientToSurfaceMatrix(matrix); matrix.mapRect(aSelection.clientRect); @@ -1651,13 +1649,13 @@ public void onShowActionRequest(@NonNull GeckoSession aSession, @NonNull Selecti @Override public void onAction(String action) { hideContextMenus(); - aResponse.respond(action); + aSelection.execute(action); } @Override public void onDismiss() { hideContextMenus(); - aResponse.respond(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT); + aSelection.execute(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT); } }); mSelectionMenu.show(KEEP_FOCUS); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SelectionActionWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SelectionActionWidget.java index f4d783f107..566a405be4 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SelectionActionWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SelectionActionWidget.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import static android.view.Gravity.CENTER_VERTICAL; @@ -34,7 +35,7 @@ public interface Delegate { private Point mPosition; private LinearLayout mContainer; private int mMinButtonWidth; - private String[] mActions; + private Collection mActions; public SelectionActionWidget(Context aContext) { super(aContext); @@ -103,21 +104,21 @@ public void setSelectionRect(@Nullable RectF aRect) { } } - public void setActions(@NonNull String[] aActions) { + public void setActions(@NonNull Collection aActions) { mActions = aActions; mContainer.removeAllViews(); ArrayList buttons = new ArrayList<>(); - if (StringUtils.contains(aActions, GeckoSession.SelectionActionDelegate.ACTION_CUT)) { + if (aActions.contains(GeckoSession.SelectionActionDelegate.ACTION_CUT)) { buttons.add(createButton(R.string.context_menu_cut_text, GeckoSession.SelectionActionDelegate.ACTION_CUT, this::handleAction)); } - if (StringUtils.contains(aActions, GeckoSession.SelectionActionDelegate.ACTION_COPY)) { + if (aActions.contains(GeckoSession.SelectionActionDelegate.ACTION_COPY)) { buttons.add(createButton(R.string.context_menu_copy_text, GeckoSession.SelectionActionDelegate.ACTION_COPY, this::handleAction)); } - if (StringUtils.contains(aActions, GeckoSession.SelectionActionDelegate.ACTION_PASTE)) { + if (aActions.contains(GeckoSession.SelectionActionDelegate.ACTION_PASTE)) { buttons.add(createButton(R.string.context_menu_paste_text, GeckoSession.SelectionActionDelegate.ACTION_PASTE, this::handleAction)); } - if (StringUtils.contains(aActions, GeckoSession.SelectionActionDelegate.ACTION_SELECT_ALL)) { + if (aActions.contains(GeckoSession.SelectionActionDelegate.ACTION_SELECT_ALL)) { buttons.add(createButton(R.string.context_menu_select_all_text, GeckoSession.SelectionActionDelegate.ACTION_SELECT_ALL, this::handleAction)); } @@ -140,11 +141,11 @@ public void setActions(@NonNull String[] aActions) { } public boolean hasAction(String aAction) { - return mActions != null && StringUtils.contains(mActions, aAction); + return mActions != null && mActions.contains(aAction); } - public boolean hasSameActions(@NonNull String[] aActions) { - return Arrays.deepEquals(mActions, aActions); + public boolean hasSameActions(@NonNull Collection aActions) { + return mActions.containsAll(aActions); } private UITextButton createButton(int aStringId, String aAction, OnClickListener aHandler) { diff --git a/versions.gradle b/versions.gradle index a67dfd9770..ff4bd5fded 100644 --- a/versions.gradle +++ b/versions.gradle @@ -24,7 +24,7 @@ ext.deps = [:] def versions = [:] // GeckoView versions can be found here: // https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/ -versions.gecko_view = "72.0.20191104094118" +versions.gecko_view = "72.0.20191118093852" versions.android_components = "19.0.1" versions.mozilla_speech = "1.0.6" versions.openwnn = "1.3.7"