fix ViewManager and UI Component Layer 38/282038/1
authorulgal-park <ulgal.park@samsung.com>
Wed, 21 Sep 2022 05:51:24 +0000 (14:51 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Mon, 26 Sep 2022 08:46:57 +0000 (17:46 +0900)
Change-Id: I57fae836c1b420feaead024da4c29ea99891d927

voice-touch/GridLayer.cs
voice-touch/TextBubbleLayer.cs
voice-touch/TooltipLayer.cs
voice-touch/VoiceTouch.cs
voice-touch/VoiceTouchEventManager.cs
voice-touch/VoiceTouchMmi/VoiceTouchResult.cs
voice-touch/VoiceTouchViewManager.cs

index 4d69c99d8a5cd6449e8b02233375a53d6a7fd3cf..051e56b11ff88f3f77ef4616a490dce8c0b6b3e9 100644 (file)
@@ -36,7 +36,6 @@ namespace VoiceTouch
 
         View highlightGridView = null;
         View highlightLabelView = null;
-        Timer highlightGridTimer = null;
 
         static int textLabelMinWidth = 40;
         static int textLabelMinHeight = 40;
@@ -114,8 +113,6 @@ namespace VoiceTouch
 
             foreach (var grid in grids)
             {
-                int col = (grid.idx - 1) % 7 + 1;
-                int row = (grid.idx - 1) / 7;
                 View boxView = new View()
                 {
                     BorderlineColor = Color.LightGray, // TODO: Change to white when Default Headed UI changed
@@ -146,7 +143,7 @@ namespace VoiceTouch
                     WidthResizePolicy = ResizePolicyType.UseNaturalSize,
                 };
                 float stride = (indexTextLabel.NaturalSize.Width < textLabelMinWidth) ? textLabelMinWidth : indexTextLabel.NaturalSize.Width;
-                indexTextLabel.Position = new Position(col * grid.width - stride - firstLayerTextLabelWidthPad, row * grid.height + firstLayerTextLabelHeightPad);
+                indexTextLabel.Position = new Position(grid.x + grid.width - stride - firstLayerTextLabelWidthPad, grid.y + firstLayerTextLabelHeightPad);
                 indexView.Add(indexTextLabel);
                 firstLayerTextLabelView.Add(indexView);
                 labelView.Add(indexView);
@@ -166,14 +163,8 @@ namespace VoiceTouch
             }
             firstLayerTextLabelView.Clear();
 
-            float basePositionX = grids[0].x;
-            float basePositionY = grids[0].y;
             foreach (var grid in grids)
             {
-                int col = (grid.idx - 1) % 4 + 1;
-                int row = (grid.idx - 1) / 4;
-                
-
                 TextLabel indexTextLabel = new TextLabel()
                 {
                     Text = grid.idx.ToString(),
@@ -192,7 +183,7 @@ namespace VoiceTouch
                     WidthResizePolicy = ResizePolicyType.UseNaturalSize,
                 };
                 float stride = (indexTextLabel.NaturalSize.Width < textLabelMinWidth) ? textLabelMinWidth : indexTextLabel.NaturalSize.Width;
-                indexTextLabel.Position = new Position(basePositionX + col * grid.width - stride - secondLayerTextLabelPad, basePositionY + row * grid.height + secondLayerTextLabelPad);
+                indexTextLabel.Position = new Position(grid.x + grid.width - stride - secondLayerTextLabelPad, grid.y + secondLayerTextLabelPad);
                 indexView.Add(indexTextLabel);
                 secondLayerTextLabelView.Add(indexView);
                 labelView.Add(indexView);
@@ -229,26 +220,26 @@ namespace VoiceTouch
             }
         }
 
