From: Lukasz Wlazly Date: Tue, 11 Jun 2019 09:01:40 +0000 (+0200) Subject: Add VoicePresenter X-Git-Tag: accepted/tizen/unified/20190620.071906~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33ce17dd8c62e5720f7fafd0c9164a8b6e13bc26;p=profile%2Fmobile%2Fapps%2Fnative%2Faccessibility-setting.git Add VoicePresenter Change-Id: Ia490cdafedbc16b23d1449082cd3b8dd0202ddbd --- diff --git a/src/model/VoiceModel.cpp b/src/model/VoiceModel.cpp new file mode 100644 index 0000000..a1b4fc5 --- /dev/null +++ b/src/model/VoiceModel.cpp @@ -0,0 +1,28 @@ +#include "VoiceModel.hpp" + +VoiceModel::VoiceModel() +{ + stateHandle_ = Singleton::instance().registerAndGet("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_ENABLED", false, [this](auto val) { + this->state_ = val; + }); + + state_.attach([](auto val) { + Singleton::instance().set("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_ENABLED", val); + }); + + rateHandle_ = Singleton::instance().registerAndGet("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_RATE", 1.0, [this](auto val) { + this->rate_ = val; + }); + + rate_.attach([](auto val) { + Singleton::instance().set("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_RATE", val); + }); + + volumeHandle_ = Singleton::instance().registerAndGet("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_VOLUME", 1.0, [this](auto val) { + this->volume_ = val; + }); + + volume_.attach([](auto val) { + Singleton::instance().set("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_VOLUME", val); + }); +} \ No newline at end of file diff --git a/src/model/VoiceModel.hpp b/src/model/VoiceModel.hpp new file mode 100644 index 0000000..a218f4f --- /dev/null +++ b/src/model/VoiceModel.hpp @@ -0,0 +1,26 @@ +#ifndef VOICE_MODEL_HPP +#define VOICE_MODEL_HPP + +#include "ObservableProperty.hpp" +#include "VConf.hpp" +#include "utils.hpp" + +class VoiceModel +{ + public: + VoiceModel(); + + const utils::Range range_ = {0.1, 1.0}; + const double step_ = 0.1; + + ObservableProperty state_; + ObservableProperty rate_; + ObservableProperty volume_; + + private: + VConfInterface::CallbackHandle stateHandle_; + VConfInterface::CallbackHandle rateHandle_; + VConfInterface::CallbackHandle volumeHandle_; +}; + +#endif \ No newline at end of file diff --git a/src/presenter/UniversalSwitchSettingsPagePresenter.cpp b/src/presenter/UniversalSwitchSettingsPagePresenter.cpp index 042e2b6..3ff5d92 100644 --- a/src/presenter/UniversalSwitchSettingsPagePresenter.cpp +++ b/src/presenter/UniversalSwitchSettingsPagePresenter.cpp @@ -7,6 +7,9 @@ #include "PauseOnFirstPresenter.hpp" #include "SoundPresenter.hpp" #include "TapDurationPresenter.hpp" +#include "AutoTapPresenter.hpp" +#include "AutoMoveIntervalPresenter.hpp" +#include "VoicePresenter.hpp" UniversalSwitchSettingsPagePresenter::UniversalSwitchSettingsPagePresenter() { @@ -293,6 +296,7 @@ void UniversalSwitchSettingsPagePresenter::createFeedbackGroup() model_.feedbackVoiceState_.value() ? std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON"} : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"}, [this](auto item) { DEBUG("feedback sound widget"); + Singleton::instance().push(std::make_unique()); }, ListItem::WidgetType::toggle, [this](auto item) { diff --git a/src/presenter/VoicePresenter.cpp b/src/presenter/VoicePresenter.cpp new file mode 100644 index 0000000..62b18e7 --- /dev/null +++ b/src/presenter/VoicePresenter.cpp @@ -0,0 +1,102 @@ +#include "VoicePresenter.hpp" + +VoicePresenter::VoicePresenter() +{ + setTitle("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_VOICE"); + + groups_.emplace_back(""); + auto &items = groups_.back().items_; + + items.push_back(std::make_unique( + model_.state_.value() ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF", + std::string{}, + [this](auto item) { + this->model_.state_ = item->widgetState_.value(); + }, + ListItem::WidgetType::toggle, + std::function{}, + std::function{}, + model_.state_.value())); + model_.state_.attach([this](auto val) { + groups_[0].items_[0]->title_ = val ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF"; + }); + + items.push_back(std::make_unique( + std::string{}, + "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SET_VALUE_DESC_FEEDBACK_VOICE")); + + groups_.emplace_back("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_VOICE_SPEECH_RATE"); + auto speechRateItem = std::make_unique( + std::string{}, + std::string{}, + std::function{}, + ListItem::WidgetType::slider, + std::function{}, + [this](auto item) { + this->model_.rate_ = item->value_; + }); + speechRateItem->value_ = model_.rate_.value(); + speechRateItem->range_ = {model_.range_.begin, model_.range_.end}; + speechRateItem->step_ = model_.step_; + + groups_.back().items_.push_back(std::move(speechRateItem)); + + groups_.emplace_back("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_VOICE_SPEECH_VOLUME"); + auto &radioItems = groups_.back().items_; + + radioItems.push_back(std::make_unique( + "Match media volume", + std::string{}, + [this](auto item) { + this->model_.volume_ = 1.0; + this->updateRadioItems(); + }, + ListItem::WidgetType::radio, + std::function{}, + std::function{}, + model_.volume_.value() == 1.0)); + + radioItems.push_back(std::make_unique( + "75% of media volume", + std::string{}, + [this](auto item) { + this->model_.volume_ = 0.75; + this->updateRadioItems(); + }, + ListItem::WidgetType::radio, + std::function{}, + std::function{}, + model_.volume_.value() == 0.75)); + + radioItems.push_back(std::make_unique( + "50% of media volume", + std::string{}, + [this](auto item) { + this->model_.volume_ = 0.50; + this->updateRadioItems(); + }, + ListItem::WidgetType::radio, + std::function{}, + std::function{}, + model_.volume_.value() == 0.50)); + + radioItems.push_back(std::make_unique( + "25% of media volume", + std::string{}, + [this](auto item) { + this->model_.volume_ = 0.25; + this->updateRadioItems(); + }, + ListItem::WidgetType::radio, + std::function{}, + std::function{}, + model_.volume_.value() == 0.25)); +} + +void VoicePresenter::updateRadioItems() +{ + for (auto i = 1; i <= 4; ++i) { + auto idx = 4 - i; + groups_[2].items_[idx]->widgetState_ = model_.volume_.value() == 0.25 * i; + } +} \ No newline at end of file diff --git a/src/presenter/VoicePresenter.hpp b/src/presenter/VoicePresenter.hpp new file mode 100644 index 0000000..ad20eaa --- /dev/null +++ b/src/presenter/VoicePresenter.hpp @@ -0,0 +1,18 @@ +#ifndef VOICE_PRESENTER_HPP +#define VOICE_PRESENTER_HPP + +#include "ListPresenter.hpp" +#include "VoiceModel.hpp" + +class VoicePresenter : public ListPresenter +{ + public: + VoicePresenter(); + + private: + void updateRadioItems(); + + VoiceModel model_; +}; + +#endif \ No newline at end of file