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

Fix Selection Action menu alignment on the Awesome Bar #2331

Merged
merged 1 commit into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -97,7 +98,7 @@ public interface NavigationURLBarDelegate {
void onVoiceSearchClicked();
void onShowAwesomeBar();
void onHideAwesomeBar();
void onLongPress(float centerX, SelectionActionWidget actionMenu);
void onURLSelectionAction(EditText aURLEdit, float centerX, SelectionActionWidget actionMenu);
void onPopUpButtonClicked();
}

Expand Down Expand Up @@ -206,7 +207,7 @@ private void initialize(Context aContext) {
showSelectionMenu();

} else {
mDelegate.onLongPress(getSelectionCenterX(), mSelectionMenu);
mDelegate.onURLSelectionAction(mBinding.urlEditText, getSelectionCenterX(), mSelectionMenu);
mSelectionMenu.updateWidget();
}
}
Expand Down Expand Up @@ -630,7 +631,7 @@ public void onDismiss() {
}

if (mDelegate != null) {
mDelegate.onLongPress(getSelectionCenterX(), mSelectionMenu);
mDelegate.onURLSelectionAction(mBinding.urlEditText, getSelectionCenterX(), mSelectionMenu);
}

mSelectionMenu.show(UIWidget.KEEP_FOCUS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.util.Pair;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -980,15 +981,15 @@ public void onHideAwesomeBar() {
}

@Override
public void onLongPress(float centerX, SelectionActionWidget actionMenu) {
public void onURLSelectionAction(EditText aURLEdit, float centerX, SelectionActionWidget actionMenu) {
actionMenu.getPlacement().parentHandle = this.getHandle();
actionMenu.getPlacement().parentAnchorY = 1.0f;
actionMenu.getPlacement().anchorY = 0.34f;
actionMenu.getPlacement().anchorY = 0.44f;
Rect offsetViewBounds = new Rect();
mURLBar.getDrawingRect(offsetViewBounds);
offsetDescendantRectToMyCoords(mURLBar, offsetViewBounds);
float x = offsetViewBounds.left + centerX;
actionMenu.getPlacement().parentAnchorX = x / getMeasuredWidth();
aURLEdit.getDrawingRect(offsetViewBounds);
offsetDescendantRectToMyCoords(aURLEdit, offsetViewBounds);
float x = aURLEdit.getPaddingLeft() + offsetViewBounds.left + centerX;
actionMenu.getPlacement().parentAnchorX = x / getWidth();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.anchorY = 0.5f;
aPlacement.translationX = 0.0f;
aPlacement.translationY = 0.0f;
aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.context_menu_z_distance);
aPlacement.translationZ = 1.0f;
aPlacement.visible = false;
}

Expand Down