-        public void HighlightGrid(ClickableObject obj, int selected)
+        public void HighlightGrid(ClickableObject obj, int depth)
         {
-            if (highlightGridView != null)
+            if (highlightLabelView != null)
             {
                 return;
             }
-            View targetGridView = secondLayerGridView[selected - 1];
-            View targetLabelView = secondLayerTextLabelView[selected - 1].GetChildAt(0);
+
             highlightGridView = new View()
             {
                 BorderlineColor = new Color("#FF6200"),
-                BorderlineWidth = 2.0f,
+                BorderlineWidth = 1.5f,
                 BorderlineOffset = -1f,
                 BackgroundColor = Color.Transparent,
                 Size = new Size(obj.width, obj.height),
                 Position = new Position(obj.x, obj.y),
             };
+
             TextLabel indexTextLabel = new TextLabel()
             {
-                Text = selected.ToString(),
+                Text = obj.idx.ToString(),
                 BackgroundColor = new Color("#FF6200"),
                 MinimumSize = new Size2D(textLabelMinWidth, textLabelMinHeight),
                 WidthResizePolicy = ResizePolicyType.UseNaturalSize,
@@ -257,16 +248,24 @@ namespace VoiceTouch
                 VerticalAlignment = VerticalAlignment.Center,
                 CornerRadius = new Vector4(0, 12, 0, 12),
                 Padding = new Extents(10, 10, 4, 4),
-                Position = new Position(targetLabelView.Position.X, targetLabelView.Position.Y),
             };
-            highlightLabelView = new View()
+
+            float stride = (indexTextLabel.NaturalSize.Width < textLabelMinWidth) ? textLabelMinWidth : indexTextLabel.NaturalSize.Width;
+            if (depth == 1)
             {
-                WidthResizePolicy = ResizePolicyType.UseNaturalSize,
-            };
+                indexTextLabel.Position = new Position(obj.x + obj.width - stride - firstLayerTextLabelWidthPad, obj.y + firstLayerTextLabelHeightPad);
+            }
+            else if (depth == 2)
+            {
+                indexTextLabel.Position = new Position(obj.x + obj.width - stride - secondLayerTextLabelPad, obj.y + secondLayerTextLabelPad);
+            }
+            highlightLabelView = new View();
             highlightLabelView.Add(indexTextLabel);
-            ClearGrid();
-            Window.Instance.Add(highlightGridView);
+
             Window.Instance.Add(highlightLabelView);
+            Window.Instance.Add(highlightGridView);
+
+            return;
         }
     }
 }
index eae12effc880dd5dabc9774e3b527b803a7c2915..b0ad647a6aca16552ad787437aee4a3e3bd416f4 100644 (file)
@@ -27,18 +27,22 @@ namespace VoiceTouch
     {
         View mView = null;
         TextLabel mTextBubble = null;
+
+        View mResponseView = null;
+        TextLabel mResponseBubble = null;
+
         static readonly int minWidth = 88;
         static readonly int minHeight = 80;
         static readonly int maxWidth = 788;
         static readonly int maxHeight = 144;
-        static Position2D rightTop;
+        static Position2D rightTop = new Position2D(1920 - 208, 93);
 
         public TextBubbleLayer()
         {
-            rightTop = new Position2D(1920 - 208, 93);
+
         }
 
-        public void CleartextBubbles()
+        public void ClearTextBubbles()
         {
             if(mView)
             {
@@ -52,7 +56,7 @@ namespace VoiceTouch
         {
             if (mView)
             {
-                CleartextBubbles();
+                ClearTextBubbles();
             }
 
             mTextBubble = new TextLabel()
@@ -68,10 +72,7 @@ namespace VoiceTouch
                 CornerRadius = new Vector4(40, 40, 40, 40),
                 Padding = new Extents(24, 24, 24, 24),
             };
-            mView = new View()
-            {
-                WidthResizePolicy = ResizePolicyType.UseNaturalSize,
-            };
+            mView = new View();
             float stride = (mTextBubble.NaturalSize.Width > minWidth) ? mTextBubble.NaturalSize.Width : minWidth;
             mTextBubble.Position = new Position(rightTop.X - stride, rightTop.Y);
 
@@ -90,16 +91,52 @@ namespace VoiceTouch
                     Padding = new Extents(24, 24, 24, 24),
                     MultiLine = true,
                 };
-                mView = new View()
-                {
-                    Size2D = new Size2D(maxWidth, maxHeight),
-                };
+                mView = new View();
                 mTextBubble.Position = new Position(rightTop.X - maxWidth, rightTop.Y);
             }
 
             mView.Add(mTextBubble);
             Window.Instance.Add(mView);
         }
+
+        public void ClearResponseBubbles()
+        {
+            if(mResponseView)
+            {
+                mResponseView.Unparent();
+                mResponseView.Dispose();
+                mResponseView = null;
+            }
+        }
+
+
+        public void CreateResponseBubble(string text, Color color)
+        {
+            if (mResponseView)
+            {
+                return;
+            }
+
+            mResponseBubble = new TextLabel()
+            {
+                Text = text,
+                BackgroundColor = new Color("#DBE3FF"),
+                MinimumSize = new Size2D(minWidth, minHeight),
+                MaximumSize = new Size2D(maxWidth, maxHeight),
+                WidthResizePolicy = ResizePolicyType.UseNaturalSize,
+                TextColor = color,
+                HorizontalAlignment = HorizontalAlignment.Center,
+                VerticalAlignment = VerticalAlignment.Center,
+                CornerRadius = new Vector4(40, 40, 40, 40),
+                Padding = new Extents(24, 24, 24, 24),
+            };
+            mResponseView = new View();
+            float stride = (mResponseBubble.NaturalSize.Width > minWidth) ? mResponseBubble.NaturalSize.Width : minWidth;
+            mResponseBubble.Position = new Position(rightTop.X - stride, rightTop.Y + mTextBubble.Size.Height + 8);
+
+            mResponseView.Add(mResponseBubble);
+            Window.Instance.Add(mResponseView);
+        }
     }
 
 }
