atspi: suppress reading of screen-reader 57/257057/8
authorShinwoo Kim <cinoo.kim@samsung.com>
Mon, 19 Apr 2021 04:57:04 +0000 (13:57 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Mon, 3 May 2021 02:20:25 +0000 (11:20 +0900)
Because there is legacy code for screen-reader, an application could want
to keep previous behavior of the screen-reader even though the ATSPI is
enabled by AT client such as Aurum test framework.

If an application wants to make screen-reader AT client do not read,
then set suppress to true. The default suppress is false.

Change-Id: I2a639b50d7920f59366def7b6467fe38bc754fbe

dali/devel-api/adaptor-framework/accessibility-impl.h
dali/devel-api/adaptor-framework/atspi-accessibility.cpp
dali/devel-api/adaptor-framework/atspi-accessibility.h
dali/internal/accessibility/bridge/bridge-accessible.cpp
dali/internal/accessibility/bridge/bridge-accessible.h
dali/internal/accessibility/bridge/dummy-atspi.h

index 7d4b9f9..31226a6 100644 (file)
@@ -254,6 +254,13 @@ struct DALI_ADAPTOR_API Bridge
   virtual void StopReading(bool alsoNonDiscardable) = 0;
 
   /**
+   * @brief Suppresses reading of screen-reader
+   *
+   * @param suppress whether to suppress reading of screen-reader
+   */
+  virtual void SuppressScreenReader(bool suppress) = 0;
+
+  /**
    * @brief Get screen reader status.
    */
   virtual bool GetScreenReaderEnabled() = 0;
index 7b36a94..563fe90 100644 (file)
@@ -42,6 +42,17 @@ void Dali::AtspiAccessibility::StopReading(bool alsoNonDiscardable)
   }
 }
 
+bool Dali::AtspiAccessibility::SuppressScreenReader(bool suppress)
+{
+  if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
+  {
+    bridge->SuppressScreenReader(suppress);
+    return true;
+  }
+
+  return false;
+}
+
 void Dali::AtspiAccessibility::Say(const std::string& text, bool discardable, std::function<void(std::string)> callback)
 {
   if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
index 6c703f8..ea95524 100644 (file)
@@ -57,6 +57,14 @@ DALI_ADAPTOR_API void Resume();
 DALI_ADAPTOR_API void StopReading(bool alsoNonDiscardable = false);
 
 /**
+ * @brief Suppresses reading of screen-reader
+ *
+ * @param suppress whether to suppress reading of screen-reader
+ * @return true on success, false otherwise
+ */
+DALI_ADAPTOR_API bool SuppressScreenReader(bool suppress);
+
+/**
  * @brief Set ATSPI to be turned On or Off forcibly.
  *
  * @param[in] turnOn true to turn on, false to turn off.
index 028d0ca..4f5ebb2 100644 (file)
@@ -341,6 +341,11 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
     describedByObject};
 }
 
+void BridgeAccessible::SuppressScreenReader(bool suppress)
+{
+   suppressScreenReader = suppress;
+}
+
 DBus::ValueOrError<bool> BridgeAccessible::DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t yBeg, int32_t xEnd, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime)
 {
   return FindSelf()->DoGesture(Dali::Accessibility::GestureInfo{type, xBeg, xEnd, yBeg, yEnd, state, eventTime});
@@ -719,7 +724,13 @@ DBus::ValueOrError<std::array<uint32_t, 2>> BridgeAccessible::GetStates()
 }
 DBus::ValueOrError<std::unordered_map<std::string, std::string>> BridgeAccessible::GetAttributes()
 {
-  return FindSelf()->GetAttributes();
+  std::unordered_map<std::string, std::string> attributes = FindSelf()->GetAttributes();
+  if(suppressScreenReader)
+  {
+    attributes.insert({"suppress-screen-reader", "true"});
+  }
+
+  return attributes;
 }
 DBus::ValueOrError<std::vector<std::string>> BridgeAccessible::GetInterfaces()
 {
index 7a59cb4..d5bdc52 100644 (file)
@@ -33,6 +33,7 @@ protected:
   BridgeAccessible();
 
   void RegisterInterfaces();
+  bool suppressScreenReader = false;
 
 public:
   enum class GetNeighborSearchMode
@@ -86,6 +87,7 @@ public:
     >;
 
   ReadingMaterialType GetReadingMaterial();
+  void                SuppressScreenReader(bool) override;
 
   DBus::ValueOrError<bool> DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t yBeg, int32_t xEnd, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime);
 
index f47a33a..e760c65 100644 (file)
@@ -140,6 +140,10 @@ struct DummyBridge : Dali::Accessibility::Bridge
   {
   }
 
+  void SuppressScreenReader(bool suppress) override
+  {
+  }
+
   bool GetScreenReaderEnabled() override
   {
     return false;