+++ /dev/null
-/*
- * Copyright 2018 Samsung Electronics Co., Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ScreenReaderPage.hpp"
-
-#include "AccessibilitySettingLog.hpp"
-#include "Genlist.hpp"
-#include "Singleton.hpp"
-#include "TextToSpeech.hpp"
-#include "setting-accessibility.h"
-
-#include <app.h>
-
-ScreenReaderPage::ScreenReaderPage()
- : context_(Singleton<AppContext>::instance())
-{
- auto genlist = Widget::make<Genlist>(context_.navContext_.getNaviframe());
- genlist->setMode(ELM_LIST_COMPRESS);
- genlist->setStyle("dialogue");
- genlist->clear(); // TODO check if necessary
-
- screenReaderItem_ = genlist->appendItem({"type1",
- "IDS_ST_MBODY_SCREEN_READER_HTTS",
- {},
- [this](auto item) {
- auto state = item->getState();
- Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, state);
- if (!state) {
- auto buf = TranslatedString{"IDS_ST_MBODY_SCREEN_READER_HTTS"} + " " + TranslatedString{"IDS_ST_BODY_OFF"};
- Singleton<TextToSpeech>::instance().play(buf.str());
- }
- },
- GenlistItem::WidgetType::toggle});
-
- auto onVConfValueChangeCb = [this](bool screenReaderState) {
- screenReaderItem_->setState(screenReaderState);
- screenReaderItem_->setDescription(screenReaderState ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF");
- };
- screenReaderStateHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>({VCONFKEY_SETAPPL_ACCESSIBILITY_TTS}, false, onVConfValueChangeCb);
-
- genlist->appendItem({"multiline", {}, "IDS_ACCS_BODY_WHILE_SCREEN_READER_IS_ENABLED_YOUR_PHONE_WILL_PROVIDE_VOICE_FEEDBACK_FOR_EXAMPLE_SCREEN_READER_WILL_MSG"});
-
- genlist->appendItem({"type1",
- "IDS_ST_OPT_SETTINGS",
- {},
- [this](auto item) {
- this->screenReaderSettingsPage_ = std::make_unique<ScreenReaderSettingsPage>();
- }});
-
- context_.navContext_.getNaviframe()->pushBack("IDS_ST_MBODY_SCREEN_READER_HTTS", genlist, [this]() {
- screenReaderStateHandle_ = {};
- });
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2018 Samsung Electronics Co., Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SCREEN_READER_PAGE_HPP
-#define SCREEN_READER_PAGE_HPP
-
-#include "AppContext.hpp"
-#include "GenlistItem.hpp"
-#include "ScreenReaderSettingsPage.hpp"
-#include "VConf.hpp"
-
-#include <Elementary.h>
-#include <vconf.h>
-
-/**
- * View allowing to turn on/off Screen Reader feature and to start configuration of its options
- *
- * @param ad global context of application
- *
- * TODO:
- * replace classical callbacks with lambda expressions
- */
-class ScreenReaderPage
-{
- public:
- ScreenReaderPage();
-
- private:
- AppContext &context_;
- std::unique_ptr<ScreenReaderSettingsPage> screenReaderSettingsPage_;
- GenlistItem *screenReaderItem_ = nullptr;
- VConfInterface::CallbackHandle screenReaderStateHandle_;
-};
-
-#endif
--- /dev/null
+#include "ScreenReaderModel.hpp"
+
+#define VCONFKEY_ACCESSIBILITY_TTS "db/setting/accessibility/tts"
+
+ScreenReaderModel::ScreenReaderModel()
+{
+ screenReaderStateHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_ACCESSIBILITY_TTS}, false, [this](auto state) {
+ this->state_ = state;
+ });
+
+ state_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_ACCESSIBILITY_TTS, val);
+ });
+}
\ No newline at end of file
--- /dev/null
+#ifndef SCREEN_READER_MODEL_HPP
+#define SCREEN_READER_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+
+class ScreenReaderModel
+{
+ public:
+ ScreenReaderModel();
+ ObservableProperty<bool> state_;
+
+ private:
+ VConfInterface::CallbackHandle screenReaderStateHandle_;
+};
+
+#endif
\ No newline at end of file
#include "MainPagePresenter.hpp"
+#include "ScreenReaderPresenter.hpp"
+
#include <app.h>
MainPagePresenter::MainPagePresenter()
groups_.emplace_back("IDS_ST_HEADER_VISION");
groups_.back().items_.push_back(std::make_unique<ListItem>(
"IDS_ST_MBODY_SCREEN_READER_HTTS",
- "IDS_ST_BODY_OFF",
- [this](auto item) { screenReaderPage_ = std::make_unique<ScreenReaderPage>(); }));
+ model_.state_.value() ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF",
+ [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<ScreenReaderPresenter>()); },
+ ListItem::WidgetType::none,
+ std::function<void(ListItem * item)>{},
+ model_.state_.value()));
groups_.back().items_.push_back(std::make_unique<ListItem>(
"IDS_ACCS_UNIVERSAL_SWITCH",
"IDS_ACCS_UNIVERSAL_SWITCH_HINT",
screenReaderStateHandle_ = {};
ui_app_exit();
};
+ model_.state_.attach([this](auto state) {
+ auto item = groups_[0].items_[0]->description_ = state ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF";
+ });
}
\ No newline at end of file
#include "AccessibilityLauncherPagePresenter.hpp"
#include "ListPresenter.hpp"
-#include "ScreenReaderPage.hpp"
+#include "ScreenReaderModel.hpp"
#include "UniversalSwitchPage.hpp"
#include "VConf.hpp"
MainPagePresenter();
private:
- std::unique_ptr<ScreenReaderPage> screenReaderPage_;
std::unique_ptr<UniversalSwitchPage> universalSwitchPage_;
std::unique_ptr<AccessibilityLauncherPagePresenter> accessibilityLauncherPage_;
VConfInterface::CallbackHandle screenReaderStateHandle_;
+ ScreenReaderModel model_;
};
#endif
\ No newline at end of file
--- /dev/null
+#include "ScreenReaderPresenter.hpp"
+
+#include "TextToSpeech.hpp"
+
+ScreenReaderPresenter::ScreenReaderPresenter()
+{
+ groups_.emplace_back("");
+
+ auto &items = groups_.back().items_;
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_MBODY_SCREEN_READER_HTTS",
+ model_.state_.value() ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF",
+ [this](auto item) {
+ this->model_.state_ = item->widgetState_.value();
+ },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ model_.state_.value()));
+ items.push_back(std::make_unique<ListItem>(
+ std::string{},
+ "IDS_ACCS_BODY_WHILE_SCREEN_READER_IS_ENABLED_YOUR_PHONE_WILL_PROVIDE_VOICE_FEEDBACK_FOR_EXAMPLE_SCREEN_READER_WILL_MSG"));
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_OPT_SETTINGS",
+ std::string{},
+ [this](auto item) {
+ this->screenReaderSettingsPage_ = std::make_unique<ScreenReaderSettingsPage>();
+ }));
+ model_.state_.attach([this](auto state) {
+ auto item = groups_[0].items_[0].get();
+ item->widgetState_ = state;
+ item->description_ = state ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF";
+ if (!state) {
+ auto buf = TranslatedString{"IDS_ST_MBODY_SCREEN_READER_HTTS"} + " " + TranslatedString{"IDS_ST_BODY_OFF"};
+ Singleton<TextToSpeech>::instance().play(buf.str());
+ }
+ });
+}
\ No newline at end of file
--- /dev/null
+#ifndef SCREEN_READER_PRESENTER_HPP
+#define SCREEN_READER_PRESENTER_HPP
+
+#include "ListPresenter.hpp"
+#include "ScreenReaderModel.hpp"
+#include "ScreenReaderSettingsPage.hpp"
+
+#include <vector>
+
+class ScreenReaderPresenter : public ListPresenter
+{
+ public:
+ ScreenReaderPresenter();
+
+ private:
+ ScreenReaderModel model_;
+ std::unique_ptr<ScreenReaderSettingsPage> screenReaderSettingsPage_;
+};
+
+#endif
\ No newline at end of file
itemsMapping_.emplace(genlistItem, it.get());
it->title_.attach([this, gi = genlistItem](auto val) { gi->setText(val); });
it->description_.attach([this, gi = genlistItem](auto val) { gi->setDescription(val); });
+ genlistItem->setState(it->widgetState_.value());
it->widgetState_.attach([this, gi = genlistItem](auto val) { gi->setState(val); });
it->enabled_.attach([this, gi = genlistItem](auto val) {
if (val)