Skip to content

Commit

Permalink
Fix Selection Action menu alignment on the Awesome Bar (MozillaRealit…
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and Alexandre Lissy committed Jan 21, 2020
1 parent b9426f8 commit dc3da77
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
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

0 comments on commit dc3da77

Please sign in to comment.