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

Commit

Permalink
Upgrade GeckoView to 72.0.20191118093852 (#2306)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin authored and MortimerGoro committed Nov 18, 2019
1 parent 6f898f0 commit 23b599a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> 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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -555,7 +556,7 @@ public boolean onDoubleTapEvent(MotionEvent motionEvent) {
};

private void showSelectionMenu() {
ArrayList<String> actions = new ArrayList<>();
Collection<String> actions = new HashSet<>();
if (mBinding.urlEditText.getSelectionEnd() > mBinding.urlEditText.getSelectionStart()) {
actions.add(GeckoSession.SelectionActionDelegate.ACTION_CUT);
actions.add(GeckoSession.SelectionActionDelegate.ACTION_COPY);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1631,18 +1629,18 @@ public void onSecurityChange(GeckoSession geckoSession, SecurityInformation secu
// GeckoSession.SelectionActionDelegate

@Override
public void onShowActionRequest(@NonNull GeckoSession aSession, @NonNull Selection aSelection, @NonNull String[] aActions, @NonNull GeckoResponse<String> 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();

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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import static android.view.Gravity.CENTER_VERTICAL;

Expand All @@ -34,7 +35,7 @@ public interface Delegate {
private Point mPosition;
private LinearLayout mContainer;
private int mMinButtonWidth;
private String[] mActions;
private Collection<String> mActions;

public SelectionActionWidget(Context aContext) {
super(aContext);
Expand Down Expand Up @@ -103,21 +104,21 @@ public void setSelectionRect(@Nullable RectF aRect) {
}
}

public void setActions(@NonNull String[] aActions) {
public void setActions(@NonNull Collection<String> aActions) {
mActions = aActions;
mContainer.removeAllViews();
ArrayList<UITextButton> 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));
}

Expand All @@ -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<String> aActions) {
return (mActions != null) && mActions.containsAll(aActions) && (mActions.size() == aActions.size());
}

private UITextButton createButton(int aStringId, String aAction, OnClickListener aHandler) {
Expand Down
2 changes: 1 addition & 1 deletion versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 23b599a

Please sign in to comment.