From 847837c5c18ef629f00dd6f044ff256e4a8c85cc Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Thu, 25 Feb 2016 23:50:12 -0800 Subject: [PATCH 1/3] readergoto: use the term page and location based on doc type --- frontend/apps/reader/modules/readergoto.lua | 33 ++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/frontend/apps/reader/modules/readergoto.lua b/frontend/apps/reader/modules/readergoto.lua index 5ec541160..dd378bb34 100644 --- a/frontend/apps/reader/modules/readergoto.lua +++ b/frontend/apps/reader/modules/readergoto.lua @@ -8,7 +8,6 @@ local _ = require("gettext") local ReaderGoto = InputContainer:new{ goto_menu_title = _("Go to"), - goto_dialog_title = _("Go to Page or Location"), } function ReaderGoto:init() @@ -26,9 +25,22 @@ function ReaderGoto:addToMainMenu(tab_item_table) end function ReaderGoto:onShowGotoDialog() - DEBUG("show goto dialog") + local dialog_title, goto_btn + if self.document.info.has_pages then + dialog_title = _("Go to Page") + goto_btn = { + text = _("Page"), + callback = function() self:gotoPage() end, + } + else + dialog_title = _("Go to Location") + goto_btn = { + text = _("Location"), + callback = function() self:gotoPage() end, + } + end self.goto_dialog = InputDialog:new{ - title = self.goto_dialog_title, + title = dialog_title, input_hint = "(1 - "..self.document:getPageCount()..")", buttons = { { @@ -39,20 +51,7 @@ function ReaderGoto:onShowGotoDialog() self:close() end, }, - { - text = _("Page"), - enabled = self.document.info.has_pages, - callback = function() - self:gotoPage() - end, - }, - { - text = _("Location"), - enabled = not self.document.info.has_pages, - callback = function() - self:gotoPage() - end, - }, + goto_btn, }, }, input_type = "number", From 46ade8e795fa8c5cfdb18da4dca7b0e425f845ac Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 26 Feb 2016 00:04:21 -0800 Subject: [PATCH 2/3] readergoto: show current page in input hint --- frontend/apps/reader/modules/readergoto.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/apps/reader/modules/readergoto.lua b/frontend/apps/reader/modules/readergoto.lua index dd378bb34..ea14d6fbc 100644 --- a/frontend/apps/reader/modules/readergoto.lua +++ b/frontend/apps/reader/modules/readergoto.lua @@ -3,7 +3,6 @@ local InputDialog = require("ui/widget/inputdialog") local UIManager = require("ui/uimanager") local Screen = require("device").screen local Event = require("ui/event") -local DEBUG = require("dbg") local _ = require("gettext") local ReaderGoto = InputContainer:new{ @@ -25,23 +24,26 @@ function ReaderGoto:addToMainMenu(tab_item_table) end function ReaderGoto:onShowGotoDialog() - local dialog_title, goto_btn + local dialog_title, goto_btn, curr_page if self.document.info.has_pages then dialog_title = _("Go to Page") goto_btn = { text = _("Page"), callback = function() self:gotoPage() end, } + curr_page = self.ui.paging.current_page else dialog_title = _("Go to Location") goto_btn = { text = _("Location"), callback = function() self:gotoPage() end, } + -- only CreDocument has this method + curr_page = self.document:getCurrentPage() end self.goto_dialog = InputDialog:new{ title = dialog_title, - input_hint = "(1 - "..self.document:getPageCount()..")", + input_hint = "@"..curr_page.." (1 - "..self.document:getPageCount()..")", buttons = { { { From 4e43dd2870065c20361de0d7903f1320e7b2c809 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 26 Feb 2016 00:23:03 -0800 Subject: [PATCH 3/3] build: increase retry time for make testfront to 5 --- .ci/common.sh | 27 +++++++++++++++++++++++++++ .ci/script.sh | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.ci/common.sh b/.ci/common.sh index 0ee4bd104..4d84291d5 100644 --- a/.ci/common.sh +++ b/.ci/common.sh @@ -30,6 +30,33 @@ travis_retry() { return $result } +retry_cmd() { + local result=0 + local count=1 + set +e + + retry_cnt=$1 + shift 1 + + while [ $count -le ${retry_cnt} ]; do + [ $result -ne 0 ] && { + echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of ${retry_cnt}${ANSI_RESET}\n" >&2 + } + "$@" + result=$? + [ $result -eq 0 ] && break + count=$(($count + 1)) + sleep 1 + done + + [ $count -gt ${retry_cnt} ] && { + echo -e "\n${ANSI_RED}The command \"$@\" failed ${retry_cnt} times.${ANSI_RESET}\n" >&2 + } + + set -e + return $result +} + export PATH=$PWD/bin:$PATH export PATH=$PATH:${TRAVIS_BUILD_DIR}/install/bin if [ -f ${TRAVIS_BUILD_DIR}/install/bin/luarocks ]; then diff --git a/.ci/script.sh b/.ci/script.sh index 64be8cb4a..a5233bad1 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -5,7 +5,7 @@ source "${CI_DIR}/common.sh" travis_retry make fetchthirdparty make all -travis_retry make testfront +retry_cmd 6 make testfront set +o pipefail luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out test $(grep Total ./luacheck.out | awk '{print $2}') -le 63