Modifying More Menu and Uninstall Popup for TaskbarService Window 72/297272/2 accepted/tizen/unified/20230821.032722
authorShivam Varshney/Core S/W Group /SRI-Delhi/Engineer/Samsung Electronics <shivam.v2@samsung.com>
Wed, 16 Aug 2023 06:27:22 +0000 (11:57 +0530)
committerShivam Varshney/Core S/W Group /SRI-Delhi/Engineer/Samsung Electronics <shivam.v2@samsung.com>
Fri, 18 Aug 2023 06:54:30 +0000 (12:24 +0530)
Change-Id: Ia16f5153d134aa7826e72130fbe850dc0236187d
Signed-off-by: Shivam Varshney/Core S/W Group /SRI-Delhi/Engineer/Samsung Electronics <shivam.v2@samsung.com>
TaskBar/Common/DeviceInfo.cs
TaskBar/Common/Resources.cs
TaskBar/TaskBar.cs
TaskBar/Views/AppItemView.cs
TaskBar/Views/CustomMenu.cs
TaskBar/Views/MainView.cs
TaskBar/Views/UninstallConfirmationView.cs
packaging/org.tizen.taskbar-1.0.0.tpk

index 88f3b8f..2e719f8 100644 (file)
@@ -1,4 +1,5 @@
 using Tizen.NUI;
+using Tizen.NUI.WindowSystem.Shell;
 
 namespace TaskBar.Common
 {
@@ -7,6 +8,7 @@ namespace TaskBar.Common
         private int width;
         private int height;
         private Window.WindowOrientation orientation;
+        private Window.WindowOrientation naturalDeviceOrientation;
 
         private static readonly DeviceInfo instance = new DeviceInfo();
 
@@ -16,6 +18,8 @@ namespace TaskBar.Common
             height = Window.Instance.Size.Height;
             IsPortrait = width < height;
             orientation = Window.Instance.GetCurrentOrientation();
+            naturalDeviceOrientation = Window.Instance.GetCurrentOrientation();
+            TaskbarPosition = TaskbarService.PlaceType.Bottom;
             if (orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse)
             {
                 if (IsPortrait == false)
@@ -34,6 +38,8 @@ namespace TaskBar.Common
         public void UpdateDeviceInfo()
         {
             Window.WindowOrientation currentOrientation = Window.Instance.GetCurrentOrientation();
+            Tizen.Log.Info(Resources.LogTag, "new Orientation: " + currentOrientation);
+            UpdateTaskbarPosition(currentOrientation);
             if (orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse)
             {
                 if (currentOrientation == Window.WindowOrientation.Landscape || currentOrientation == Window.WindowOrientation.LandscapeInverse)
@@ -51,6 +57,34 @@ namespace TaskBar.Common
             orientation = currentOrientation;
         }
 
+        public void SetFullInputRegion()
+        {
+            Window.Instance.SetInputRegion(new Rectangle(0, 0, width, height));
+        }
+
+        public void SetTaskbarInputRegion()
+        {
+            int sizeWidth = width;
+            int sizeHeight = Resources.TaskbarHeight.SpToPx();
+            int positionX = 0;
+            int positionY = height - sizeHeight;
+            Window.Instance.SetInputRegion(new Rectangle(positionX, positionY, sizeWidth, sizeHeight));
+        }
+
+        private void UpdateTaskbarPosition(Window.WindowOrientation newOrientation)
+        {
+            int difference = (newOrientation - naturalDeviceOrientation) / 90;
+            difference = difference >= 0 ? difference : 4 + difference;
+            TaskbarPosition = difference switch
+            {
+                1 => TaskbarService.PlaceType.Left,
+                2 => TaskbarService.PlaceType.Top,
+                3 => TaskbarService.PlaceType.Right,
+                _ => TaskbarService.PlaceType.Bottom,
+            };
+            Tizen.Log.Info(Resources.LogTag, "new Position: " + TaskbarPosition);
+        }
+
         private void ToggleOrientation()
         {
             (width, height) = (height, width);
@@ -62,5 +96,7 @@ namespace TaskBar.Common
         public int DisplayWidth { get => width; }
 
         public int DisplayHeight { get => height; }
+
+        public TaskbarService.PlaceType TaskbarPosition { get; private set; }
     }
 }
index f4673b9..634b0cb 100644 (file)
@@ -13,12 +13,12 @@ namespace TaskBar.Common
         public static readonly Color LightMenuBackground = new Color(0.98f, 0.98f, 0.98f, 0.5f);
         public static readonly Color DarkMenuBackground = new Color(0.0863f, 0.0745f, 0.1020f, 0.5f);
 
+        public const int TaskbarHeight = 64;
         public const int MenuItemWidth = 220;
         public const int MenuItemHeight = 44;
         public static readonly Vector4 SingleItemCornerRadius = new Vector4(8, 8, 8, 8);
         public static readonly Vector4 TopItemCornerRadius = new Vector4(8, 8, 0, 0);
         public static readonly Vector4 BottomItemCornerRadius = new Vector4(0, 0, 8, 8);
-        private static Window moreMenuWindow;
 
         public static string GetImagePath()
         {
@@ -44,34 +44,5 @@ namespace TaskBar.Common
         {
             return (ThemeManager.PlatformThemeId == LightPlatformThemeId) ? GetLightImagePath() : GetDarkImagePath();
         }
-
-        public static Window MoreMenuWindow
-        {
-            get
-            {
-                if (moreMenuWindow == null)
-                {
-                    Tizen.Log.Info(LogTag, "Create menu window");
-                    moreMenuWindow = new Window();
-                    moreMenuWindow.SetTransparency(true);
-                    moreMenuWindow.BackgroundColor = Color.Transparent;
-                    List<Window.WindowOrientation> list = new List<Window.WindowOrientation>
-                    {
-                        Window.WindowOrientation.Landscape,
-                        Window.WindowOrientation.LandscapeInverse,
-                        Window.WindowOrientation.NoOrientationPreference,
-                        Window.WindowOrientation.Portrait,
-                        Window.WindowOrientation.PortraitInverse
-                    };
-                    moreMenuWindow.SetAvailableOrientations(list);
-                }
-                return moreMenuWindow;
-            }
-        }
-
-        public static void DisposeMoreMenuWindow()
-        {
-            moreMenuWindow?.Dispose();
-        }
     }
 }
\ No newline at end of file
index b8f3083..7e28604 100644 (file)
@@ -13,11 +13,6 @@ namespace TaskBar
         {
         }
 
-        private const int WindowHeight = 64;
-        private bool isTaskBarVisible = true;
-
-        private TaskbarService.PlaceType taskBarPosition;
-
         private static Window window;
         private MainView mainView;
         private TizenShell tizenShell;
@@ -36,15 +31,13 @@ namespace TaskBar
                 Window.WindowOrientation.PortraitInverse
             };
             window.SetAvailableOrientations(list);
