mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-05 07:41:23 +00:00
Exit full screen swipe is now a down gesture.
This commit is contained in:
parent
9c1b543ed6
commit
2e9405cfdb
1 changed files with 46 additions and 16 deletions
|
@ -6,6 +6,7 @@ import android.animation.ObjectAnimator
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.drawable.Animatable
|
import android.graphics.drawable.Animatable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.util.Log
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
@ -57,8 +58,10 @@ class GestureControlView : LinearLayout {
|
||||||
private var _isFullScreen = false;
|
private var _isFullScreen = false;
|
||||||
private var _animatorBrightness: ObjectAnimator? = null;
|
private var _animatorBrightness: ObjectAnimator? = null;
|
||||||
private val _layoutControlsFullscreen: FrameLayout;
|
private val _layoutControlsFullscreen: FrameLayout;
|
||||||
private var _adjustingFullscreen: Boolean = false;
|
private var _adjustingFullscreenUp: Boolean = false;
|
||||||
private var _fullScreenFactor = 1.0f;
|
private var _adjustingFullscreenDown: Boolean = false;
|
||||||
|
private var _fullScreenFactorUp = 1.0f;
|
||||||
|
private var _fullScreenFactorDown = 1.0f;
|
||||||
|
|
||||||
val onSeek = Event1<Long>();
|
val onSeek = Event1<Long>();
|
||||||
val onBrightnessAdjusted = Event1<Float>();
|
val onBrightnessAdjusted = Event1<Float>();
|
||||||
|
@ -100,10 +103,14 @@ class GestureControlView : LinearLayout {
|
||||||
_soundFactor = (_soundFactor + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f);
|
_soundFactor = (_soundFactor + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f);
|
||||||
_progressSound.progress = _soundFactor;
|
_progressSound.progress = _soundFactor;
|
||||||
onSoundAdjusted.emit(_soundFactor);
|
onSoundAdjusted.emit(_soundFactor);
|
||||||
} else if (_adjustingFullscreen) {
|
} else if (_adjustingFullscreenUp) {
|
||||||
val adjustAmount = (distanceY * 2) / height;
|
val adjustAmount = (distanceY * 2) / height;
|
||||||
_fullScreenFactor = (_fullScreenFactor + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f);
|
_fullScreenFactorUp = (_fullScreenFactorUp + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f);
|
||||||
_layoutControlsFullscreen.transitionAlpha = _fullScreenFactor;
|
_layoutControlsFullscreen.alpha = _fullScreenFactorUp;
|
||||||
|
} else if (_adjustingFullscreenDown) {
|
||||||
|
val adjustAmount = (-distanceY * 2) / height;
|
||||||
|
_fullScreenFactorDown = (_fullScreenFactorDown + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f);
|
||||||
|
_layoutControlsFullscreen.alpha = _fullScreenFactorDown;
|
||||||
} else {
|
} else {
|
||||||
val rx = p0.x / width;
|
val rx = p0.x / width;
|
||||||
val ry = p0.y / height;
|
val ry = p0.y / height;
|
||||||
|
@ -114,7 +121,11 @@ class GestureControlView : LinearLayout {
|
||||||
} else if (_isFullScreen && rx > 0.6) {
|
} else if (_isFullScreen && rx > 0.6) {
|
||||||
startAdjustingSound();
|
startAdjustingSound();
|
||||||
} else if (rx >= 0.4 && rx <= 0.6) {
|
} else if (rx >= 0.4 && rx <= 0.6) {
|
||||||
startAdjustingFullscreen();
|
if (_isFullScreen) {
|
||||||
|
startAdjustingFullscreenDown();
|
||||||
|
} else {
|
||||||
|
startAdjustingFullscreenUp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,11 +191,18 @@ class GestureControlView : LinearLayout {
|
||||||
stopAdjustingBrightness();
|
stopAdjustingBrightness();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_adjustingFullscreen && ev.action == MotionEvent.ACTION_UP) {
|
if (_adjustingFullscreenUp && ev.action == MotionEvent.ACTION_UP) {
|
||||||
if (_fullScreenFactor > 0.5) {
|
if (_fullScreenFactorUp > 0.5) {
|
||||||
onToggleFullscreen.emit();
|
onToggleFullscreen.emit();
|
||||||
}
|
}
|
||||||
stopAdjustingFullscreen();
|
stopAdjustingFullscreenUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_adjustingFullscreenDown && ev.action == MotionEvent.ACTION_UP) {
|
||||||
|
if (_fullScreenFactorDown > 0.5) {
|
||||||
|
onToggleFullscreen.emit();
|
||||||
|
}
|
||||||
|
stopAdjustingFullscreenDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
startHideJobIfNecessary();
|
startHideJobIfNecessary();
|
||||||
|
@ -468,15 +486,27 @@ class GestureControlView : LinearLayout {
|
||||||
_animatorSound?.start();
|
_animatorSound?.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startAdjustingFullscreen() {
|
private fun startAdjustingFullscreenUp() {
|
||||||
_adjustingFullscreen = true;
|
_adjustingFullscreenUp = true;
|
||||||
_fullScreenFactor = 0f;
|
_fullScreenFactorUp = 0f;
|
||||||
_layoutControlsFullscreen.transitionAlpha = 0f;
|
_layoutControlsFullscreen.alpha = 0f;
|
||||||
_layoutControlsFullscreen.visibility = View.VISIBLE;
|
_layoutControlsFullscreen.visibility = View.VISIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopAdjustingFullscreen() {
|
private fun stopAdjustingFullscreenUp() {
|
||||||
_adjustingFullscreen = false;
|
_adjustingFullscreenUp = false;
|
||||||
|
_layoutControlsFullscreen.visibility = View.GONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startAdjustingFullscreenDown() {
|
||||||
|
_adjustingFullscreenDown = true;
|
||||||
|
_fullScreenFactorDown = 0f;
|
||||||
|
_layoutControlsFullscreen.alpha = 0f;
|
||||||
|
_layoutControlsFullscreen.visibility = View.VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun stopAdjustingFullscreenDown() {
|
||||||
|
_adjustingFullscreenDown = false;
|
||||||
_layoutControlsFullscreen.visibility = View.GONE;
|
_layoutControlsFullscreen.visibility = View.GONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +540,7 @@ class GestureControlView : LinearLayout {
|
||||||
//onSoundAdjusted.emit(1.0f);
|
//onSoundAdjusted.emit(1.0f);
|
||||||
stopAdjustingBrightness();
|
stopAdjustingBrightness();
|
||||||
stopAdjustingSound();
|
stopAdjustingSound();
|
||||||
stopAdjustingFullscreen();
|
stopAdjustingFullscreenUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
_isFullScreen = isFullScreen;
|
_isFullScreen = isFullScreen;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue