diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index 312715e5e..04f563044 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -149,6 +149,9 @@ local footerTextGeneratorMap = { local prefix = symbol_prefix[symbol_type].battery local powerd = Device:getPowerDevice() local batt_lvl = powerd:getCapacity() + if footer.settings.all_at_once and batt_lvl > footer.settings.battery_hide_threshold then + return "" + end -- If we're using icons, use fancy variable icons if symbol_type == "icons" or symbol_type == "compact_items" then if powerd:isCharging() then @@ -415,6 +418,7 @@ ReaderFooter.default_settings = { time = true, pages_left = true, battery = Device:hasBattery(), + battery_hide_threshold = 100, percentage = true, book_time_to_read = true, chapter_time_to_read = true, @@ -872,6 +876,7 @@ function ReaderFooter:addToMainMenu(menu_items) } -- menu item to fake footer tapping when touch area is disabled + local settings_submenu_num = 1 if Geom:new{ x = DTAP_ZONE_MINIBAR.x, y = DTAP_ZONE_MINIBAR.y, @@ -885,6 +890,7 @@ function ReaderFooter:addToMainMenu(menu_items) end, callback = function() self:onTapFooter(true) end, }) + settings_submenu_num = 2 end local getMinibarOption = function(option, callback) @@ -968,6 +974,7 @@ function ReaderFooter:addToMainMenu(menu_items) sub_item_table = { { text = _("Sort items"), + separator = true, callback = function() local item_table = {} for i=1, #self.mode_index do @@ -1047,7 +1054,6 @@ function ReaderFooter:addToMainMenu(menu_items) }, { text = _("Font"), - separator = true, sub_item_table = { { text_func = function() @@ -1423,6 +1429,36 @@ function ReaderFooter:addToMainMenu(menu_items) }, } }) + if Device:hasBattery() then + table.insert(sub_items[settings_submenu_num].sub_item_table, 4, { + text_func = function() + return T(_("Hide battery status if level higher than (%1%)"), self.settings.battery_hide_threshold) + end, + enabled_func = function() + return self.settings.all_at_once == true + end, + separator = true, + callback = function(touchmenu_instance) + local SpinWidget = require("ui/widget/spinwidget") + local battery_threshold = SpinWidget:new{ + width = math.floor(Screen:getWidth() * 0.6), + value = self.settings.battery_hide_threshold, + value_min = 0, + value_max = 100, + default_value = 100, + value_hold_step = 10, + title_text = _("Hide battery threshold"), + callback = function(spin) + self.settings.battery_hide_threshold = spin.value + self:refreshFooter(true, true) + if touchmenu_instance then touchmenu_instance:updateItems() end + end, + } + UIManager:show(battery_threshold) + end, + keep_menu_open = true, + }) + end table.insert(sub_items, { text = _("Progress bar"), separator = true, diff --git a/frontend/ui/data/onetime_migration.lua b/frontend/ui/data/onetime_migration.lua index 77217619c..20620d696 100644 --- a/frontend/ui/data/onetime_migration.lua +++ b/frontend/ui/data/onetime_migration.lua @@ -7,7 +7,7 @@ local lfs = require("libs/libkoreader-lfs") local logger = require("logger") -- Date at which the last migration snippet was added -local CURRENT_MIGRATION_DATE = 20210531 +local CURRENT_MIGRATION_DATE = 20210622 -- Retrieve the date of the previous migration, if any local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0) @@ -219,8 +219,9 @@ if last_migration_date < 20210508 then end -- 20210518, ReaderFooter, https://github.com/koreader/koreader/pull/7702 -if last_migration_date < 20210518 then - logger.info("Performing one-time migration for 20210518") +-- 20210622, ReaderFooter, https://github.com/koreader/koreader/pull/7876 +if last_migration_date < 20210622 then + logger.info("Performing one-time migration for 20210622") local ReaderFooter = require("apps/reader/modules/readerfooter") local settings = G_reader_settings:readSetting("footer", ReaderFooter.default_settings)