优化
This commit is contained in:
@@ -17,11 +17,9 @@ object AppLog {
|
|||||||
mLogs.removeLastOrNull()
|
mLogs.removeLastOrNull()
|
||||||
}
|
}
|
||||||
mLogs.add(0, Triple(System.currentTimeMillis(), message, throwable))
|
mLogs.add(0, Triple(System.currentTimeMillis(), message, throwable))
|
||||||
if (throwable != null) {
|
if (BuildConfig.DEBUG) {
|
||||||
if (BuildConfig.DEBUG) {
|
val stackTrace = Thread.currentThread().stackTrace
|
||||||
val stackTrace = Thread.currentThread().stackTrace
|
Log.e(stackTrace[3].className, message, throwable)
|
||||||
Log.e(stackTrace[3].className, message, throwable)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,15 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
super.onWindowFocusChanged(hasFocus)
|
super.onWindowFocusChanged(hasFocus)
|
||||||
upSystemUiVisibility()
|
upSystemUiVisibility()
|
||||||
binding.readMenu.upBrightnessState()
|
if (hasFocus) {
|
||||||
|
//调节系统亮度后如果设置亮度值和原来一样亮度不会变
|
||||||
|
launch {
|
||||||
|
delay(100)
|
||||||
|
binding.readMenu.setScreenBrightness(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE)
|
||||||
|
delay(1000)
|
||||||
|
binding.readMenu.upBrightnessState()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import android.view.Gravity
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import android.view.View.OnLongClickListener
|
import android.view.View.OnLongClickListener
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
@@ -248,26 +248,24 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
binding.ivBrightnessAuto.setColorFilter(context.buttonDisabledColor)
|
binding.ivBrightnessAuto.setColorFilter(context.buttonDisabledColor)
|
||||||
binding.seekBrightness.isEnabled = true
|
binding.seekBrightness.isEnabled = true
|
||||||
}
|
}
|
||||||
setScreenBrightness(AppConfig.readBrightness)
|
setScreenBrightness(AppConfig.readBrightness.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置屏幕亮度
|
* 设置屏幕亮度
|
||||||
*/
|
*/
|
||||||
private fun setScreenBrightness(value: Int) {
|
fun setScreenBrightness(value: Float) {
|
||||||
activity?.run {
|
activity?.run {
|
||||||
var brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
var brightness = BRIGHTNESS_OVERRIDE_NONE
|
||||||
if (!brightnessAuto()) {
|
if (!brightnessAuto() && value != BRIGHTNESS_OVERRIDE_NONE) {
|
||||||
brightness = value.toFloat()
|
brightness = value
|
||||||
if (brightness < 1f) brightness = 1f
|
if (brightness < 1f) brightness = 1f
|
||||||
brightness /= 255f
|
brightness /= 255f
|
||||||
}
|
}
|
||||||
val params = window.attributes
|
val params = window.attributes
|
||||||
params.screenBrightness = brightness
|
params.screenBrightness = brightness
|
||||||
window.attributes = params
|
window.attributes = params
|
||||||
if (AppConfig.recordLog) {
|
AppLog.put("设置亮度$brightness")
|
||||||
AppLog.put("设置亮度$brightness")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,7 +362,7 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
|
|
||||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
setScreenBrightness(progress)
|
setScreenBrightness(progress.toFloat())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user