\ No newline at end of file
index 847604a3fc54df09ab631c8f088f5fc869a5add1..6456103afc5f218982486b397f164cbbaa3e2e6b 100644 (file)
@@ -27,11 +27,7 @@ namespace VoiceTouch
     {
         List<View> tooltips;
 
-        Timer highlightObjectTimer = null;
-        View highlightObjectView = null;
-
         View highlightTooltipView = null;
-        Timer highlightTooltipTimer = null;
 
         static readonly int minWidth = 40;
         static readonly int tooltipHeight = 40;
@@ -110,13 +106,17 @@ namespace VoiceTouch
                     VerticalAlignment = VerticalAlignment.Center,
                     CornerRadius = new Vector4(0, 12, 0, 12),
                     Padding = new Extents(10, 10, 4, 4),
+                    EnableAutoScroll = true,
+                    AutoScrollSpeed = 40, // 100px per second
+                    AutoScrollLoopCount = 0, //infite loop
+                    AutoScrollGap = w - 20,
                 };
 
                 tooltipView = new View()
                 {
                     Size2D = new Size2D(w, tooltipHeight),
                 };
-                tooltipTextLabel.Position = new Position(x + w - tooltipTextLabel.NaturalSize.Width, y);
+                tooltipTextLabel.Position = new Position(x + w - tooltipTextLabel.Size.Width, y);
             }
 
             tooltipView.Add(tooltipTextLabel);
index e171aaeb016254fa1259aef3574aa09da0bd8c85..2a6bc037dc09cf511900f3341efcc45a56a22132 100644 (file)
@@ -44,7 +44,7 @@ namespace VoiceTouch
             window.SetNotificationLevel(NotificationLevel.Top);
             window.SetTransparency(true);
             window.BackgroundColor = Color.Transparent;
-            window.SetAcceptFocus(true);
+            window.SetAcceptFocus(false);
             window.SetInputRegion(new Rectangle(0, 0, 0, 0));
 
             mVoiceTouchMmiManager = new VoiceTouchMmiManager();
index b93eb9c5073ef6c9dfc9e53c0338635796b02e52..ab567fe1d0ec7f5b28116dff60f359f3f78b18d7 100644 (file)
@@ -62,7 +62,14 @@ namespace VoiceTouch
                         }
                         return;
                     case UI_CLICKED_OBJECT:
-                        mVoiceTouchViewManager.HighlightTooltip(voiceTouchResult.uiClickedObject.infoOfClickedObjects, previousTooltipType);
+                        if (voiceTouchResult.uiClickedObject.uiObjectResultType == UI_OBJECT_RESULT_BY_GRID)
+                        {
+                            mVoiceTouchViewManager.HighlightGrid(voiceTouchResult.uiClickedObject.infoOfClickedObjects, voiceTouchResult.uiClickedObject.gridDepth);
+                        }
+                        else
+                        {
+                            mVoiceTouchViewManager.HighlightTooltip(voiceTouchResult.uiClickedObject.infoOfClickedObjects, previousTooltipType);
+                        }
                         return;
                     case ASR_PARTIAL_RESULT:
                         mVoiceTouchViewManager.ShowAsrPartialResult(voiceTouchResult.asrPartialResult.result);
@@ -71,7 +78,8 @@ namespace VoiceTouch
                         mVoiceTouchViewManager.ShowAsrFinalResult(voiceTouchResult.asrFinalResult.result);
                         return;
                     case REJECT:
-                        mVoiceTouchViewManager.ShowAsrFinalResult(voiceTouchResult.reject.reason);
+                        // mVoiceTouchViewManager.ShowResponse(voiceTouchResult.reject.reason);
+                        mVoiceTouchViewManager.ShowResponse("Sorry, I don't know how to help with that. Let's try again.");
                         return;
                     case ERROR:
                         mVoiceTouchViewManager.ShowAsrFinalResult(voiceTouchResult.error.reason);
index bc4d492fa4a24867af122cd291fd90002b5212e1..fa199eaaccfac82d9c55287187b668a1e114d893 100644 (file)
@@ -48,6 +48,8 @@ namespace VoiceTouch.VoiceTouchMmi
         public string foregroundApp;
         public ClickableObject infoOfClickedObjects;
         public int timestamp;
