Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tolino Page 2 support #458

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/org/koreader/launcher/TestActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.koreader.launcher.device.lights.OnyxSdkLightsController
import org.koreader.launcher.device.lights.OnyxWarmthController
import org.koreader.launcher.device.lights.TolinoRootController
import org.koreader.launcher.device.lights.TolinoNtxController
import org.koreader.launcher.device.lights.TolinoNtxNoWarmthController
import org.koreader.launcher.device.lights.BoyueS62RootController
import org.koreader.launcher.dialog.LightDialog

Expand Down Expand Up @@ -71,6 +72,7 @@ class TestActivity: AppCompatActivity() {
lightsMap["Onyx (warmth)"] = OnyxWarmthController()
lightsMap["Tolino Root"] = TolinoRootController()
lightsMap["Tolino Ntx"] = TolinoNtxController()
lightsMap["Tolino Ntx (no warmth)"] = TolinoNtxNoWarmthController()

// Device ID
binding.info.append("Manufacturer: ${DeviceInfo.MANUFACTURER}\n")
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/koreader/launcher/device/DeviceInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ object DeviceInfo {
RIDI_PAPER_3,
TAGUS_GEA,
TOLINO_EPOS,
TOLINO_PAGE2,
TOLINO_SHINE3,
TOLINO_VISION4,
TOLINO_VISION5
Expand Down Expand Up @@ -229,6 +230,7 @@ object DeviceInfo {
private val SONY_RP1: Boolean
private val TAGUS_GEA: Boolean
private val TOLINO_EPOS: Boolean
private val TOLINO_PAGE2: Boolean
private val TOLINO_SHINE3: Boolean
private val TOLINO_VISION4: Boolean
private val TOLINO_VISION5: Boolean
Expand Down Expand Up @@ -539,8 +541,15 @@ object DeviceInfo {
&& DEVICE.contentEquals("ntx_6sl")
&& !HARDWARE.contentEquals("e60k00")
&& !HARDWARE.contentEquals("e60q50")
&& !HARDWARE.contentEquals("e60qv0")
RubixDev marked this conversation as resolved.
Show resolved Hide resolved
&& !HARDWARE.contentEquals("e70k00")

// Tolino Page 2 has no warmth lights
TOLINO_PAGE2 = BRAND.contentEquals("rakutenkobo")
&& MODEL.contentEquals("tolino")
&& DEVICE.contentEquals("ntx_6sl")
&& HARDWARE.contentEquals("e60qv0")

// Tolino Shine 3 also has warmth lights, but with ntx_io file
TOLINO_SHINE3 = BRAND.contentEquals("rakutenkobo")
&& MODEL.contentEquals("tolino")
Expand Down Expand Up @@ -696,6 +705,7 @@ object DeviceInfo {
lightsMap[LightsDevice.RIDI_PAPER_3] = RIDI_PAPER_3
lightsMap[LightsDevice.TAGUS_GEA] = TAGUS_GEA
lightsMap[LightsDevice.TOLINO_EPOS] = TOLINO_EPOS
lightsMap[LightsDevice.TOLINO_PAGE2] = TOLINO_PAGE2
lightsMap[LightsDevice.TOLINO_SHINE3] = TOLINO_SHINE3
lightsMap[LightsDevice.TOLINO_VISION4] = TOLINO_VISION4
lightsMap[LightsDevice.TOLINO_VISION5] = TOLINO_VISION5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ object LightsFactory {
logController("TolinoNTX")
TolinoNtxController()
}
DeviceInfo.LightsDevice.TOLINO_PAGE2 -> {
logController("TolinoNTXNoWarmth")
TolinoNtxNoWarmthController()
}
DeviceInfo.LightsDevice.ONYX_DARWIN7,
DeviceInfo.LightsDevice.ONYX_EDISON,
DeviceInfo.LightsDevice.ONYX_FAUST3,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package org.koreader.launcher.device.lights

import android.app.Activity
import android.provider.Settings
import android.util.Log
import org.koreader.launcher.device.Ioctl
import org.koreader.launcher.device.LightsInterface

/* Special controller for Tolino Page 2
*
* Same as `./TolinoNtxController.kt` but without warmth support.
*/

class TolinoNtxNoWarmthController : Ioctl(), LightsInterface {

companion object {
private const val TAG = "Lights"
private const val BRIGHTNESS_MAX = 255
private const val MIN = 0
private const val NTX_IO_FILE = "/dev/ntx_io"
}

override fun getPlatform(): String {
return "tolino"
}

override fun hasFallback(): Boolean {
return false
}

override fun hasWarmth(): Boolean {
return false
}

override fun needsPermission(): Boolean {
return false
}

override fun enableFrontlightSwitch(activity: Activity): Int {
return 1
}

override fun getBrightness(activity: Activity): Int {
return try {
Settings.System.getInt(activity.applicationContext.contentResolver,
"screen_brightness")
} catch (e: Exception) {
Log.w(TAG, e.toString())
0
}
}

override fun getWarmth(activity: Activity): Int {
Log.w(TAG, "getWarmth: not implemented")
return 0
}

override fun setBrightness(activity: Activity, brightness: Int) {
if (brightness < MIN || brightness > BRIGHTNESS_MAX) {
Log.w(TAG, "brightness value of of range: $brightness")
return
}
Log.v(TAG, "Setting brightness to $brightness")
try {
Settings.System.putInt(activity.applicationContext.contentResolver,
"screen_brightness", brightness)
} catch (e: Exception) {
Log.w(TAG, "$e")
}
}

override fun setWarmth(activity: Activity, warmth: Int) {
Log.w(TAG, "ignoring setWarmth: not implemented")
}

override fun getMinWarmth(): Int {
return 0
}

override fun getMaxWarmth(): Int {
return 0
}

override fun getMinBrightness(): Int {
return MIN
}

override fun getMaxBrightness(): Int {
return BRIGHTNESS_MAX
}
}