android: add an option to ignore volume keys or use them to turn pages

This commit is contained in:
Martín Fernández
2019-08-01 18:27:24 +02:00
parent 53adb9d0e1
commit 91b2faae6a
6 changed files with 20 additions and 2 deletions

2
base

Submodule base updated: 9ee0e9ebe7...6301277ce8

View File

@@ -182,6 +182,11 @@ function Device:init()
self:toggleFullscreen()
end
-- check if we ignore volume keys and then they're forwarded to system services.
if G_reader_settings:isTrue("android_ignore_volume_keys") then
android.setVolumeKeysIgnored(true);
end
Generic.init(self)
end

View File

@@ -175,6 +175,17 @@ if Device:isAndroid() then
-- screen timeout options, disabled if device needs wakelocks.
common_settings.screen_timeout = require("ui/elements/screen_android"):getTimeoutMenuTable()
-- volume key events
common_settings.android_volume_keys = {
text = _("Volume key page turning"),
checked_func = function() return not android.getVolumeKeysIgnored() end,
callback = function()
local is_ignored = android.getVolumeKeysIgnored()
android.setVolumeKeysIgnored(not is_ignored)
G_reader_settings:saveSetting("android_ignore_volume_keys", not is_ignored)
end,
}
-- fullscreen toggle on devices with compatible fullscreen methods (apis 14-18)
if Device.firmware_rev < 19 then
common_settings.fullscreen = {

View File

@@ -49,6 +49,7 @@ local order = {
"back_to_exit",
"back_in_filemanager",
"enable_back_history",
"android_volume_keys",
"----------------------------",
"invert_page_turn_buttons",
},

View File

@@ -68,6 +68,7 @@ local order = {
"back_to_exit",
"back_in_filemanager",
"enable_back_history",
"android_volume_keys",
"----------------------------",
"invert_page_turn_buttons",
},