Skip to content

Commit

Permalink
rework DeviceInfo.kt
Browse files Browse the repository at this point in the history
Reduce duplication to make it easier to maintain.

Fix the following issues:

- possible problem with `EINK` value on `TOLINO_EPOS3` devices
  (since both `TOLINO` and `TOLINO_EPOS3` booleans would be set)
- `EINK` was never set to `EinkDevice.TOLINO_VISION6`,
  but checked in `device/EPDFactory.kt`
- same with `HANVON_960` & `HYREAD_MINI6`
- `LIGHTS` was never set to `LightsDevice.ONYX_NOTE_PRO`,
  but checked in `device/LightsFactory.kt`
- `LIGHTS` could be set to `LightsDevice.ONYX_PALMA`,
  but was never checked in `device/LightsFactory.kt`

Note: also drop device properties: `is_boyue` (unused) & `is_tolino`
(only used to add direction pad mappings, details were added to the
relevant wiki page instead), and no hardware rotation quirk (which
was an incomplete emulator only workaround).
  • Loading branch information
benoit-pierre committed Nov 10, 2024
1 parent 4af40b5 commit f8c12ad
Show file tree
Hide file tree
Showing 6 changed files with 580 additions and 905 deletions.
6 changes: 1 addition & 5 deletions app/src/main/java/org/koreader/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,7 @@ class MainActivity : NativeActivity(), LuaInterface,
}

override fun hasNativeRotation(): Boolean {
return if (platform == "android") {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
!(device.bugRotation)
} else false
} else false
return platform == "android" && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
}

override fun hasOTAUpdates(): Boolean {
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/org/koreader/launcher/device/Device.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Device(activity: Activity) {
@Suppress("unused")
val product = DeviceInfo.PRODUCT
val needsWakelocks = DeviceInfo.QUIRK_NEEDS_WAKELOCKS
val bugRotation = DeviceInfo.QUIRK_NO_HW_ROTATION
val bugLifecycle = DeviceInfo.QUIRK_BROKEN_LIFECYCLE
val hasColorScreen = DeviceInfo.HAS_COLOR_SCREEN

Expand All @@ -31,13 +30,12 @@ class Device(activity: Activity) {
val einkPlatform = epd.getPlatform()

val properties: String
get() = String.format("%s;%s;%s;%s;%s;%s;%b;%b",
get() = String.format("%s;%s;%s;%s;%s;%s",
DeviceInfo.MANUFACTURER,
DeviceInfo.BRAND,
DeviceInfo.MODEL,
DeviceInfo.DEVICE,
DeviceInfo.PRODUCT,
DeviceInfo.HARDWARE,
DeviceInfo.BOYUE,
DeviceInfo.TOLINO)
)
}
Loading

0 comments on commit f8c12ad

Please sign in to comment.