[NUI] Add sound feedback for Control
authorzhouleonlei <zhouleon.lei@samsung.com>
Fri, 11 Dec 2020 07:31:03 +0000 (15:31 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 15 Dec 2020 06:33:59 +0000 (15:33 +0900)
src/Tizen.NUI.Components/Controls/Control.cs
src/Tizen.NUI.Components/Tizen.NUI.Components.csproj
src/Tizen.NUI.Components/Tizen.NUI.Components.sln

index 8daafcf..959d58a 100755 (executable)
  * limitations under the License.
  *
  */
+
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Binding;
 using System.Windows.Input;
+using Tizen.System;
 
 namespace Tizen.NUI.Components
 {
@@ -42,6 +44,8 @@ namespace Tizen.NUI.Components
 
         private bool onThemeChangedEventOverrideChecker;
 
+        private Feedback feedback = new Feedback();
+
         private TapGestureDetector tapGestureDetector = new TapGestureDetector();
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -90,6 +94,13 @@ namespace Tizen.NUI.Components
             ThemeChangeSensitive = true;
         }
 
+        /// <summary>
+        /// The flag of sound feedback when tap gesture detected.
+        /// </summary>
+        /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool IsTapGestureFeedback { get; set; } = false;
+
         /// Internal used.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public ICommand Command
@@ -148,6 +159,12 @@ namespace Tizen.NUI.Components
             {
                 tapGestureDetector.Detected -= OnTapGestureDetected;
                 tapGestureDetector.Detach(this);
+
+                if (feedback != null)
+                {
+                    feedback.Stop();
+                    feedback = null;
+                }
             }
 
             base.Dispose(type);
@@ -213,7 +230,16 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual void OnTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e) { }
+        protected virtual void OnTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e)
+        {
+            if (IsTapGestureFeedback && e?.TapGesture?.State == Gesture.StateType.Started)
+            {
+                if (feedback != null && feedback.IsSupportedPattern(FeedbackType.Sound, "Tap"))
+                {
+                    feedback.Play(FeedbackType.Sound, "Tap");
+                }
+            }
+        }
 
         /// <summary>
         /// Update by style.
index cfc5d93..f4bd4d6 100755 (executable)
@@ -8,6 +8,7 @@
   <ItemGroup>
     <ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
     <ProjectReference Include="..\Tizen.NUI\Tizen.NUI.csproj" />
+    <ProjectReference Include="..\Tizen.System.Feedback\Tizen.System.Feedback.csproj" />
     <ProjectReference Include="..\Tizen.System.Information\Tizen.System.Information.csproj" />
   </ItemGroup>
 
index f3d1317..12c4174 100755 (executable)
@@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.SystemSettings
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Information", "..\Tizen.System.Information\Tizen.System.Information.csproj", "{11CACB07-AF47-480E-AB25-88E3C3297631}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Feedback", "..\Tizen.System.Feedback\Tizen.System.Feedback.csproj", "{675DA71D-4314-4F10-8632-C804A9F720D4}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
                {11CACB07-AF47-480E-AB25-88E3C3297631}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {11CACB07-AF47-480E-AB25-88E3C3297631}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {11CACB07-AF47-480E-AB25-88E3C3297631}.Release|Any CPU.Build.0 = Release|Any CPU
+               {675DA71D-4314-4F10-8632-C804A9F720D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {675DA71D-4314-4F10-8632-C804A9F720D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {675DA71D-4314-4F10-8632-C804A9F720D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {675DA71D-4314-4F10-8632-C804A9F720D4}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE