[Tizen] Add a flag to check whether it is forced to enable
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / common / accessibility-adaptor-impl.cpp
index 678f13a..e057821 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
 
 // EXTERNAL INCLUDES
+#include <system_settings.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/touch-integ.h>
 #include <dali/integration-api/events/hover-event-integ.h>
-#include <dali/integration-api/events/gesture-requests.h>
 
 // INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/system/common/system-settings.h>
 
 namespace Dali
@@ -49,13 +51,22 @@ Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogg
 AccessibilityAdaptor::AccessibilityAdaptor()
 : mReadPosition(),
   mActionHandler( NULL ),
-  mIsEnabled( false )
+  mIsEnabled( false ),
+  mIsForced( false )
 {
   mAccessibilityGestureDetector = new AccessibilityGestureDetector();
 }
 
 void AccessibilityAdaptor::EnableAccessibility()
 {
+  bool accessibilityState = false;
+  system_settings_get_value_bool( SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, &accessibilityState );
+  if(accessibilityState == false)
+  {
+    DALI_LOG_ERROR("The Current Accessibility system cannot run. \n");
+    return;
+  }
+
   if(mIsEnabled == false)
   {
     mIsEnabled = true;
@@ -93,6 +104,16 @@ bool AccessibilityAdaptor::IsEnabled() const
   return mIsEnabled;
 }
 
+void AccessibilityAdaptor::SetForcedEnable( bool forced )
+{
+  mIsForced = forced;
+}
+
+bool AccessibilityAdaptor::IsForcedEnable() const
+{
+  return mIsForced;
+}
+
 Vector2 AccessibilityAdaptor::GetReadPosition() const
 {
   return mReadPosition;
@@ -159,8 +180,8 @@ bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y,
 
   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
 
-  mReadPosition.x = x;
-  mReadPosition.y = y;
+  mReadPosition.x = static_cast< float > (x);
+  mReadPosition.y = static_cast< float > (y);
 
   if( mActionHandler )
   {
@@ -241,7 +262,7 @@ bool AccessibilityAdaptor::HandleActionClearFocusEvent()
   return ret;
 }
 
-bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
+bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, uint32_t timeStamp)
 {
   bool ret = false;
 
@@ -249,15 +270,14 @@ bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsi
   // so always send the action to the action handler.
   if( mActionHandler )
   {
-    Dali::TouchEvent event(timeStamp);
-    event.points.push_back(point);
-    ret = mActionHandler->AccessibilityActionScroll( event );
+    Dali::TouchEvent touch = Integration::NewTouchEvent( timeStamp, point );
+    ret = mActionHandler->AccessibilityActionScroll( touch );
   }
 
   Integration::TouchEvent touchEvent;
   Integration::HoverEvent hoverEvent;
   Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent( Integration::Point( point ), timeStamp, touchEvent, hoverEvent );
-  if( type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth ) // hover event is ignored
+  if( type == Integration::TouchEventCombiner::DISPATCH_TOUCH || type == Integration::TouchEventCombiner::DISPATCH_BOTH ) // hover event is ignored
   {
     // Process the touch event in accessibility gesture detector
     if( mAccessibilityGestureDetector )
@@ -270,20 +290,6 @@ bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsi
   return ret;
 }
 
-bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
-{
-  bool ret = false;
-
-  Dali::TouchEvent touchEvent(timeStamp);
-  touchEvent.points.push_back(point);
-
-  if( mActionHandler )
-  {
-    ret = mActionHandler->AccessibilityActionTouch(touchEvent);
-  }
-  return ret;
-}
-
 bool AccessibilityAdaptor::HandleActionBackEvent()
 {
   bool ret = false;