From f9215a3a045dc454b88c2d8809f7c0b0dfcc1732 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Jun 2014 23:48:34 +0800 Subject: [PATCH] use android config interface to detect device keyboard and screen dpi --- android/luajit-launcher | 2 +- frontend/ui/device.lua | 25 ++++++++++++++++++------- koreader-base | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/android/luajit-launcher b/android/luajit-launcher index 3cee0cff6..7a87eeb5f 160000 --- a/android/luajit-launcher +++ b/android/luajit-launcher @@ -1 +1 @@ -Subproject commit 3cee0cff606e0fba035c651ed5306fc27f0402bc +Subproject commit 7a87eeb5f9ecab9fca1544f1b1b6cd3c5d45baec diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index d4577e21c..5d604cb86 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -3,6 +3,8 @@ local KoboPowerD = require("ui/device/kobopowerd") local BasePowerD = require("ui/device/basepowerd") local Screen = require("ui/device/screen") local util = require("ffi/util") +local ffi = require("ffi") +local isAndroid, android = pcall(require, "android") -- lfs local Device = { @@ -104,9 +106,14 @@ Device.isAndroid = util.isAndroid function Device:hasNoKeyboard() if self.has_no_keyboard ~= nil then return self.has_no_keyboard end - local model = self:getModel() - self.has_no_keyboard = (model == "KindlePaperWhite") or (model == "KindlePaperWhite2") - or (model == "KindleTouch") or self:isKobo() or self:isAndroid() + if not isAndroid then + local model = self:getModel() + self.has_no_keyboard = (model == "KindlePaperWhite") or (model == "KindlePaperWhite2") + or (model == "KindleTouch") or self:isKobo() + else + self.has_no_keyboard = ffi.C.AConfiguration_getKeyboard(android.app.config) + ~= ffi.C.ACONFIGURATION_KEYBOARD_QWERTY + end return self.has_no_keyboard end @@ -116,10 +123,14 @@ end function Device:isTouchDevice() if self.is_touch_device ~= nil then return self.is_touch_device end - local model = self:getModel() - self.is_touch_device = (model == "KindlePaperWhite") or (model == "KindlePaperWhite2") - or (model == "KindleTouch") or self:isKobo() or util.isEmulated() - or util.isAndroid() + if not isAndroid then + local model = self:getModel() + self.is_touch_device = (model == "KindlePaperWhite") or (model == "KindlePaperWhite2") + or (model == "KindleTouch") or self:isKobo() or util.isEmulated() + else + self.is_touch_device = ffi.C.AConfiguration_getTouchscreen(android.app.config) + ~= ffi.C.ACONFIGURATION_TOUCHSCREEN_NOTOUCH + end return self.is_touch_device end diff --git a/koreader-base b/koreader-base index 271d3dced..dc61f9e2c 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit 271d3dcede9f9bcc7f5613c7f81f28f17271a0d5 +Subproject commit dc61f9e2cabafed25ae7fbb3f0b13122c6074400