mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
Dispatcher/DeviceListener: temporarily turn on Accelerometer/GSensor for 5 sec (#12419)
This commit is contained in:
parent
d097dc0f8c
commit
2a9fe6fdcf
15
frontend/device/devicelistener.lua
Normal file → Executable file
15
frontend/device/devicelistener.lua
Normal file → Executable file
@ -207,6 +207,21 @@ if Device:hasGSensor() then
|
||||
return true
|
||||
end
|
||||
|
||||
function DeviceListener:onTempGSensorOn()
|
||||
local new_text
|
||||
if G_reader_settings:nilOrFalse("input_ignore_gsensor") then
|
||||
new_text = _("Accelerometer rotation events already on.")
|
||||
else
|
||||
Device:toggleGSensor(true)
|
||||
new_text = _("Accelerometer rotation events on for 5 seconds.")
|
||||
UIManager:scheduleIn(5.0, function()
|
||||
Device:toggleGSensor(false)
|
||||
end)
|
||||
end
|
||||
Notification:notify(new_text)
|
||||
return true
|
||||
end
|
||||
|
||||
function DeviceListener:onLockGSensor()
|
||||
G_reader_settings:flipNilOrFalse("input_lock_gsensor")
|
||||
Device:lockGSensor(G_reader_settings:isTrue("input_lock_gsensor"))
|
||||
|
@ -84,6 +84,7 @@ local settingsList = {
|
||||
----
|
||||
toggle_key_repeat = {category="none", event="ToggleKeyRepeat", title=_("Toggle key repeat"), device=true, condition=Device:hasKeys() and Device:canKeyRepeat(), separator=true},
|
||||
toggle_gsensor = {category="none", event="ToggleGSensor", title=_("Toggle accelerometer"), device=true, condition=Device:hasGSensor()},
|
||||
temp_gsensor_on = {category="none", event="TempGSensorOn", title=_("Enable accelerometer for 5 seconds"), device=true, condition=Device:hasGSensor()},
|
||||
lock_gsensor = {category="none", event="LockGSensor", title=_("Lock auto rotation to current orientation"), device=true, condition=Device:hasGSensor()},
|
||||
toggle_rotation = {category="none", event="SwapRotation", title=_("Toggle orientation"), device=true},
|
||||
invert_rotation = {category="none", event="InvertRotation", title=_("Invert rotation"), device=true},
|
||||
@ -310,6 +311,7 @@ local dispatcher_menu_order = {
|
||||
----
|
||||
"toggle_key_repeat",
|
||||
"toggle_gsensor",
|
||||
"temp_gsensor_on",
|
||||
"lock_gsensor",
|
||||
"rotation_mode",
|
||||
"toggle_rotation",
|
||||
|
Loading…
Reference in New Issue
Block a user