From 427abd1cf6af1373919e5dfdd027f3c9d6fe42bf Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 26 Feb 2016 09:38:51 -0800 Subject: [PATCH 1/3] bump base for android fix --- base | 2 +- platform/android/luajit-launcher | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/base b/base index 5131b24d4..65b219563 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 5131b24d461bc2d000df545c74c546a6e420e64a +Subproject commit 65b2195631621faa15e1caed82083fd77a82f519 diff --git a/platform/android/luajit-launcher b/platform/android/luajit-launcher index cc5c30286..08f23b83e 160000 --- a/platform/android/luajit-launcher +++ b/platform/android/luajit-launcher @@ -1 +1 @@ -Subproject commit cc5c30286ade5151848a8dbb2be64e90fb2c8fcf +Subproject commit 08f23b83e882b16b587cf0ec8e267b5c7708a71f From 71184cfb73e8b63d03ea2ff614183027d0b47e3e Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 28 Feb 2016 12:16:32 -0800 Subject: [PATCH 2/3] kodev: add log command for android --- kodev | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/kodev b/kodev index 6d65fb239..45fc377b2 100755 --- a/kodev +++ b/kodev @@ -130,6 +130,7 @@ ${SUPPORTED_TARGETS}" ;; android) make TARGET=android clean + rm *.apk ;; pocketbook) make TARGET=pocketbook clean @@ -313,6 +314,36 @@ OPTIONS: popd } +function kodev-log { + LOG_HELP_MSG=" +usage: log + +TARGET: + + android +" + + if [ $# -lt 1 ]; then + echo "${LOG_HELP_MSG}" + exit 1 + fi + + case $1 in + -h | --help) + echo "${LOG_HELP_MSG}" + exit 0 + ;; + android) + adb logcat 'luajit-launcher:D *:S' + ;; + *) + echo "Unsupported target: $1." + echo "${LOG_HELP_MSG}" + exit 1 + ;; + esac +} + HELP_MSG=" @@ -327,6 +358,7 @@ Supported commands: run Run KOReader wbuilder Run wbuilder.lua script (useful for building new UI widget) test Run tests + log Tail log stream for a running KOReader app " if [ $# -lt 1 ]; then @@ -362,6 +394,10 @@ case $1 in shift 1 kodev-test $@ ;; + log) + shift 1 + kodev-log $@ + ;; --help | -h) echo "${HELP_MSG}" exit 0 From 0772fd1439f10b467232d7d4f3ed094093f49e4c Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 28 Feb 2016 13:32:25 -0800 Subject: [PATCH 3/3] touchmenu: fix menu height calculation --- frontend/ui/widget/touchmenu.lua | 76 ++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index d50b6cacf..88ca06b0f 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -375,32 +375,47 @@ function TouchMenu:init() self.item_group, } - self.bar:switchToTab(self.last_index or 1) + self.item_width = self.width - self.padding*2 - self.bordersize*2 + self.split_line = HorizontalGroup:new{ + -- pad with 10 pixel to align with the up arrow in footer + HorizontalSpan:new{width = 10}, + LineWidget:new{ + style = "dashed", + dimen = Geom:new{ + w = self.item_width - 20, + h = 1, + } + } + } + self.footer_top_margin = VerticalSpan:new{width = Screen:scaleBySize(2)} -- Make sure we always show an up to date battery status when first opening the menu... Device:getPowerDevice():refreshCapacity() - self:updateItems() + self.bar:switchToTab(self.last_index or 1) end function TouchMenu:onCloseWidget() UIManager:setDirty(nil, "partial", self.dimen) end -function TouchMenu:_recalculateDimen() - self.dimen.w = self.width +function TouchMenu:_recalculatePageLayout() + local content_height -- content == item_list + footer - -- if height not given, dynamically calculate it - if not self.height then - self.dimen.h = (#self.item_table + 2) * self.item_height - + self.bar:getSize().h + local bar_height = self.bar:getSize().h + local footer_height = self.footer:getSize().h + if self.height then + content_height = self.height - bar_height else - self.dimen.h = self.height + content_height = #self.item_table * self.item_height + footer_height + -- split line height + content_height = content_height + (#self.item_table - 1) + content_height = content_height + self.footer_top_margin:getSize().h end - -- make sure self.dimen.h does not overflow screen height - if self.dimen.h > Screen:getHeight() then - self.dimen.h = Screen:getHeight() - self.bar:getSize().h + if content_height + bar_height > Screen:getHeight() then + content_height = Screen:getHeight() - bar_height end - self.perpage = math.floor(self.dimen.h / self.item_height) - 2 + local item_list_content_height = content_height - footer_height + self.perpage = math.floor(item_list_content_height / self.item_height) if self.perpage > self.max_per_page then self.perpage = self.max_per_page end @@ -410,12 +425,10 @@ end function TouchMenu:updateItems() local old_dimen = self.dimen and self.dimen:copy() - self:_recalculateDimen() + self:_recalculatePageLayout() self.item_group:clear() table.insert(self.item_group, self.bar) - local item_width = self.dimen.w - self.padding*2 - self.bordersize*2 - for c = 1, self.perpage do -- calculate index in item_table local i = (self.page - 1) * self.perpage + c @@ -424,7 +437,7 @@ function TouchMenu:updateItems() item = self.item_table[i], menu = self, dimen = Geom:new{ - w = item_width, + w = self.item_width, h = self.item_height, }, show_parent = self.show_parent, @@ -432,36 +445,31 @@ function TouchMenu:updateItems() table.insert(self.item_group, item_tmp) -- insert split line if c ~= self.perpage then - table.insert(self.item_group, HorizontalGroup:new{ - -- pad with 10 pixel to align with the up arrow in footer - HorizontalSpan:new{width = 10}, - LineWidget:new{ - style = "dashed", - dimen = Geom:new{ - w = item_width - 20, - h = 1, - } - } - }) + table.insert(self.item_group, self.split_line) end else -- item not enough to fill the whole page, break out of loop - --table.insert(self.item_group, - --VerticalSpan:new{ - --width = self.item_height - --}) break end -- if i <= self.items end -- for c=1, self.perpage - table.insert(self.item_group, VerticalSpan:new{width = Screen:scaleBySize(2)}) + table.insert(self.item_group, self.footer_top_margin) table.insert(self.item_group, self.footer) self.page_info_text.text = util.template(_("Page %1 of %2"), self.page, self.page_num) self.page_info_left_chev:showHide(self.page_num > 1) self.page_info_right_chev:showHide(self.page_num > 1) self.page_info_left_chev:enableDisable(self.page > 1) self.page_info_right_chev:enableDisable(self.page < self.page_num) - self.time_info.text = os.date("%H:%M").." @ "..(Device:getPowerDevice():isCharging() and "+" or "")..Device:getPowerDevice():getCapacity().."%" + local time_info_txt = os.date("%H:%M").." @ " + if Device:getPowerDevice():isCharging() then + time_info_txt = time_info_txt.."+" + end + time_info_txt = time_info_txt..Device:getPowerDevice():getCapacity().."%" + self.time_info:setText(time_info_txt) + + -- recalculate dimen based on new layout + self.dimen.w = self.width + self.dimen.h = self.item_group:getSize().h + self.bordersize*2 + self.padding*2 UIManager:setDirty("all", function() local refresh_dimen =