Save rotation across restarts (#7096)

pull/7119/head
yparitcher 3 years ago committed by GitHub
parent 00556715f4
commit 1c9c40fb95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -70,13 +70,10 @@ function FileManager:onSetRotationMode(rotation)
return true return true
end end
-- init should be set to True when starting the FM for the first time function FileManager:setRotationMode()
-- (not coming from the reader). This allows the default to be properly set.
function FileManager:setRotationMode(init)
local locked = G_reader_settings:isTrue("lock_rotation") local locked = G_reader_settings:isTrue("lock_rotation")
local rotation_mode = G_reader_settings:readSetting("fm_rotation_mode") or Screen.ORIENTATION_PORTRAIT if not locked then
-- Only enforce the default rotation on first FM open, or when switching to the FM when sticky rota is disabled. local rotation_mode = G_reader_settings:readSetting("fm_rotation_mode") or Screen.ORIENTATION_PORTRAIT
if init or not locked then
self:onSetRotationMode(rotation_mode) self:onSetRotationMode(rotation_mode)
end end
end end

@ -151,6 +151,13 @@ end
if G_reader_settings:isTrue("night_mode") then if G_reader_settings:isTrue("night_mode") then
Device.screen:toggleNightMode() Device.screen:toggleNightMode()
end end
-- Ensure the proper rotation on startup.
-- We default to the rotation KOReader closed with.
-- If the rotation is not locked it will be overridden by a book or the FM when opened.
local rotation_mode = G_reader_settings:readSetting("closed_rotation_mode")
if rotation_mode and rotation_mode ~= Device.screen:getRotationMode() then
Device.screen:setRotationMode(rotation_mode)
end
-- Dithering -- Dithering
if Device:hasEinkScreen() then if Device:hasEinkScreen() then
Device.screen:setupDithering() Device.screen:setupDithering()
@ -262,7 +269,6 @@ if file then
elseif directory then elseif directory then
local FileManager = require("apps/filemanager/filemanager") local FileManager = require("apps/filemanager/filemanager")
UIManager:nextTick(function() UIManager:nextTick(function()
FileManager:setRotationMode(true)
FileManager:showFiles(directory) FileManager:showFiles(directory)
end) end)
exit_code = UIManager:run() exit_code = UIManager:run()
@ -289,7 +295,6 @@ else
local home_dir = local home_dir =
G_reader_settings:readSetting("home_dir") or Device.home_dir or lfs.currentdir() G_reader_settings:readSetting("home_dir") or Device.home_dir or lfs.currentdir()
UIManager:nextTick(function() UIManager:nextTick(function()
FileManager:setRotationMode(true)
FileManager:showFiles(home_dir) FileManager:showFiles(home_dir)
end) end)
-- Always open history on top of filemanager so closing history -- Always open history on top of filemanager so closing history
@ -334,6 +339,9 @@ local function exitReader()
-- Save any device settings before closing G_reader_settings -- Save any device settings before closing G_reader_settings
Device:saveSettings() Device:saveSettings()
-- Save current rotation to have it for next startup
G_reader_settings:saveSetting("closed_rotation_mode", Device.screen:getRotationMode())
G_reader_settings:close() G_reader_settings:close()
-- Close lipc handles -- Close lipc handles

Loading…
Cancel
Save