#include "presenters/KeypadPage.h"
#include "view/VolumeControl.h"
+#include "presenters/AtspiHighlightHelper.h"
+
#include "resources.h"
#include "common.h"
unregisterCallbacks();
}
+ Result KeypadPage::doPrepare(NaviItem &item)
+ {
+ FAIL_RETURN(createWidget(), "createWidget() failed!");
+
+ FAIL_RETURN(createEntry(), "createEntry() failed!");
+
+ FAIL_RETURN(createButtons(), "createButtons() failed!");
+
+ FAIL_RETURN(createVolumeControl(), "createVolumeControl() failed!");
+
+ registerCallbacks();
+
+ updateVolume(m_sm->getVolume());
+
+ FAIL_RETURN(createAtspiHighlightHelper(),
+ "createAtspiHighlightHelper() failed!");
+
+ item = getNaviframe().push(*m_widget);
+ if (!item) {
+ LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+ }
+
+ return RES_OK;
+ }
+
void KeypadPage::onBtnPressed(Widget &widget, void *eventInfo)
{
- impl::ButtonInfo *btn =
+ impl::ButtonInfo *info =
static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
- ILOG("button pressed: %c", *(btn->str));
+ DLOG("Button pressed [%c]", *(info->str));
- if (btn->type == impl::OperationType::DTMF) {
- elm_entry_entry_append(*m_entry, btn->str);
+ if (info->type == impl::OperationType::DTMF) {
+ elm_entry_entry_append(*m_entry, info->str);
elm_entry_cursor_end_set(*m_entry);
- startDtmf(*(btn->str));
+ startDtmf(*(info->str));
}
}
void KeypadPage::onBtnUnpressed(Widget &widget, void *eventInfo)
{
- impl::ButtonInfo *btn =
+ impl::ButtonInfo *info =
static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
- ILOG("button unpressed: %c", *(btn->str));
+ DLOG("Button unpressed [%c]", *(info->str));
stopDtmf();
}
void KeypadPage::onBtnClicked(Widget &widget, void *eventInfo)
{
- impl::ButtonInfo *btn =
+ impl::ButtonInfo *info =
static_cast<impl::ButtonInfo*>(widget.getData(impl::BTN_DATA_KEY));
- if(btn->type == impl::OperationType::VOLUME) {
- ILOG("button clicked: volume");
+ if(info->type == impl::OperationType::VOLUME) {
+ DLOG("Button clicked [volume]");
show(*m_vc);
startVCTimer();
- }
- }
-
- Result KeypadPage::doPrepare(NaviItem &item)
- {
- FAIL_RETURN(createWidget(), "createWidget() failed!");
-
- FAIL_RETURN(createEntry(), "createEntry() failed!");
-
- FAIL_RETURN(createButtons(), "createButtons() failed!");
-
- FAIL_RETURN(createVolumeControl(), "createVolumeControl() failed!");
- registerCallbacks();
-
- updateVolume(m_sm->getVolume());
-
- item = getNaviframe().push(*m_widget);
- if (!item) {
- LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+ elm_atspi_component_highlight_grab(*m_vc);
}
-
- return RES_OK;
}
Result KeypadPage::createWidget()
LOG_RETURN(RES_FAIL, "Layout::build() failed!");
}
+ setDeactivatorSink(m_widget);
+
return RES_OK;
}
}
buttonSRef = makeShared<StyledWidget>(button);
+ buttonSRef->bindToEo();
buttonSRef->setData(impl::BTN_DATA_KEY, &(impl::buttonsInfo[i]));
buttonSRef->setStyle(impl::buttonsInfo[i].style);
asWeak(*this)));
}
+ // Screen Reader
+ elm_atspi_accessible_name_cb_set(*buttonSRef,
+ [](void *data, Evas_Object *obj) -> char *
+ {
+ impl::ButtonInfo *info =
+ static_cast<impl::ButtonInfo*>(asWidget(obj)->
+ getData(impl::BTN_DATA_KEY));
+ if (info->type == impl::OperationType::DTMF) {
+ return strdup(info->str);
+ } else {
+ return strdup(AO_STR_VOLUME.translate());
+ }
+ return nullptr;
+ },
+ this);
+
m_widget->setContent(button, impl::buttonsInfo[i].swlPart);
show(*buttonSRef);
}
m_vc->resize(w, h);
hide(*m_vc);
+ registerVolumeControlAo();
+
return RES_OK;
}
m_vc->setIncreaseBtnEnable(true);
m_vc->setDecreaseBtnEnable(true);
}
+
+ // Screen Reader
+ if (m_vc->isVisible()) {
+ elm_atspi_bridge_utils_say(std::to_string(cur).c_str(),
+ EINA_FALSE, nullptr, nullptr);
+ }
}
void KeypadPage::onAudioStateChanged(AudioStateType state)
{
stopVCTimer();
- m_vcTimer = ecore_timer_add(CALL_VC_TIMER_INTERVAL,
+ auto timerInterval = CALL_VC_TIMER_INTERVAL;
+ if (elm_atspi_bridge_utils_is_screen_reader_enabled()) {
+ timerInterval = CALL_VC_SCREEN_READER_TIMER_INTERVAL;
+ }
+
+ m_vcTimer = ecore_timer_add(timerInterval,
CALLBACK_B(KeypadPage::onVCTimerCb),
this);
}
m_sm->delVolumeStateHandler(DELEGATE(
KeypadPage::onVolumeLevelChanged, this));
}
+
+ // Screen Reader
+ Result KeypadPage::createAtspiHighlightHelper()
+ {
+ m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
+ if (!m_atspiHelper) {
+ LOG_RETURN(RES_FAIL,
+ "AtspiHighlightHelper::newInstance() failed!");
+ }
+
+ m_atspiHelper->setRelationEventHandler(WEAK_DELEGATE(
+ KeypadPage::onAtspiHighlight, asWeak(*this)));
+
+ m_atspiHelper->registerWidget(*getFirstButton());
+ m_atspiHelper->registerWidget(*getLastButton());
+ m_atspiHelper->registerWidget(*m_vc.get());
+ m_atspiHelper->registerWidget(*m_vc->getDecreaseBtn());
+ m_atspiHelper->registerWidget(*m_vc->getIncreaseBtn());
+ m_atspiHelper->registerWidget(*m_vc->getValueTxtAo());
+
+ return RES_OK;
+ }
+
+ Elm_Interface_Atspi_Accessible *KeypadPage::onAtspiHighlight(
+ Elm_Interface_Atspi_Accessible *ao,
+ Elm_Atspi_Relation_Type flowRelation)
+ {
+ DLOG("FlowRelation [%s]",
+ flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ?
+ "FROM" : "TO");
+
+ auto firstBtn = getFirstButton();
+ auto lastBtn = getLastButton();
+ auto vcLayout = m_vc.get();
+ auto vcDecrVolumeBtn = m_vc->getDecreaseBtn();
+ auto vcIncrVolumeBtn = m_vc->getIncreaseBtn();
+ auto vcVolumeValueAo = m_vc->getValueTxtAo();
+
+ if (ao == *firstBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return nullptr;
+ }
+ } else if (ao == *lastBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return nullptr;
+ }
+ } else if (ao == *vcLayout) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcDecrVolumeBtn;
+ }
+ } else if (ao == *vcDecrVolumeBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcVolumeValueAo;
+ } else {
+ return *vcLayout;
+ }
+ } else if (ao == *vcVolumeValueAo) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+ return *vcIncrVolumeBtn;
+ } else {
+ return *vcDecrVolumeBtn;
+ }
+ } else if (ao == *vcIncrVolumeBtn) {
+ if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+ return *vcVolumeValueAo;
+ }
+ } else if (ao == getWindow()) {
+ return *firstBtn;
+ } else {
+ LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+ }
+
+ return ao;
+ }
+
+ ElmWidget *KeypadPage::getFirstButton()
+ {
+ return dynamicWidgetCast<ElmWidget>(
+ m_widget->getContent(impl::buttonsInfo[0].swlPart));
+ }
+
+ ElmWidget *KeypadPage::getLastButton()
+ {
+ return dynamicWidgetCast<ElmWidget>(
+ m_widget->getContent(impl::buttonsInfo[(
+ impl::KEYPAD_BTN_MAX_COUNT - 1)].swlPart));
+ }
+
+ void KeypadPage::registerVolumeControlAo()
+ {
+ auto decrBtn = m_vc->getDecreaseBtn();
+
+ if (decrBtn) {
+ decrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
+ WEAK_DELEGATE(KeypadPage::
+ onVolumeControlScreenReaderReadStart,
+ asWeak(*this)));
+ }
+
+ auto incrBtn = m_vc->getIncreaseBtn();
+ if (incrBtn) {
+ incrBtn->addEventHandler(ATSPI_HIGHLIGHTED,
+ WEAK_DELEGATE(KeypadPage::
+ onVolumeControlScreenReaderReadStart,
+ asWeak(*this)));
+ }
+ }
+
+ void KeypadPage::onVolumeControlScreenReaderReadStart(
+ Widget &widget,
+ void *eventInfo)
+ {
+ restartVCTimer();
+ }
}