From 7094519e1bf08dbd4117fc3d969ec44cd9ed6b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Fdez?= Date: Wed, 8 Jul 2020 14:42:19 +0200 Subject: [PATCH] android: support for native surface rotation --- base | 2 +- frontend/device/android/device.lua | 24 +++++++++++++++++++++--- platform/android/luajit-launcher | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/base b/base index 62bb7955d..0c326d6ee 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 62bb7955db058184ddf529c3eaa51ec03b70543d +Subproject commit 0c326d6eee1447dca6af507ea921551c06610f2d diff --git a/frontend/device/android/device.lua b/frontend/device/android/device.lua index 76402393e..94ec45a9d 100644 --- a/frontend/device/android/device.lua +++ b/frontend/device/android/device.lua @@ -129,6 +129,7 @@ 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" @@ -136,6 +137,19 @@ function Device:init() 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 @@ -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() @@ -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() @@ -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) @@ -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() diff --git a/platform/android/luajit-launcher b/platform/android/luajit-launcher index b6eaf1e50..f73c343f2 160000 --- a/platform/android/luajit-launcher +++ b/platform/android/luajit-launcher @@ -1 +1 @@ -Subproject commit b6eaf1e50fbb193c499882763d302b8a854044c1 +Subproject commit f73c343f20fb438372e689eb77faf87e2bb940e5