Gesture intervals spinwidgets - do not show default value in info-text (#8488)

Default values are now shown in SpinWidget default button.
Optimized SpinWidget calls.
reviewable/pr8491/r1
hius07 3 years ago committed by GitHub
parent 7495ea29ef
commit c7a3c17ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,12 +6,14 @@ local Dispatcher = require("dispatcher")
local Event = require("ui/event") local Event = require("ui/event")
local FFIUtil = require("ffi/util") local FFIUtil = require("ffi/util")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local GestureDetector = require("device/gesturedetector")
local GestureRange = require("ui/gesturerange") local GestureRange = require("ui/gesturerange")
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local InputContainer = require("ui/widget/container/inputcontainer") local InputContainer = require("ui/widget/container/inputcontainer")
local InputDialog = require("ui/widget/inputdialog") local InputDialog = require("ui/widget/inputdialog")
local LuaSettings = require("luasettings") local LuaSettings = require("luasettings")
local Screen = require("device").screen local Screen = require("device").screen
local SpinWidget = require("ui/widget/spinwidget")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local util = require("util") local util = require("util")
local T = FFIUtil.template local T = FFIUtil.template
@ -441,18 +443,13 @@ function Gestures:addIntervals(menu_items)
text = _("Text selection rate"), text = _("Text selection rate"),
keep_menu_open = true, keep_menu_open = true,
callback = function() callback = function()
local SpinWidget = require("ui/widget/spinwidget") local default_value = Screen.low_pan_rate and 5.0 or 30.0
local current_value = G_reader_settings:readSetting("hold_pan_rate") local current_value = G_reader_settings:readSetting("hold_pan_rate", default_value)
if not current_value then
current_value = Screen.low_pan_rate and 5.0 or 30.0
end
local items = SpinWidget:new{ local items = SpinWidget:new{
title_text = _("Text selection rate"), title_text = _("Text selection rate"),
info_text = T(_([[ info_text = _([[
The rate is how often screen will be refreshed per second while selecting text. The rate is how often screen will be refreshed per second while selecting text.
Higher values mean faster screen updates, but also use more CPU. Higher values mean faster screen updates, but also use more CPU.]]),
Default value: %1]]), Screen.low_pan_rate and 5.0 or 30.0),
width = math.floor(Screen:getWidth() * 0.75), width = math.floor(Screen:getWidth() * 0.75),
value = current_value, value = current_value,
value_min = 1.0, value_min = 1.0,
@ -460,7 +457,7 @@ Default value: %1]]), Screen.low_pan_rate and 5.0 or 30.0),
value_step = 1, value_step = 1,
value_hold_step = 15, value_hold_step = 15,
ok_text = _("Set rate"), ok_text = _("Set rate"),
default_value = Screen.low_pan_rate and 5.0 or 30.0, default_value = default_value,
callback = function(spin) callback = function(spin)
G_reader_settings:saveSetting("hold_pan_rate", spin.value) G_reader_settings:saveSetting("hold_pan_rate", spin.value)
UIManager:broadcastEvent(Event:new("UpdateHoldPanRate")) UIManager:broadcastEvent(Event:new("UpdateHoldPanRate"))
@ -474,15 +471,12 @@ Default value: %1]]), Screen.low_pan_rate and 5.0 or 30.0),
text = _("Tap interval"), text = _("Tap interval"),
keep_menu_open = true, keep_menu_open = true,
callback = function() callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local GestureDetector = require("device/gesturedetector")
local items = SpinWidget:new{ local items = SpinWidget:new{
title_text = _("Tap interval"), title_text = _("Tap interval"),
info_text = T(_([[ info_text = _([[
Any other taps made within this interval after a first tap will be considered accidental and ignored. Any other taps made within this interval after a first tap will be considered accidental and ignored.
The interval value is in milliseconds and can range from 0 (0 seconds) to 2000 (2 seconds). The interval value is in milliseconds and can range from 0 (0 seconds) to 2000 (2 seconds).]]),
Default value: %1]]), GestureDetector.TAP_INTERVAL/1000),
width = math.floor(Screen:getWidth() * 0.75), width = math.floor(Screen:getWidth() * 0.75),
value = GestureDetector:getInterval("ges_tap_interval")/1000, value = GestureDetector:getInterval("ges_tap_interval")/1000,
value_min = 0, value_min = 0,
@ -503,16 +497,14 @@ Default value: %1]]), GestureDetector.TAP_INTERVAL/1000),
text = _("Tap interval on keyboard"), text = _("Tap interval on keyboard"),
keep_menu_open = true, keep_menu_open = true,
callback = function() callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local items = SpinWidget:new{ local items = SpinWidget:new{
title_text = _("Tap interval on keyboard"), title_text = _("Tap interval on keyboard"),
info_text = _([[ info_text = _([[
Any other taps made within this interval after a first tap will be considered accidental and ignored. Any other taps made within this interval after a first tap will be considered accidental and ignored.
The interval value is in milliseconds and can range from 0 (0 seconds) to 2000 (2 seconds). The interval value is in milliseconds and can range from 0 (0 seconds) to 2000 (2 seconds).]]),
Default value: 0]]),
width = math.floor(Screen:getWidth() * 0.75), width = math.floor(Screen:getWidth() * 0.75),
value = (G_reader_settings:readSetting("ges_tap_interval_on_keyboard") or 0)/1000, value = G_reader_settings:readSetting("ges_tap_interval_on_keyboard", 0)/1000,
value_min = 0, value_min = 0,
value_max = 2000, value_max = 2000,
value_step = 50, value_step = 50,
@ -530,15 +522,12 @@ Default value: 0]]),
text = _("Double tap interval"), text = _("Double tap interval"),
keep_menu_open = true, keep_menu_open = true,
callback = function() callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local GestureDetector = require("device/gesturedetector")
local items = SpinWidget:new{ local items = SpinWidget:new{
title_text = _("Double tap interval"), title_text = _("Double tap interval"),
info_text = T(_([[ info_text = _([[
When double tap is enabled, this sets the time to wait for the second tap. A single tap will take at least this long to be detected. When double tap is enabled, this sets the time to wait for the second tap. A single tap will take at least this long to be detected.
The interval value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds). The interval value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds).]]),
Default value: %1]]), GestureDetector.DOUBLE_TAP_INTERVAL/1000),
width = math.floor(Screen:getWidth() * 0.75), width = math.floor(Screen:getWidth() * 0.75),
value = GestureDetector:getInterval("ges_double_tap_interval")/1000, value = GestureDetector:getInterval("ges_double_tap_interval")/1000,
value_min = 100, value_min = 100,
@ -559,15 +548,12 @@ Default value: %1]]), GestureDetector.DOUBLE_TAP_INTERVAL/1000),
text = _("Two finger tap duration"), text = _("Two finger tap duration"),
keep_menu_open = true, keep_menu_open = true,
callback = function() callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local GestureDetector = require("device/gesturedetector")
local items = SpinWidget:new{ local items = SpinWidget:new{
title_text = _("Two finger tap duration"), title_text = _("Two finger tap duration"),
info_text = T(_([[ info_text = _([[
This sets the allowed duration of any of the two fingers touch/release for the combined event to be considered a two finger tap. This sets the allowed duration of any of the two fingers touch/release for the combined event to be considered a two finger tap.
The duration value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds). The duration value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds).]]),
Default value: %1]]), GestureDetector.TWO_FINGER_TAP_DURATION/1000),
width = math.floor(Screen:getWidth() * 0.75), width = math.floor(Screen:getWidth() * 0.75),
value = GestureDetector:getInterval("ges_two_finger_tap_duration")/1000, value = GestureDetector:getInterval("ges_two_finger_tap_duration")/1000,
value_min = 100, value_min = 100,
@ -588,15 +574,12 @@ Default value: %1]]), GestureDetector.TWO_FINGER_TAP_DURATION/1000),
text = _("Long-press interval"), text = _("Long-press interval"),
keep_menu_open = true, keep_menu_open = true,
callback = function() callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local GestureDetector = require("device/gesturedetector")
local items = SpinWidget:new{ local items = SpinWidget:new{
title_text = _("Long-press interval"), title_text = _("Long-press interval"),
info_text = T(_([[ info_text = _([[
If a touch is not released in this interval, it is considered a long-press. On document text, single word selection will then be triggered. If a touch is not released in this interval, it is considered a long-press. On document text, single word selection will then be triggered.
The interval value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds). The interval value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds).]]),
Default value: %1]]), GestureDetector.HOLD_INTERVAL/1000),
width = math.floor(Screen:getWidth() * 0.75), width = math.floor(Screen:getWidth() * 0.75),
value = GestureDetector:getInterval("ges_hold_interval")/1000, value = GestureDetector:getInterval("ges_hold_interval")/1000,
value_min = 100, value_min = 100,
@ -617,15 +600,12 @@ Default value: %1]]), GestureDetector.HOLD_INTERVAL/1000),
text = _("Swipe interval"), text = _("Swipe interval"),
keep_menu_open = true, keep_menu_open = true,
callback = function() callback = function()
local SpinWidget = require("ui/widget/spinwidget")
local GestureDetector = require("device/gesturedetector")
local items = SpinWidget:new{ local items = SpinWidget:new{
title_text = _("Swipe interval"), title_text = _("Swipe interval"),
info_text = T(_([[ info_text = _([[
This sets the maximum delay between the start and the end of a swipe for it to be considered a swipe. Above this interval, it's considered panning. This sets the maximum delay between the start and the end of a swipe for it to be considered a swipe. Above this interval, it's considered panning.
The interval value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds). The interval value is in milliseconds and can range from 100 (0.1 seconds) to 2000 (2 seconds).]]),
Default value: %1]]), GestureDetector.SWIPE_INTERVAL/1000),
width = math.floor(Screen:getWidth() * 0.75), width = math.floor(Screen:getWidth() * 0.75),
value = GestureDetector:getInterval("ges_swipe_interval")/1000, value = GestureDetector:getInterval("ges_swipe_interval")/1000,
value_min = 100, value_min = 100,

Loading…
Cancel
Save