diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index dbdb11b1e..3346df73e 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -94,15 +94,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } read_menu.setListener(object : ReadMenu.Callback { override fun setScreenBrightness(value: Int) { - var brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE - if (this@ReadBookActivity.getPrefBoolean("brightnessAuto").not()) { - brightness = value.toFloat() - if (brightness < 1f) brightness = 1f - brightness = brightness * 1.0f / 255f - } - val params = window.attributes - params.screenBrightness = brightness - window.attributes = params + this@ReadBookActivity.setScreenBrightness(value) } override fun autoPage() { @@ -295,6 +287,18 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } } + fun setScreenBrightness(value: Int) { + var brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE + if (this.getPrefBoolean("brightnessAuto").not()) { + brightness = value.toFloat() + if (brightness < 1f) brightness = 1f + brightness = brightness * 1.0f / 255f + } + val params = window.attributes + params.screenBrightness = brightness + window.attributes = params + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (resultCode == Activity.RESULT_OK) { diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 06ddce418..d5cec54d1 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -14,4 +14,10 @@ android:key="hideNavigationBar" app:iconSpaceReserved="false" /> + + \ No newline at end of file