2 * Copyright (c) 2015 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.
19 #include "accessibility-adaptor-impl.h"
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/integration-api/events/gesture-requests.h>
29 #include "system-settings.h"
40 namespace // unnamed namespace
43 #if defined(DEBUG_ENABLED)
44 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
47 } // unnamed namespace
49 AccessibilityAdaptor::AccessibilityAdaptor()
51 mActionHandler( NULL ),
54 mIndicatorFocused( false )
56 mAccessibilityGestureDetector = new AccessibilityGestureDetector();
59 void AccessibilityAdaptor::EnableAccessibility()
61 if(mIsEnabled == false)
67 mActionHandler->ChangeAccessibilityStatus();
72 void AccessibilityAdaptor::DisableAccessibility()
74 if(mIsEnabled == true)
80 mActionHandler->ChangeAccessibilityStatus();
83 // Destroy the TtsPlayer if exists.
84 if ( Adaptor::IsAvailable() )
86 Dali::Adaptor& adaptor = Dali::Adaptor::Get();
87 Adaptor& adaptorImpl = Adaptor::GetImplementation( adaptor );
88 adaptorImpl.DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER );
93 bool AccessibilityAdaptor::IsEnabled() const
98 Vector2 AccessibilityAdaptor::GetReadPosition() const
100 return mReadPosition;
103 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
105 mActionHandler = &handler;
108 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
110 if( mAccessibilityGestureDetector )
112 mAccessibilityGestureDetector->SetGestureHandler(handler);
116 void AccessibilityAdaptor::SetIndicator(IndicatorInterface* indicator)
118 mIndicator = indicator;
121 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
127 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
130 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
135 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
141 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
144 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
149 bool AccessibilityAdaptor::HandleActionActivateEvent()
155 ret = mActionHandler->AccessibilityActionActivate();
158 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
163 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
167 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
174 ret = mActionHandler->AccessibilityActionRead( allowReadAgain );
175 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
181 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
187 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
190 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
195 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
201 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
204 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
209 bool AccessibilityAdaptor::HandleActionUpEvent()
215 ret = mActionHandler->AccessibilityActionUp();
218 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
223 bool AccessibilityAdaptor::HandleActionDownEvent()
229 ret = mActionHandler->AccessibilityActionDown();
232 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
237 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
243 ret = mActionHandler->ClearAccessibilityFocus();
246 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
251 bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
255 // We always need to emit a scroll signal, whether it's only a hover or not,
256 // so always send the action to the action handler.
259 Dali::TouchEvent event(timeStamp);
260 event.points.push_back(point);
261 ret = mActionHandler->AccessibilityActionScroll( event );
264 Integration::TouchEvent touchEvent;
265 Integration::HoverEvent hoverEvent;
266 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent( Integration::Point( point ), timeStamp, touchEvent, hoverEvent );
267 if( type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth ) // hover event is ignored
269 // Process the touch event in accessibility gesture detector
270 if( mAccessibilityGestureDetector )
272 mAccessibilityGestureDetector->SendEvent( touchEvent );
280 bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
284 Dali::TouchEvent touchEvent(timeStamp);
285 touchEvent.points.push_back(point);
289 ret = mActionHandler->AccessibilityActionTouch(touchEvent);
294 bool AccessibilityAdaptor::HandleActionBackEvent()
300 ret = mActionHandler->AccessibilityActionBack();
303 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
308 void AccessibilityAdaptor::HandleActionEnableEvent()
310 EnableAccessibility();
313 void AccessibilityAdaptor::HandleActionDisableEvent()
315 DisableAccessibility();
318 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
324 ret = mActionHandler->AccessibilityActionScrollUp();
327 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
333 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
339 ret = mActionHandler->AccessibilityActionScrollDown();
342 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
347 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
353 ret = mActionHandler->AccessibilityActionPageLeft();
356 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
361 bool AccessibilityAdaptor::HandleActionPageRightEvent()
367 ret = mActionHandler->AccessibilityActionPageRight();
370 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
375 bool AccessibilityAdaptor::HandleActionPageUpEvent()
381 ret = mActionHandler->AccessibilityActionPageUp();
384 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
389 bool AccessibilityAdaptor::HandleActionPageDownEvent()
395 ret = mActionHandler->AccessibilityActionPageDown();
398 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
403 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
409 ret = mActionHandler->AccessibilityActionMoveToFirst();
412 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
417 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
423 ret = mActionHandler->AccessibilityActionMoveToLast();
426 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
431 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
437 ret = mActionHandler->AccessibilityActionReadFromTop();
440 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
445 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
451 ret = mActionHandler->AccessibilityActionReadFromNext();
454 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
459 bool AccessibilityAdaptor::HandleActionZoomEvent()
465 ret = mActionHandler->AccessibilityActionZoom();
468 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
473 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
479 ret = mActionHandler->AccessibilityActionReadIndicatorInformation();
482 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
487 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
493 ret = mActionHandler->AccessibilityActionReadPauseResume();
496 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
501 bool AccessibilityAdaptor::HandleActionStartStopEvent()
507 ret = mActionHandler->AccessibilityActionStartStop();
510 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
515 AccessibilityAdaptor::~AccessibilityAdaptor()
517 // Do any platform specific clean-up in OnDestroy()
521 } // namespace Adaptor
523 } // namespace Internal