-
-            UpdateWindowDimensions();
             window.SetTransparency(true);
             window.BackgroundColor = Color.Transparent;
 
             tizenShell = new TizenShell();
-            taskBarPosition = TaskbarService.PlaceType.Bottom;
-            taskbarService = new TaskbarService(tizenShell, window, taskBarPosition);
-            taskbarService.SetSize((uint)window.Size.Width, (uint)window.Size.Height);
+            taskbarService = new TaskbarService(tizenShell, window);
+            taskbarService.SetSize((uint)DeviceInfo.Instance.DisplayWidth, (uint)Resources.TaskbarHeight.SpToPx());
+            DeviceInfo.Instance.SetTaskbarInputRegion();
 
             PinnedAppsDataBase.Instance.InitializeDataBase();
 
@@ -53,20 +46,11 @@ namespace TaskBar
             window.OrientationChanged += OnOrientationChanged;
         }
 
-        private void UpdateWindowDimensions()
-        {
-            int sizeWidth = DeviceInfo.Instance.DisplayWidth;
-            int sizeHeight = WindowHeight.SpToPx();
-            int positionX = 0;
-            int positionY = DeviceInfo.Instance.DisplayHeight - sizeHeight;
-            window.WindowPosition = new Position2D(positionX, positionY);
-            window.WindowSize = new Size2D(sizeWidth, sizeHeight);
-        }
-
         private void OnOrientationChanged(object sender, WindowOrientationChangedEventArgs e)
         {
             DeviceInfo.Instance.UpdateDeviceInfo();
-            UpdateWindowDimensions();
+            DeviceInfo.Instance.SetTaskbarInputRegion();
+            //taskbarService.SetPlaceType(DeviceInfo.Instance.TaskbarPosition);
             mainView.UpdateView();
         }
 