+        public string uiObjectResultType;
+        public int gridDepth;
     }
     class ASRResult
     {
index 80770018c396a41525fa53fc6e0746a83e90b749..67a5481f0470037ced1c29fb92d1978244aea06e 100644 (file)
@@ -33,9 +33,18 @@ namespace VoiceTouch
         protected TextBubbleLayer mTextBubbleLayer = null;
         protected GridLayer mGridLayer = null;
 
-        internal uint responseMilliseconds = 5000;
-        internal uint successMilliseconds = 1000;
-        protected TimerState currentTimerState;
+        protected Timer mResponseTimer = null;
+        protected Timer mTooltipTimer = null;
+        protected Timer mHighlightTooltipTimer = null;
+        protected Timer mGridTimer = null;
+        protected Timer mHighlightGridTimer = null;
+
+        internal uint responseMilliseconds = 2000;
+        internal uint successMilliseconds = 2000;
+        protected TimerState currentTextBubbleTimerState;
+        protected TimerState currentResponseBubbleTimerState;
+        protected TimerState currentHighlightTooltipTimerState;
+        protected TimerState currentHighlightGridTimerState;
         public enum TimerState
         {
             Inactive = 0,
@@ -56,7 +65,10 @@ namespace VoiceTouch
             mTextBubbleLayer = new TextBubbleLayer();
             mTooltipLayer = new TooltipLayer();
             mGridLayer = new GridLayer();
-            currentTimerState = TimerState.Inactive;
+            currentTextBubbleTimerState = TimerState.Inactive;
+            currentResponseBubbleTimerState = TimerState.Inactive;
+            currentHighlightTooltipTimerState = TimerState.Inactive;
+            currentHighlightGridTimerState = TimerState.Inactive;
             currentVoiceTouchState = VoiceTouchState.Idle;
         }
 
@@ -120,7 +132,7 @@ namespace VoiceTouch
         /// <param name="asrPartialResult"></param>
         public void ShowAsrPartialResult(string asrPartialResult)
         {
-            if (currentTimerState == TimerState.Active)
+            if (currentTextBubbleTimerState == TimerState.Active)
             {
                 return;
             }
@@ -141,9 +153,9 @@ namespace VoiceTouch
         /// <param name="asrFinalResult"></param>
         public void ShowAsrFinalResult(string asrFinalResult)
         {
-            if (currentTimerState == TimerState.Active)
+            if (currentTextBubbleTimerState == TimerState.Active)
             {
-                currentTimerState = TimerState.Inactive;
+                currentTextBubbleTimerState = TimerState.Inactive;
                 mGridLayer.ClearHighlightedGrid();
                 mTooltipLayer.ClearHighlightedTooltip();
             }
@@ -163,11 +175,11 @@ namespace VoiceTouch
         /// <param name="asrFinalResult"></param>
         public void ShowResponse(string response)
         {
-            mTextBubbleLayer.CreateTextBubble(response, new Color("#666666"));
-            Timer timer = new Timer(responseMilliseconds);
-            timer.Tick += ClearTextBubble;
-            timer.Start();
-            currentTimerState = TimerState.Active;
+            mTextBubbleLayer.CreateResponseBubble(response, new Color("#666666"));
+            mResponseTimer = new Timer(responseMilliseconds);
+            mResponseTimer.Tick += ClearResponseBubble;
+            mResponseTimer.Start();
+            currentResponseBubbleTimerState = TimerState.Active;
         }
 
         /// <summary>
@@ -177,7 +189,6 @@ namespace VoiceTouch
         /// <param name="tooltipMode">number, name</param>
         public void ShowTooltip(List<ClickableObject> objs, string tooltipMode)
         {
-            Tizen.Log.Error("Tizen.Mmi", "show tooltip");
             mGridLayer.ClearGrid();
             if (tooltipMode == "tooltipNumber")
             {
@@ -187,12 +198,11 @@ namespace VoiceTouch
             {
                 mTooltipLayer.CreateNameTooltips(objs);
             }
-            Tizen.Log.Error("Tizen.Mmi", "show tooltip");
             // add timer for remove final result text bubble
-            Timer timer = new Timer(successMilliseconds);
-            timer.Tick += ClearTextBubble;
-            timer.Start();
-            currentTimerState = TimerState.Active;
+            mTooltipTimer = new Timer(successMilliseconds);
+            mTooltipTimer.Tick += ClearTextBubble;
+            mTooltipTimer.Start();
+            currentTextBubbleTimerState = TimerState.Active;
         }
 
         /// <summary>
@@ -205,10 +215,10 @@ namespace VoiceTouch
         {
             mTooltipLayer.HighlightTooltip(obj, tooltipMode);
             // add timer for remove final result text bubble, highlighted tooltip
-            Timer timer = new Timer(successMilliseconds);
-            timer.Tick += ClearHighlightedTooltip;
-            timer.Start();
-            currentTimerState = TimerState.Active;
+            mHighlightTooltipTimer = new Timer(successMilliseconds);
+            mHighlightTooltipTimer.Tick += ClearHighlightedTooltip;
+            mHighlightTooltipTimer.Start();
+            currentHighlightTooltipTimerState = TimerState.Active;
         }
 
         /// <summary>
@@ -229,10 +239,10 @@ namespace VoiceTouch
             }
             // add timer for remove final result text bubble
 
-            Timer timer = new Timer(successMilliseconds);
-            timer.Tick += ClearHighlightedGrid;
-            timer.Start();
-            currentTimerState = TimerState.Active;
+            mGridTimer = new Timer(successMilliseconds);
+            mGridTimer.Tick += ClearTextBubble;
+            mGridTimer.Start();
+            currentTextBubbleTimerState = TimerState.Active;
         }
 
         /// <summary>
@@ -241,14 +251,14 @@ namespace VoiceTouch
         /// </summary>
         /// <param name="obj">Clicked grid info</param>
         /// <param name="idx">index of grid info</param>
-        public void HighlightGrid(ClickableObject obj, int idx)
+        public void HighlightGrid(ClickableObject obj, int depth)
         {
-            mGridLayer.HighlightGrid(obj, idx);
+            mGridLayer.HighlightGrid(obj, depth);
             // add timer for remove final result text bubble, highlighted tooltip
-            Timer timer = new Timer(successMilliseconds);
-            timer.Tick += ClearHighlightedGrid;
-            timer.Start();
-            currentTimerState = TimerState.Active;
+            mHighlightGridTimer = new Timer(successMilliseconds);
+            mHighlightGridTimer.Tick += ClearHighlightedGrid;
+            mHighlightGridTimer.Start();
+            currentHighlightGridTimerState = TimerState.Active;
         }
 
         /// <summary>
@@ -256,43 +266,41 @@ namespace VoiceTouch
         /// </summary>
         public void ClearAll()
         {
-            mTextBubbleLayer.CleartextBubbles();
+            mTextBubbleLayer.ClearTextBubbles();
             mTooltipLayer.ClearTooltips();
             mGridLayer.ClearGrid();
         }
 
-        private bool ClearTextBubble(object target, Timer.TickEventArgs args)
+        public bool ClearTextBubble(object target, Timer.TickEventArgs args)
         {
-            if (currentTimerState == TimerState.Inactive)
-            {
-                return false;
-            }
-            mTextBubbleLayer.CleartextBubbles();
-            currentTimerState = TimerState.Inactive;
+            mTextBubbleLayer.ClearTextBubbles();
+            currentTextBubbleTimerState = TimerState.Inactive;
             return false;
         }
 
-        private bool ClearHighlightedTooltip(object target, Timer.TickEventArgs args)
+        public bool ClearResponseBubble(object target, Timer.TickEventArgs args)
+        {
+            mTextBubbleLayer.ClearResponseBubbles();
+            mResponseTimer = null;
+            currentResponseBubbleTimerState = TimerState.Inactive;
+            return false;
+        }
+
+        public bool ClearHighlightedTooltip(object target, Timer.TickEventArgs args)
         {
-            if (currentTimerState == TimerState.Inactive)
-            {
-                return false;
-            }
             mTooltipLayer.ClearHighlightedTooltip();
-            mTextBubbleLayer.CleartextBubbles();
-            currentTimerState = TimerState.Inactive;
+            mTextBubbleLayer.ClearTextBubbles();
+            mHighlightTooltipTimer = null;
+            currentHighlightTooltipTimerState = TimerState.Inactive;
             return false;
         }
 
-        private bool ClearHighlightedGrid(object target, Timer.TickEventArgs args)
+        public bool ClearHighlightedGrid(object target, Timer.TickEventArgs args)
         {
-            if (currentTimerState == TimerState.Inactive)
-            {
-                return false;
-            }
             mGridLayer.ClearHighlightedGrid();
-            mTextBubbleLayer.CleartextBubbles();
-            currentTimerState = TimerState.Inactive;
+            mTextBubbleLayer.ClearTextBubbles();
+            mHighlightGridTimer = null;
+            currentHighlightGridTimerState = TimerState.Inactive;
             return false;
         }
     }