[Android] Mitigate the default video brightness jump
Nicolas Pomepuy
git at videolan.org
Fri Apr 12 14:48:57 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Apr 12 13:20:06 2019 +0200| [b2c96ea3cdd17dbd10d8b10cbb0578e595980c1b] | committer: Geoffrey Métais
Mitigate the default video brightness jump
> https://code.videolan.org/videolan/vlc-android/commit/b2c96ea3cdd17dbd10d8b10cbb0578e595980c1b
---
.../videolan/vlc/gui/video/VideoTouchDelegate.kt | 25 ++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
index 7a2e84b6e..32c32291f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
@@ -2,6 +2,7 @@ package org.videolan.vlc.gui.video
import android.content.res.Configuration
import android.media.AudioManager
+import android.provider.Settings
import android.util.DisplayMetrics
import android.view.*
import androidx.core.view.GestureDetectorCompat
@@ -28,9 +29,9 @@ private const val MAX_FOV = 150f
private const val JOYSTICK_INPUT_DELAY = 300
class VideoTouchDelegate(private val player: VideoPlayerActivity,
- private val mTouchControls : Int,
- var screenConfig : ScreenConfig,
- private val tv : Boolean) {
+ private val mTouchControls: Int,
+ var screenConfig: ScreenConfig,
+ private val tv: Boolean) {
private var mTouchAction = TOUCH_NONE
private var mInitTouchY = 0f
@@ -285,7 +286,19 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
private fun initBrightnessTouch() {
val lp = player.window.attributes
- val brightnesstemp = if (lp.screenBrightness != -1f) lp.screenBrightness else 0.6f
+
+ //Check if we already have a brightness
+ val brightnesstemp = if (lp.screenBrightness != -1f)
+ lp.screenBrightness
+ else {
+ //Check if the device is in auto mode
+ val contentResolver = player.applicationContext.contentResolver
+ if (Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+ //cannot retrieve a value -> 0.5
+ 0.5f
+ } else Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS, 128).toFloat() / 255
+ }
+
lp.screenBrightness = brightnesstemp
player.window.attributes = lp
mIsFirstBrightnessGesture = false
@@ -304,7 +317,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
private val mScaleListener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
- private var savedScale : MediaPlayer.ScaleType? = null
+ private var savedScale: MediaPlayer.ScaleType? = null
override fun onScaleBegin(detector: ScaleGestureDetector): Boolean {
return screenConfig.xRange != 0 || player.fov == 0f
}
@@ -366,7 +379,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
return false
}
- override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float ) = false
+ override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float) = false
}
}
More information about the Android
mailing list