From 31e24463ef3058a1b9ea3a9d540d319ef7a8d6bb Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 5 Dec 2022 19:10:50 +0100 Subject: [PATCH] [BH-1612] Show battery 100% on 24h vert. face with date Decrease space between colon and digits in TimeSetSpinner for smaller fonts. Decrease main vertical time width. Use battery icon with smaller width. Decrease space between battery icon and percentage. --- module-apps/apps-common/widgets/TimeSetSpinner.hpp | 5 +++-- products/BellHybrid/CMakeLists.txt | 4 ++-- .../windows/RelaxationRunningLoopWindow.cpp | 2 +- .../layouts/HomeScreenLayoutVerticalWithDate.hpp | 2 +- .../common/include/common/widgets/BellBattery.hpp | 11 +++++++++-- .../common/src/layouts/HomeScreenLayoutClassic.cpp | 2 +- .../layouts/HomeScreenLayoutVerticalWithDate.cpp | 13 ++----------- .../apps/common/src/widgets/BellBattery.cpp | 14 +++++++++----- .../apps/common/src/widgets/LayoutVertical.cpp | 2 +- 9 files changed, 29 insertions(+), 26 deletions(-) diff --git a/module-apps/apps-common/widgets/TimeSetSpinner.hpp b/module-apps/apps-common/widgets/TimeSetSpinner.hpp index 8a882c4584fefe8087d06681b620ff3fb4e6d058..16cd9d96abcbe5f9cf7b28ea63577eb373d9f2db 100644 --- a/module-apps/apps-common/widgets/TimeSetSpinner.hpp +++ b/module-apps/apps-common/widgets/TimeSetSpinner.hpp @@ -16,6 +16,7 @@ namespace style::time_set_spinner inline constexpr auto size = 6U; } // namespace focus + inline constexpr auto very_small_margin = 3U; inline constexpr auto small_margin = 6U; inline constexpr auto big_margin = 6U; inline constexpr auto gargantuan_margin_left = 14U; @@ -56,9 +57,9 @@ namespace gui std::map colonMarginsMap = { {style::window::font::verybiglight, - {style::time_set_spinner::small_margin, 0, style::time_set_spinner::small_margin, 0}}, + {style::time_set_spinner::very_small_margin, 0, style::time_set_spinner::very_small_margin, 0}}, {style::window::font::veryverybiglight, - {style::time_set_spinner::small_margin, 0, style::time_set_spinner::small_margin, 0}}, + {style::time_set_spinner::very_small_margin, 0, style::time_set_spinner::very_small_margin, 0}}, {style::window::font::largelight, {style::time_set_spinner::small_margin, 0, style::time_set_spinner::small_margin, 0}}, {style::window::font::supersizeme, diff --git a/products/BellHybrid/CMakeLists.txt b/products/BellHybrid/CMakeLists.txt index e75bc3e676ca3bfc3051006ee46b2cb322274a0f..8c5bbcfef7bb3e6ed1010d10abc195cf5c013107 100644 --- a/products/BellHybrid/CMakeLists.txt +++ b/products/BellHybrid/CMakeLists.txt @@ -115,14 +115,14 @@ download_asset_release_json(json-common-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_common.json ${CMAKE_BINARY_DIR}/sysroot/sys/current/ MuditaOSPublicAssets - 0.0.14 + 0.0.15 ${MUDITA_CACHE_DIR} ) download_asset_release_json(json-community-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_community.json ${CMAKE_BINARY_DIR}/sysroot/sys/current/ MuditaOSPublicAssets - 0.0.14 + 0.0.15 ${MUDITA_CACHE_DIR} ) download_asset_json(json-rt1051-target diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp index 9274274c6fed4213ffb50a1e6638f5f87bb4c54e..e2798dff39c24a6c715052de33af4e02fcd361dc 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp @@ -60,7 +60,7 @@ namespace gui::BellBattery *createBattery(gui::VBox *parent) { - auto battery = new gui::BellBattery(parent); + auto battery = new gui::BellBattery(parent, gui::BatteryWidthMode::Fixed); battery->setMinimumSize(gui::battery::battery_widget_w, gui::battery::battery_widget_h); battery->setEdges(gui::RectangleEdge::None); battery->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center)); diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp index cf40659416e8bd74158361a2d7e618e5ef83fec0..a921b5fb44d68b407b33c7171e552fbe31bb3801 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp @@ -23,7 +23,7 @@ namespace gui void setTimeFormat(utils::time::Locale::TimeFormat fmt) override; private: - void setBatteryLevelState(const Store::Battery &batteryContext) override; + bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext) override; bool isAlarmTimeVisibilityAllowed() override; TextFixedSize *ampm = nullptr; diff --git a/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp b/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp index 812f8fcd223789e60f3f75329d969272e3ef6a24..541a7cc5d32714637f0c7d4515233a230e3331c3 100644 --- a/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp +++ b/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp @@ -14,7 +14,7 @@ namespace gui namespace battery { constexpr auto font_small = style::window::font::largelight; - constexpr auto image_right_margin = 10U; + constexpr auto image_right_margin = 5U; constexpr auto percent_h = 102U; constexpr auto percent_w = 106U; constexpr auto battery_widget_h = 64U; @@ -28,10 +28,16 @@ namespace gui Hide // Never show percentage }; + enum class BatteryWidthMode + { + Fixed, + FitToContent + }; + class BellBattery : public gui::HBox { public: - BellBattery(Item *parent); + BellBattery(Item *parent, BatteryWidthMode widthMode); void setFont(const UTF8 &fontName); void update(units::SOC soc, bool isCharging); void setBatteryPercentMode(BatteryPercentMode mode); @@ -42,5 +48,6 @@ namespace gui BatteryPercentMode batteryPercentMode = BatteryPercentMode::Show; Text *percentText = nullptr; Image *img = nullptr; + BatteryWidthMode widthMode = BatteryWidthMode::Fixed; }; } // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp index 448e979854125cd923a22efe79c919ec4d25dd66..353146e62ad1085ee176f21f44a7fad88eb6475c 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp @@ -69,7 +69,7 @@ namespace gui statusBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); statusBox->setVisible(true); - battery = new BellBattery(statusBox); + battery = new BellBattery(statusBox, gui::BatteryWidthMode::FitToContent); battery->setMaximumSize(battery::battery_widget_w, battery::battery_widget_h); battery->setEdges(RectangleEdge::None); battery->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp index 96113aa8dcd308de38f687978153625f9a920a40..201c7f6c39f885595baec0bb1ea5df5999763283 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp @@ -108,18 +108,9 @@ namespace gui } } - void HomeScreenLayoutVerticalWithDate::setBatteryLevelState(const Store::Battery &batteryContext) + bool HomeScreenLayoutVerticalWithDate::isBatteryVisibilityAllowed(const Store::Battery &batteryContext) { - // In 24h mode battery indicator is lower so 100% is too long to be displayed - if (!ampm->visible) { - const auto percentMode = batteryContext.level < 100 ? BatteryPercentMode::Show : BatteryPercentMode::Hide; - battery->setBatteryPercentMode(percentMode); - } - else - battery->setBatteryPercentMode(BatteryPercentMode::Show); - battery->update(batteryContext.level, isBatteryCharging(batteryContext.state)); - battery->setVisible(true); - battery->informContentChanged(); + return true; } bool HomeScreenLayoutVerticalWithDate::isAlarmTimeVisibilityAllowed() diff --git a/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp b/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp index 931a24c5354c05d492089c8a087d9e16a1c534f1..8c2f405aed7058930eb3756c9f9a36ea9278f597 100644 --- a/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp +++ b/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp @@ -20,7 +20,7 @@ namespace namespace gui { - BellBattery::BellBattery(Item *parent) : HBox(parent) + BellBattery::BellBattery(Item *parent, BatteryWidthMode widthMode) : HBox(parent), widthMode(widthMode) { img = new Image(this, battery_low, gui::ImageTypeSpecifier::W_M); img->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); @@ -33,8 +33,8 @@ namespace gui percentText->setEditMode(EditMode::Browse); percentText->activeItem = false; percentText->drawUnderline(false); - percentText->setVisible(false); percentText->setText("000%"); + percentText->setVisible(false); } void BellBattery::setFont(const UTF8 &fontName) @@ -50,8 +50,10 @@ namespace gui } const auto text = UTF8(std::to_string(soc) + "%"); - // Without this the text is not set properly if percentText was hidden - percentText->setMinimumWidthToFitText(text); + if (widthMode == BatteryWidthMode::FitToContent) { + // Without this the text is not set properly if percentText was hidden + percentText->setMinimumWidthToFitText(text); + } percentText->setText(text); if (isCharging) { @@ -76,7 +78,9 @@ namespace gui percentText->setVisible(false); } - setWidthsToFitContent(); + if (widthMode == BatteryWidthMode::FitToContent) { + setWidthsToFitContent(); + } img->informContentChanged(); } diff --git a/products/BellHybrid/apps/common/src/widgets/LayoutVertical.cpp b/products/BellHybrid/apps/common/src/widgets/LayoutVertical.cpp index b1498b0e25b72c2c29d66d54054fb51d85240d59..1644f33b812184ab31158497135505f5cb9db03a 100644 --- a/products/BellHybrid/apps/common/src/widgets/LayoutVertical.cpp +++ b/products/BellHybrid/apps/common/src/widgets/LayoutVertical.cpp @@ -70,7 +70,7 @@ namespace gui alarmMainTime->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center)); alarmMainTime->setVisible(false); - battery = new BellBattery(nullptr); + battery = new BellBattery(nullptr, gui::BatteryWidthMode::Fixed); battery->setMinimumSize(battery::battery_widget_w, battery::battery_widget_h); battery->setEdges(RectangleEdge::None); battery->setVisible(true);