ADD_DEPENDENCIES(${PROJECT_NAME} accessibility-smart-switch-accessory-popup.edj)
INSTALL(FILES ${CMAKE_BINARY_DIR}/accessibility-smart-switch-accessory-popup.edj DESTINATION ${EDJDIR})
+ADD_CUSTOM_TARGET(genlist.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/resource/images -id ${CMAKE_SOURCE_DIR}/resource/icons -sd ${CMAKE_SOURCE_DIR}/resource/sounds
+ ${CMAKE_SOURCE_DIR}/resource/genlist.edc ${CMAKE_BINARY_DIR}/genlist.edj
+ DEPENDS ${CMAKE_SOURCE_DIR}/resource/genlist.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} genlist.edj)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/genlist.edj DESTINATION ${EDJDIR})
+
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESDIR} FILES_MATCHING PATTERN "*.png")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PKGNAME}.xml DESTINATION ${TZ_SYS_RO_PACKAGES})
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ *
+ */
+collections {
+ #define POPUP_TEXT_SLIDER_BG_MIN_INC 0 42
+ #define POPUP_TEXT_SLIDER_PADDING_SIZE_INC 47 27
+ base_scale: 3;
+ group { name: "gl_custom_item";
+ styles{
+ style { name: "text_style";
+ base: "color=#FF0000FF font=Tizen:style=Regular font_size=20 text_class=list_item ellipsis=1.0";
+ tag: "br" "\n";
+ tag: "ps" "ps";
+ tag: "tab" "\t";
+ tag: "b" "+ font_weight=Bold";
+ tag: "match" "+ color=#0051B5FF";
+ }
+ }
+ parts {
+ part { name: "base";
+ type: SPACER;
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 0 120; //GENLIST_ITEM_1LINE_HEIGHT
+ }
+ }
+ part { name: "left_padding";
+ type: SPACER;
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 24 0;
+ align: 0.0 0.0;
+ rel1 { to: "base"; relative: 0.0 0.0; }
+ rel2 { to: "base"; relative: 0.0 1.0; }
+ }
+ }
+ part { name: "right_padding";
+ type: SPACER;
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 24 0;
+ align: 1.0 0.0;
+ rel1 { to: "base"; relative: 1.0 0.0; }
+ rel2 { to: "base"; relative: 1.0 1.0; }
+ }
+ }
+ part { name: "top_padding";
+ type: SPACER;
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 0 17;
+ align: 0.0 0.0;
+ rel1 { to_x: "left_padding"; to_y: "base"; relative: 1.0 0.0; }
+ rel2 { to_x: "right_padding"; to_y: "base"; relative: 0.0 0.0; }
+ }
+ }
+ part { name: "elm.text";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ min: 0 41;
+ align: 0.0 0.0;
+ rel1 { to: "top_padding"; relative: 0.0 1.0; }
+ rel2 { to: "top_padding"; relative: 1.0 1.0; }
+ }
+ }
+ part { name: "text_content_padding";
+ type: SPACER;
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 0 10;
+ align: 0.0 0.0;
+ rel1 { to: "elm.text"; relative: 0.0 1.0; }
+ rel2 { to: "elm.text"; relative: 1.0 1.0; }
+ }
+ }
+ part {
+ name: "pad_l_t";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+ max: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+ fixed: 1 1;
+ rel1 {
+ relative: 0.0 0.0;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ }
+ align: 0.0 0.0;
+ }
+ }
+ part {
+ name: "pad_r_t";
+ type: SPACER;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+ max: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+ fixed: 1 1;
+ rel1.relative: 1.0 1.0;
+ rel2.relative: 1.0 1.0;
+ align: 1.0 1.0;
+ }
+ }
+ part { name: "elm.swallow.content";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 0 1;
+ min: POPUP_TEXT_SLIDER_BG_MIN_INC;
+ rel1 {
+ relative: 1.0 0.0;
+ to_y: "pad_r_t";
+ to_x: "pad_l_t";
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ to: "pad_r_t";
+ }
+ align: 0.0 1.0;
+ }
+ }
+ part { name: "bottom_padding";
+ type: SPACER;
+ scale: 1;
+ description { state: "default" 0.0;
+ min: 0 24;
+ align: 0.5 1.0;
+ rel1 { to: "base"; relative: 0.0 1.0; }
+ rel2 { to: "base"; relative: 1.0 1.0; }
+ }
+ }
+ }
+ }
+}
context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_SOUND)->setState(item->getState());
item->setDescription(item->getState() ? "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON" : "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
},
+ {},
GenlistItem::WidgetType::toggle});
feedbackSound_->setState(context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_SOUND)->getState());
context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_VOICE)->setState(item->getState());
item->setDescription(item->getState() ? "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON" : "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"); },
+ {},
GenlistItem::WidgetType::toggle});
feedbackVoice_->setState(context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_VOICE)->getState());
}
!item->getState(),
"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
item->setDescription(str); },
+ {},
GenlistItem::WidgetType::toggle});
if (context_.usScanningProperties.getScanningProperty(Property::PAUSE_ON_FIRST_ITEM)->getState()) {
pauseOnFirst_->setState(true);
!item->getState(),
"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
item->setDescription(str); },
+ {},
GenlistItem::WidgetType::toggle});
if (context_.usScanningProperties.getScanningProperty(Property::TAP_DURATION)->getState()) {
!item->getState(),
"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
item->setDescription(str); },
+ {},
GenlistItem::WidgetType::toggle});
if (context_.usScanningProperties.getScanningProperty(Property::SINGLE_INTERACTION_INTERVAL)->getState()) {
!item->getState(),
"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
item->setDescription(str); },
+ {},
GenlistItem::WidgetType::toggle});
if (context_.usScanningProperties.getScanningProperty(Property::AUTO_TAP)->getState()) {
auto str = getValueUnitText(NULL, &moveIntervalValue, "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS",
!item->getState(), "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
item->setDescription(str); },
+ {},
GenlistItem::WidgetType::toggle});
if (context_.usScanningProperties.getScanningProperty(Property::AUTO_MOVE_INTERVAL)->getState()) {
autoMoveInterval_->setState(true);
--- /dev/null
+#include "ScreenReaderSettingsModel.hpp"
+#include "TextToSpeech.hpp"
+
+#include <vconf-internal-keys.h>
+
+ScreenReaderSettingsModel::ScreenReaderSettingsModel()
+{
+ speechRate_ = Singleton<TextToSpeech>::instance().getSpeed();
+
+ Singleton<TextToSpeech>::instance().addSpeedChangedCb([this](auto val) {
+ this->speechRate_ = val;
+ });
+
+ speechRateMin_ = Singleton<TextToSpeech>::instance().getSpeedRange().min;
+
+ speechRateMax_ = Singleton<TextToSpeech>::instance().getSpeedRange().max;
+
+ keyboardFeedbackHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_KEYBOARD_FEEDBACK}, false, [this](auto value) {
+ this->keyboardFeedback_ = value;
+ });
+
+ readUsageHintsHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_DESCRIPTION}, false, [this](auto value) {
+ this->readUsageHints_ = value;
+ });
+
+ vibrationFeedbackHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_HAPTIC}, false, [this](auto value) {
+ this->vibrationFeedback_ = value;
+ });
+
+ soundFeedbackHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_SOUND_FEEDBACK}, false, [this](auto value) {
+ this->soundFeedback_ = value;
+ });
+
+ speechRate_.attach([](auto val) {
+ Singleton<TextToSpeech>::instance().setSpeed(val);
+ });
+
+
+ keyboardFeedback_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_KEYBOARD_FEEDBACK, val);
+ });
+
+ readUsageHints_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_DESCRIPTION, val);
+ });
+
+ vibrationFeedback_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_HAPTIC, val);
+ });
+
+ soundFeedback_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_SOUND_FEEDBACK, val);
+ });
+
+}
+
+ScreenReaderSettingsModel::~ScreenReaderSettingsModel()
+{
+ Singleton<TextToSpeech>::instance().clearSpeedChangedCallbacks();
+}
+
--- /dev/null
+#ifndef SCREEN_READER_SETTINGS_MODEL_HPP
+#define SCREEN_READER_SETTINGS_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+
+class ScreenReaderSettingsModel
+{
+ public:
+ ScreenReaderSettingsModel();
+ ~ScreenReaderSettingsModel();
+
+ size_t speechRateMin_;
+ size_t speechRateMax_;
+ ObservableProperty<int> speechRate_;
+ ObservableProperty<bool> keyboardFeedback_;
+ ObservableProperty<bool> readUsageHints_;
+ ObservableProperty<bool> vibrationFeedback_;
+ ObservableProperty<bool> soundFeedback_;
+
+ private:
+ VConfInterface::CallbackHandle keyboardFeedbackHandle_;
+ VConfInterface::CallbackHandle readUsageHintsHandle_;
+ VConfInterface::CallbackHandle vibrationFeedbackHandle_;
+ VConfInterface::CallbackHandle soundFeedbackHandle_;
+};
+
+#endif
--- /dev/null
+#include "StatusBarInformationModel.hpp"
+
+#include <vconf-internal-keys.h>
+
+StatusBarInformationModel::StatusBarInformationModel()
+{
+ timeEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_TIME}, false, [this](auto value) {
+ this->timeEnabled_ = value;
+ });
+
+ dateEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_DATE}, false, [this](auto value) {
+ this->dateEnabled_ = value;
+ });
+
+ batteryEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BATTERY}, false, [this](auto value) {
+ this->batteryEnabled_ = value;
+ });
+
+ signalStrenghtEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_SIGNAL_STRENGHT}, false, [this](auto value) {
+ this->signalStrenghtEnabled_ = value;
+ });
+
+ bluetoothEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BLUETOOTH}, false, [this](auto value) {
+ this->bluetoothEnabled_ = value;
+ });
+
+ missedEventsEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_MISSED_EVENTS}, false, [this](auto value) {
+ this->missedEventsEnabled_ = value;
+ });
+
+
+ timeEnabled_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_TIME, val);
+ });
+
+ dateEnabled_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_DATE, val);
+ });
+
+ batteryEnabled_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BATTERY, val);
+ });
+
+ signalStrenghtEnabled_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_SIGNAL_STRENGHT, val);
+ });
+
+ bluetoothEnabled_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BLUETOOTH, val);
+ });
+
+ missedEventsEnabled_.attach([](auto val) {
+ Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_MISSED_EVENTS, val);
+ });
+
+}
+
--- /dev/null
+#ifndef STATUS_BAR_INFORMATION_MODEL_HPP
+#define STATUS_BAR_INFORMATION_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+
+class StatusBarInformationModel
+{
+ public:
+ StatusBarInformationModel();
+
+ ObservableProperty<bool> timeEnabled_;
+ ObservableProperty<bool> dateEnabled_;
+ ObservableProperty<bool> batteryEnabled_;
+ ObservableProperty<bool> signalStrenghtEnabled_;
+ ObservableProperty<bool> bluetoothEnabled_;
+ ObservableProperty<bool> missedEventsEnabled_;
+
+ private:
+ VConfInterface::CallbackHandle timeEnabledHandle_;
+ VConfInterface::CallbackHandle dateEnabledHandle_;
+ VConfInterface::CallbackHandle batteryEnabledHandle_;
+ VConfInterface::CallbackHandle signalStrenghtEnabledHandle_;
+ VConfInterface::CallbackHandle bluetoothEnabledHandle_;
+ VConfInterface::CallbackHandle missedEventsEnabledHandle_;
+};
+
+#endif
--- /dev/null
+#include "TextToSpeechModel.hpp"
+#include "Singleton.hpp"
+#include "TextToSpeech.hpp"
+
+TextToSpeechModel::TextToSpeechModel() {
+
+ speechRate_ = Singleton<TextToSpeech>::instance().getSpeed();
+
+ Singleton<TextToSpeech>::instance().addSpeedChangedCb([this](auto val) {
+ this->speechRate_ = val;
+ });
+
+ speechRate_.attach([](auto val) {
+ Singleton<TextToSpeech>::instance().setSpeed(val);
+ });
+
+ auto speedRange = Singleton<TextToSpeech>::instance().getSpeedRange();
+ speechRateMin_ = speedRange.min;
+ speechRateMax_ = speedRange.max;
+}
+
+TextToSpeechModel::~TextToSpeechModel() {
+
+ Singleton<TextToSpeech>::instance().clearSpeedChangedCallbacks();
+
+}
+
--- /dev/null
+#ifndef MODEL_TEXT_TO_SPEECH_MODEL_HPP
+#define MODEL_TEXT_TO_SPEECH_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+
+class TextToSpeechModel
+{
+ public:
+ TextToSpeechModel();
+ ~TextToSpeechModel();
+ ObservableProperty<int> speechRate_;
+ size_t speechRateMin_;
+ size_t speechRateMax_;
+};
+
+#endif /* MODEL_TEXT_TO_SPEECH_MODEL_HPP */
std::function<void(ListItem *item)> onItemSelection,
WidgetType type,
std::function<void(ListItem *item)> onWidgetSelection,
+ std::function<void(ListItem *item)> onWidgetChanged,
bool state,
std::string iconPath)
: title_(std::move(title)),
onItemSelection_(std::move(onItemSelection)),
widgetType_(type),
onWidgetSelection_(std::move(onWidgetSelection)),
+ onWidgetChanged_(std::move(onWidgetChanged)),
widgetState_(state),
iconPath_(std::move(iconPath))
{}
check,
toggle,
radio,
- icon
+ icon,
+ slider
};
ListItem(std::string title,
std::function<void(ListItem *item)> onItemSelection = {},
WidgetType type = WidgetType::none,
std::function<void(ListItem *item)> onWidgetSelection = {},
+ std::function<void(ListItem *item)> onWidgetChanged = {},
bool state = false,
std::string iconPath = {});
const std::function<void(ListItem *item)> onItemSelection_;
const WidgetType widgetType_ = WidgetType::none;
const std::function<void(ListItem *item)> onWidgetSelection_;
+ const std::function<void(ListItem *item)> onWidgetChanged_;
ObservableProperty<bool> widgetState_ = false;
const std::string iconPath_;
ObservableProperty<bool> enabled_ = true;
+ double value_;
+ std::pair<double, double> range_;
};
#endif
\ No newline at end of file
[this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<ScreenReaderPresenter>()); },
ListItem::WidgetType::none,
std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
model_.state_.value()));
groups_.back().items_.push_back(std::make_unique<ListItem>(
"IDS_ACCS_UNIVERSAL_SWITCH",
#include "ScreenReaderPresenter.hpp"
+#include "ScreenReaderSettingsPresenter.hpp"
#include "TextToSpeech.hpp"
},
ListItem::WidgetType::toggle,
std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
model_.state_.value()));
items.push_back(std::make_unique<ListItem>(
std::string{},
items.push_back(std::make_unique<ListItem>(
"IDS_ST_OPT_SETTINGS",
std::string{},
- [this](auto item) {
- this->screenReaderSettingsPage_ = std::make_unique<ScreenReaderSettingsPage>();
- }));
+ [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<ScreenReaderSettingsPresenter>()); }));
model_.state_.attach([this](auto state) {
auto item = groups_[0].items_[0].get();
item->widgetState_ = state;
Singleton<TextToSpeech>::instance().play(buf.str());
}
});
-}
\ No newline at end of file
+}
--- /dev/null
+#include "ScreenReaderSettingsPresenter.hpp"
+
+#include "AppContext.hpp"
+#include "StatusBarInformationPresenter.hpp"
+#include "TextToSpeechPresenter.hpp"
+#include "utils.hpp"
+
+ScreenReaderSettingsPresenter::ScreenReaderSettingsPresenter()
+ : ListPresenter("IDS_ST_OPT_SETTINGS")
+{
+ groups_.emplace_back("");
+
+ auto &items = groups_.back().items_;
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_BODY_SPEECH_RATE",
+ std::to_string(utils::rescale(model_.speechRate_.value(), {model_.speechRateMin_, model_.speechRateMax_})),
+ [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<TextToSpeechPresenter>()); } //TODO: add TextToSpeechPresenter
+ ));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ACCS_OPT_KEYBOARD_FEEDBACK_TTS",
+ "IDS_ACCS_OPT_ALWAYS_READ_OUT_KEYBOARD_INPUT_TTS",
+ [this](auto item) { this->model_.keyboardFeedback_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.keyboardFeedback_.value()));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ACCS_MBODY_READ_OUT_USAGE_HINTS_ABB",
+ std::string{},
+ [this](auto item) { this->model_.readUsageHints_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.readUsageHints_.value()));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ACCS_MBODY_VIBRATION_FEEDBACK",
+ std::string{},
+ [this](auto item) { this->model_.vibrationFeedback_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.vibrationFeedback_.value()));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ACCS_MBODY_SOUND_FEEDBACK",
+ std::string{},
+ [this](auto item) { this->model_.soundFeedback_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.soundFeedback_.value()));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ACCS_TMBODY_STATUS_BAR_INFORMATION",
+ std::string{},
+ [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<StatusBarInformationPresenter>()); } //TODO: add StatusBarInformationPresenter
+ ));
+
+ items.push_back(std::make_unique<ListItem>(
+ std::string{},
+ "IDS_ACCS_SBODY_SELECT_WHICH_INFORMATION_FROM_INDICATORS_SHOWN_ON_THE_STATUS_BAR_WILL_BE_READ_OUT_WHEN_YOU_TRIPLE_"
+ "TAP_THE_SCREEN_WITH_TWO_FINGERS_MSG"));
+
+ model_.speechRate_.attach([this](auto value) {
+ auto item = groups_[0].items_[0].get();
+ item->description_ = std::to_string(utils::rescale(value, {this->model_.speechRateMin_, this->model_.speechRateMax_}));
+ });
+
+ model_.keyboardFeedback_.attach([this](auto state) {
+ auto item = groups_[0].items_[1].get();
+ item->widgetState_ = state;
+ });
+
+ model_.readUsageHints_.attach([this](auto state) {
+ auto item = groups_[0].items_[2].get();
+ item->widgetState_ = state;
+ });
+
+ model_.vibrationFeedback_.attach([this](auto state) {
+ auto item = groups_[0].items_[3].get();
+ item->widgetState_ = state;
+ });
+
+ model_.soundFeedback_.attach([this](auto state) {
+ auto item = groups_[0].items_[4].get();
+ item->widgetState_ = state;
+ });
+}
--- /dev/null
+#ifndef SCREEN_READER_SETTINGS_PRESENTER_HPP
+#define SCREEN_READER_SETTINGS_PRESENTER_HPP
+
+#include "ListPresenter.hpp"
+#include "ScreenReaderSettingsModel.hpp"
+
+class ScreenReaderSettingsPresenter : public ListPresenter
+{
+ public:
+ ScreenReaderSettingsPresenter();
+
+ private:
+ ScreenReaderSettingsModel model_;
+};
+
+#endif
--- /dev/null
+#include "StatusBarInformationPresenter.hpp"
+
+StatusBarInformationPresenter::StatusBarInformationPresenter()
+:ListPresenter("IDS_ACCS_TMBODY_STATUS_BAR_INFORMATION")
+{
+ groups_.emplace_back("");
+
+ auto &items = groups_.back().items_;
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_HEADER_TIME",
+ std::string{},
+ [this](auto item) { this->model_.timeEnabled_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.timeEnabled_.value()
+ ));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_BODY_DATE",
+ std::string{},
+ [this](auto item) { this->model_.dateEnabled_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.dateEnabled_.value()
+ ));
+
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_BODY_BATTERY",
+ std::string{},
+ [this](auto item) { this->model_.batteryEnabled_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.batteryEnabled_.value()
+ ));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_BODY_SIGNAL_STRENGTH",
+ std::string{},
+ [this](auto item) { this->model_.signalStrenghtEnabled_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.signalStrenghtEnabled_.value()
+ ));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_BODY_BLUETOOTH",
+ std::string{},
+ [this](auto item) { this->model_.bluetoothEnabled_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.bluetoothEnabled_.value()
+ ));
+
+ items.push_back(std::make_unique<ListItem>(
+ "IDS_ST_BODY_MISSED_EVENTS",
+ std::string{},
+ [this](auto item) { this->model_.missedEventsEnabled_ = item->widgetState_.value(); },
+ ListItem::WidgetType::toggle,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ model_.missedEventsEnabled_.value()
+ ));
+
+
+ model_.timeEnabled_.attach([this](auto state) {
+ auto item = groups_[0].items_[0].get();
+ item->widgetState_ = state;
+ });
+
+ model_.dateEnabled_.attach([this](auto state) {
+ auto item = groups_[0].items_[1].get();
+ item->widgetState_ = state;
+ });
+
+ model_.batteryEnabled_.attach([this](auto state) {
+ auto item = groups_[0].items_[2].get();
+ item->widgetState_ = state;
+ });
+
+ model_.signalStrenghtEnabled_.attach([this](auto state) {
+ auto item = groups_[0].items_[3].get();
+ item->widgetState_ = state;
+ });
+
+ model_.bluetoothEnabled_.attach([this](auto state) {
+ auto item = groups_[0].items_[4].get();
+ item->widgetState_ = state;
+ });
+
+ model_.missedEventsEnabled_.attach([this](auto state) {
+ auto item = groups_[0].items_[5].get();
+ item->widgetState_ = state;
+ });
+}
--- /dev/null
+#ifndef STATUS_BAR_INFORMATION_PRESENTER_HPP
+#define STATUS_BAR_INFORMATION_PRESENTER_HPP
+
+#include "ListPresenter.hpp"
+#include "StatusBarInformationModel.hpp"
+
+class StatusBarInformationPresenter : public ListPresenter
+{
+ public:
+ StatusBarInformationPresenter();
+
+ private:
+ StatusBarInformationModel model_;
+
+};
+
+#endif
--- /dev/null
+#include "TextToSpeechPresenter.hpp"
+
+#include "utils.hpp"
+
+TextToSpeechPresenter::TextToSpeechPresenter()
+ : ListPresenter("IDS_ST_BODY_SPEECH_RATE")
+{
+ groups_.emplace_back("");
+
+ auto &items = groups_.back().items_;
+ 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_.speechRate_ = utils::rescale(static_cast<size_t>(item->value_), {0, 100}, {this->model_.speechRateMin_, this->model_.speechRateMax_});
+ });
+ speechRateItem->value_ = utils::rescale(model_.speechRate_.value(), {this->model_.speechRateMin_, this->model_.speechRateMax_});
+ speechRateItem->range_ = {0, 100};
+
+ items.push_back(std::move(speechRateItem));
+
+ model_.speechRate_.attach([this](auto value) {
+ auto &item = groups_[0].items_[0];
+ item->value_ = utils::rescale(value, {this->model_.speechRateMin_, this->model_.speechRateMax_});
+ });
+}
--- /dev/null
+#ifndef TEXT_TO_SPEECH_PRESENTER_HPP
+#define TEXT_TO_SPEECH_PRESENTER_HPP
+
+#include "ListPresenter.hpp"
+#include "TextToSpeechModel.hpp"
+
+class TextToSpeechPresenter : public ListPresenter
+{
+ public:
+ TextToSpeechPresenter();
+
+ private:
+ TextToSpeechModel model_;
+
+};
+
+#endif
for (auto it : self->speedChangedCallbacks_)
if (it)
it(speed);
-}
\ No newline at end of file
+}
#include "Check.hpp"
#include "Genlist.hpp"
#include "Icon.hpp"
+#include "Label.hpp"
+#include "Layout.hpp"
#include "Radio.hpp"
+#include "Slider.hpp"
+
+#include <app.h>
GenlistItem::GenlistItem(std::string style, TranslatedString text, TranslatedString desc, Type type)
: style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), type_(type)
-{
-}
+{}
GenlistItem::GenlistItem(
std::string style,
std::function<void(GenlistItem *)> onItemSelection,
Type type)
: style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), type_(type)
-{
-}
+{}
GenlistItem::GenlistItem(std::string style,
TranslatedString text,
std::function<void(GenlistItem *)> onItemSelection,
WidgetType type)
: style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), widgetType_(type)
-{
-}
+{}
GenlistItem::GenlistItem(std::string style,
TranslatedString text,
std::string iconPath,
WidgetType type)
: style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), iconPath_(std::move(iconPath)), widgetType_(type)
-{
-}
+{}
GenlistItem::GenlistItem(std::string style,
TranslatedString text,
TranslatedString desc,
std::function<void(GenlistItem *)> onItemSelection,
std::function<void(GenlistItem *)> onContentSelection,
+ std::function<void(GenlistItem *)> onContentValueChanged,
WidgetType type)
- : style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), onContentSelection_(std::move(onContentSelection)), widgetType_(type)
-{
-}
+ : style_(std::move(style)),
+ text_(std::move(text)),
+ description_(std::move(desc)),
+ onItemSelection_(std::move(onItemSelection)),
+ onContentSelection_(std::move(onContentSelection)),
+ onContentValueChanged_(std::move(onContentValueChanged)),
+ widgetType_(type)
+{}
void GenlistItem::setText(const TranslatedString &text)
{
return fromRawItem(raw);
}
+double GenlistItem::getValue()
+{
+ return value_;
+}
+
+void GenlistItem::setValue(double val)
+{
+ value_ = val;
+}
+
+void GenlistItem::setRange(std::pair<double, double> range)
+{
+ range_ = std::move(range);
+}
+
void GenlistItem::setId(size_t id)
{
id_ = id;
char *GenlistItem::textRealizator(void *data, Evas_Object *obj, const char *part)
{
auto self = static_cast<GenlistItem *>(data);
+ if (self->widgetType_ == WidgetType::slider)
+ return nullptr;
+
using namespace std::string_literals;
if (part == "elm.text"s && !self->text_.empty())
case WidgetType::radio:
return self->realizeRadio(part);
+ case WidgetType::slider:
+ return self->realizeSlider(part);
+
default:
break;
}
return radio->getObject();
}
+Evas_Object *GenlistItem::realizeSlider(const std::string &part)
+{
+ auto layout = Widget::make<Layout>(genlist_, "edje/genlist.edj", "gl_custom_item");
+ auto label = Widget::make<Label>(genlist_, text_);
+ layout->setPartContent("elm.text", label);
+
+ auto slider = Widget::make<Slider>(layout);
+ slider->showIndicator(true);
+ slider->setWeightHint(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ slider->setAlignHint(EVAS_HINT_FILL, EVAS_HINT_FILL);
+ slider->setIndicatorFormat("%1.0f");
+ slider->setRange(range_.first, range_.second);
+ slider->setValue(value_);
+ layout->setPartContent("elm.swallow.content", slider);
+
+ slider->setEvasSmartCallback("delay,changed", [=]() {
+ value_ = slider->getValue();
+ if (onContentValueChanged_) {
+ onContentValueChanged_(this);
+ }
+ });
+
+ return layout->getObject();
+}
+
void GenlistItem::onItemSelection(void *data, Evas_Object *obj, void *event_info)
{
auto self = static_cast<GenlistItem *>(data);
if (self->onItemSelection_)
self->onItemSelection_(self);
elm_genlist_item_selected_set(self->objItem_, EINA_FALSE);
-}
\ No newline at end of file
+}
check,
toggle,
radio,
- icon
+ icon,
+ slider
};
GenlistItem(std::string style, TranslatedString text, TranslatedString desc = {}, Type type = Type::group);
TranslatedString text,
TranslatedString desc,
std::function<void(GenlistItem *)> onItemSelection,
- std::function<void(GenlistItem *)> onWidgetSelection,
+ std::function<void(GenlistItem *)> onContentSelection,
+ std::function<void(GenlistItem *)> onContentValueChanged,
WidgetType type);
void setText(const TranslatedString &text);
void enable();
GenlistItem *next();
GenlistItem *prev();
+ double getValue();
+ void setValue(double val);
+ void setRange(std::pair<double, double> range);
// TODO: current implementation does not take advantage from radio groups.
// When legacy solution for adding genlist items is completely removed
Evas_Object *realizeCheck(const std::string &part);
Evas_Object *realizeIcon(const std::string &part);
Evas_Object *realizeRadio(const std::string &part);
+ Evas_Object *realizeSlider(const std::string &part);
static char *textRealizator(void *data, Evas_Object *obj, const char *part);
static Evas_Object *contentRealizator(void *data, Evas_Object *obj, const char *part);
TranslatedString description_;
std::function<void(GenlistItem *)> onItemSelection_;
std::function<void(GenlistItem *)> onContentSelection_;
+ std::function<void(GenlistItem *)> onContentValueChanged_;
Genlist *genlist_ = nullptr;
Eina_Bool state_ = EINA_FALSE;
std::string iconPath_;
Type type_ = Type::regular;
WidgetType widgetType_ = WidgetType::none;
size_t id_ = 0;
+ double value_ = 0.0;
+ std::pair<double, double> range_;
};
-#endif
\ No newline at end of file
+#endif
#include "Elementary.h"
-#include <memory>
-
using SettingCallback = void (*)(void *, Evas_Object *, void *);
namespace utils
elm_genlist_item_class_free(it);
}
};
+
+ struct Range
+ {
+ size_t begin;
+ size_t end;
+ };
+
+ inline size_t rescale(size_t value, Range source, Range target = {0, 100})
+ {
+ auto denominator = source.end - source.begin;
+ auto rescaledValue = target.begin;
+ if (denominator != 0)
+ rescaledValue += (value - source.begin) * target.end / denominator;
+
+ return rescaledValue;
+ }
} // namespace utils
#endif
search->second->onWidgetSelection_(search->second);
};
+ auto wrappedOnWidgetChanged = [this](GenlistItem *item) {
+ auto search = itemsMapping_.find(item);
+ ASSERT(search != itemsMapping_.end(), "Item not mapped");
+ search->second->widgetState_ = item->getState();
+ search->second->value_ = item->getValue();
+ if (search->second->onWidgetChanged_) {
+ search->second->onWidgetChanged_(search->second);
+ }
+ };
+
for (const auto &g : listPresenter_->getListGroups()) {
GenlistItem *groupItem = nullptr;
if (!g.name_.empty())
for (const auto &it : g.items_) {
auto type = translateType(it->widgetType_);
auto style = it->description_.value().empty() ? "type1" : "multiline";
+ if (it->widgetType_ == ListItem::WidgetType::slider)
+ style = "full";
auto genlistItem = genlist_->appendItem({style,
it->title_.value(),
it->description_.value(),
it->onItemSelection_ ? wrappedOnItemSelection : std::function<void(GenlistItem *)>{},
it->onWidgetSelection_ ? wrappedOnWidgetSelection : std::function<void(GenlistItem *)>{},
+ it->onWidgetChanged_ ? wrappedOnWidgetChanged : std::function<void(GenlistItem *)>{},
type},
groupItem);
if (!it->enabled_.value())
genlistItem->disable();
+ genlistItem->setValue(it->value_);
+ genlistItem->setRange(std::move(it->range_));
+
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); });
case ListItem::WidgetType::icon:
return GenlistItem::WidgetType::icon;
+
+ case ListItem::WidgetType::slider:
+ return GenlistItem::WidgetType::slider;
}
ERROR("Invalid type");
return {};