From c68a416293e8a97f327240457b187864ea55cf9f Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Jun 2014 21:59:29 +0800 Subject: [PATCH 1/6] update ignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 72e3a3349..9fefedcdb 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ spec/unit/data emu koreader-*.zip +koreader-*.apk /.cproject /.project From 5aa8eb52dafbe96caafb955ba3269a929ad1fa62 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Jun 2014 22:01:11 +0800 Subject: [PATCH 2/6] add missing Blitbuffer since it's removed from global space --- frontend/document/credocument.lua | 1 + frontend/document/document.lua | 1 + frontend/ui/widget/textboxwidget.lua | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 76ac52e61..aff95677b 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -1,4 +1,5 @@ local Geom = require("ui/geometry") +local Blitbuffer = require("ffi/blitbuffer") local CreOptions = require("ui/data/creoptions") local Document = require("document/document") local Geom = require("ui/geometry") diff --git a/frontend/document/document.lua b/frontend/document/document.lua index 261743098..60608f6a3 100644 --- a/frontend/document/document.lua +++ b/frontend/document/document.lua @@ -1,4 +1,5 @@ local DrawContext = require("ffi/drawcontext") +local Blitbuffer = require("ffi/blitbuffer") local Cache = require("cache") local CacheItem = require("cacheitem") local TileCacheItem = require("document/tilecacheitem") diff --git a/frontend/ui/widget/textboxwidget.lua b/frontend/ui/widget/textboxwidget.lua index cd67c04c5..7964af4d0 100644 --- a/frontend/ui/widget/textboxwidget.lua +++ b/frontend/ui/widget/textboxwidget.lua @@ -1,3 +1,4 @@ +local Blitbuffer = require("ffi/blitbuffer") local Widget = require("ui/widget/widget") local RenderText = require("ui/rendertext") local Screen = require("ui/screen") @@ -71,7 +72,7 @@ However string.gmatch() has one significant disadvantage for me: You can't split a string while matching both the delimited strings and the delimiters themselves without tracking positions and substrings. The string.gsplit() function below takes care of -this problem. +this problem. Author: Peter Odding License: MIT/X11 Source: http://snippets.luacode.org/snippets/String_splitting_130 From b2e0d2a73572077e7abe05333d9f8e1de92ae5d3 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Jun 2014 22:01:38 +0800 Subject: [PATCH 3/6] detect screen DPI for android devices --- frontend/ui/device/screen.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/ui/device/screen.lua b/frontend/ui/device/screen.lua index f27fb8a14..5bc4de6e1 100644 --- a/frontend/ui/device/screen.lua +++ b/frontend/ui/device/screen.lua @@ -1,3 +1,4 @@ +local Blitbuffer = require("ffi/blitbuffer") local Geom = require("ui/geometry") local DEBUG = require("dbg") @@ -73,13 +74,17 @@ end function Screen:getDPI() if self.dpi ~= nil then return self.dpi end local model = self.device:getModel() - if model == "KindlePaperWhite" or model == "KindlePaperWhite2" + if model == "KindlePaperWhite" or model == "KindlePaperWhite2" or model == "Kobo_kraken" or model == "Kobo_phoenix" then self.dpi = 212 elseif model == "Kobo_dragon" then self.dpi = 265 elseif model == "Kobo_pixie" then self.dpi = 200 + elseif util.isAndroid() then + local android = require("android") + local ffi = require("ffi") + self.dpi = ffi.C.AConfiguration_getDensity(android.app.config) else self.dpi = 167 end From 0fdba1ff357078673301e054f4ad417195103546 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Jun 2014 22:55:41 +0800 Subject: [PATCH 4/6] remove least used koptoptions to save space for small screens --- frontend/ui/data/koptoptions.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/ui/data/koptoptions.lua b/frontend/ui/data/koptoptions.lua index e54f66308..b9a6ad68c 100644 --- a/frontend/ui/data/koptoptions.lua +++ b/frontend/ui/data/koptoptions.lua @@ -104,12 +104,12 @@ local KoptOptions = { options = { { name = "font_size", - item_text = {"Aa","Aa","Aa","Aa","Aa","Aa","Aa","Aa","Aa","Aa"}, + item_text = {"Aa","Aa","Aa","Aa","Aa","Aa","Aa","Aa"}, item_align_center = 1.0, spacing = 15, height = 60, - item_font_size = {22,24,28,32,34,36,38,42,46,50}, - values = {0.1, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0, 4.0}, + item_font_size = {24,28,32,34,36,38,42,46}, + values = {0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0}, default_value = DKOPTREADER_CONFIG_FONT_SIZE, event = "FontSizeUpdate", }, @@ -132,14 +132,14 @@ local KoptOptions = { { name = "contrast", name_text = S.CONTRAST, - name_align_right = 0.2, - item_text = {S.LIGHTEST , S.LIGHTER, S.DEFAULT, S.DARKER, S.DARKEST}, + name_align_right = 0.25, + item_text = {S.LIGHTER, S.DEFAULT, S.DARKER, S.DARKEST}, item_font_size = 18, - item_align_center = 0.8, - values = {2.0, 1.5, 1.0, 0.5, 0.2}, + item_align_center = 0.7, + values = {1.5, 1.0, 0.5, 0.2}, default_value = DKOPTREADER_CONFIG_CONTRAST, event = "GammaUpdate", - args = {0.5, 0.8, 1.0, 2.0, 4.0}, + args = {0.8, 1.0, 2.0, 4.0}, } } }, From a33ab1fb8c07b0324bb9720e469890484c49677f Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Jun 2014 22:57:50 +0800 Subject: [PATCH 5/6] GUI tweaks for small screen that sets a maximum size that won't render content outside of the screen --- frontend/ui/widget/configdialog.lua | 36 +++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index e2ad13ff0..153671318 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -248,6 +248,21 @@ function ConfigOption:init() end end if self.options[c].item_text then + local items_count = #self.options[c].item_text + local middle_index = math.ceil(items_count/2) + local middle_item = OptionTextItem:new{ + TextWidget:new{ + text = self.options[c].item_text[middle_index], + face = Font:getFace(item_font_face, + option_items_fixed and item_font_size[middle_index] + or item_font_size), + } + } + local max_item_spacing = (Screen:getWidth() * item_align - + middle_item:getSize().w * items_count) / items_count + local items_spacing = HorizontalSpan:new{ + width = math.min(max_item_spacing, Screen:scaleByDPI(item_spacing_with)) + } for d = 1, #self.options[c].item_text do local option_item = nil if option_items_fixed then @@ -285,6 +300,17 @@ function ConfigOption:init() end if self.options[c].item_icons then + local items_count = #self.options[c].item_icons + local first_item = OptionIconItem:new{ + icon = ImageWidget:new{ + file = self.options[c].item_icons[1] + } + } + local max_item_spacing = (Screen:getWidth() * item_align - + first_item:getSize().w * items_count) / items_count + local items_spacing = HorizontalSpan:new{ + width = math.min(max_item_spacing, Screen:scaleByDPI(item_spacing_with)) + } for d = 1, #self.options[c].item_icons do local option_item = OptionIconItem:new{ icon = ImageWidget:new{ @@ -293,12 +319,6 @@ function ConfigOption:init() padding = -2, color = d == current_item and 15 or 0, } - local icons_count = #self.options[c].item_icons - local min_item_spacing = (Screen:getWidth() * item_align - - option_item:getSize().w * icons_count) / icons_count - local items_spacing = HorizontalSpan:new{ - width = math.min(min_item_spacing, Screen:scaleByDPI(item_spacing_with)) - } option_items[d] = option_item option_item.items = option_items option_item.name = self.options[c].name @@ -315,8 +335,10 @@ function ConfigOption:init() end if self.options[c].toggle then + local max_toggle_width = Screen:getWidth() / 2 + local toggle_width = Screen:scaleByDPI(self.options[c].width or 216) local switch = ToggleSwitch:new{ - width = Screen:scaleByDPI(self.options[c].width or 216), + width = math.min(max_toggle_width, toggle_width), name = self.options[c].name, toggle = self.options[c].toggle, alternate = self.options[c].alternate, From f9215a3a045dc454b88c2d8809f7c0b0dfcc1732 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Jun 2014 23:48:34 +0800 Subject: [PATCH 6/6] 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