~aleteoryx/muditaos

00fd29f8bd867f09f7d34b032e3dab5067ccc539 — Marcin Zieliński 3 years ago adc1010
[MOS-477] Add the call log erasing option

Add the call log erasing option
M image/assets/lang/English.json => image/assets/lang/English.json +2 -0
@@ 166,6 166,8 @@
  "app_calllog_date": "Date",
  "app_calllog_options_delete_call": "Delete call",
  "app_calllog_delete_call_confirmation": "Delete this call from the list?",
  "app_calllog_delete_all_calls": "Delete all calls",
  "app_calllog_delete_all_calls_confirmation": "Delete all calls from the list?",
  "app_desktop_unlock": "UNLOCK",
  "app_desktop_menu": "MENU",
  "app_desktop_emergency": "SOS",

M image/assets/lang/Polski.json => image/assets/lang/Polski.json +2 -0
@@ 195,6 195,8 @@
  "app_calllog_date": "Data",
  "app_calllog_options_delete_call": "Usuń połączenie",
  "app_calllog_delete_call_confirmation": "Czy chcesz usunąć to połączenie z listy?",
  "app_calllog_delete_all_calls": "Usuń wszystkie połączenia",
  "app_calllog_delete_all_calls_confirmation": "Czy chcesz usunąć wszystkie połączenia z listy?",
  "app_music_player_artists": "<text color='9'>Wykonawcy</text>",
  "app_music_player_albums": "<text color='9'>Albumy</text>",
  "app_music_player_playlists": "<text color='9'>Playlisty</text>",

M module-apps/application-calllog/windows/CallLogMainWindow.cpp => module-apps/application-calllog/windows/CallLogMainWindow.cpp +56 -8
@@ 5,8 5,13 @@
#include "data/CallLogInternals.hpp"
#include "ApplicationCallLog.hpp"
#include "widgets/CalllogItem.hpp"
#include "header/DeleteAction.hpp"

#include <service-db/DBCalllogMessage.hpp>
#include <DialogMetadata.hpp>
#include <DialogMetadataMessage.hpp>

#include <service-appmgr/Controller.hpp>
#include <queries/calllog/QueryCalllogDeleteAll.hpp>
#include <i18n/i18n.hpp>
#include <Label.hpp>
#include <Margins.hpp>


@@ 39,12 44,15 @@ namespace gui
        list->rebuildList(gui::listview::RebuildType::InPlace);
    }

    gui::header::DeleteAction *ptr;
    void CallLogMainWindow::buildInterface()
    {
        AppWindow::buildInterface();

        setTitle(utils::translate("app_calllog_title_main"));

        header->navigationIndicatorAdd((ptr = new gui::header::DeleteAction()), gui::header::BoxSelection::Right);

        navBar->setText(nav_bar::Side::Left, utils::translate(style::strings::common::call));
        navBar->setText(nav_bar::Side::Center, utils::translate(style::strings::common::open));
        navBar->setText(nav_bar::Side::Right, utils::translate(style::strings::common::back));


@@ 163,18 171,26 @@ namespace gui
    bool CallLogMainWindow::onDatabaseMessage(sys::Message *msg)
    {
        auto notification = dynamic_cast<db::NotificationMessage *>(msg);
        if (notification != nullptr) {
            if (notification->interface == db::Interface::Name::Calllog &&
                notification->type == db::Query::Type::Create) {
                rebuild();
                return true;
            }
        if (!notification) {
            return false;
        }
        return false;

        if (notification->interface != db::Interface::Name::Calllog) {
            return false;
        }

        if (notification->type != db::Query::Type::Create && notification->type != db::Query::Type::Update) {
            return false;
        }

        rebuild();
        return true;
    }

    void CallLogMainWindow::onEmptyList()
    {
        header->removeWidget(ptr);

        navBar->setActive(gui::nav_bar::Side::Left, false);
        navBar->setActive(gui::nav_bar::Side::Center, false);
        emptyLayout->setVisible(true);


@@ 188,4 204,36 @@ namespace gui
        emptyLayout->setVisible(false);
        application->refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP);
    }

    bool CallLogMainWindow::isEmpty() const
    {
        return list->isEmpty();
    }

    bool CallLogMainWindow::onInput(InputEvent const &inputEvent)
    {
        if (inputEvent.getKeyCode() != gui::KeyCode::KEY_RIGHT || !inputEvent.isKeyRelease()) {
            return AppWindow::onInput(inputEvent);
        }

        if (isEmpty()) {
            return false;
        }

        auto dialogMetadata = gui::DialogMetadata{
            utils::translate("app_calllog_delete_all_calls"),
            "delete_128px_W_G",
            utils::translate("app_calllog_delete_all_calls_confirmation"),
            "",
            [&]() -> bool {
                DBServiceAPI::GetQuery(
                    application, db::Interface::Name::Calllog, std::make_unique<db::query::calllog::DeleteAll>());
                app::manager::Controller::sendAction(application, app::manager::actions::ShowCallLog);
                return true;
            }};
        auto metaData = std::make_unique<gui::DialogMetadataMessage>(dialogMetadata);

        application->switchWindow(calllog::settings::DialogYesNoStr, std::move(metaData));
        return false;
    }
} /* namespace gui */

