koreader / android-luajit-launcher

Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
MIT License
132 stars 84 forks source link

Add hasStandaloneWarmth for OnyxWarmthController devices #426

Closed mergen3107 closed 8 months ago

mergen3107 commented 1 year ago

@pazos These are the changes I did (https://github.com/koreader/koreader/pull/8120#issuecomment-1636970460)


This change is Reviewable

mergen3107 commented 1 year ago

Do not merge yet please, needs testing.

pazos commented 1 year ago

(P.S. I am trying now to put these file changes to a branch so you can see better)

Thanks. Way easier for me :)

Abort message: 'JNI DETECTED ERROR IN APPLICATION: JNI CallBooleanMethod called with pending exception java.lang.NoSuchMethodError: no non-static method "Lorg/koreader/launcher/MainActivity;.hasStandaloneWarmth()Z"

What am I doing wrong?

Nothing wrong, my comment wasn't exhaustive. You'll need to add the method to https://github.com/koreader/android-luajit-launcher/blob/master/app/src/main/java/org/koreader/launcher/LuaInterface.kt and override it in https://github.com/koreader/android-luajit-launcher/blob/master/app/src/main/java/org/koreader/launcher/MainActivity.kt

It (mainactivity) will look like:

override fun hasStandaloneWarmth(): Boolean {
    return device.lights.hasStandaloneWarmth()
}
mergen3107 commented 1 year ago

Thank you @pazos ! KOReader was able to open with these changes. I am able to turn off the frontlight (cold and warm) via a gesture.

However, when I turn it back on, only cold light turns on. I am trying to investigate this.

mergen3107 commented 8 months ago

However, when I turn it back on, only cold light turns on. I am trying to investigate this.

https://github.com/koreader/koreader/pull/11275

android-luajit side of things (this PR) is correct. The mentioned PR is in discussion.

@pazos Please review this PR. It should be generalized enough so that we don't need to add devices one by one to make these changes apply - as long as they properly refer to this OnyxWarmthController.

Thank you for all your help!

pazos commented 8 months ago

Please review this PR. It should be generalized enough so that we don't need to add devices one by one to make these changes apply.

That's the entire point of the device abstraction ;)

PR is fine by me, please address specific comments.

mergen3107 commented 8 months ago

Thank you! While adding my newlines, I noticed some methods didn't have them, so I added those newlines too, for consistency.