SomeGuy 2 weeks ago committed by GitHub
commit 128cdf1621
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -66,6 +66,9 @@ function ReaderBookmark:onGesture() end
function ReaderBookmark:registerKeyEvents()
if Device:hasKeyboard() then
self.key_events.ShowBookmark = { { "B" } }
elseif Device:hasFiveWay() then
self.key_events.ShowBookmark = { { "ScreenKB", "Left" } }
self.key_events.ToggleBookmark = { { "ScreenKB", "Right" } }
end
end

@ -229,7 +229,16 @@ end
function ReaderHighlight:onGesture() end
function ReaderHighlight:registerKeyEvents()
if Device:hasKeys() then
if Device:hasDPad() then
self.key_events.StopHighlightIndicator = { { Device.input.group.Back }, args = true } -- true: clear highlight selection
self.key_events.UpHighlightIndicator = { { "Up" }, event = "MoveHighlightIndicator", args = {0, -1} }
self.key_events.DownHighlightIndicator = { { "Down" }, event = "MoveHighlightIndicator", args = {0, 1} }
-- let hasFewKeys device move the indicator left
self.key_events.LeftHighlightIndicator = { { "Left" }, event = "MoveHighlightIndicator", args = {-1, 0} }
self.key_events.RightHighlightIndicator = { { "Right" }, event = "MoveHighlightIndicator", args = {1, 0} }
self.key_events.HighlightPress = { { "Press" } }
end
if Device:hasKeyboard() then
-- Used for text selection with dpad/keys
local QUICK_INDICATOR_MOVE = true
self.key_events.QuickUpHighlightIndicator = { { "Shift", "Up" }, event = "MoveHighlightIndicator", args = {0, -1, QUICK_INDICATOR_MOVE} }
@ -237,15 +246,12 @@ function ReaderHighlight:registerKeyEvents()
self.key_events.QuickLeftHighlightIndicator = { { "Shift", "Left" }, event = "MoveHighlightIndicator", args = {-1, 0, QUICK_INDICATOR_MOVE} }
self.key_events.QuickRightHighlightIndicator = { { "Shift", "Right" }, event = "MoveHighlightIndicator", args = {1, 0, QUICK_INDICATOR_MOVE} }
self.key_events.StartHighlightIndicator = { { "H" } }
if Device:hasDPad() then
self.key_events.StopHighlightIndicator = { { Device.input.group.Back }, args = true } -- true: clear highlight selection
self.key_events.UpHighlightIndicator = { { "Up" }, event = "MoveHighlightIndicator", args = {0, -1} }
self.key_events.DownHighlightIndicator = { { "Down" }, event = "MoveHighlightIndicator", args = {0, 1} }
-- let hasFewKeys device move the indicator left
self.key_events.LeftHighlightIndicator = { { "Left" }, event = "MoveHighlightIndicator", args = {-1, 0} }
self.key_events.RightHighlightIndicator = { { "Right" }, event = "MoveHighlightIndicator", args = {1, 0} }
self.key_events.HighlightPress = { { "Press" } }
end
elseif Device:hasFiveWay() then
local QUICK_INDICATOR_MOVE = true
self.key_events.QuickUpHighlightIndicator = { { "ScreenKB", "Up" }, event = "MoveHighlightIndicator", args = {0, -1, QUICK_INDICATOR_MOVE} }
self.key_events.QuickDownHighlightIndicator = { { "ScreenKB", "Down" }, event = "MoveHighlightIndicator", args = {0, 1, QUICK_INDICATOR_MOVE} }
self.key_events.QuickLeftHighlightIndicator = { { "ScreenKB", "Left" }, event = "MoveHighlightIndicator", args = {-1, 0, QUICK_INDICATOR_MOVE} }
self.key_events.QuickRightHighlightIndicator = { { "ScreenKB", "Right" }, event = "MoveHighlightIndicator", args = {1, 0, QUICK_INDICATOR_MOVE} }
end
end
@ -575,6 +581,7 @@ function ReaderHighlight:addToMainMenu(menu_items)
help_text = _([[
Auto-scroll to show part of the previous page when your text selection reaches the top left corner, or of the next page when it reaches the bottom right corner.
Except when in two columns mode, where this is limited to showing only the previous or next column.]]),
separator = true,
checked_func = function()
if self.ui.paging then return false end
return not self.view.highlight.disabled and G_reader_settings:nilOrTrue("highlight_corner_scroll")
@ -588,6 +595,76 @@ Except when in two columns mode, where this is limited to showing only the previ
self.allow_corner_scroll = G_reader_settings:nilOrTrue("highlight_corner_scroll")
end,
})
-- we allow user to select the rate at which the content selection tool moves through screen
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))
end,
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local curr_val = G_reader_settings:readSetting("highlight_non_touch_factor", 4)
local spin_widget = SpinWidget:new{
value = curr_val,
value_min = 0.25,
value_max = 5,
precision = "%.2f",
value_step = 0.25,
default_value = 4,
title_text = _("Rate of movement"),
info_text = _("Select a decimal value from 0.25 to 5. A smaller value results in a larger travel distance per keystroke. Font size and this value are inversely correlated, meaning a smaller font size requires a larger value and vice versa."),
callback = function(spin)
G_reader_settings:saveSetting("highlight_non_touch_factor", spin.value)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(spin_widget)
end,
})
table.insert(menu_items.long_press.sub_item_table, {
text = _("Speed-up rate on multiple keystrokes"),
checked_func = function()
return G_reader_settings:nilOrTrue("highlight_non_touch_spedup")
end,
enabled_func = function()
return not self.view.highlight.disabled
end,
callback = function()
G_reader_settings:flipNilOrTrue("highlight_non_touch_spedup")
end,
})
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
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 spin_widget = SpinWidget:new{
value = curr_val,
value_min = 0.1,
value_max = 1,
precision = "%.1f",
value_step = 0.1,
default_value = 1,
title_text = _("Time interval"),
info_text = _("Select a decimal value up to 1 second. This is the period of time within which multiple keystrokes will speed-up rate of travel."),
callback = function(spin)
G_reader_settings:saveSetting("highlight_non_touch_interval", spin.value)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(spin_widget)
end,
})
end
-- long_press setting is under taps_and_gestures menu which is not available for non-touch devices
-- Clone long_press setting and change its label, making it much more meaningful for non-touch device users.
@ -2192,8 +2269,8 @@ function ReaderHighlight:onMoveHighlightIndicator(args)
local dx, dy, quick_move = unpack(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, small and capable to move on word with small font size and narrow line height
local move_distance = Size.item.height_default / 4
-- 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 rect = self._current_indicator_pos:copy()
if quick_move then
rect.x = rect.x + quick_move_distance_dx * dx
@ -2202,12 +2279,16 @@ function ReaderHighlight:onMoveHighlightIndicator(args)
local now = time:now()
if dx == self._last_indicator_move_args.dx and dy == self._last_indicator_move_args.dy then
local diff = now - self._last_indicator_move_args.time
-- if press same arrow key in 1 second, speed up
-- if user presses same arrow key within 1 second (default, user adjustable), speed up
-- double press: 4 single move distances, usually move to next word or line
-- triple press: 16 single distances, usually skip several words or lines
-- quadruple press: 54 single distances, almost move to screen edge
if diff < time.s(1) then
move_distance = self._last_indicator_move_args.distance * 4
-- 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
move_distance = self._last_indicator_move_args.distance * 4
end
end
end
rect.x = rect.x + move_distance * dx

@ -51,7 +51,33 @@ end
function ReaderPaging:onGesture() end
function ReaderPaging:registerKeyEvents()
if Device:hasKeys() then
if Device:hasFiveWay() then
-- this targets all devices (kindles) non-touch with dPads (i.e dx, kk, k4 and others)
self.key_events.GotoNextPos = {
{ { "RPgFwd", "LPgFwd" } },
event = "GotoPosRel",
args = 1,
}
self.key_events.GotoPrevPos = {
{ { "RPgBack", "LPgBack" } },
event = "GotoPosRel",
args = -1,
}
self.key_events.ContentSelection = {
{ { "Up", "Down" } },
event = "ContentSelection",
}
self.key_events.GotoNextChapter = {
{ "Right" },
event = "GotoNextChapter",
args = 1,
}
self.key_events.GotoPrevChapter = {
{ "Left" },
event = "GotoPrevChapter",
args = -1,
}
elseif Device:hasKeys() then
self.key_events.GotoNextPage = {
{ { "RPgFwd", "LPgFwd", not Device:hasFewKeys() and "Right" } },
event = "GotoViewRel",
@ -73,6 +99,15 @@ function ReaderPaging:registerKeyEvents()
args = -1,
}
end
--[[ upcoming
if Device:hasFiveWay() and not Device:hasKeyboard() then
-- targets exclusively kindle 4
self.key_events.PrevDocument = {
{ "ScreenKB", "Back" },
event = "PrevDocument",
args = 0,
}
end ]]
if Device:hasKeyboard() then
self.key_events.GotoFirst = {
{ "1" },
@ -133,6 +168,10 @@ function ReaderPaging:onReaderReady()
self:setupTouchZones()
end
function ReaderPaging:onContentSelection()
return self.ui.highlight:onStartHighlightIndicator()
end
function ReaderPaging:setupTouchZones()
if not Device:isTouchDevice() then return end
@ -202,6 +241,10 @@ function ReaderPaging:onSaveSettings()
self.ui.doc_settings:saveSetting("flipping_scroll_mode", self.flipping_scroll_mode)
end
function ReaderPaging:onPrevDocument()
return self.ui:onOpenLastDoc()
end
function ReaderPaging:getLastProgress()
return self:getTopPage()
end

@ -116,7 +116,30 @@ end
function ReaderRolling:onGesture() end
function ReaderRolling:registerKeyEvents()
if Device:hasKeys() then
if Device:hasFiveWay() then
self.key_events.GotoNextView = {
{ { "RPgFwd", "LPgFwd" } },
event = "GotoViewRel",
args = 1,
}
self.key_events.GotoPrevView = {
{ { "RPgBack", "LPgBack" } },
event = "GotoViewRel",
args = -1,
}
if Device:hasKeyboard() then
self.key_events.MoveUp = {
{ "Shift", { "RPgBack", "LPgBack" } },
event = "Panning",
args = {0, -1},
}
self.key_events.MoveDown = {
{ "Shift", { "RPgFwd", "LPgFwd" } },
event = "Panning",
args = {0, 1},
}
end
elseif Device:hasKeys() then
self.key_events.GotoNextView = {
{ { "RPgFwd", "LPgFwd", "Right" } },
event = "GotoViewRel",
@ -128,7 +151,22 @@ function ReaderRolling:registerKeyEvents()
args = -1,
}
end
if Device:hasDPad() then
if Device:hasFiveWay() then
self.key_events.ContentSelection = {
{ { "Up", "Down" } },
event = "ContentSelection",
}
self.key_events.GotoNextChapter = {
{ "Right" },
event = "GotoNextChapter",
args = 1,
}
self.key_events.GotoPrevChapter = {
{ "Left" },
event = "GotoPrevChapter",
args = -1,
}
elseif Device:hasDPad() then
self.key_events.MoveUp = {
{ "Up" },
event = "Panning",
@ -140,6 +178,25 @@ function ReaderRolling:registerKeyEvents()
args = {0, 1},
}
end
if Device:hasFiveWay() and not Device:hasKeyboard() then
--[[ upcoming
self.key_events.PrevDocument = {
{ "ScreenKB", "Back" },
event = "PrevDocument",
args = 0,
} ]]
self.key_events.MoveUp = {
{ "ScreenKB", { "RPgBack", "LPgBack" } },
event = "Panning",
args = {0, -1},
}
self.key_events.MoveDown = {
{ "ScreenKB", { "RPgFwd", "LPgFwd" } },
event = "Panning",
args = {0, 1},
}
end
if Device:hasKeyboard() then
self.key_events.GotoFirst = {
{ "1" },
@ -350,6 +407,10 @@ function ReaderRolling:onCloseDocument()
-- if namespaces ~= "" then logger.info("cre unknown namespaces: ", namespaces) end
end
function ReaderRolling:onPrevDocument()
return self.ui:onOpenLastDoc()
end
function ReaderRolling:onCheckDomStyleCoherence()
if self.ui.document and self.ui.document:isBuiltDomStale() then
local has_bookmarks_warn_txt = ""
@ -780,6 +841,10 @@ function ReaderRolling:onGotoPrevChapter()
return true
end
function ReaderRolling:onContentSelection()
return self.ui.highlight:onStartHighlightIndicator()
end
function ReaderRolling:onNotCharging()
self:updateBatteryState()
end

@ -62,6 +62,8 @@ function ReaderToc:onGesture() end
function ReaderToc:registerKeyEvents()
if Device:hasKeyboard() then
self.key_events.ShowToc = { { "T" } }
elseif Device:hasFiveWay() then
self.key_events.ShowToc = { { "ScreenKB", "Up" } }
end
end

@ -41,6 +41,7 @@ local Device = {
hasAuxBattery = no,
hasKeyboard = no,
hasKeys = no,
hasFiveWay = no,
canKeyRepeat = no,
hasDPad = no,
hasExitOptions = yes,

@ -518,6 +518,7 @@ local Kindle2 = Kindle:extend{
isREAGL = no,
hasKeyboard = yes,
hasKeys = yes,
hasFiveWay = yes,
hasDPad = yes,
canHWInvert = no,
canModifyFBInfo = no,
@ -531,6 +532,7 @@ local KindleDXG = Kindle:extend{
isREAGL = no,
hasKeyboard = yes,
hasKeys = yes,
hasFiveWay = yes,
hasDPad = yes,
canHWInvert = no,
canModifyFBInfo = no,
@ -544,6 +546,7 @@ local Kindle3 = Kindle:extend{
isREAGL = no,
hasKeyboard = yes,
hasKeys = yes,
hasFiveWay = yes,
hasDPad = yes,
canHWInvert = no,
canModifyFBInfo = no,
@ -555,6 +558,7 @@ local Kindle4 = Kindle:extend{
model = "Kindle4",
isREAGL = no,
hasKeys = yes,
hasFiveWay = yes,
hasDPad = yes,
canHWInvert = no,
canModifyFBInfo = no,

Loading…
Cancel
Save