From 22678ee5ffacf5862ecb77ea7b4391efad7c05d5 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 12 Aug 2023 03:15:11 +0200 Subject: [PATCH] Misc: Review pass on the previous commits * Unbreak the Device test * Rename a few things * Tweak a few comments --- frontend/apps/filemanager/filemanagermenu.lua | 4 ++-- frontend/apps/reader/modules/readermenu.lua | 4 ++-- frontend/device/devicelistener.lua | 8 ++++---- frontend/device/generic/device.lua | 6 ++++-- frontend/device/kobo/device.lua | 6 +++--- frontend/ui/elements/filemanager_menu_order.lua | 2 +- ...{platform_navigation.lua => physical_buttons.lua} | 12 ++++++------ frontend/ui/elements/reader_menu_order.lua | 2 +- spec/unit/device_spec.lua | 2 ++ 9 files changed, 25 insertions(+), 21 deletions(-) rename frontend/ui/elements/{platform_navigation.lua => physical_buttons.lua} (79%) diff --git a/frontend/apps/filemanager/filemanagermenu.lua b/frontend/apps/filemanager/filemanagermenu.lua index 73ea41c22..e622584a5 100644 --- a/frontend/apps/filemanager/filemanagermenu.lua +++ b/frontend/apps/filemanager/filemanagermenu.lua @@ -464,9 +464,9 @@ To: self.menu_items[id] = common_setting end - -- settings > Navigation; this mostly concerns platform-specific features or physical keys, and applies *everywhere* + -- Settings > Navigation; this mostly concerns physical keys, and applies *everywhere* if Device:hasKeys() then - self.menu_items.platform_navigation_features = require("ui/elements/platform_navigation") + self.menu_items.physical_buttons_setup = require("ui/elements/physical_buttons") end -- settings tab - Document submenu diff --git a/frontend/apps/reader/modules/readermenu.lua b/frontend/apps/reader/modules/readermenu.lua index 196853139..e65ce24d5 100644 --- a/frontend/apps/reader/modules/readermenu.lua +++ b/frontend/apps/reader/modules/readermenu.lua @@ -240,9 +240,9 @@ function ReaderMenu:setUpdateItemTable() -- Mostly concern about touch related page turn stuff, which only applies to Reader; ends up in Taps & Gestures self.menu_items.page_turns = require("ui/elements/page_turns") end - -- While also related to page turns, this mostly concerns platform-specific features or physical keys, and applies *everywhere* + -- Settings > Navigation; while also related to page turns, this mostly concerns physical keys, and applies *everywhere* if Device:hasKeys() then - self.menu_items.platform_navigation_features = require("ui/elements/platform_navigation") + self.menu_items.physical_buttons_setup = require("ui/elements/physical_buttons") end -- insert DjVu render mode submenu just before the last entry (show advanced) -- this is a bit of a hack diff --git a/frontend/device/devicelistener.lua b/frontend/device/devicelistener.lua index f57d7b59d..b59455d49 100644 --- a/frontend/device/devicelistener.lua +++ b/frontend/device/devicelistener.lua @@ -319,13 +319,13 @@ end function DeviceListener:onToggleKeyRepeat(toggle) if toggle == true then - G_reader_settings:makeFalse("input_no_key_repeats") + G_reader_settings:makeFalse("input_no_key_repeat") elseif toggle == false then - G_reader_settings:makeTrue("input_no_key_repeats") + G_reader_settings:makeTrue("input_no_key_repeat") else - G_reader_settings:flipNilOrFalse("input_no_key_repeats") + G_reader_settings:flipNilOrFalse("input_no_key_repeat") end - Device:toggleKeyRepeat(G_reader_settings:nilOrFalse("input_no_key_repeats")) + Device:toggleKeyRepeat(G_reader_settings:nilOrFalse("input_no_key_repeat")) end function DeviceListener:onRestart() diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index 0a7d4e061..1b37f2ec1 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -525,9 +525,11 @@ function Device:enableCPUCores(amount) end function Device:getKeyRepeat() end -- Device specific method to disable key repeat function Device:disableKeyRepeat() end --- Device specific method to restore key repeat +-- Device specific method to restore the initial key repeat config function Device:restoreKeyRepeat() end --- Device specific method to toggle key repeat (between off and a hard-coded delay/period combo) +-- NOTE: This one is for the user-facing toggle, it *ignores* the stock delay/period combo, +-- opting instead for a hard-coded one (as we can't guarantee that key repeat is actually setup properly or at all). +-- Device specific method to toggle key repeat function Device:toggleKeyRepeat(toggle) end --[[ diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index 4b88960a4..c89a4a5dc 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -890,8 +890,8 @@ function Kobo:init() self.hasIRGridSysfsKnob = "/sys/devices/platform/imx-i2c.1/i2c-1/1-0050/neocmd" end - -- Disable key repeats if requested - if G_reader_settings:isTrue("input_no_key_repeats") then + -- Disable key repeat if requested + if G_reader_settings:isTrue("input_no_key_repeat") then self:toggleKeyRepeat(false) end @@ -901,7 +901,7 @@ function Kobo:init() end function Kobo:exit() - -- Re-enable key repeats on exit, that's the default state + -- Re-enable key repeat on exit, that's the default state self:toggleKeyRepeat(true) Generic.exit(self) diff --git a/frontend/ui/elements/filemanager_menu_order.lua b/frontend/ui/elements/filemanager_menu_order.lua index 05bc0f601..543e5507c 100644 --- a/frontend/ui/elements/filemanager_menu_order.lua +++ b/frontend/ui/elements/filemanager_menu_order.lua @@ -70,7 +70,7 @@ local order = { "back_in_reader", "backspace_as_back", "----------------------------", - "platform_navigation_features", + "physical_buttons_setup", "----------------------------", "android_volume_keys", "android_haptic_feedback", diff --git a/frontend/ui/elements/platform_navigation.lua b/frontend/ui/elements/physical_buttons.lua similarity index 79% rename from frontend/ui/elements/platform_navigation.lua rename to frontend/ui/elements/physical_buttons.lua index 4d0ad1dcd..454ba3e2e 100644 --- a/frontend/ui/elements/platform_navigation.lua +++ b/frontend/ui/elements/physical_buttons.lua @@ -4,8 +4,8 @@ local UIManager = require("ui/uimanager") local _ = require("gettext") -- This whole menu is hidden behind a hasKeys device cap. -local PlatformNav = { - text = _("Page turn behavior"), -- Mainly so as to differentiate w/ "Page Turns" when in readermenu... +local PhysicalButtons = { + text = _("Physical buttons"), -- Mainly so as to differentiate w/ "Page Turns" when in readermenu... sub_item_table = { { text = _("Invert page turn buttons"), @@ -20,11 +20,11 @@ local PlatformNav = { } if Device:canKeyRepeat() then - table.insert(PlatformNav.sub_item_table, { - text = _("Disable key repeats"), + table.insert(PhysicalButtons.sub_item_table, { + text = _("Disable key repeat"), help_text = _("Useful if you don't like the behavior or if your device has faulty switches"), checked_func = function() - return G_reader_settings:isTrue("input_no_key_repeats") + return G_reader_settings:isTrue("input_no_key_repeat") end, callback = function() UIManager:broadcastEvent(Event:new("ToggleKeyRepeat")) @@ -33,4 +33,4 @@ if Device:canKeyRepeat() then }) end -return PlatformNav +return PhysicalButtons diff --git a/frontend/ui/elements/reader_menu_order.lua b/frontend/ui/elements/reader_menu_order.lua index 89424f046..2e03f0bc7 100644 --- a/frontend/ui/elements/reader_menu_order.lua +++ b/frontend/ui/elements/reader_menu_order.lua @@ -114,7 +114,7 @@ local order = { "back_in_reader", "backspace_as_back", "----------------------------", - "platform_navigation_features", + "physical_buttons_setup", "----------------------------", "android_volume_keys", "android_haptic_feedback", diff --git a/spec/unit/device_spec.lua b/spec/unit/device_spec.lua index babe2db43..721473b07 100644 --- a/spec/unit/device_spec.lua +++ b/spec/unit/device_spec.lua @@ -25,6 +25,8 @@ describe("device module", function() scaleBySize = fb.scaleBySize, setWindowTitle = function() end, refreshFull = function() end, + getHWNightmode = function() return false end, + setupDithering = function() end, } end }