--- /dev/null
+#include "VoiceModel.hpp"
+
+VoiceModel::VoiceModel()
+{
+ stateHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_ENABLED", false, [this](auto val) {
+ this->state_ = val;
+ });
+
+ state_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_ENABLED", val);
+ });
+
+ rateHandle_ = Singleton<VConfInterface>::instance().registerAndGet<double>("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_RATE", 1.0, [this](auto val) {
+ this->rate_ = val;
+ });
+
+ rate_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_RATE", val);
+ });
+
+ volumeHandle_ = Singleton<VConfInterface>::instance().registerAndGet<double>("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_VOLUME", 1.0, [this](auto val) {
+ this->volume_ = val;
+ });
+
+ volume_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set("db/setting/accessibility/universal-switch/FEEDBACK_VOICE_SPEECH_VOLUME", val);
+ });
+}
\ No newline at end of file
--- /dev/null
+#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<ListItem>(
+ 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<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ 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<ListItem>(
+ 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<ListItem>(
+ std::string{},
+ std::string{},
+ std::function<void(ListItem * item)>{},
+ ListItem::WidgetType::slider,
+ std::function<void(ListItem * item)>{},
+ [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<ListItem>(
+ "Match media volume",
+ std::string{},
+ [this](auto item) {
+ this->model_.volume_ = 1.0;
+ this->updateRadioItems();
+ },
+ ListItem::WidgetType::radio,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.volume_.value() == 1.0));
+
+ radioItems.push_back(std::make_unique<ListItem>(
+ "75% of media volume",
+ std::string{},
+ [this](auto item) {
+ this->model_.volume_ = 0.75;
+ this->updateRadioItems();
+ },
+ ListItem::WidgetType::radio,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.volume_.value() == 0.75));
+
+ radioItems.push_back(std::make_unique<ListItem>(
+ "50% of media volume",
+ std::string{},
+ [this](auto item) {
+ this->model_.volume_ = 0.50;
+ this->updateRadioItems();
+ },
+ ListItem::WidgetType::radio,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.volume_.value() == 0.50));
+
+ radioItems.push_back(std::make_unique<ListItem>(
+ "25% of media volume",
+ std::string{},
+ [this](auto item) {
+ this->model_.volume_ = 0.25;
+ this->updateRadioItems();
+ },
+ ListItem::WidgetType::radio,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ 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