Allow locking the gyro to the current screen mode (#6347)

* Allow locking the gyro to the current screen mode (i.e., orientation).
* Tweak the "sticky rota" option to work both ways
* More rotation constant usage instead of magic numbers
This commit is contained in:
NiLuJe
2020-07-09 19:11:44 +02:00
committed by GitHub
parent f9293a67b0
commit 509ee7bb86
12 changed files with 137 additions and 45 deletions

View File

@@ -724,13 +724,19 @@ end
function ReaderView:onReadSettings(config)
self.render_mode = config:readSetting("render_mode") or 0
local locked = G_reader_settings:readSetting("lock_rotation")
local rotation_mode = config:readSetting("rotation_mode")
if not rotation_mode and locked then
if self.ui.document.info.has_pages then
rotation_mode = G_reader_settings:readSetting("kopt_rotation_mode") or 0
else
rotation_mode = G_reader_settings:readSetting("copt_rotation_mode") or 0
local rotation_mode = nil
local locked = G_reader_settings:isTrue("lock_rotation")
-- Keep current rotation by doing nothing when sticky rota is enabled.
if not locked then
-- Honor docsettings's rotation
rotation_mode = config:readSetting("rotation_mode") -- Doc's
if not rotation_mode then
-- No doc specific rotation, pickup global defaults for the doc type
if self.ui.document.info.has_pages then
rotation_mode = G_reader_settings:readSetting("kopt_rotation_mode") or Screen.ORIENTATION_PORTRAIT
else
rotation_mode = G_reader_settings:readSetting("copt_rotation_mode") or Screen.ORIENTATION_PORTRAIT
end
end
end
if rotation_mode then