~aleteoryx/muditaos

ref: 6e901d066b293bc7a2a182f342151cba7615160d muditaos/module-apps/apps-common/popups/lock-popups/SimInfoWindow.cpp -rw-r--r-- 2.9 KiB
6e901d06 — Marcin Zieliński [MOS-350] Revert partially 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SimInfoWindow.hpp"
#include <locks/data/LockStyle.hpp>
#include <locks/data/LockData.hpp>
#include <i18n/i18n.hpp>

using namespace gui;

SimInfoWindow::SimInfoWindow(app::ApplicationCommon *app, const std::string &name) : WindowWithTimer(app, name)
{
    buildInterface();
}

status_bar::Configuration SimInfoWindow::configureStatusBar(status_bar::Configuration appConfiguration)
{
    appConfiguration.enable(status_bar::Indicator::NetworkAccessTechnology);
    appConfiguration.enable(status_bar::Indicator::Time);
    appConfiguration.enable(status_bar::Indicator::PhoneMode);
    appConfiguration.enable(status_bar::Indicator::Battery);
    appConfiguration.enable(status_bar::Indicator::Signal);
    appConfiguration.enable(status_bar::Indicator::SimCard);
    appConfiguration.enable(status_bar::Indicator::Bluetooth);
    appConfiguration.enable(status_bar::Indicator::AlarmClock);
    return appConfiguration;
}

void SimInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
    WindowWithTimer::onBeforeShow(mode, data);

    if (auto infoData = dynamic_cast<locks::SimLockData *>(data)) {

        switch (infoData->getSimInputTypeAction()) {
        case locks::SimInputTypeAction::UnlockWithPuk:
        case locks::SimInputTypeAction::ChangePin:
            setTitle(utils::translate("sim_change_pin"));
            infoIcon->text->setRichText(utils::translate("sim_pin_changed_successfully"));
            break;
        case locks::SimInputTypeAction::EnablePin:
            setTitle("");
            infoIcon->text->setRichText(utils::translate("sim_card_pin_enabled"));
            break;
        case locks::SimInputTypeAction::DisablePin:
            setTitle("");
            infoIcon->text->setRichText(utils::translate("sim_card_pin_disabled"));
            break;
        case locks::SimInputTypeAction::Error:
            setTitle(utils::translate("app_settings_net"));
            infoIcon->text->setRichText(utils::translate("sim_card_cant_connect"),
                                        {{"$SIM", infoData->getLock().getLockName()}});
            infoIcon->image->set("sim_128px_W_G");
            break;
        default:
            break;
        }
    }
}

void SimInfoWindow::buildInterface()
{
    AppWindow::buildInterface();

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

    infoIcon = new gui::Icon(this,
                             style::window::default_left_margin,
                             style::window::default_vertical_pos,
                             style::window::default_body_width,
                             style::window::default_body_height,
                             "success_128px_W_G",
                             utils::translate("sim_pin_changed_successfully"));
    infoIcon->setAlignment(Alignment::Horizontal::Center);
}