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 diff --git a/frontend/apps/reader/modules/readergoto.lua b/frontend/apps/reader/modules/readergoto.lua index 5ec541160..ea14d6fbc 100644 --- a/frontend/apps/reader/modules/readergoto.lua +++ b/frontend/apps/reader/modules/readergoto.lua @@ -3,12 +3,10 @@ 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{ goto_menu_title = _("Go to"), - goto_dialog_title = _("Go to Page or Location"), } function ReaderGoto:init() @@ -26,10 +24,26 @@ function ReaderGoto:addToMainMenu(tab_item_table) end function ReaderGoto:onShowGotoDialog() - DEBUG("show goto dialog") + 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 = self.goto_dialog_title, - input_hint = "(1 - "..self.document:getPageCount()..")", + title = dialog_title, + input_hint = "@"..curr_page.." (1 - "..self.document:getPageCount()..")", buttons = { { { @@ -39,20 +53,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",