M module-apps/application-calllog/windows/CallLogMainWindow.hpp => module-apps/application-calllog/windows/CallLogMainWindow.hpp +3 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 18,12 18,14 @@ namespace gui
        gui::ListView *list                        = nullptr;

        gui::VBox *emptyLayout = nullptr;
        bool isEmpty() const;

      public:
        explicit CallLogMainWindow(app::ApplicationCommon *app);

        // virtual methods
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        bool onInput(InputEvent const &inputEvent) override;

        void rebuild() override;
        void buildInterface() override;

M module-db/CMakeLists.txt => module-db/CMakeLists.txt +1 -0
@@ 63,6 63,7 @@ set(SOURCES
        queries/alarm_events/QueryAlarmEventsGetInRange.cpp
        queries/alarm_events/QueryAlarmEventsRemove.cpp
        queries/alarm_events/QueryAlarmEventsToggleAll.cpp
        queries/calllog/QueryCalllogDeleteAll.cpp
        queries/calllog/QueryCalllogGet.cpp
        queries/calllog/QueryCalllogGetByContactID.cpp
        queries/calllog/QueryCalllogGetCount.cpp

M module-db/Interface/CalllogRecord.cpp => module-db/Interface/CalllogRecord.cpp +17 -0
@@ 11,6 11,7 @@
#include "queries/calllog/QueryCalllogGet.hpp"
#include "queries/calllog/QueryCalllogGetCount.hpp"
#include "queries/calllog/QueryCalllogRemove.hpp"
#include "queries/calllog/QueryCalllogDeleteAll.hpp"
#include "queries/calllog/QueryCalllogGetByContactID.hpp"

#include <cassert>


@@ 250,6 251,11 @@ bool CalllogRecordInterface::SetAllRead()
    return calllogDB->calls.SetAllRead();
}

bool CalllogRecordInterface::DeleteAll()
{
    return calllogDB->calls.DeleteAll();
}

