From 717c782de63e6431874e6bbb5507a62ca7d1471b Mon Sep 17 00:00:00 2001 From: daron-walters Date: Mon, 20 Apr 2020 22:59:10 -0400 Subject: [PATCH] Fixes #2948 Updated change per Manuel that removed widget wide hover code for volume slider and moved it to volume button and slider respectively. Fixes #2948 --- .../ui/widgets/MediaControlsWidget.java | 53 ++++++++----------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MediaControlsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MediaControlsWidget.java index f01f2e17f..17e953a5f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MediaControlsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/MediaControlsWidget.java @@ -15,6 +15,7 @@ import android.widget.FrameLayout; import android.widget.TextView; +import org.mozilla.telemetry.schedule.jobscheduler.TelemetryJobService; import org.mozilla.vrbrowser.R; import org.mozilla.geckoview.MediaElement; import org.mozilla.vrbrowser.browser.Media; @@ -83,7 +84,7 @@ private void initialize(Context aContext) { mOffsetViewBounds = new Rect(); mVolumeCtrlRunnable = () -> { if ((mHideVolumeSlider) && (mVolumeControl.getVisibility() == View.VISIBLE)) { - mVolumeControl.setVisibility(View.GONE); + mVolumeControl.setVisibility(View.INVISIBLE); stopVolumeCtrlHandler(); } }; @@ -204,39 +205,16 @@ public void onSeekPreview(String aText, double aRatio) { mVolumeControl.requestFocusFromTouch(); }); - this.setOnHoverListener((v, event) -> { - if (mMedia == null) { - return false; - } - if (event.getX() < 0) { - this.mHideVolumeSlider = true; - this.startVolumeCtrlHandler(); - return false; - } - if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE || event.getAction() == MotionEvent.ACTION_HOVER_ENTER) { - float threshold = mMediaVolumeButton.getX(); - boolean isVisible = mVolumeControl.getVisibility() == View.VISIBLE; - boolean makeVisible = event.getX() >= threshold; - if (isVisible != makeVisible) { - if (makeVisible) { - mVolumeControl.setVisibility(View.VISIBLE); - this.mHideVolumeSlider = false; - this.stopVolumeCtrlHandler(); - } else { - this.mHideVolumeSlider = true; - this.startVolumeCtrlHandler(); - } - } - } else if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT && !mMediaVolumeButton.isHovered() && this.isInTouchMode()) { - //mVolumeControl.setVisibility(View.INVISIBLE); + + mMediaVolumeButton.setOnHoverListener((v, event) -> { + float startY = v.getY(); + float maxY = startY + v.getHeight(); + //for this we only hide on the left side of volume button or outside y area of button + if ((event.getX() <= 0) || (!(event.getY() > startY && event.getY() < maxY))) { this.mHideVolumeSlider = true; this.startVolumeCtrlHandler(); - } - return false; - }); - mMediaVolumeButton.setOnHoverListener((v, event) -> { - if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER || event.getAction() == MotionEvent.ACTION_HOVER_MOVE) { + } else { mVolumeControl.setVisibility(View.VISIBLE); this.mHideVolumeSlider = false; this.stopVolumeCtrlHandler(); @@ -244,6 +222,18 @@ public void onSeekPreview(String aText, double aRatio) { return false; }); + mVolumeControl.setOnHoverListener((v, event) -> { + float startY = v.getY(); + float maxY = startY + v.getHeight(); + //for this we only hide on the right side of volume button or outside y area of button + if ((event.getX() < 0) || (event.getX() >= v.getWidth()) || (!(event.getY() > startY && event.getY() < maxY))) { + this.mHideVolumeSlider = true; + this.startVolumeCtrlHandler(); + } + return false; + }); + + mMediaProjectionButton.setOnHoverListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER || event.getAction() == MotionEvent.ACTION_HOVER_MOVE) { // mVolumeControl.setVisibility(View.INVISIBLE); @@ -390,4 +380,5 @@ public void stopVolumeCtrlHandler() { mVolumeCtrlHandler.removeCallbacks(mVolumeCtrlRunnable); } + }