diff --git a/frontend/device/devicelistener.lua b/frontend/device/devicelistener.lua old mode 100644 new mode 100755 index 8481f7670..509c79ee6 --- a/frontend/device/devicelistener.lua +++ b/frontend/device/devicelistener.lua @@ -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")) diff --git a/frontend/dispatcher.lua b/frontend/dispatcher.lua index ea71d2f1d..551333f93 100644 --- a/frontend/dispatcher.lua +++ b/frontend/dispatcher.lua @@ -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",