~aleteoryx/muditaos

12386846f573c57880caa544f8e597764351b0b1 — Pawel Olejniczak 5 years ago 5da3145
[EGD-2519] Fix keyboard mode in the search windows

Keyboard mode was not displayed in the search windows.
Now its fixed, both in Phonebook and Messages search.
Additionaly code of the Phonebook Search window is cleaned up.
M changelog.md => changelog.md +3 -2
@@ 7,14 7,14 @@
* VoLTE ON/OFF switch in Settings Network window
* Add PLL2 clock switching
* Support for asynchronous callbacks on application side.
* APN settings window - empty
* APN settings window - empty.

### Changed

* Input keyboard language files parser from KBD to JSON.
* Input language files are now loaded based on files in "profiles" folder.
* Minimum CPU frequency is now 132 MHz
* Icon widget now accepts rich text
* Icon widget now accepts rich text.

### Fixed



@@ 22,6 22,7 @@
* Fix newly added contact recognized as a duplicate of temporary contact.
* Fix default borderCallback navigation in GridLayout.
* Fix crash on enter Settings -> Information.
* Fix keyboard mode in the search windows.

## [0.52.1 2020-12-23]


M module-apps/application-messages/windows/SearchStart.cpp => module-apps/application-messages/windows/SearchStart.cpp +5 -0
@@ 22,6 22,11 @@ namespace gui
        body->setBoundingBox(bodySize());
        addWidget(body);
        auto text = inputBox(this, utils::localize.get("common_search_uc"), "search");
        text->setInputMode(new InputMode(
            {InputMode::ABC, InputMode::abc, InputMode::digit},
            [=](const UTF8 &Text) { application->getCurrentWindow()->bottomBarTemporaryMode(Text); },
            [=]() { application->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); },
            [=]() { application->getCurrentWindow()->selectSpecialCharacter(); }));

        inputCallback = [=](Item &, const InputEvent &inputEvent) -> bool {
            auto app = dynamic_cast<app::ApplicationMessages *>(application);

M module-apps/application-phonebook/windows/PhonebookSearch.cpp => module-apps/application-phonebook/windows/PhonebookSearch.cpp +33 -38
@@ 3,10 3,9 @@

#include "PhonebookSearch.hpp"
#include "application-phonebook/ApplicationPhonebook.hpp"
#include "application-phonebook/data/PhonebookItemData.hpp"
#include "widgets/InputBox.hpp"

#include <Utils.hpp>

namespace gui
{
    PhonebookSearch::PhonebookSearch(app::Application *app) : AppWindow(app, gui::window::name::search)


@@ 22,6 21,12 @@ namespace gui
        setTitle(utils::localize.get("app_phonebook_title_main"));

        inputField = inputBox(this, utils::localize.get("common_search_uc"), "search");
        inputField->setInputMode(new InputMode(
            {InputMode::ABC, InputMode::abc, InputMode::digit},
            [=](const UTF8 &Text) { application->getCurrentWindow()->bottomBarTemporaryMode(Text); },
            [=]() { application->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); },
            [=]() { application->getCurrentWindow()->selectSpecialCharacter(); }));

        bottomBar->setActive(BottomBar::Side::LEFT, false);
        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);


@@ 32,60 37,50 @@ namespace gui
        setFocusItem(inputField);
    }

    void PhonebookSearch::rebuild()
    {}

    void PhonebookSearch::destroyInterface()
    {
        AppWindow::destroyInterface();
    }

    void PhonebookSearch::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        inputField->setText("");
        setFocusItem(inputField);
    }

    bool PhonebookSearch::handleSwitchData(SwitchData *data)
    auto PhonebookSearch::handleSwitchData(SwitchData *data) -> bool
    {
        if (data == nullptr) {
            LOG_ERROR("Received null pointer");
            return false;
        }

        PhonebookSearchQuery *item = dynamic_cast<PhonebookSearchQuery *>(data);
        auto item = dynamic_cast<PhonebookSearchQuery *>(data);
        assert(item != nullptr);
        inputField->setText(item->getQuery());

        return true;
    }

    bool PhonebookSearch::onInput(const InputEvent &inputEvent)
    void PhonebookSearch::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        inputField->clear();
        setFocusItem(inputField);
    }

    auto PhonebookSearch::onInput(const InputEvent &inputEvent) -> bool
    {
        bool ret = AppWindow::onInput(inputEvent);
        if (ret) {
            return ret;
        if (AppWindow::onInput(inputEvent)) {
            return true;
        }

        if ((inputEvent.state != InputEvent::State::keyReleasedShort) &&
            ((inputEvent.state != InputEvent::State::keyReleasedLong))) {
        if (!inputEvent.isShortPress()) {
            return false;
        }
        if (!inputEvent.is(gui::KeyCode::KEY_ENTER)) {
            return false;
        }

        if (inputEvent.keyCode == KeyCode::KEY_ENTER) {
            std::string searchFilter = utils::trim(inputField->getText());

            if (searchFilter.size() > 0) {
                auto app = dynamic_cast<app::ApplicationPhonebook *>(application);
                if (app == nullptr) {
                    LOG_ERROR("Failed to get phonebook application.");
                    return false;
                }
        std::string searchFilter = utils::trim(inputField->getText());
        if (searchFilter.empty()) {
            return false;
        }

                app->onSearchRequest(searchFilter);
                return true;
            }
        auto app = dynamic_cast<app::ApplicationPhonebook *>(application);
        if (app == nullptr) {
            LOG_ERROR("Failed to get phonebook application.");
            return false;
        }

        return ret;
        app->onSearchRequest(searchFilter);
        return true;
    }
} // namespace gui

M module-apps/application-phonebook/windows/PhonebookSearch.hpp => module-apps/application-phonebook/windows/PhonebookSearch.hpp +7 -13
@@ 3,11 3,8 @@

#pragma once

#include "application-phonebook/data/PhonebookItemData.hpp"
#include "application-phonebook/models/PhonebookModel.hpp"
#include "application-phonebook/widgets/PhonebookListView.hpp"

#include <AppWindow.hpp>
#include <ContactRecord.hpp>
#include <Text.hpp>

namespace gui


@@ 15,19 12,16 @@ namespace gui
    class PhonebookSearch : public AppWindow
    {
      public:
        PhonebookSearch(app::Application *app);
        ~PhonebookSearch() override = default;
        explicit PhonebookSearch(app::Application *app);

        bool onInput(const InputEvent &inputEvent) override;
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        bool handleSwitchData(SwitchData *data) override;
        void rebuild() override;
      private:
        void buildInterface() override;
        void destroyInterface() override;
        auto handleSwitchData(SwitchData *data) -> bool override;
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        auto onInput(const InputEvent &inputEvent) -> bool override;

      private:
        Text *inputField                       = nullptr;
        std::shared_ptr<ContactRecord> contact = nullptr;
        Text *inputField                       = nullptr;
    };

} /* namespace gui */