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

@ -151,6 +151,13 @@ end
if G_reader_settings:isTrue("night_mode") then
Device.screen:toggleNightMode()
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
if Device:hasEinkScreen() then
Device.screen:setupDithering()
@ -262,7 +269,6 @@ if file then
elseif directory then
local FileManager = require("apps/filemanager/filemanager")
UIManager:nextTick(function()
FileManager:setRotationMode(true)
FileManager:showFiles(directory)
end)
exit_code = UIManager:run()
@ -289,7 +295,6 @@ else
local home_dir =
G_reader_settings:readSetting("home_dir") or Device.home_dir or lfs.currentdir()
UIManager:nextTick(function()
FileManager:setRotationMode(true)
FileManager:showFiles(home_dir)
end)
-- 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
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()
-- Close lipc handles

Loading…
Cancel
Save