~aleteoryx/muditaos

3a86d65b1db67e91f27f28eb1d6cdb0a97c70f38 — mkamonMdt 5 years ago 11aa4c7
[EGD-3633] Fix new message recipient

Known issues with recipient filed fixed:
- on contact, clearing there was leftover data
- on contact, one could keep adding numbers to visible name
- on contact, to delete it one had to delete each visible name char
- `select` in center button was not restored in some edge cases
- wrong recipient label
M image/assets/lang/English.json => image/assets/lang/English.json +1 -1
@@ 474,7 474,7 @@
  "app_music_player_music_empty_window_notification": "Press Music Library to choose\n a song from the library",
  "app_special_input_window": "Special characters",
  "app_emoji_input_window": "Emoji",
  "sms_add_rec_num": "Add contact",
  "sms_add_rec_num": "Add recipient or type a number",
  "sms_title_message": "New message",
  "sms_call_text": "Call ",
  "sms_resend_failed": "Send again",

M module-apps/application-messages/windows/NewMessage.cpp => module-apps/application-messages/windows/NewMessage.cpp +24 -18
@@ 7,7 7,6 @@
#include "application-messages/data/SMSdata.hpp"
#include "application-messages/data/MessagesStyle.hpp"

#include <application-phonebook/ApplicationPhonebook.hpp>
#include <application-phonebook/windows/PhonebookSearchResults.hpp>
#include <service-appmgr/Controller.hpp>
#include <service-db/DBServiceAPI.hpp>


@@ 177,6 176,7 @@ namespace gui
                bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));
                return;
            }
            bottomBar->setActive(BottomBar::Side::LEFT, false);
            bottomBar->setActive(BottomBar::Side::CENTER, false);
        }
    }


@@ 185,8 185,6 @@ namespace gui
    {
        namespace msgStyle = style::messages::newMessage;
        AppWindow::buildInterface();
        bottomBar->setText(BottomBar::Side::LEFT, utils::localize.get(style::strings::common::options));
        bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));

        setTitle(utils::localize.get("sms_title_message"));


@@ 202,19 200,14 @@ namespace gui
        recipientLabel->setFont(style::window::font::small);
        recipientLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));

        auto reciepientHbox = new gui::HBox(body, 0, 0, body->getWidth(), msgStyle::text::h);
        reciepientHbox->setAlignment(gui::Alignment::Vertical::Center);
        reciepientHbox->setEdges(gui::RectangleEdge::Bottom);
        reciepientHbox->setPenFocusWidth(style::window::default_border_focus_w);
        reciepientHbox->setPenWidth(style::window::default_border_rect_no_focus);

        recipient = new gui::Text(reciepientHbox,
                                  0,
                                  0,
                                  body->getWidth() - msgStyle::recipientImg::w,
                                  msgStyle::text::h,
                                  "",
                                  ExpandMode::None);
        auto recipientHBox = new gui::HBox(body, 0, 0, body->getWidth(), msgStyle::text::h);
        recipientHBox->setAlignment(gui::Alignment::Vertical::Center);
        recipientHBox->setEdges(gui::RectangleEdge::Bottom);
        recipientHBox->setPenFocusWidth(style::window::default_border_focus_w);
        recipientHBox->setPenWidth(style::window::default_border_rect_no_focus);

        recipient = new gui::Text(
            recipientHBox, 0, 0, body->getWidth() - msgStyle::recipientImg::w, msgStyle::text::h, "", ExpandMode::None);
        recipient->setEdges(gui::RectangleEdge::None);
        recipient->setInputMode(new InputMode({InputMode::phone}));
        recipient->setFont(style::window::font::mediumbold);


@@ 222,16 215,29 @@ namespace gui
        recipient->activatedCallback    = [=](Item &) -> bool { return selectContact(); };
        recipient->focusChangedCallback = [=](Item &) -> bool {
            updateBottomBar();
            bottomBar->setActive(BottomBar::Side::LEFT, false);
            return true;
        };
        recipient->inputCallback = [this]([[maybe_unused]] Item &, const InputEvent &inputEvent) -> bool {
            if (contact != nullptr) {
                if (inputEvent.isShortPress() && inputEvent.is(KeyCode::KEY_PND)) {
                    recipient->clear();
                    return true;
                }
                if (0 <= gui::toNumeric(inputEvent.keyCode) && gui::toNumeric(inputEvent.keyCode) <= 9) {
                    return true;
                }
            }
            return false;
        };
        recipient->setTextChangedCallback([this]([[maybe_unused]] Item &item, const UTF8 &text) {
            if (recipient->getText().empty()) {
                contact = nullptr;
                phoneNumber.clear();
            }
            updateBottomBar();
        });

        auto img        = new gui::Image(reciepientHbox, 0, 0, 0, 0, "phonebook_small");
        auto img        = new gui::Image(recipientHBox, 0, 0, 0, 0, "phonebook_small");
        img->activeItem = false;

        auto labelMessage = new Label(body, 0, 0, body->getWidth(), msgStyle::messageLabel::h);

M module-gui/gui/widgets/Text.cpp => module-gui/gui/widgets/Text.cpp +1 -0
@@ 179,6 179,7 @@ namespace gui
    void Text::clear()
    {
        buildDocument("");
        onTextChanged();
    }

    bool Text::isEmpty()