mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
UI Changes (#5508)
* Changed File Browser text
KOReader looks nicer than KOReader File Browser,
* Remove the "page x of x" if only one page
Removes it from the bottom of the file browser
* Remove the "page x of x" if only one page
Removes it from the top menu, if there is only one page, why show page 1 of 1
* Renamed ~ to Home
Since the file browser can be considered "Home"
* Added 12 hour time option
Also tweaked the charging icon, ⚡ looks nicer than +, tweaked seperator between time and battery, - instead of @
This commit is contained in:
@@ -55,7 +55,7 @@ local function truncatePath(text)
|
||||
end
|
||||
|
||||
local FileManager = InputContainer:extend{
|
||||
title = _("KOReader File Browser"),
|
||||
title = _("KOReader"),
|
||||
root_path = lfs.currentdir(),
|
||||
onExit = function() end,
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ This module contains miscellaneous helper functions for FileManager
|
||||
local Device = require("device")
|
||||
local DocSettings = require("docsettings")
|
||||
local util = require("ffi/util")
|
||||
local _ = require("gettext")
|
||||
|
||||
local filemanagerutil = {}
|
||||
|
||||
@@ -24,13 +25,15 @@ end
|
||||
|
||||
function filemanagerutil.abbreviate(path)
|
||||
if not path then return "" end
|
||||
local home_dir_name = G_reader_settings:readSetting("home_dir_display_name")
|
||||
if home_dir_name ~= nil then
|
||||
if G_reader_settings:nilOrTrue("shorten_home_dir") then
|
||||
local home_dir = G_reader_settings:readSetting("home_dir") or filemanagerutil.getDefaultDir()
|
||||
if path == home_dir then
|
||||
return _("Home")
|
||||
end
|
||||
local len = home_dir:len()
|
||||
local start = path:sub(1, len)
|
||||
if start == home_dir then
|
||||
return home_dir_name .. path:sub(len+1)
|
||||
return path:sub(len+2)
|
||||
end
|
||||
end
|
||||
return path
|
||||
|
||||
@@ -55,6 +55,16 @@ if Device:setDateTime() then
|
||||
common_settings.time = {
|
||||
text = _("Time and date"),
|
||||
sub_item_table = {
|
||||
{
|
||||
text = _("12-hour clock"),
|
||||
keep_menu_open = true,
|
||||
checked_func = function()
|
||||
return G_reader_settings:nilOrTrue("twelve_hour_clock")
|
||||
end,
|
||||
callback = function()
|
||||
G_reader_settings:flipNilOrTrue("twelve_hour_clock")
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Set time"),
|
||||
keep_menu_open = true,
|
||||
|
||||
@@ -498,7 +498,7 @@ function KeyValuePage:_populateItems()
|
||||
table.insert(self.main_content,
|
||||
VerticalSpan:new{ width = self.item_margin })
|
||||
end
|
||||
self.page_info_text:setText(T(_("page %1 of %2"), self.show_page, self.pages))
|
||||
self.page_info_text:setText(T(_("Page %1 of %2"), self.show_page, self.pages))
|
||||
self.page_info_left_chev:showHide(self.pages > 1)
|
||||
self.page_info_right_chev:showHide(self.pages > 1)
|
||||
self.page_info_first_chev:showHide(self.pages > 2)
|
||||
|
||||
@@ -898,7 +898,11 @@ function Menu:updatePageInfo(select_number)
|
||||
self.selected = { x = 1, y = select_number }
|
||||
end
|
||||
-- update page information
|
||||
self.page_info_text:setText(util.template(_("page %1 of %2"), self.page, self.page_num))
|
||||
if self.page_num > 1 then
|
||||
self.page_info_text:setText(util.template(_("Page %1 of %2"), self.page, self.page_num))
|
||||
else
|
||||
self.page_info_text:setText("");
|
||||
end
|
||||
self.page_info_left_chev:showHide(self.page_num > 1)
|
||||
self.page_info_right_chev:showHide(self.page_num > 1)
|
||||
self.page_info_first_chev:showHide(self.page_num > 2)
|
||||
|
||||
@@ -593,17 +593,27 @@ function TouchMenu:updateItems()
|
||||
|
||||
table.insert(self.item_group, self.footer_top_margin)
|
||||
table.insert(self.item_group, self.footer)
|
||||
-- @translators %1 is the current page. %2 is the total number of pages. In some languages a good translation might need to reverse this order, for instance: "Total %2, page %1".
|
||||
self.page_info_text.text = util.template(_("Page %1 of %2"), self.page, self.page_num)
|
||||
if self.page_num > 1 then
|
||||
-- @translators %1 is the current page. %2 is the total number of pages. In some languages a good translation might need to reverse this order, for instance: "Total %2, page %1".
|
||||
self.page_info_text:setText(util.template(_("Page %1 of %2"), self.page, self.page_num))
|
||||
else
|
||||
self.page_info_text:setText("")
|
||||
end
|
||||
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)
|
||||
local time_info_txt = os.date("%H:%M").." @ "
|
||||
if Device:getPowerDevice():isCharging() then
|
||||
time_info_txt = time_info_txt.."+"
|
||||
|
||||
local time_info_txt
|
||||
if G_reader_settings:nilOrTrue("twelve_hour_clock") then
|
||||
time_info_txt = os.date("%I:%M %p")
|
||||
else
|
||||
time_info_txt = os.date("%H:%M")
|
||||
end
|
||||
time_info_txt = time_info_txt .. " – " .. Device:getPowerDevice():getCapacity() .. "%"
|
||||
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
|
||||
|
||||
@@ -370,7 +370,7 @@ function ListMenuItem:update()
|
||||
elseif percent_finished then
|
||||
if pages then
|
||||
if BookInfoManager:getSetting("show_pages_read_as_progress") then
|
||||
pages_str = T(_("page %1 of %2"), Math.round(percent_finished*pages), pages)
|
||||
pages_str = T(_("Page %1 of %2"), Math.round(percent_finished*pages), pages)
|
||||
else
|
||||
pages_str = T(_("%1 % of %2 pages"), math.floor(100*percent_finished), pages)
|
||||
end
|
||||
|
||||
@@ -132,16 +132,13 @@ function CoverBrowser:addToMainMenu(menu_items)
|
||||
separator = true,
|
||||
},
|
||||
{
|
||||
text = _("Shorten home directory to ~"),
|
||||
checked_func = function() return G_reader_settings:readSetting("home_dir_display_name") end,
|
||||
text = _("Shorten home directory"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:nilOrTrue("shorten_home_dir")
|
||||
end,
|
||||
callback = function()
|
||||
if G_reader_settings:readSetting("home_dir_display_name") then
|
||||
G_reader_settings:delSetting("home_dir_display_name")
|
||||
if FileManager.instance then FileManager.instance:reinit() end
|
||||
else
|
||||
G_reader_settings:saveSetting("home_dir_display_name", "~")
|
||||
if FileManager.instance then FileManager.instance:reinit() end
|
||||
end
|
||||
G_reader_settings:flipNilOrTrue("shorten_home_dir")
|
||||
if FileManager.instance then FileManager.instance:reinit() end
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -395,7 +395,7 @@ function DoubleKeyValuePage:_populateItems()
|
||||
table.insert(self.main_content,
|
||||
VerticalSpan:new{ width = self.item_margin })
|
||||
end
|
||||
self.page_info_text:setText(T(_("page %1 of %2"), self.show_page, self.pages))
|
||||
self.page_info_text:setText(T(_("Page %1 of %2"), self.show_page, self.pages))
|
||||
self.page_info_left_chev:showHide(self.pages > 1)
|
||||
self.page_info_right_chev:showHide(self.pages > 1)
|
||||
self.page_info_left_chev:enableDisable(self.show_page > 1)
|
||||
|
||||
Reference in New Issue
Block a user