@@ -76,7 +60,6 @@ namespace TaskBar
             window?.Remove(mainView);
             mainView?.Dispose();
             mainView = null;
-            Resources.DisposeMoreMenuWindow();
 
             taskbarService?.Dispose();
             tizenShell?.Dispose();
index 185b7bd..7c1926b 100644 (file)
@@ -86,20 +86,24 @@ namespace TaskBar.Views
 
         private void OnLongPressGestureDetected(object source, LongPressGestureDetector.DetectedEventArgs e)
         {
-            Tizen.Log.Info(Resources.LogTag, "LongPress Detected");
+            Tizen.Log.Info(Resources.LogTag, "LongPress Detected" + e.LongPressGesture.State);
             if (e.LongPressGesture.State == Gesture.StateType.Started)
             {
                 if (menuItemNames != null && menuItemNames.Count > 0)
                 {
                     AddMoreMenu();
                     UpdateMenuItems();
-                    Resources.MoreMenuWindow.SetParent(Window.Instance);
-                    Resources.MoreMenuWindow.Show();
-                    Resources.MoreMenuWindow.Raise();
-                    moreMenu.SetScrimAttributes(Resources.MoreMenuWindow);
-                    moreMenu.Post(Resources.MoreMenuWindow);
+                    moreMenu.SetScrimAttributes();
+                    moreMenu.Post();
+                    //Input region is set to Full screen when more menu is added.
+                    DeviceInfo.Instance.SetFullInputRegion();
+                    AppIcon.IsEnabled = false;
                 }
             }
+            else
+            {
+                AppIcon.IsEnabled = true;
+            }
         }
 
         private void AddButton()
@@ -161,7 +165,7 @@ namespace TaskBar.Views
             moreMenuWidth = Resources.MenuItemWidth.SpToPx();
             moreMenuHeight = (menuItemNames.Count * Resources.MenuItemHeight).SpToPx();
             moreMenuPositionX = (int)ScreenPosition.X;
-            moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Window.Instance.WindowSize.Height - moreMenuHeight;
+            moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx() - moreMenuHeight;
             if (moreMenu == null)
             {
                 Tizen.Log.Info(Resources.LogTag, "Custom Menu");
@@ -173,12 +177,11 @@ namespace TaskBar.Views
             moreMenu.Position2D = new Position2D(moreMenuPositionX, moreMenuPositionY);
             moreMenu.VisibilityChanged += (object sender, VisibilityChangedEventArgs e) =>
             {
-                // when more menu is dismissed, its visibilty state changes to false, and window hide is handled here.
+                // when more menu is dismissed, its visibilty state changes to false, and input region is updated again.
                 if (e.Visibility == false)
                 {
+                    DeviceInfo.Instance.SetTaskbarInputRegion();
                     DisposeMenuItems();
-                    Resources.MoreMenuWindow.Unparent();
-                    Resources.MoreMenuWindow.Hide();
                 }
             };
         }
@@ -229,9 +232,10 @@ namespace TaskBar.Views
         private void OnItemClicked(object sender, ClickedEventArgs e)
         {
             MenuItem item = sender as MenuItem;
-            MenuItemSelectCommand.Execute(item.Text);
+            string itemText = item.Text;
             DisposeMenuItems();
             DisposeMoreMenu();
+            MenuItemSelectCommand.Execute(itemText);
         }
 
         private void DisposeMenuItems()
@@ -254,9 +258,6 @@ namespace TaskBar.Views
             {
                 moreMenu.Dismiss();
                 moreMenu = null;
-
-                Resources.MoreMenuWindow.Unparent();
-                Resources.MoreMenuWindow.Hide();
             }
         }
 
index ddb03cb..ab06183 100644 (file)
@@ -21,14 +21,10 @@ namespace TaskBar.Views
             Tizen.Log.Info(Resources.LogTag, "Custom Menu with MenuStyle");
         }
 
-        public void SetScrimAttributes(Window win)
+        public void SetScrimAttributes()
         {
-            if (win != null)
-            {
-                Scrim.Size2D = win.Size;
-                Scrim.Position2D = win.WindowPosition;
-                Scrim.BackgroundColor = new Color(0, 0, 0, 0.3f);
-            }
+            Scrim.BackgroundColor = new Color(0, 0, 0, 0.3f);
+            Scrim.AllowOnlyOwnTouch = true;
         }
     }
 }
index 49bbbd1..c8aace7 100644 (file)
@@ -29,7 +29,9 @@ namespace TaskBar.Views
 
         public MainView() : base()
         {
-            Size2D = Window.Instance.Size;
+            WidthSpecification = DeviceInfo.Instance.DisplayWidth;
+            HeightSpecification = Resources.TaskbarHeight.SpToPx();
+            Position2D = new Position2D(0, DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx());
             CornerRadius = new Vector4(24, 24, 0, 0);
             Layout = new LinearLayout()
             {
@@ -59,7 +61,9 @@ namespace TaskBar.Views
 
         public void UpdateView()
         {
-            Size2D = Window.Instance.Size;
+            WidthSpecification = DeviceInfo.Instance.DisplayWidth;
+            HeightSpecification = Resources.TaskbarHeight.SpToPx();
+            Position2D = new Position2D(0, DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx());
             DisposeMoreMenu();
             quickAccessView.UpdateView();
             applicationsView.UpdateView();
@@ -110,11 +114,15 @@ namespace TaskBar.Views
             if (e.LongPressGesture.State == Gesture.StateType.Started)
             {
                 CreateMoreMenu();
-                Resources.MoreMenuWindow.SetParent(Window.Instance);
-                Resources.MoreMenuWindow.Show();
-                Resources.MoreMenuWindow.Raise();
-                addButtonMoreMenu.SetScrimAttributes(Resources.MoreMenuWindow);
-                addButtonMoreMenu.Post(Resources.MoreMenuWindow);
+                addButtonMoreMenu.SetScrimAttributes();
+                addButtonMoreMenu.Post();
+                //Input region is set to Full screen when more menu is added.
+                DeviceInfo.Instance.SetFullInputRegion();
+                addPinnedAppsButton.IsEnabled = false;
+            }
+            else if (e.LongPressGesture.State == Gesture.StateType.Finished)
+            {
+                addPinnedAppsButton.IsEnabled = true;
             }
         }
 
@@ -123,7 +131,7 @@ namespace TaskBar.Views
             moreMenuWidth = Resources.MenuItemWidth.SpToPx();
             moreMenuHeight = Resources.MenuItemHeight.SpToPx();
             moreMenuPositionX = (int)addPinnedAppsButton.ScreenPosition.X;
-            moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Window.Instance.WindowSize.Height - moreMenuHeight;
+            moreMenuPositionY = DeviceInfo.Instance.DisplayHeight - Resources.TaskbarHeight.SpToPx() - moreMenuHeight;
             if (addButtonMoreMenu == null)
             {
                 Tizen.Log.Info(Resources.LogTag, "Custom Menu");
@@ -135,11 +143,10 @@ namespace TaskBar.Views
             addButtonMoreMenu.Position2D = new Position2D(moreMenuPositionX, moreMenuPositionY);
             addButtonMoreMenu.VisibilityChanged += (object sender, VisibilityChangedEventArgs e) =>
             {
-                // when more menu is dismissed, its visibilty state changes to false, and window hide is handled here.
+                // when more menu is dismissed, its visibilty state changes to false, and input region is updated again.
                 if (e.Visibility == false)
                 {
-                    Resources.MoreMenuWindow.Unparent();
-                    Resources.MoreMenuWindow.Hide();
+                    DeviceInfo.Instance.SetTaskbarInputRegion();
                 }
             };
             MenuItem item = new MenuItem("MenuItems")
@@ -214,9 +221,6 @@ namespace TaskBar.Views
                 }
                 addButtonMoreMenu.Dismiss();
                 addButtonMoreMenu = null;
-
-                Resources.MoreMenuWindow.Unparent();
-                Resources.MoreMenuWindow.Hide();
             }
         }
 
