2 * Copyright 2018 Samsung Electronics Co., Ltd
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "ScreenReaderPage.hpp"
19 #include "AccessibilitySettingLog.hpp"
20 #include "Genlist.hpp"
21 #include "Singleton.hpp"
22 #include "TextToSpeech.hpp"
23 #include "setting-accessibility.h"
27 ScreenReaderPage::ScreenReaderPage()
28 : context_(Singleton<AppContext>::instance())
30 auto genlist = Widget::make<Genlist>(context_.navContext_.getNaviframe());
31 genlist->setMode(ELM_LIST_COMPRESS);
32 genlist->setStyle("dialogue");
33 genlist->clear(); // TODO check if necessary
35 screenReaderItem_ = genlist->appendItem({"type1",
36 "IDS_ST_MBODY_SCREEN_READER_HTTS",
39 auto state = item->getState();
40 Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, state);
42 auto buf = TranslatedString{"IDS_ST_MBODY_SCREEN_READER_HTTS"} + " " + TranslatedString{"IDS_ST_BODY_OFF"};
43 Singleton<TextToSpeech>::instance().play(buf.str());
46 GenlistItem::WidgetType::toggle});
48 auto onVConfValueChangeCb = [this](bool screenReaderState) {
49 screenReaderItem_->setState(screenReaderState);
50 screenReaderItem_->setDescription(screenReaderState ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF");
52 screenReaderStateHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>({VCONFKEY_SETAPPL_ACCESSIBILITY_TTS}, false, onVConfValueChangeCb);
54 genlist->appendItem({"multiline", {}, "IDS_ACCS_BODY_WHILE_SCREEN_READER_IS_ENABLED_YOUR_PHONE_WILL_PROVIDE_VOICE_FEEDBACK_FOR_EXAMPLE_SCREEN_READER_WILL_MSG"});
56 genlist->appendItem({"type1",
57 "IDS_ST_OPT_SETTINGS",
60 this->screenReaderSettingsPage_ = std::make_unique<ScreenReaderSettingsPage>();
63 context_.navContext_.getNaviframe()->pushBack("IDS_ST_MBODY_SCREEN_READER_HTTS", genlist, [this]() {
64 screenReaderStateHandle_ = {};