mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-11 02:29:31 +00:00
Gesture controls can individually be enabled/disabled and can be toggled to use system or non-system values.
This commit is contained in:
parent
ba87261f9f
commit
745aad385b
5 changed files with 67 additions and 17 deletions
|
@ -813,20 +813,20 @@ class Settings : FragmentedStorageFileJson() {
|
|||
var gestureControls = GestureControls();
|
||||
@Serializable
|
||||
class GestureControls {
|
||||
@FormField(R.string.volume_slider, FieldForm.TOGGLE, -1, 1)
|
||||
@FormField(R.string.volume_slider, FieldForm.TOGGLE, R.string.volume_slider_descr, 1)
|
||||
var volumeSlider: Boolean = true;
|
||||
|
||||
@FormField(R.string.brightness_slider, FieldForm.TOGGLE, -1, 2)
|
||||
@FormField(R.string.brightness_slider, FieldForm.TOGGLE, R.string.brightness_slider_descr, 2)
|
||||
var brightnessSlider: Boolean = true;
|
||||
|
||||
@FormField(R.string.toggle_full_screen, FieldForm.TOGGLE, -1, 3)
|
||||
@FormField(R.string.toggle_full_screen, FieldForm.TOGGLE, R.string.toggle_full_screen_descr, 3)
|
||||
var toggleFullscreen: Boolean = true;
|
||||
|
||||
@FormField(R.string.system_brightness, FieldForm.TOGGLE, -1, 4)
|
||||
var useSystemBrightness: Boolean = false;
|
||||
@FormField(R.string.system_brightness, FieldForm.TOGGLE, R.string.system_brightness_descr, 4)
|
||||
var useSystemBrightness: Boolean = true;
|
||||
|
||||
@FormField(R.string.system_brightness, FieldForm.TOGGLE, -1, 4)
|
||||
var useSystemVolume: Boolean = false;
|
||||
@FormField(R.string.system_volume, FieldForm.TOGGLE, R.string.system_volume_descr, 5)
|
||||
var useSystemVolume: Boolean = true;
|
||||
}
|
||||
|
||||
@FormField(R.string.info, FieldForm.GROUP, -1, 20)
|
||||
|
|
|
@ -145,7 +145,6 @@ import com.futo.polycentric.core.Opinion
|
|||
import com.futo.polycentric.core.toURLInfoSystemLinkUrl
|
||||
import com.google.protobuf.ByteString
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -1372,7 +1371,9 @@ class VideoDetailView : ConstraintLayout {
|
|||
val toResume = _videoResumePositionMilliseconds;
|
||||
_videoResumePositionMilliseconds = 0;
|
||||
loadCurrentVideo(toResume);
|
||||
_player.setGestureSoundFactor(1.0f);
|
||||
if (!Settings.instance.gestureControls.useSystemVolume) {
|
||||
_player.setGestureSoundFactor(1.0f);
|
||||
}
|
||||
|
||||
updateQueueState();
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@ package com.futo.platformplayer.views.behavior
|
|||
import android.animation.Animator
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ObjectAnimator
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.media.AudioManager
|
||||
import android.util.AttributeSet
|
||||
import android.view.GestureDetector
|
||||
import android.view.LayoutInflater
|
||||
|
@ -60,6 +62,7 @@ class GestureControlView : LinearLayout {
|
|||
private val _progressSound: CircularProgressBar;
|
||||
private var _animatorSound: ObjectAnimator? = null;
|
||||
private var _brightnessFactor = 1.0f;
|
||||
private var _originalBrightnessFactor = 1.0f;
|
||||
private var _adjustingBrightness: Boolean = false;
|
||||
private val _layoutControlsBrightness: FrameLayout;
|
||||
private val _progressBrightness: CircularProgressBar;
|
||||
|
@ -560,10 +563,34 @@ class GestureControlView : LinearLayout {
|
|||
|
||||
fun setFullscreen(isFullScreen: Boolean) {
|
||||
if (isFullScreen) {
|
||||
val c = context
|
||||
if (c is Activity && Settings.instance.gestureControls.useSystemBrightness) {
|
||||
_brightnessFactor = c.window.attributes.screenBrightness
|
||||
if (_brightnessFactor == -1.0f) {
|
||||
_brightnessFactor = android.provider.Settings.System.getInt(
|
||||
context.contentResolver,
|
||||
android.provider.Settings.System.SCREEN_BRIGHTNESS
|
||||
) / 255.0f;
|
||||
}
|
||||
_originalBrightnessFactor = _brightnessFactor
|
||||
}
|
||||
|
||||
if (Settings.instance.gestureControls.useSystemVolume) {
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
_soundFactor = currentVolume.toFloat() / maxVolume.toFloat()
|
||||
}
|
||||
|
||||
onBrightnessAdjusted.emit(_brightnessFactor);
|
||||
onSoundAdjusted.emit(_soundFactor);
|
||||
} else {
|
||||
onBrightnessAdjusted.emit(1.0f);
|
||||
val c = context
|
||||
if (c is Activity && Settings.instance.gestureControls.useSystemBrightness) {
|
||||
onBrightnessAdjusted.emit(_originalBrightnessFactor);
|
||||
} else {
|
||||
onBrightnessAdjusted.emit(1.0f);
|
||||
}
|
||||
//onSoundAdjusted.emit(1.0f);
|
||||
stopAdjustingBrightness();
|
||||
stopAdjustingSound();
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
package com.futo.platformplayer.views.video
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.media.AudioManager
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.view.WindowManager
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import android.widget.TextView
|
||||
|
@ -235,14 +238,29 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
|
|||
|
||||
gestureControl.setupTouchArea(_layoutControls, background);
|
||||
gestureControl.onSeek.subscribe { seekFromCurrent(it); };
|
||||
gestureControl.onSoundAdjusted.subscribe { setVolume(it) };
|
||||
gestureControl.onSoundAdjusted.subscribe {
|
||||
if (Settings.instance.gestureControls.useSystemVolume) {
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (it * maxVolume).toInt(), 0)
|
||||
} else {
|
||||
setVolume(it)
|
||||
}
|
||||
};
|
||||
gestureControl.onToggleFullscreen.subscribe { setFullScreen(!isFullScreen) };
|
||||
gestureControl.onBrightnessAdjusted.subscribe {
|
||||
if (it == 1.0f) {
|
||||
_overlay_brightness.visibility = View.GONE;
|
||||
if (context is Activity && Settings.instance.gestureControls.useSystemBrightness) {
|
||||
val window = context.window
|
||||
val layout: WindowManager.LayoutParams = window.attributes
|
||||
layout.screenBrightness = it
|
||||
window.attributes = layout
|
||||
} else {
|
||||
_overlay_brightness.visibility = View.VISIBLE;
|
||||
_overlay_brightness.setBackgroundColor(Color.valueOf(0.0f, 0.0f, 0.0f, (1.0f - it)).toArgb());
|
||||
if (it == 1.0f) {
|
||||
_overlay_brightness.visibility = View.GONE;
|
||||
} else {
|
||||
_overlay_brightness.visibility = View.VISIBLE;
|
||||
_overlay_brightness.setBackgroundColor(Color.valueOf(0.0f, 0.0f, 0.0f, (1.0f - it)).toArgb());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -730,7 +748,6 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fun setGestureSoundFactor(soundFactor: Float) {
|
||||
gestureControl.setSoundFactor(soundFactor);
|
||||
}
|
||||
|
|
|
@ -346,10 +346,15 @@
|
|||
<string name="info">Info</string>
|
||||
<string name="gesture_controls">Gesture controls</string>
|
||||
<string name="volume_slider">Volume slider</string>
|
||||
<string name="volume_slider_descr">Enable slide gesture to change volume</string>
|
||||
<string name="brightness_slider">Brightness slider</string>
|
||||
<string name="toggle_full_screen">Toogle full screen</string>
|
||||
<string name="brightness_slider_descr">Enable slide gesture to change brightness</string>
|
||||
<string name="toggle_full_screen">Toggle full screen</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_descr">Gesture controls adjust system brightness</string>
|
||||
<string name="system_volume">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="full_screen_portrait">Fullscreen portrait</string>
|
||||
<string name="allow_full_screen_portrait">Allow fullscreen portrait</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue