Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: disable exit menu & disable wakelocks by default. #4493

Merged
merged 2 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/apps/filemanager/filemanagermenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ function FileManagerMenu:setUpdateItemTable()
self:exitOrRestart(function() UIManager:restartKOReader() end)
end,
}
if Device:isAndroid() then
self.menu_items.exit_menu = self.menu_items.exit
self.menu_items.exit = nil
self.menu_items.restart_koreader = nil
end
if not Device:isTouchDevice() then
--add a shortcut on non touch-device
--because this menu is not accessible otherwise
Expand Down
5 changes: 5 additions & 0 deletions frontend/apps/reader/modules/readermenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ function ReaderMenu:setUpdateItemTable()
self:exitOrRestart(function() UIManager:restartKOReader() end)
end,
}
if Device:isAndroid() then
self.menu_items.exit_menu = self.menu_items.exit
self.menu_items.exit = nil
self.menu_items.restart_koreader = nil
end

local getPreviousFile = function()
local previous_file = nil
Expand Down
6 changes: 3 additions & 3 deletions frontend/device/android/device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ function Device:init()
self.isTouchDevice = yes
end

-- check if we disabled support for wakelocks
if G_reader_settings:isTrue("disable_android_wakelock") then
android.setWakeLock(false)
-- check if we enabled support for wakelocks
if G_reader_settings:isTrue("enable_android_wakelock") then
android.setWakeLock(true)
end

Generic.init(self)
Expand Down
2 changes: 1 addition & 1 deletion frontend/ui/elements/common_settings_menu_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ if Device:isAndroid() then
table.insert(common_settings.screen.sub_item_table,
{
text = _("Keep screen on"),
checked_func = function() return not G_reader_settings:isTrue("disable_android_wakelock") end,
checked_func = function() return G_reader_settings:isTrue("enable_android_wakelock") end,
callback = function() require("ui/elements/screen_android"):toggleWakelock() end,
})

Expand Down
6 changes: 6 additions & 0 deletions frontend/ui/elements/filemanager_menu_order.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local Device = require("device")

local order = {
["KOMenu:menu_buttons"] = {
"filemanager_settings",
Expand Down Expand Up @@ -119,4 +121,8 @@ local order = {
}
}

if Device:isAndroid() then
order.exit_menu = nil
end

return order
6 changes: 6 additions & 0 deletions frontend/ui/elements/reader_menu_order.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local Device = require("device")

local order = {
["KOMenu:menu_buttons"] = {
"navi",
Expand Down Expand Up @@ -142,4 +144,8 @@ local order = {
}
}

if Device:isAndroid() then
order.exit_menu = nil
end

return order
4 changes: 2 additions & 2 deletions frontend/ui/elements/screen_android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ end

-- toggle android wakelock support
function ScreenHelper:toggleWakelock()
local is_wakelock = not G_reader_settings:isTrue("disable_android_wakelock")
local is_wakelock = G_reader_settings:isTrue("enable_android_wakelock")
android.setWakeLock(not is_wakelock)
G_reader_settings:saveSetting("disable_android_wakelock", is_wakelock)
G_reader_settings:saveSetting("enable_android_wakelock", not is_wakelock)
end

return ScreenHelper