Skip to content

Commit

Permalink
android: support for native surface rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos committed Jul 8, 2020
1 parent 580b38e commit 7094519
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
24 changes: 21 additions & 3 deletions frontend/device/android/device.lua
Expand Up @@ -129,13 +129,27 @@ function Device:init()
device = self,
event_map = require("device/android/event_map"),
handleMiscEv = function(this, ev)
local UIManager = require("ui/uimanager")
logger.dbg("Android application event", ev.code)
if ev.code == C.APP_CMD_SAVE_STATE then
return "SaveState"
elseif ev.code == C.APP_CMD_GAINED_FOCUS
or ev.code == C.APP_CMD_INIT_WINDOW
or ev.code == C.APP_CMD_WINDOW_REDRAW_NEEDED then
this.device.screen:_updateWindow()
elseif ev.code == C.APP_CMD_CONFIG_CHANGED then
-- orientation and size changes
if android.screen.width ~= android.getScreenWidth()
or android.screen.height ~= android.getScreenHeight() then
this.device.screen:resize()
local new_size = this.device.screen:getSize()
logger.info("Resizing screen to", new_size)
local Event = require("ui/event")
UIManager:broadcastEvent(Event:new("SetDimensions", new_size))
UIManager:broadcastEvent(Event:new("ScreenResize", new_size))
UIManager:broadcastEvent(Event:new("RedrawCurrentPage"))
end
-- to-do: keyboard connected, disconnected
elseif ev.code == C.APP_CMD_RESUME then
EXTERNAL_DICTS_AVAILABILITY_CHECKED = false
if external_dict_when_back_callback then
Expand All @@ -145,7 +159,6 @@ function Device:init()
local new_file = android.getIntent()
if new_file ~= nil and lfs.attributes(new_file, "mode") == "file" then
-- we cannot blit to a window here since we have no focus yet.
local UIManager = require("ui/uimanager")
local InfoMessage = require("ui/widget/infomessage")
local BD = require("ui/bidi")
UIManager:scheduleIn(0.1, function()
Expand All @@ -162,7 +175,6 @@ function Device:init()
local content_path = android.getLastImportedPath()
if content_path ~= nil then
local FileManager = require("apps/filemanager/filemanager")
local UIManager = require("ui/uimanager")
UIManager:scheduleIn(0.5, function()
if FileManager.instance then
FileManager.instance:onRefresh()
Expand Down Expand Up @@ -324,10 +336,16 @@ end

function Device:info()
local is_eink, eink_platform = android.isEink()
local product_type = android.getPlatformName()

local common_text = T(_("%1\n\nOS: Android %2, api %3\nBuild flavor: %4\n"),
android.prop.product, getCodename(), Device.firmware_rev, android.prop.flavor)

local platform_text = ""
if product_type ~= "android" then
platform_text = T(_("\nDevice type: %1\n"), product_type)
end

local eink_text = ""
if is_eink then
eink_text = T(_("\nE-ink display supported.\nPlatform: %1\n"), eink_platform)
Expand All @@ -338,7 +356,7 @@ function Device:info()
wakelocks_text = _("\nThis device needs CPU, screen and touchscreen always on.\nScreen timeout will be ignored while the app is in the foreground!\n")
end

return common_text..eink_text..wakelocks_text
return common_text..platform_text..eink_text..wakelocks_text
end

function Device:epdTest()
Expand Down

0 comments on commit 7094519

Please sign in to comment.