Merge pull request #1855 from koreader/houqp-master

bump base for android fix
pull/1859/head
Huang Xin 8 years ago
commit 03d7b7d61c

@ -1 +1 @@
Subproject commit 5131b24d461bc2d000df545c74c546a6e420e64a Subproject commit 65b2195631621faa15e1caed82083fd77a82f519

@ -375,32 +375,47 @@ function TouchMenu:init()
self.item_group, 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... -- Make sure we always show an up to date battery status when first opening the menu...
Device:getPowerDevice():refreshCapacity() Device:getPowerDevice():refreshCapacity()
self:updateItems() self.bar:switchToTab(self.last_index or 1)
end end
function TouchMenu:onCloseWidget() function TouchMenu:onCloseWidget()
UIManager:setDirty(nil, "partial", self.dimen) UIManager:setDirty(nil, "partial", self.dimen)
end end
function TouchMenu:_recalculateDimen() function TouchMenu:_recalculatePageLayout()
self.dimen.w = self.width local content_height -- content == item_list + footer
-- if height not given, dynamically calculate it local bar_height = self.bar:getSize().h
if not self.height then local footer_height = self.footer:getSize().h
self.dimen.h = (#self.item_table + 2) * self.item_height if self.height then
+ self.bar:getSize().h content_height = self.height - bar_height
else 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 end
-- make sure self.dimen.h does not overflow screen height if content_height + bar_height > Screen:getHeight() then
if self.dimen.h > Screen:getHeight() then content_height = Screen:getHeight() - bar_height
self.dimen.h = Screen:getHeight() - self.bar:getSize().h
end 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 if self.perpage > self.max_per_page then
self.perpage = self.max_per_page self.perpage = self.max_per_page
end end
@ -410,12 +425,10 @@ end
function TouchMenu:updateItems() function TouchMenu:updateItems()
local old_dimen = self.dimen and self.dimen:copy() local old_dimen = self.dimen and self.dimen:copy()
self:_recalculateDimen() self:_recalculatePageLayout()
self.item_group:clear() self.item_group:clear()
table.insert(self.item_group, self.bar) 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 for c = 1, self.perpage do
-- calculate index in item_table -- calculate index in item_table
local i = (self.page - 1) * self.perpage + c local i = (self.page - 1) * self.perpage + c
@ -424,7 +437,7 @@ function TouchMenu:updateItems()
item = self.item_table[i], item = self.item_table[i],
menu = self, menu = self,
dimen = Geom:new{ dimen = Geom:new{
w = item_width, w = self.item_width,
h = self.item_height, h = self.item_height,
}, },
show_parent = self.show_parent, show_parent = self.show_parent,
@ -432,36 +445,31 @@ function TouchMenu:updateItems()
table.insert(self.item_group, item_tmp) table.insert(self.item_group, item_tmp)
-- insert split line -- insert split line
if c ~= self.perpage then if c ~= self.perpage then
table.insert(self.item_group, HorizontalGroup:new{ table.insert(self.item_group, self.split_line)
-- 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,
}
}
})
end end
else else
-- item not enough to fill the whole page, break out of loop -- item not enough to fill the whole page, break out of loop
--table.insert(self.item_group,
--VerticalSpan:new{
--width = self.item_height
--})
break break
end -- if i <= self.items end -- if i <= self.items
end -- for c=1, self.perpage 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) 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_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_left_chev:showHide(self.page_num > 1)
self.page_info_right_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_left_chev:enableDisable(self.page > 1)
self.page_info_right_chev:enableDisable(self.page < self.page_num) 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() UIManager:setDirty("all", function()
local refresh_dimen = local refresh_dimen =

36
kodev

@ -130,6 +130,7 @@ ${SUPPORTED_TARGETS}"
;; ;;
android) android)
make TARGET=android clean make TARGET=android clean
rm *.apk
;; ;;
pocketbook) pocketbook)
make TARGET=pocketbook clean make TARGET=pocketbook clean
@ -313,6 +314,36 @@ OPTIONS:
popd popd
} }
function kodev-log {
LOG_HELP_MSG="
usage: log <TARGET>
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=" HELP_MSG="
@ -327,6 +358,7 @@ Supported commands:
run Run KOReader run Run KOReader
wbuilder Run wbuilder.lua script (useful for building new UI widget) wbuilder Run wbuilder.lua script (useful for building new UI widget)
test Run tests test Run tests
log Tail log stream for a running KOReader app
" "
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
@ -362,6 +394,10 @@ case $1 in
shift 1 shift 1
kodev-test $@ kodev-test $@
;; ;;
log)
shift 1
kodev-log $@
;;
--help | -h) --help | -h)
echo "${HELP_MSG}" echo "${HELP_MSG}"
exit 0 exit 0

@ -1 +1 @@
Subproject commit cc5c30286ade5151848a8dbb2be64e90fb2c8fcf Subproject commit 08f23b83e882b16b587cf0ec8e267b5c7708a71f
Loading…
Cancel
Save