Landscape FM / Refactor rotation (#6309)

* landscape FM / Refactor rotation

refactor and simplify the orientation handling code. the user generally cares about the rotation (what direction the device is facing) and not about if koreader is displaying in portrait or landscape mode

* bump base

update luasocket, libjpeg-turbo, curl
add logging to evernote-sdk-lua
update framebuffer for proper rotation
This commit is contained in:
yparitcher
2020-07-01 16:17:41 -04:00
committed by GitHub
parent 09c654c7ec
commit f7d538b108
30 changed files with 287 additions and 157 deletions

View File

@@ -1,5 +1,5 @@
describe("Readerrolling module", function()
local DocumentRegistry, ReaderUI, Event
local DocumentRegistry, ReaderUI, Event, Screen
local readerui, rolling
setup(function()
@@ -7,9 +7,11 @@ describe("Readerrolling module", function()
DocumentRegistry = require("document/documentregistry")
ReaderUI = require("apps/reader/readerui")
Event = require("ui/event")
Screen = require("device").screen
local sample_epub = "spec/front/unit/data/juliet.epub"
readerui = ReaderUI:new{
dimen = Screen:getSize(),
document = DocumentRegistry:openDocument(sample_epub),
}
rolling = readerui.rolling
@@ -17,7 +19,7 @@ describe("Readerrolling module", function()
describe("test in portrait screen mode", function()
it("should goto portrait screen mode", function()
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_PORTRAIT))
end)
it("should goto certain page", function()
@@ -79,6 +81,7 @@ describe("Readerrolling module", function()
it("should emit EndOfBook event at the end sample txt", function()
local sample_txt = "spec/front/unit/data/sample.txt"
local txt_readerui = ReaderUI:new{
dimen = Screen:getSize(),
document = DocumentRegistry:openDocument(sample_txt),
}
local called = false
@@ -108,7 +111,7 @@ describe("Readerrolling module", function()
describe("test in landscape screen mode", function()
it("should go to landscape screen mode", function()
readerui:handleEvent(Event:new("ChangeScreenMode", "landscape"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_LANDSCAPE))
end)
it("should goto certain page", function()
for i = 1, 10, 5 do
@@ -156,27 +159,27 @@ describe("Readerrolling module", function()
describe("switching screen mode should not change current page number", function()
teardown(function()
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_PORTRAIT))
end)
it("for portrait-landscape-portrait switching", function()
for i = 80, 100, 10 do
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_PORTRAIT))
rolling:onGotoPage(i)
assert.are.same(i, rolling.current_page)
readerui:handleEvent(Event:new("ChangeScreenMode", "landscape"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_LANDSCAPE))
assert.are_not.same(i, rolling.current_page)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_PORTRAIT))
assert.are.same(i, rolling.current_page)
end
end)
it("for landscape-portrait-landscape switching", function()
for i = 110, 130, 10 do
readerui:handleEvent(Event:new("ChangeScreenMode", "landscape"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_LANDSCAPE))
rolling:onGotoPage(i)
assert.are.same(i, rolling.current_page)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_PORTRAIT))
assert.are_not.same(i, rolling.current_page)
readerui:handleEvent(Event:new("ChangeScreenMode", "landscape"))
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_LANDSCAPE))
assert.are.same(i, rolling.current_page)
end
end)
@@ -184,14 +187,11 @@ describe("Readerrolling module", function()
describe("test changing word gap - space condensing", function()
it("should show pages for different word gap", function()
readerui.document:setWordSpacing({100, 90})
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetWordSpacing", {100, 90}))
assert.are.same(252, readerui.document:getPageCount())
readerui.document:setWordSpacing({95, 75})
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetWordSpacing", {95, 75}))
assert.are.same(241, readerui.document:getPageCount())
readerui.document:setWordSpacing({75, 50})
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
readerui:handleEvent(Event:new("SetWordSpacing", {75, 50}))
assert.are.same(231, readerui.document:getPageCount())
end)
end)