android: add a toggle to ignore back button events (#6269)

Requires koreader/android-luajit-launcher#233
Requires koreader/koreader-base#1117

It is a workaround for #6263 but can be useful on some devices with erratic back key behaviour too (yep, Onyx)
This commit is contained in:
Martín Fernández
2020-06-15 07:43:37 +02:00
committed by GitHub
parent b23af97914
commit 765b35a7bf
6 changed files with 19 additions and 2 deletions

2
base

Submodule base updated: 21ac242ab2...2210b65f5a

View File

@@ -224,6 +224,11 @@ function Device:init()
android.setVolumeKeysIgnored(true)
end
-- check if we ignore the back button completely
if G_reader_settings:isTrue("android_ignore_back_button") then
android.setBackButtonIgnored(true)
end
-- check if we enable a custom light level for this activity
local last_value = G_reader_settings:readSetting("fl_last_level")
if type(last_value) == "number" and last_value >= 0 then

View File

@@ -239,6 +239,16 @@ if Device:isAndroid() then
callback = function() G_reader_settings:flipNilOrFalse("camera_key_toggles_touchscreen") end,
}
common_settings.android_back_button = {
text = _("Ignore back button completely"),
checked_func = function() return android.isBackButtonIgnored() end,
callback = function()
local is_ignored = android.isBackButtonIgnored()
android.setBackButtonIgnored(not is_ignored)
G_reader_settings:saveSetting("android_ignore_back_button", 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

@@ -55,6 +55,7 @@ local order = {
"android_volume_keys",
"android_camera_key",
"android_haptic_feedback",
"android_back_button",
"----------------------------",
"invert_page_turn_buttons",
},

View File

@@ -75,6 +75,7 @@ local order = {
"android_volume_keys",
"android_camera_key",
"android_haptic_feedback",
"android_back_button",
"----------------------------",
"invert_page_turn_gestures",
"invert_page_turn_buttons",