index 511e371..a887895 100644 (file)
@@ -14,24 +14,11 @@ namespace TaskBar.Views
         public UninstallConfirmationView()
         {
             Tizen.Log.Info(Resources.LogTag, "Popup Added");
-            confirmationPopupWindow = new Window();
-            List<Window.WindowOrientation> list = new List<Window.WindowOrientation>
-            {
-                Window.WindowOrientation.Landscape,
-                Window.WindowOrientation.LandscapeInverse,
-                Window.WindowOrientation.NoOrientationPreference,
-                Window.WindowOrientation.Portrait,
-                Window.WindowOrientation.PortraitInverse
-            };
-            confirmationPopupWindow.SetAvailableOrientations(list);
-
-            confirmationPopupWindow.SetTransparency(true);
-            confirmationPopupWindow.BackgroundColor = Color.Transparent;
             baseView = new View()
             {
                 BackgroundColor = new Color(0, 0, 0, 0.3f),
             };
-            confirmationPopupWindow.Add(baseView);
+            Window.Instance.Add(baseView);
 
             Button cancelButton = new Button("CancelButton");
             Button deleteButton = new Button()
@@ -40,6 +27,7 @@ namespace TaskBar.Views
                 Text = "Delete",
             };
             deleteButton.PointSize = 16.SpToPx();
+
             confirmationPopup = new AlertDialog()
             {
                 StyleName = "AlertDialogBackground",
@@ -48,13 +36,10 @@ namespace TaskBar.Views
                 Actions = new List<Button>() { cancelButton, deleteButton },
             };
             baseView.Add(confirmationPopup);
-            UpdateConfirmationPopupWindowDimensions();
-            confirmationPopupWindow.SetParent(Window.Instance);
-            confirmationPopupWindow.Raise();
-            confirmationPopupWindow.OrientationChanged += (object sender, WindowOrientationChangedEventArgs e) =>
-            {
-                UpdateConfirmationPopupWindowDimensions();
-            };
+            UpdatePopup();
+
+            baseView.TouchEvent += OnBaseViewTouched;
+            Window.Instance.OrientationChanged += OnOrientationChanged;
 
             cancelButton.Clicked += (object sender, ClickedEventArgs e) =>
             {
@@ -67,30 +52,44 @@ namespace TaskBar.Views
             };
         }
 
-        private void UpdateConfirmationPopupWindowDimensions()
+        private bool OnBaseViewTouched(object source, View.TouchEventArgs e)
         {
-            baseView.WidthSpecification = confirmationPopupWindow.Size.Width;
-            baseView.HeightSpecification = confirmationPopupWindow.Size.Height - Window.Instance.Size.Height;
-            baseView.Remove(confirmationPopup);
-            baseView.Add(confirmationPopup);
+            RemoveConfirmationPopup();
+            return true;
+        }
+
+        private void OnOrientationChanged(object sender, WindowOrientationChangedEventArgs e)
+        {
+            UpdatePopup();
+        }
+
+        private void UpdatePopup()
+        {
+            if (baseView != null)
+            {
+                baseView.Size2D = Window.Instance.Size;
+                baseView.Remove(confirmationPopup);
+                baseView.Add(confirmationPopup);
+                DeviceInfo.Instance.SetFullInputRegion();
+            }
         }
 
         private void RemoveConfirmationPopup()
         {
             if (confirmationPopup != null)
             {
-                confirmationPopupWindow?.Remove(baseView);
+                Window.Instance.Remove(baseView);
                 baseView?.Remove(confirmationPopup);
                 confirmationPopup.Dispose();
                 confirmationPopup = null;
                 baseView?.Dispose();
                 baseView = null;
-                confirmationPopupWindow?.Dispose();
-                confirmationPopupWindow = null;
+
+                Window.Instance.OrientationChanged -= OnOrientationChanged;
+                DeviceInfo.Instance.SetTaskbarInputRegion();
             }
         }
 
-        private Window confirmationPopupWindow;
         private View baseView;
         private AlertDialog confirmationPopup;
     }
index 87315bf..49a3df6 100644 (file)
Binary files a/packaging/org.tizen.taskbar-1.0.0.tpk and b/packaging/org.tizen.taskbar-1.0.0.tpk differ