pull/32/head
kunfei 5 years ago
parent f982626291
commit a6d99214ea
  1. 22
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 6
      app/src/main/res/xml/pref_config_read.xml

@ -94,15 +94,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(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<ReadBookViewModel>(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) {

@ -14,4 +14,10 @@
android:key="hideNavigationBar"
app:iconSpaceReserved="false" />
<io.legado.app.lib.theme.prefs.ATESwitchPreference
android:defaultValue="false"
android:title="@string/pt_hide_navigation_bar"
android:key="volumeKeyPageTurning"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceScreen>
Loading…
Cancel
Save