M module-apps/application-calllog/ApplicationCallLog.cpp => module-apps/application-calllog/ApplicationCallLog.cpp +8 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ApplicationCallLog.hpp"
@@ 21,13 21,19 @@
using namespace calllog;
+namespace
+{
+ constexpr auto applicationCallLogStackSize = 1024 * 7;
+}
+
namespace app
{
ApplicationCallLog::ApplicationCallLog(std::string name,
std::string parent,
StatusIndicators statusIndicators,
StartInBackground startInBackground)
- : Application(std::move(name), std::move(parent), statusIndicators, startInBackground, 5120)
+ : Application(
+ std::move(name), std::move(parent), statusIndicators, startInBackground, applicationCallLogStackSize)
{
bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
addActionReceiver(manager::actions::ShowCallLog, [this](auto &&data) {
M module-apps/application-phonebook/models/PhonebookModel.cpp => module-apps/application-phonebook/models/PhonebookModel.cpp +6 -6
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <application-phonebook/ApplicationPhonebook.hpp>
@@ 20,7 20,10 @@
#include <string>
#include <utility>
-const static std::uint32_t phonebookModelTimeout = 1000;
+namespace
+{
+ constexpr auto phonebookModelTimeout = 1000;
+}
PhonebookModel::PhonebookModel(app::ApplicationCommon *app) : DatabaseModel(app), app::AsyncCallbackReceiver{app}
{}
@@ 103,7 106,6 @@ auto PhonebookModel::getMinimalItemSpaceRequired() const -> unsigned int
auto PhonebookModel::getItem(gui::Order order) -> gui::ListItem *
{
-
const auto contact = getRecord(order);
if (contact == nullptr) {
@@ 169,9 171,7 @@ auto PhonebookModel::getLabelMarkerDisplayMode(uint32_t posOnList) -> LabelMarke
if (posOnList < letterMap.favouritesCount) {
return LabelMarkerDisplayMode::IncludeFavourites;
}
- else {
- return LabelMarkerDisplayMode::IgnoreFavourites;
- }
+ return LabelMarkerDisplayMode::IgnoreFavourites;
}
void PhonebookModel::setFilter(std::string filter, const std::uint32_t groupFilter, const std::uint32_t displayMode)
M module-apps/application-phonebook/widgets/PhonebookListView.cpp => module-apps/application-phonebook/widgets/PhonebookListView.cpp +39 -29
@@ 1,13 1,16 @@
-// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PhonebookListView.hpp"
namespace gui
{
-
- PhonebookListView::PhonebookListView(
- Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h, std::shared_ptr<ListItemProvider> prov)
+ PhonebookListView::PhonebookListView(Item *parent,
+ std::uint32_t x,
+ std::uint32_t y,
+ std::uint32_t w,
+ std::uint32_t h,
+ std::shared_ptr<ListItemProvider> prov)
: ListView(parent, x, y, w, h, std::move(prov))
{}
@@ 20,18 23,28 @@ namespace gui
body->addWidget(new PhonebookMarkItem(labelMark));
}
break;
+
case listview::Direction::Top:
if (currentPageSize == 0) {
labelMark = item->getLabelMarker();
- return;
+ break;
}
- else if (labelMark != item->getLabelMarker()) {
- previousLabelMark = labelMark;
- labelMark = item->getLabelMarker();
+
+ if (labelMark != item->getLabelMarker()) {
+ const auto initialSlotsLeft = getSlotsLeft();
+ const auto previousLabelMark = labelMark;
+ labelMark = item->getLabelMarker();
body->removeWidget(item);
body->addWidget(new PhonebookMarkItem(previousLabelMark));
+
+ /* Add item to body even if it won't fit to avoid manual memory
+ * management for item, but apply correction to currentPageSize
+ * if it is not visible. */
body->addWidget(item);
+ if (initialSlotsLeft == 0) {
+ currentPageSize--;
+ }
previousItemIsLabel = true;
}
@@ 42,50 55,42 @@ namespace gui
void PhonebookListView::addItemsOnPage()
{
currentPageSize = 0;
+ labelMark = "";
+
ListItem *item = nullptr;
ListItem *previousListItem = nullptr;
- labelMark = "";
- previousLabelMark = "";
while ((item = provider->getItem(getOrderFromDirection())) != nullptr) {
- // if direction bot add label mark before adding item
+ /* If direction is top-to-bottom, add label mark before adding phonebook item. */
if (direction == listview::Direction::Bottom) {
addLabelMarker(dynamic_cast<gui::PhonebookItem *>(item));
}
- body->addWidget(item);
-
- // if added item is not visible -> page is full.
- if (!item->visible) {
-
- // if page full and direction top remove last element and add floating label mark on top if there was no
- // one previously
+ /* Check if new item fits, if it does - add it, if not - handle label insertion
+ * case for bottom-to-top navigation direction. */
+ if (getSlotsLeft() > 0) {
+ body->addWidget(item);
+ }
+ else {
if (direction == listview::Direction::Top) {
-
if (previousItemIsLabel) {
break;
}
- else {
-
- body->erase(item);
- body->erase(previousListItem);
-
- body->addWidget(new PhonebookMarkItem(labelMark));
- currentPageSize--;
- }
+ body->erase(previousListItem);
+ body->addWidget(new PhonebookMarkItem(labelMark));
+ currentPageSize--;
}
break;
}
- // if direction top add label mark after adding item
+ /* If direction is bottom-to-top, add label mark after adding phonebook item. */
if (direction == listview::Direction::Top) {
previousItemIsLabel = false;
addLabelMarker(dynamic_cast<gui::PhonebookItem *>(item));
}
previousListItem = item;
-
currentPageSize++;
}
@@ 97,4 102,9 @@ namespace gui
}
}
+ std::size_t PhonebookListView::getSlotsLeft()
+ {
+ const auto singleSlotSpace = getProvider()->getMinimalItemSpaceRequired();
+ return body->getPrimarySizeLeft() / singleSlotSpace;
+ }
} /* namespace gui */
M module-apps/application-phonebook/widgets/PhonebookListView.hpp => module-apps/application-phonebook/widgets/PhonebookListView.hpp +13 -9
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 14,16 14,20 @@ namespace gui
class PhonebookListView : public ListView
{
- UTF8 labelMark = "";
- UTF8 previousLabelMark = "";
- bool previousItemIsLabel = false;
-
+ public:
+ PhonebookListView(Item *parent,
+ std::uint32_t x,
+ std::uint32_t y,
+ std::uint32_t w,
+ std::uint32_t h,
+ std::shared_ptr<ListItemProvider> prov);
+
+ private:
void addItemsOnPage() override;
void addLabelMarker(PhonebookItem *item);
+ std::size_t getSlotsLeft();
- public:
- PhonebookListView(
- Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h, std::shared_ptr<ListItemProvider> prov);
+ UTF8 labelMark = "";
+ bool previousItemIsLabel = false;
};
-
} /* namespace gui */
M module-apps/apps-common/DatabaseModel.hpp => module-apps/apps-common/DatabaseModel.hpp +21 -22
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 13,7 13,6 @@
namespace app
{
-
template <class T>
class DatabaseModel
{
@@ 39,17 38,15 @@ namespace app
assert(dbRecords.size() <= recordsCount);
- if (!dbRecords.empty()) {
- for (uint32_t i = 0; i < dbRecords.size(); i++) {
- records.push_back(std::make_shared<T>(dbRecords[i]));
- }
-
- return true;
- }
- else {
- LOG_WARN("DB is empty");
+ if (dbRecords.empty()) {
+ LOG_INFO("DB is empty");
return false;
}
+
+ for (const auto &dbRecord : dbRecords) {
+ records.push_back(std::make_shared<T>(dbRecord));
+ }
+ return true;
}
void clear()
@@ 60,24 57,27 @@ namespace app
std::shared_ptr<T> getRecord(gui::Order order)
{
- auto index = 0;
- if (order == gui::Order::Next) {
- index = modelIndex;
+ int index = 0;
+ switch (order) {
+ case gui::Order::Next:
+ index = modelIndex;
modelIndex++;
- }
- else if (order == gui::Order::Previous) {
- index = records.size() - 1 + modelIndex;
+ break;
+ case gui::Order::Previous:
+ index = records.size() - 1 + modelIndex;
modelIndex--;
- }
+ break;
- if (isIndexValid(index)) {
- return records[index];
+ default:
+ break;
}
- else {
+
+ if (!isIndexValid(index)) {
return nullptr;
}
+ return records[index];
}
[[nodiscard]] bool isIndexValid(unsigned int index) const noexcept
@@ 85,5 85,4 @@ namespace app
return index < records.size();
}
};
-
} /* namespace app */
M module-gui/gui/widgets/ListViewEngine.hpp => module-gui/gui/widgets/ListViewEngine.hpp +1 -1
@@ 109,7 109,7 @@ namespace gui
[[nodiscard]] unsigned getFocusItemIndex();
/// Total provider elements count
- unsigned int elementsCount = listview::nPos;
+ unsigned elementsCount = listview::nPos;
void setElementsCount(unsigned count);
void onElementsCountChanged(unsigned count);
bool shouldCallEmptyListCallbacks = false;
M pure_changelog.md => pure_changelog.md +1 -0
@@ 18,6 18,7 @@
* Fixed unwanted autolock on template selection window while rejecting call
* Fixed scenario when Alarm not being handled properly during a phone call
* Fixed handsfree device still ringing after caller has hung up
+* Fixed missing contact entries when scrolling through the contact list
## [1.7.1 2023-07-13]