std::unique_ptr<db::QueryResult> CalllogRecordInterface::runQuery(std::shared_ptr<db::Query> query)
{
    if (typeid(*query) == typeid(db::query::CalllogGet)) {


@@ 261,6 267,9 @@ std::unique_ptr<db::QueryResult> CalllogRecordInterface::runQuery(std::shared_pt
    else if (typeid(*query) == typeid(db::query::calllog::SetAllRead)) {
        return setAllReadQuery(query);
    }
    else if (typeid(*query) == typeid(db::query::calllog::DeleteAll)) {
        return deleteAllQuery(query);
    }
    else if (typeid(*query) == typeid(db::query::CalllogGetCount)) {
        return getCountQuery(query);
    }


@@ 310,6 319,14 @@ std::unique_ptr<db::QueryResult> CalllogRecordInterface::setAllReadQuery(std::sh
    return response;
}

std::unique_ptr<db::QueryResult> CalllogRecordInterface::deleteAllQuery(std::shared_ptr<db::Query> query)
{
    auto db_result = DeleteAll();
    auto response  = std::make_unique<db::query::calllog::DeleteAllResult>(db_result);
    response->setRequestQuery(query);
    return response;
}

std::unique_ptr<db::QueryResult> CalllogRecordInterface::getCountQuery(std::shared_ptr<db::Query> query)
{
    auto localQuery = static_cast<db::query::CalllogGetCount *>(query.get());

M module-db/Interface/CalllogRecord.hpp => module-db/Interface/CalllogRecord.hpp +2 -0
@@ 55,6 55,7 @@ class CalllogRecordInterface : public RecordInterface<CalllogRecord, CalllogReco
    uint32_t GetCount() override final;
    uint32_t GetCount(EntryState state);
    bool SetAllRead();
    bool DeleteAll();

    std::unique_ptr<std::vector<CalllogRecord>> GetLimitOffset(uint32_t offset, uint32_t limit) override final;



@@ 75,6 76,7 @@ class CalllogRecordInterface : public RecordInterface<CalllogRecord, CalllogReco

    std::unique_ptr<db::QueryResult> getQuery(std::shared_ptr<db::Query> query);
    std::unique_ptr<db::QueryResult> setAllReadQuery(std::shared_ptr<db::Query> query);
    std::unique_ptr<db::QueryResult> deleteAllQuery(std::shared_ptr<db::Query> query);
    std::unique_ptr<db::QueryResult> getCountQuery(std::shared_ptr<db::Query> query);
    std::unique_ptr<db::QueryResult> removeQuery(std::shared_ptr<db::Query> query);
    std::unique_ptr<db::QueryResult> getByContactIDQuery(std::shared_ptr<db::Query> query);

M module-db/Tables/CalllogTable.cpp => module-db/Tables/CalllogTable.cpp +6 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "CalllogTable.hpp"


@@ 226,3 226,8 @@ bool CalllogTable::SetAllRead()
{
    return db->execute("UPDATE calls SET isRead = 1;");
}

bool CalllogTable::DeleteAll()
{
    return db->execute("DELETE FROM calls;");
}

M module-db/Tables/CalllogTable.hpp => module-db/Tables/CalllogTable.hpp +2 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 75,4 75,5 @@ class CalllogTable : public Table<CalllogTableRow, CalllogTableFields>
    uint32_t count(EntryState state);
    uint32_t countByFieldId(const char *field, uint32_t id) override final;
    bool SetAllRead();
    bool DeleteAll();
};

A module-db/queries/calllog/QueryCalllogDeleteAll.cpp => module-db/queries/calllog/QueryCalllogDeleteAll.cpp +23 -0
@@ 0,0 1,23 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "QueryCalllogDeleteAll.hpp"

namespace db::query::calllog
{
    DeleteAll::DeleteAll() : Query(Query::Type::Update)
    {}

    auto DeleteAll::debugInfo() const -> std::string
    {
        return "QueryDeleteAll";
    }

    DeleteAllResult::DeleteAllResult(bool ret) : ret(ret)
    {}

    [[nodiscard]] auto DeleteAllResult::debugInfo() const -> std::string
    {
        return "DeleteAllResult";
    }
} // namespace db::query::calllog

A module-db/queries/calllog/QueryCalllogDeleteAll.hpp => module-db/queries/calllog/QueryCalllogDeleteAll.hpp +28 -0
@@ 0,0 1,28 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <Common/Query.hpp>
#include <string>

namespace db::query::calllog
{
    class DeleteAll : public Query
    {
      public:
        DeleteAll();

        [[nodiscard]] auto debugInfo() const -> std::string override;
    };

    class DeleteAllResult : public QueryResult
    {
      public:
        explicit DeleteAllResult(bool ret);
        [[nodiscard]] auto debugInfo() const -> std::string override;

        const bool ret = true;
    };

}; // namespace db::query::calllog

M module-gui/gui/widgets/CMakeLists.txt => module-gui/gui/widgets/CMakeLists.txt +2 -0
@@ 26,6 26,7 @@ target_sources( ${PROJECT_NAME}
        "${CMAKE_CURRENT_LIST_DIR}/ThreeBox.cpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/Header.cpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/IceAction.cpp"
	"${CMAKE_CURRENT_LIST_DIR}/header/DeleteAction.cpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/AddElementAction.cpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/SearchAction.cpp"
        "${CMAKE_CURRENT_LIST_DIR}/SideListView.cpp"


@@ 74,6 75,7 @@ target_sources( ${PROJECT_NAME}
        "${CMAKE_CURRENT_LIST_DIR}/StatusBar.hpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/Header.hpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/IceAction.hpp"
	"${CMAKE_CURRENT_LIST_DIR}/header/DeleteAction.hpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/AddElementAction.hpp"
        "${CMAKE_CURRENT_LIST_DIR}/header/SearchAction.hpp"
        "${CMAKE_CURRENT_LIST_DIR}/CheckBoxWithLabel.hpp"

A module-gui/gui/widgets/header/DeleteAction.cpp => module-gui/gui/widgets/header/DeleteAction.cpp +33 -0
@@ 0,0 1,33 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "DeleteAction.hpp"
#include "Style.hpp"

#include <Text.hpp>
#include <Image.hpp>
#include <i18n/i18n.hpp>

namespace gui::header
{
    DeleteAction::DeleteAction(Item *parent)
        : HBox(parent, 0, 0, style::header::navigation_indicator::w, style::header::navigation_indicator::h)
    {
        setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center));
        setEdges(RectangleEdge::None);
        setMargins(Margins(style::header::navigation_indicator::right_left_margin,
                           style::header::navigation_indicator::top_margin,
                           0,
                           0));

        auto wasteBin        = new gui::Image("delete_24px_W_G");
        wasteBin->activeItem = false;
        wasteBin->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center));
        addWidget(wasteBin);

        auto arrow        = new gui::Image("arrow_right_24px_W_G");
        arrow->activeItem = false;
        arrow->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center));
        addWidget(arrow);
    }
} // namespace gui::header

