[Tizen] Add a flag to check whether it is forced to enable 16/249416/2 accepted/tizen/6.0/unified/20201213.214019 submit/tizen_6.0/20201211.074400
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 11 Dec 2020 07:27:24 +0000 (16:27 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 11 Dec 2020 07:31:09 +0000 (16:31 +0900)
- If an application controls Accessibility status by itself,
 dali does not have to control Accessibility enabled.
- Check the state of global accessibility.
- Enable Accessibility when only AllApps shows and the app is itself.

Change-Id: Ic7f1a94ed13134ee9e17bb7275501d8678b3b8cf

dali/devel-api/adaptor-framework/accessibility-adaptor.cpp
dali/devel-api/adaptor-framework/accessibility-adaptor.h
dali/internal/accessibility/common/accessibility-adaptor-impl.cpp
dali/internal/accessibility/common/accessibility-adaptor-impl.h
dali/internal/window-system/common/event-handler.cpp

index 685ed9a..6c1166d 100644 (file)
@@ -43,6 +43,7 @@ Vector2 AccessibilityAdaptor::GetReadPosition() const
 
 void AccessibilityAdaptor::EnableAccessibility(bool enabled)
 {
+  SetForcedEnable( true );
   if(enabled)
   {
     Internal::Adaptor::AccessibilityAdaptor::GetImplementation(*this).EnableAccessibility();
@@ -58,6 +59,11 @@ bool AccessibilityAdaptor::IsEnabled() const
   return Internal::Adaptor::AccessibilityAdaptor::GetImplementation(*this).IsEnabled();
 }
 
+void AccessibilityAdaptor::SetForcedEnable( bool forced )
+{
+  Internal::Adaptor::AccessibilityAdaptor::GetImplementation(*this).SetForcedEnable(forced);
+}
+
 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
 {
   Internal::Adaptor::AccessibilityAdaptor::GetImplementation(*this).SetActionHandler(handler);
index a138db8..ec09c7f 100644 (file)
@@ -86,6 +86,12 @@ public:
   bool IsEnabled() const;
 
   /**
+   * @brief Sets Accessibility enabled forcibly.
+   * @param forced Whether accessibility sets enabled forcibly
+   */
+  void SetForcedEnable( bool forced );
+
+  /**
    * @brief Set the handler to handle accessibility actions.
    *
    * @param[in] handler The Accessibility action handler.
index aed44c7..e057821 100644 (file)
@@ -19,6 +19,7 @@
 #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>
@@ -50,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;
@@ -94,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;
index 29cbb08..b67f506 100644 (file)
@@ -79,6 +79,16 @@ public:
   bool IsEnabled() const;
 
   /**
+   * @copydoc Dali::AccessibilityAdaptor::SetForcedEnable()
+   */
+  void SetForcedEnable( bool forced );
+
+  /**
+   * Whether the accessibility is enabled forcibly or not
+   */
+  bool IsForcedEnable() const;
+
+  /**
    * @copydoc Dali::AccessibilityAdaptor::GetReadPosition() const
    */
   Vector2 GetReadPosition() const;
@@ -256,6 +266,8 @@ protected:
 
   bool mIsEnabled        : 1; ///< enable/disable the accessibility action
 
+  bool mIsForced         : 1; ///< Is the accessibility enabled forcibly
+
 public:
 
   // Helpers for public-api forwarding methods
index f8219a7..8bdec19 100755 (executable)
@@ -271,6 +271,12 @@ void EventHandler::OnAccessibilityNotification( const WindowBase::AccessibilityI
     return;
   }
 
+  if( !accessibilityAdaptor->IsEnabled() )
+  {
+    DALI_LOG_ERROR( "The current dali accessibility is not available. \n" );
+    return;
+  }
+
   if( ( info.quickpanelInfo & ( 1 << QUICKPANEL_TYPE_SYSTEM_DEFAULT ) ) && ( info.quickpanelInfo & ( 1 << QUICKPANEL_TYPE_APPS_MENU ) ) )
   {
     DALI_LOG_ERROR("Quickpanel is top now, so all dali apps should be stopped \n");
@@ -532,14 +538,28 @@ void EventHandler::OnAccessibilityQuickpanelChanged( const unsigned char& info )
   }
 
   if( ( ( info & ( 1 << QUICKPANEL_TYPE_SYSTEM_DEFAULT ) ) && ( info & ( 1 << QUICKPANEL_TYPE_APPS_MENU ) ) ) || // Both QuickPanel and Apps are shown
-      ( info & ( 1 << QUICKPANEL_TYPE_APPS_MENU ) ) || // Only Apps menu (dali application) is shown
       ( info & ( 1 << QUICKPANEL_TYPE_SYSTEM_DEFAULT ) ) ) // QuickPanel is shown
   {
     // dali apps should be disabled.
+    DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Quickpanel show -> DisableAccessibility \n" );
     accessibilityAdaptor->DisableAccessibility();
   }
+  else if( info & ( 1 << QUICKPANEL_TYPE_APPS_MENU ) ) // Only Apps menu (dali application) is shown
+  {
+    if( !accessibilityAdaptor->IsForcedEnable() ) // It is not in case of that an application controls the accessibility status itself
+    {
+      DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Only Apps show, but not forced dali -> DisableAccessibility \n" );
+      accessibilityAdaptor->DisableAccessibility();
+    }
+    else
+    {
+      DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Only Apps show and it is a forced dali -> EnableAccessibility \n" );
+      accessibilityAdaptor->EnableAccessibility();
+    }
+  }
   else
   {
+    DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Nothing shows -> EnableAccessibility \n" );
     // dali app should be enabled.
     accessibilityAdaptor->EnableAccessibility();
   }