mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-05 15:49:22 +00:00
Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay
This commit is contained in:
commit
8964dc68f0
3 changed files with 69 additions and 14 deletions
|
@ -827,6 +827,15 @@ class Settings : FragmentedStorageFileJson() {
|
||||||
|
|
||||||
@FormField(R.string.system_volume, FieldForm.TOGGLE, R.string.system_volume_descr, 5)
|
@FormField(R.string.system_volume, FieldForm.TOGGLE, R.string.system_volume_descr, 5)
|
||||||
var useSystemVolume: Boolean = true;
|
var useSystemVolume: Boolean = true;
|
||||||
|
|
||||||
|
@FormField(R.string.restore_system_brightness, FieldForm.TOGGLE, R.string.restore_system_brightness_descr, 6)
|
||||||
|
var restoreSystemBrightness: Boolean = true;
|
||||||
|
|
||||||
|
@FormField(R.string.zoom_option, FieldForm.TOGGLE, R.string.zoom_option_descr, 7)
|
||||||
|
var zoom: Boolean = true;
|
||||||
|
|
||||||
|
@FormField(R.string.pan_option, FieldForm.TOGGLE, R.string.pan_option_descr, 8)
|
||||||
|
var pan: Boolean = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@FormField(R.string.info, FieldForm.GROUP, -1, 20)
|
@FormField(R.string.info, FieldForm.GROUP, -1, 20)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.animation.AnimatorSet
|
||||||
import android.animation.ObjectAnimator
|
import android.animation.ObjectAnimator
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.Matrix
|
||||||
import android.graphics.drawable.Animatable
|
import android.graphics.drawable.Animatable
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
@ -38,6 +39,7 @@ import kotlinx.coroutines.ensureActive
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
class GestureControlView : LinearLayout {
|
class GestureControlView : LinearLayout {
|
||||||
private val _scope = CoroutineScope(Dispatchers.Main);
|
private val _scope = CoroutineScope(Dispatchers.Main);
|
||||||
private val _imageFastForward: ImageView;
|
private val _imageFastForward: ImageView;
|
||||||
|
@ -82,6 +84,7 @@ class GestureControlView : LinearLayout {
|
||||||
private var _translationY = 0.0f
|
private var _translationY = 0.0f
|
||||||
private val _layoutControlsZoom: FrameLayout
|
private val _layoutControlsZoom: FrameLayout
|
||||||
private val _textZoom: TextView
|
private val _textZoom: TextView
|
||||||
|
private var _isZooming = false
|
||||||
|
|
||||||
private val _gestureController: GestureDetectorCompat;
|
private val _gestureController: GestureDetectorCompat;
|
||||||
|
|
||||||
|
@ -113,16 +116,39 @@ class GestureControlView : LinearLayout {
|
||||||
|
|
||||||
_scaleGestureDetector = ScaleGestureDetector(context, object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
_scaleGestureDetector = ScaleGestureDetector(context, object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
||||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||||
Logger.i(TAG, "onScale _scaleFactor $_scaleFactor sf " + detector.scaleFactor.toString())
|
if (!_isFullScreen || !Settings.instance.gestureControls.zoom) {
|
||||||
_scaleFactor = (_scaleFactor + detector.scaleFactor - 1.0f).coerceAtLeast(1.0f).coerceAtMost(5.0f)
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var newScaleFactor = (_scaleFactor * detector.scaleFactor).coerceAtLeast(1.0f).coerceAtMost(5.0f)
|
||||||
|
|
||||||
|
//Make original zoom sticky
|
||||||
|
if (newScaleFactor - 1.0f < 0.01f) {
|
||||||
|
newScaleFactor = 1.0f
|
||||||
|
}
|
||||||
|
|
||||||
|
val scaleFactorChange = newScaleFactor / _scaleFactor
|
||||||
|
_scaleFactor = newScaleFactor
|
||||||
onZoom.emit(_scaleFactor)
|
onZoom.emit(_scaleFactor)
|
||||||
|
|
||||||
_translationX = _translationX.coerceAtLeast(-height / _scaleFactor)
|
val sx = detector.focusX
|
||||||
_translationY = _translationY.coerceAtLeast(-width / _scaleFactor)
|
val sy = detector.focusY
|
||||||
onPan.emit(_translationX, _translationY)
|
|
||||||
|
val tx = _translationX + width / 2.0f
|
||||||
|
val ty = _translationY + height / 2.0f
|
||||||
|
|
||||||
|
val matrix = Matrix()
|
||||||
|
matrix.postTranslate(-sx, -sy)
|
||||||
|
matrix.postScale(scaleFactorChange, scaleFactorChange)
|
||||||
|
matrix.postTranslate(sx, sy)
|
||||||
|
|
||||||
|
val point = floatArrayOf(tx, ty)
|
||||||
|
matrix.mapPoints(point)
|
||||||
|
pan(point[0] - width / 2.0f, point[1] - height / 2.0f)
|
||||||
|
|
||||||
_layoutControlsZoom.visibility = View.VISIBLE
|
_layoutControlsZoom.visibility = View.VISIBLE
|
||||||
_textZoom.text = "${String.format("%.1f", _scaleFactor)}x"
|
_textZoom.text = "${String.format("%.1f", _scaleFactor)}x"
|
||||||
|
_isZooming = true
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -175,14 +201,9 @@ class GestureControlView : LinearLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_isFullScreen) {
|
} else if (_isFullScreen && !_isZooming && Settings.instance.gestureControls.pan) {
|
||||||
stopAllGestures()
|
stopAllGestures()
|
||||||
|
pan(_translationX - distanceX, _translationY - distanceY)
|
||||||
_translationX = (_translationX - distanceX).coerceAtLeast(-height / _scaleFactor)
|
|
||||||
_translationY = (_translationY - distanceY).coerceAtLeast(-width / _scaleFactor)
|
|
||||||
|
|
||||||
Logger.i(TAG, "onPan " + _translationX.toString() + ", " + _translationY.toString())
|
|
||||||
onPan.emit(_translationX, _translationY)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -223,6 +244,22 @@ class GestureControlView : LinearLayout {
|
||||||
isClickable = true
|
isClickable = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun pan(translationX: Float, translationY: Float) {
|
||||||
|
val xc = width / 2.0f
|
||||||
|
val yc = height / 2.0f
|
||||||
|
|
||||||
|
val xmin = xc - width / 2.0f * _scaleFactor
|
||||||
|
val xmax = xc + width / 2.0f * _scaleFactor - width
|
||||||
|
|
||||||
|
val ymin = yc - height / 2.0f * _scaleFactor
|
||||||
|
val ymax = yc + height / 2.0f * _scaleFactor - height
|
||||||
|
|
||||||
|
_translationX = translationX.coerceAtLeast(xmin).coerceAtMost(xmax)
|
||||||
|
_translationY = translationY.coerceAtLeast(ymin).coerceAtMost(ymax)
|
||||||
|
|
||||||
|
onPan.emit(_translationX, _translationY)
|
||||||
|
}
|
||||||
|
|
||||||
fun setupTouchArea(layoutControls: ViewGroup? = null, background: View? = null) {
|
fun setupTouchArea(layoutControls: ViewGroup? = null, background: View? = null) {
|
||||||
_layoutControls = layoutControls;
|
_layoutControls = layoutControls;
|
||||||
_background = background;
|
_background = background;
|
||||||
|
@ -268,8 +305,9 @@ class GestureControlView : LinearLayout {
|
||||||
stopAdjustingFullscreenDown();
|
stopAdjustingFullscreenDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_layoutControlsZoom.visibility == View.VISIBLE && ev.action == MotionEvent.ACTION_UP) {
|
if (_isZooming && ev.action == MotionEvent.ACTION_UP) {
|
||||||
_layoutControlsZoom.visibility = View.GONE
|
_layoutControlsZoom.visibility = View.GONE
|
||||||
|
_isZooming = false
|
||||||
}
|
}
|
||||||
|
|
||||||
startHideJobIfNecessary();
|
startHideJobIfNecessary();
|
||||||
|
@ -639,7 +677,9 @@ class GestureControlView : LinearLayout {
|
||||||
} else {
|
} else {
|
||||||
val c = context
|
val c = context
|
||||||
if (c is Activity && Settings.instance.gestureControls.useSystemBrightness) {
|
if (c is Activity && Settings.instance.gestureControls.useSystemBrightness) {
|
||||||
|
if (Settings.instance.gestureControls.restoreSystemBrightness) {
|
||||||
onBrightnessAdjusted.emit(_originalBrightnessFactor);
|
onBrightnessAdjusted.emit(_originalBrightnessFactor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
onBrightnessAdjusted.emit(1.0f);
|
onBrightnessAdjusted.emit(1.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,6 +353,12 @@
|
||||||
<string name="toggle_full_screen_descr">Enable swipe gesture to toggle fullscreen</string>
|
<string name="toggle_full_screen_descr">Enable swipe gesture to toggle fullscreen</string>
|
||||||
<string name="system_brightness">System brightness</string>
|
<string name="system_brightness">System brightness</string>
|
||||||
<string name="system_brightness_descr">Gesture controls adjust system brightness</string>
|
<string name="system_brightness_descr">Gesture controls adjust system brightness</string>
|
||||||
|
<string name="restore_system_brightness">Restore system brightness</string>
|
||||||
|
<string name="restore_system_brightness_descr">Restore system brightness when exiting fullscreen</string>
|
||||||
|
<string name="zoom_option">Enable zoom</string>
|
||||||
|
<string name="zoom_option_descr">Enable two finger pinch zoom gesture</string>
|
||||||
|
<string name="pan_option">Enable pan</string>
|
||||||
|
<string name="pan_option_descr">Enable two finger pan gesture</string>
|
||||||
<string name="system_volume">System volume</string>
|
<string name="system_volume">System volume</string>
|
||||||
<string name="system_volume_descr">Gesture controls adjust system volume</string>
|
<string name="system_volume_descr">Gesture controls adjust system volume</string>
|
||||||
<string name="live_chat_webview">Live Chat Webview</string>
|
<string name="live_chat_webview">Live Chat Webview</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue