BookMap on devices with useDPadAsActionKeys (#11916)

as first discussed here #11908. This PR brings the book map to non-touch devices that useDPadAsActionKeys().

Book map can be accessed from the menu or by using the following shortcut: ScreenKB + Down or Shift + Down depending on whether you use a K4 device or a kindle with keyboard respectively.

Inside the book map, a user can toggle the hamburger menu by pressing the Menu key and make any adjustment from there. ScreenKB (or Shift) + Up/Down allows it to scroll and Page turn buttons to move by whole full page turns. Back key allows user to exit the map.
This commit is contained in:
David
2024-06-05 21:50:22 +01:00
committed by GitHub
parent 21213f35af
commit 04eec52eee
4 changed files with 69 additions and 33 deletions

View File

@@ -19,6 +19,7 @@ local ffiUtil = require("ffi/util")
local time = require("ui/time")
local _ = require("gettext")
local C_ = _.pgettext
local N_ = _.npgettext
local T = ffiUtil.template
local Screen = Device.screen
@@ -601,11 +602,11 @@ Except when in two columns mode, where this is limited to showing only the previ
if not Device:isTouchDevice() and Device:hasDPad() then
table.insert(menu_items.long_press.sub_item_table, {
text_func = function()
return T(_("Rate of movement in content selection: %1"), G_reader_settings:readSetting("highlight_non_touch_factor", 4))
return T(_("Rate of movement in content selection: %1"), G_reader_settings:readSetting("highlight_non_touch_factor") or 4)
end,
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local curr_val = G_reader_settings:readSetting("highlight_non_touch_factor", 4)
local curr_val = G_reader_settings:readSetting("highlight_non_touch_factor") or 4
local spin_widget = SpinWidget:new{
value = curr_val,
value_min = 0.25,
@@ -637,18 +638,15 @@ Except when in two columns mode, where this is limited to showing only the previ
})
table.insert(menu_items.long_press.sub_item_table, {
text_func = function()
if G_reader_settings:readSetting("highlight_non_touch_interval") == 1 then
return T(_("Interval to speed-up rate: %1 second"), G_reader_settings:readSetting("highlight_non_touch_interval", 1))
else
return T(_("Interval to speed-up rate: %1 seconds"), G_reader_settings:readSetting("highlight_non_touch_interval", 1))
end
local highlight_non_touch_interval = G_reader_settings:readSetting("highlight_non_touch_interval") or 1
return T(N_("Speed-up rate interval: %1 second", "Speed-up rate interval: %1 seconds", highlight_non_touch_interval), highlight_non_touch_interval)
end,
enabled_func = function()
return not self.view.highlight.disabled and G_reader_settings:nilOrTrue("highlight_non_touch_spedup")
end,
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local curr_val = G_reader_settings:readSetting("highlight_non_touch_interval", 1)
local curr_val = G_reader_settings:readSetting("highlight_non_touch_interval") or 1
local spin_widget = SpinWidget:new{
value = curr_val,
value_min = 0.1,
@@ -2274,7 +2272,7 @@ function ReaderHighlight:onMoveHighlightIndicator(args)
local quick_move_distance_dx = self.view.visible_area.w * (1/5) -- quick move distance: fifth of visible_area
local quick_move_distance_dy = self.view.visible_area.h * (1/5)
-- single move distance, user adjustable, default value (4) capable to move on word with small font size and narrow line height
local move_distance = Size.item.height_default / G_reader_settings:readSetting("highlight_non_touch_factor")
local move_distance = Size.item.height_default / (G_reader_settings:readSetting("highlight_non_touch_factor") or 4)
local rect = self._current_indicator_pos:copy()
if quick_move then
rect.x = rect.x + quick_move_distance_dx * dx
@@ -2289,8 +2287,8 @@ function ReaderHighlight:onMoveHighlightIndicator(args)
-- quadruple press: 64 single distances, almost move to screen edge
if G_reader_settings:nilOrTrue("highlight_non_touch_spedup") then
-- user selects whether to use 'constant' or [this] 'sped up' rate (speed-up on by default)
local x_inter = G_reader_settings:readSetting("highlight_non_touch_interval")
if diff < time.s( x_inter ) then
local t_inter = G_reader_settings:readSetting("highlight_non_touch_interval") or 1
if diff < time.s( t_inter ) then
move_distance = self._last_indicator_move_args.distance * 4
end
end