From 5d2b831fc91a62ffaef73651e32a405906e77914 Mon Sep 17 00:00:00 2001 From: Sreedeep Moulik Date: Tue, 23 Apr 2013 10:26:36 +0530 Subject: [PATCH] Accesibility Issue Fixes in DTP Change-Id: I23248550f3463357943e6aa1a21a5772eb8e7aa7 Signed-off-by: Sreedeep Moulik Signed-off-by: Syed Khaja Moinuddin --- src/ui/controls/FUiCtrl_DateTimePicker.cpp | 101 +++++++++++++++-------------- src/ui/inc/FUiCtrl_DateTimePicker.h | 2 + 2 files changed, 55 insertions(+), 48 deletions(-) diff --git a/src/ui/controls/FUiCtrl_DateTimePicker.cpp b/src/ui/controls/FUiCtrl_DateTimePicker.cpp index 52fd093..3a9ad1a 100644 --- a/src/ui/controls/FUiCtrl_DateTimePicker.cpp +++ b/src/ui/controls/FUiCtrl_DateTimePicker.cpp @@ -63,7 +63,6 @@ _DateTimePicker::_DateTimePicker(_DateTimePresenter* pPresenter, const String& t , __pFont(null) , __pDisplayVisualElement(null) { - GetAccessibilityContainer()->Activate(true); } _DateTimePicker::~_DateTimePicker(void) @@ -89,23 +88,6 @@ _DateTimePicker::~_DateTimePicker(void) delete __pPresenter; __pPresenter = null; - - if (likely(_AccessibilityManager::IsActivated())) - { - _AccessibilityElement* pElement = null; - while (__accessibilityElements.GetCount() > 0) - { - if ((__accessibilityElements.GetAt(0, pElement)) == E_SUCCESS) - { - __accessibilityElements.RemoveAt(0); - pElement->GetParent()->RemoveElement(*pElement); - } - else - { - __accessibilityElements.RemoveAt(0); - } - } - } } _DateTimePicker* @@ -172,7 +154,7 @@ _DateTimePicker::CreateDateTimePickerN(int style, const String& title) SysTryCatch(NID_UI_CTRL, (pView->__pDateTimeChangeEvent != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - if (likely(_AccessibilityManager::IsActivated()) && pView->GetAccessibilityContainer() != null) + if (pView->GetAccessibilityContainer() != null) { pView->GetAccessibilityContainer()->Activate(true); } @@ -741,10 +723,9 @@ void _DateTimePicker::SetAccessibilityElementText(int index, const String& text, bool isAmPm) { _AccessibilityElement* pElement = null; - int elementIndex = __accessibilityElements.GetCount() - 1 - index; String hintAmPmText(L"Double tap to change to "); - if (__accessibilityElements.GetAt(elementIndex, pElement) == E_SUCCESS) + if (__accessibilityElements.GetAt(index, pElement) == E_SUCCESS) { result r = GetLastResult(); SysTryReturnVoidResult(NID_UI_CTRL, (pElement != null), r, "[%s] Propagating.", GetErrorMessage(r)); @@ -805,11 +786,6 @@ _DateTimePicker::OnTouchCanceled(const _Control& source, const _TouchInfo& touch result _DateTimePicker::OnAttachedToMainTree(void) { - if (likely(!(_AccessibilityManager::IsActivated()))) - { - return E_SUCCESS; - } - _AccessibilityContainer* pContainer = GetAccessibilityContainer(); if (pContainer != null) { @@ -905,16 +881,23 @@ _DateTimePicker::OnAttachedToMainTree(void) pElement->SetHint(hintAmPmText); pContainer->AddElement(*pElement); } - } - if (pContainer) - { pContainer->GetElements(__accessibilityElements); + _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM); + } return E_SUCCESS; } +result +_DateTimePicker::OnDetachingFromMainTree(void) +{ + RemoveAllAccessibilityElement(); + + return _Window::OnDetachingFromMainTree(); +} + void _DateTimePicker::OnChangeLayout(_ControlOrientation orientation) { @@ -953,33 +936,33 @@ _DateTimePicker::OnChangeLayout(_ControlOrientation orientation) __pPresenter->OnChangeLayout(orientation); - if (likely(_AccessibilityManager::IsActivated())) + const _DateTimeDisplayBox* pBox = null; + IEnumeratorT<_AccessibilityElement*>* pEnumerator = __accessibilityElements.GetEnumeratorN(); + SysTryReturnVoidResult(NID_UI_CTRL, (pEnumerator != null), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _AccessibilityElement* pElement = null; + int index = 0; + while (pEnumerator->MoveNext() == E_SUCCESS) { - const _DateTimeDisplayBox* pBox = null; - IEnumeratorT<_AccessibilityElement*>* pEnumerator = __accessibilityElements.GetEnumeratorN(); - _AccessibilityElement* pElement = null; - int index = 0; - while (pEnumerator->MoveNext() == E_SUCCESS) + if (pEnumerator->GetCurrent(pElement) == E_SUCCESS) { - if (pEnumerator->GetCurrent(pElement) == E_SUCCESS) + pBox = __pPresenter->GetDisplayBox(index); + if (pBox != null) { - pBox = __pPresenter->GetDisplayBox(index); - if (pBox != null) - { - FloatRectangle displayBoxBounds = pBox->GetDisplayBoxBounds(); - - if (__pDisplayVisualElement) - { - displayBoxBounds.y += __pDisplayVisualElement->GetBounds().y; - } + FloatRectangle displayBoxBounds = pBox->GetDisplayBoxBounds(); - pElement->SetBounds(displayBoxBounds); + if (__pDisplayVisualElement) + { + displayBoxBounds.y += __pDisplayVisualElement->GetBounds().y; } + + pElement->SetBounds(displayBoxBounds); } - index++; } - delete pEnumerator; + index++; } + delete pEnumerator; return; } @@ -1106,4 +1089,26 @@ _DateTimePicker::GetIndicatorBoundsF(void) return indicatorBounds; } +void +_DateTimePicker::RemoveAllAccessibilityElement(void) +{ + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _AccessibilityElement* pAccessibilityElement = null; + + while (__accessibilityElements.GetCount() > 0) + { + if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(0); + pContainer->RemoveElement(*pAccessibilityElement); + } + else + { + __accessibilityElements.RemoveAt(0); + } + } +} + }}} // Tizen::Ui::Controls diff --git a/src/ui/inc/FUiCtrl_DateTimePicker.h b/src/ui/inc/FUiCtrl_DateTimePicker.h index cbca1aa..0478877 100644 --- a/src/ui/inc/FUiCtrl_DateTimePicker.h +++ b/src/ui/inc/FUiCtrl_DateTimePicker.h @@ -135,6 +135,7 @@ public: void SetAccessibilityElementText(int index, const Tizen::Base::String& text, bool isAmPm); virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); virtual void OnDraw(void); virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); @@ -174,6 +175,7 @@ private: _DateTimePicker(const _DateTimePicker&); _DateTimePicker& operator =(const _DateTimePicker&); + void RemoveAllAccessibilityElement(void); private: _DateTimePresenter* __pPresenter; -- 2.7.4