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

Commit

Permalink
Fixes #2948 Updated change per Manuel that removed widget wide hover …
Browse files Browse the repository at this point in the history
…code for volume slider and moved it to volume button and slider respectively. Fixes #2948
  • Loading branch information
daron-walters committed Apr 21, 2020
1 parent a70b9a2 commit 717c782
Showing 1 changed file with 22 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
};
Expand Down Expand Up @@ -204,46 +205,35 @@ 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();
}
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);
Expand Down Expand Up @@ -390,4 +380,5 @@ public void stopVolumeCtrlHandler() {
mVolumeCtrlHandler.removeCallbacks(mVolumeCtrlRunnable);
}


}

0 comments on commit 717c782

Please sign in to comment.