A module-gui/gui/widgets/header/DeleteAction.hpp => module-gui/gui/widgets/header/DeleteAction.hpp +14 -0
@@ 0,0 1,14 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <BoxLayout.hpp>

namespace gui::header
{
    struct DeleteAction : HBox
    {
        explicit DeleteAction(Item *parent = nullptr);
    };
} // namespace gui::header

M products/PurePhone/CMakeLists.txt => products/PurePhone/CMakeLists.txt +2 -2
@@ 143,14 143,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.7
                            0.0.8
                            ${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.7
                            0.0.8
                            ${MUDITA_CACHE_DIR}
    )
download_asset_json(json-rt1051-target

M products/PurePhone/assets/assets_common.json => products/PurePhone/assets/assets_common.json +1 -0
@@ 35,6 35,7 @@
        {"name":"release.tgz", "tarfile": "./image/assets/images/desktop-menu/menu_tools_calculator_W_G.vpi", "output": "assets/images/desktop-menu/menu_tools_calculator_W_G.vpi" },
        {"name":"release.tgz", "tarfile": "./image/assets/images/dot_12px_hard_alpha_W_M.vpi", "output": "assets/images/dot_12px_hard_alpha_W_M.vpi" },
        {"name":"release.tgz", "tarfile": "./image/assets/images/label_rectangle_W_M.vpi", "output": "assets/images/label_rectangle_W_M.vpi" },
        {"name":"release.tgz", "tarfile": "./image/assets/images/delete_24px_W_G.vpi", "output": "assets/images/delete_24px_W_G.vpi" },
        {"name":"release.tgz", "tarfile": "./image/assets/images/arrow_right_24px_W_G.vpi", "output": "assets/images/arrow_right_24px_W_G.vpi" },
        {"name":"release.tgz", "tarfile": "./image/assets/images/arrow_right_32px_W_G.vpi", "output": "assets/images/arrow_right_32px_W_G.vpi" },
        {"name":"release.tgz", "tarfile": "./image/assets/images/phonebook/phonebook_empty_grey_circle_speed_dial.vpi", "output": "assets/images/phonebook/phonebook_empty_grey_circle_speed_dial.vpi" },