Skip to content

Commit

Permalink
[Lights]: add hasStandaloneWarmth (#426)
Browse files Browse the repository at this point in the history
* implementation for onyx devices
  • Loading branch information
mergen3107 committed Dec 27, 2023
1 parent 968c3b2 commit 462be28
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/org/koreader/launcher/LuaInterface.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface LuaInterface {
fun hasNativeRotation(): Boolean
fun hasOTAUpdates(): Boolean
fun hasRuntimeChanges(): Boolean
fun hasStandaloneWarmth(): Boolean
fun installApk()
fun isCharging(): Boolean
fun isChromeOS(): Boolean
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/koreader/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ class MainActivity : NativeActivity(), LuaInterface,
}
}

override fun hasStandaloneWarmth(): Boolean {
return device.lights.hasStandaloneWarmth()
}

override fun hasRuntimeChanges(): Boolean {
return MainApp.supports_runtime_changes
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ interface LightsInterface {
fun getMinBrightness(): Int
fun getMaxBrightness(): Int
fun enableFrontlightSwitch(activity: Activity): Int
fun hasStandaloneWarmth(): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ class BoyueS62RootController : LightsInterface {
override fun getMaxBrightness(): Int {
return BRIGHTNESS_MAX
}

override fun hasStandaloneWarmth(): Boolean {
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,20 @@ class GenericController : LightsInterface {
override fun getMinWarmth(): Int {
return 0
}

override fun getMaxWarmth(): Int {
return 0
}

override fun getMinBrightness(): Int {
return BRIGHTNESS_MIN
}

override fun getMaxBrightness(): Int {
return BRIGHTNESS_MAX
}

override fun hasStandaloneWarmth(): Boolean {
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,20 @@ class OnyxC67Controller : LightsInterface {
override fun getMinWarmth(): Int {
return 0
}

override fun getMaxWarmth(): Int {
return 0
}

override fun getMinBrightness(): Int {
return BRIGHTNESS_MIN
}

override fun getMaxBrightness(): Int {
return BRIGHTNESS_MAX
}

override fun hasStandaloneWarmth(): Boolean {
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,20 @@ class OnyxColorController : LightsInterface {
override fun getMinWarmth(): Int {
return 0
}

override fun getMaxWarmth(): Int {
return 0
}

override fun getMinBrightness(): Int {
return BRIGHTNESS_MIN
}

override fun getMaxBrightness(): Int {
return BRIGHTNESS_MAX
}

override fun hasStandaloneWarmth(): Boolean {
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class OnyxSdkLightsController : LightsInterface {
override fun enableFrontlightSwitch(activity: Activity): Int {
return 1
}

override fun hasStandaloneWarmth(): Boolean {
return false
}
}

object FrontLight {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ class OnyxWarmthController : LightsInterface {
override fun enableFrontlightSwitch(activity: Activity): Int {
return 1
}

override fun hasStandaloneWarmth(): Boolean {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ class TolinoNtxController : Ioctl(), LightsInterface {
override fun getMaxBrightness(): Int {
return BRIGHTNESS_MAX
}

override fun hasStandaloneWarmth(): Boolean {
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,8 @@ class TolinoRootController : LightsInterface {
override fun getMaxBrightness(): Int {
return BRIGHTNESS_MAX
}

override fun hasStandaloneWarmth(): Boolean {
return false
}
}
10 changes: 10 additions & 0 deletions assets/android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,16 @@ local function run(android_app_state)
end)
end

android.hasStandaloneWarmth = function()
return JNI:context(android.app.activity.vm, function(jni)
return jni:callBooleanMethod(
android.app.activity.clazz,
"hasStandaloneWarmth",
"()Z"
)
end)
end

android.hasNativeRotation = function()
return JNI:context(android.app.activity.vm, function(jni)
return jni:callBooleanMethod(
Expand Down

0 comments on commit 462be28

Please sign in to comment.