AutoTap page in MVP 48/207648/3
authorAdrian Wojciechowski <a.wojciecho3@partner.samsung.com>
Mon, 10 Jun 2019 14:45:00 +0000 (16:45 +0200)
committerLukasz Wlazly <l.wlazly@partner.samsung.com>
Tue, 18 Jun 2019 08:06:05 +0000 (10:06 +0200)
Change-Id: Iccbed7933a672535dd6e679e545ec09450552753

src/model/AutoTapModel.cpp [new file with mode: 0644]
src/model/AutoTapModel.hpp [new file with mode: 0644]
src/presenter/AutoTapPresenter.cpp [new file with mode: 0644]
src/presenter/AutoTapPresenter.hpp [new file with mode: 0644]
src/presenter/UniversalSwitchSettingsPagePresenter.cpp

diff --git a/src/model/AutoTapModel.cpp b/src/model/AutoTapModel.cpp
new file mode 100644 (file)
index 0000000..b901c89
--- /dev/null
@@ -0,0 +1,22 @@
+#include "AutoTapModel.hpp"
+
+#include "UniversalSwitchConstants.hpp"
+
+AutoTapModel::AutoTapModel()
+{
+       stateHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_STATE, defaultState_, [this](auto val) {
+               this->state_ = val;
+       });
+
+       state_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_STATE, val);
+       });
+
+       valueHandle_ = Singleton<VConfInterface>::instance().registerAndGet<double>(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_VALUE, defaultValue_, [this](auto val) {
+               this->value_ = val;
+       });
+
+       value_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_VALUE, val);
+       });
+}
\ No newline at end of file
diff --git a/src/model/AutoTapModel.hpp b/src/model/AutoTapModel.hpp
new file mode 100644 (file)
index 0000000..9ac0ba1
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef AUTO_TAP_MODEL_HPP_
+#define AUTO_TAP_MODEL_HPP_
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+#include "utils.hpp"
+
+class AutoTapModel
+{
+       public:
+       AutoTapModel();
+       ObservableProperty<bool> state_;
+       ObservableProperty<double> value_;
+
+       const utils::Range<double> range_ = {0.5, 5.0};
+
+       const double step_ = 0.1;
+       const double defaultValue_ = 1.0;
+
+       const bool editable_ = true;
+       const bool defaultState_ = false;
+
+       private:
+       VConfInterface::CallbackHandle stateHandle_;
+       VConfInterface::CallbackHandle valueHandle_;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/presenter/AutoTapPresenter.cpp b/src/presenter/AutoTapPresenter.cpp
new file mode 100644 (file)
index 0000000..c03727e
--- /dev/null
@@ -0,0 +1,40 @@
+#include "AutoTapPresenter.hpp"
+
+AutoTapPresenter::AutoTapPresenter()
+       : SpinnerPresenterWithToggle("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_AUTO_TAP")
+{
+       state_ = model_.state_.value();
+       state_.attach([this](auto state) {
+               model_.state_ = state;
+       });
+
+       value_ = model_.value_.value();
+       value_.attach([this](auto val) {
+               model_.value_ = val;
+       });
+}
+
+utils::Range<double> AutoTapPresenter::getRange()
+{
+       return model_.range_;
+}
+
+bool AutoTapPresenter::isEditable()
+{
+       return model_.editable_;
+}
+
+double AutoTapPresenter::getStep()
+{
+       return model_.step_;
+}
+
+std::string AutoTapPresenter::getFormat()
+{
+       return "%1.1f seconds";
+}
+
+std::string AutoTapPresenter::getLabel()
+{
+       return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_AUTO_TAP";
+}
\ No newline at end of file
diff --git a/src/presenter/AutoTapPresenter.hpp b/src/presenter/AutoTapPresenter.hpp
new file mode 100644 (file)
index 0000000..c3b36d4
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef AUTO_TAP_PRESENTER_HPP_
+#define AUTO_TAP_PRESENTER_HPP_
+
+#include "SpinnerPresenterWithToggle.hpp"
+#include "AutoTapModel.hpp"
+
+class AutoTapPresenter : public SpinnerPresenterWithToggle
+{
+       public:
+       AutoTapPresenter();
+
+       utils::Range<double> getRange() override;
+       double getStep() override;
+       bool isEditable() override;
+       std::string getLabel() override;
+       std::string getFormat() override;
+
+       private:
+       AutoTapModel model_;
+};
+#endif
\ No newline at end of file
index 19ac7d6..db13900 100644 (file)
@@ -4,6 +4,7 @@
 #include "ManageMenuOptionsPagePresenter.hpp"
 #include "PauseOnFirstPresenter.hpp"
 #include "TapDurationPresenter.hpp"
+#include "AutoTapPresenter.hpp"
 
 UniversalSwitchSettingsPagePresenter::UniversalSwitchSettingsPagePresenter()
 {
@@ -189,6 +190,7 @@ void UniversalSwitchSettingsPagePresenter::createAdditionalSettingsGroup()
                                                                         : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("auto tap widget");
+                       Singleton<AppContext>::instance().push(std::make_unique<AutoTapPresenter>());
                },
                ListItem::WidgetType::toggle,
                [this](auto item) {