From bed8f558fa23786413843b8d95efa6fddf7cc980 Mon Sep 17 00:00:00 2001 From: David <97603719+Commodore64user@users.noreply.github.com> Date: Sat, 7 Mar 2026 07:24:16 +0000 Subject: [PATCH] Switch virtual keyboard default to false on hasKeyboard (#15057) --- frontend/ui/data/onetime_migration.lua | 13 ++++++++++++- frontend/ui/elements/menu_keyboard_layout.lua | 8 ++++---- frontend/ui/widget/inputdialog.lua | 4 ++-- frontend/ui/widget/inputtext.lua | 4 ++-- frontend/ui/widget/multiinputdialog.lua | 4 ++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/frontend/ui/data/onetime_migration.lua b/frontend/ui/data/onetime_migration.lua index 544425761..e5dda122c 100644 --- a/frontend/ui/data/onetime_migration.lua +++ b/frontend/ui/data/onetime_migration.lua @@ -12,7 +12,7 @@ local util = require("util") local _ = require("gettext") -- Date at which the last migration snippet was added -local CURRENT_MIGRATION_DATE = 20250929 +local CURRENT_MIGRATION_DATE = 20260306 -- Retrieve the date of the previous migration, if any local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0) @@ -945,5 +945,16 @@ if last_migration_date < 20250929 then end end +-- 20260306, Screensaver message position refactor: top/middle/bottom -> banner/box with custom positioning +-- https://github.com/koreader/koreader/pull/15057 +if last_migration_date < 20260306 then + logger.info("Performing one-time migration for 20260306") + + local Device = require("device") + if Device:hasScreenKB() and G_reader_settings:hasNot("virtual_keyboard_enabled") then + G_reader_settings:makeTrue("virtual_keyboard_enabled") + end +end + -- We're done, store the current migration date G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE) diff --git a/frontend/ui/elements/menu_keyboard_layout.lua b/frontend/ui/elements/menu_keyboard_layout.lua index 69fdae776..bee009d8b 100644 --- a/frontend/ui/elements/menu_keyboard_layout.lua +++ b/frontend/ui/elements/menu_keyboard_layout.lua @@ -164,7 +164,7 @@ local sub_item_table = { text = _("Keyboard appearance settings"), keep_menu_open = true, enabled_func = function() - return G_reader_settings:nilOrTrue("virtual_keyboard_enabled") + return G_reader_settings:isTrue("virtual_keyboard_enabled") or (Device:isTouchDevice() and not Device:hasKeyboard()) end, callback = function(touchmenu_instance) local InputDialog = require("ui/widget/inputdialog") @@ -233,11 +233,11 @@ if Device:hasKeyboard() or Device:hasScreenKB() then text = _("Show virtual keyboard"), help_text = _("Enable this setting to always display the virtual keyboard within a text input field. When a field is selected (in focus), you can temporarily toggle the keyboard on/off by pressing 'Shift' (or 'ScreenKB') + 'Home'."), checked_func = function() - return G_reader_settings:nilOrTrue("virtual_keyboard_enabled") + return G_reader_settings:isTrue("virtual_keyboard_enabled") end, callback = function() - G_reader_settings:flipNilOrTrue("virtual_keyboard_enabled") - if G_reader_settings:isFalse("virtual_keyboard_enabled") then + G_reader_settings:flipNilOrFalse("virtual_keyboard_enabled") + if G_reader_settings:nilOrFalse("virtual_keyboard_enabled") then local keyboard_infomessage if Device:hasScreenKB() then keyboard_infomessage = _("When a text field is selected (in focus), you can temporarily bring up the virtual keyboard by pressing 'ScreenKB' + 'Home'.") diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua index 82087a648..fd5baa402 100644 --- a/frontend/ui/widget/inputdialog.lua +++ b/frontend/ui/widget/inputdialog.lua @@ -223,7 +223,7 @@ function InputDialog:init() if self.fullscreen or self.add_nav_bar then self.deny_keyboard_hiding = true end - if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then + if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled") then self.keyboard_visible = false self.skip_first_show_keyboard = true end @@ -642,7 +642,7 @@ function InputDialog:isKeyboardVisible() end function InputDialog:lockKeyboard(toggle) - if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then + if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled") then -- do not lock the virtual keyboard when user is hiding it, we still *might* want to activate it via shortcuts ("Shift" + "Home") when in need of special characters or symbols return end diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua index 430296d22..1557bcb8d 100644 --- a/frontend/ui/widget/inputtext.lua +++ b/frontend/ui/widget/inputtext.lua @@ -142,7 +142,7 @@ local function initTouchEvents() if self.parent.onSwitchFocus then self.parent:onSwitchFocus(self) else - if not ((Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled")) then + if not ((Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled")) then self:onShowKeyboard() end Device:startTextInput() @@ -209,7 +209,7 @@ local function initDPadEvents() -- Event sent by focusmanager if self.parent.onSwitchFocus then self.parent:onSwitchFocus(self) - elseif (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then + elseif (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled") then do end -- luacheck: ignore 541 else if not self:isKeyboardVisible() then diff --git a/frontend/ui/widget/multiinputdialog.lua b/frontend/ui/widget/multiinputdialog.lua index 7955ee0ac..1460c19e8 100644 --- a/frontend/ui/widget/multiinputdialog.lua +++ b/frontend/ui/widget/multiinputdialog.lua @@ -112,7 +112,7 @@ function MultiInputDialog:init() -- Reset self.keyboard_visible because InputDialog:onCloseKeyboard sets it to false, which can lead to an incorrect keyboard -- visibility state since we still might want our very own virtual keyboard. - if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then + if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled") then do end -- luacheck: ignore 541 elseif self.readonly then do end -- luacheck: ignore 541 @@ -263,7 +263,7 @@ function MultiInputDialog:onSwitchFocus(inputbox) self._input_widget:focus() self.focused_field_idx = inputbox.idx - if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then + if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:nilOrFalse("virtual_keyboard_enabled") then -- do not load virtual keyboard when user is hiding it. return end