Fix window position issue in vertical orientation. 42/313542/1
authorAzijur Rahman Sheatu <azijur.r@samsung.com>
Thu, 27 Jun 2024 13:34:30 +0000 (19:34 +0600)
committerAzijur Rahman Sheatu <azijur.r@samsung.com>
Thu, 27 Jun 2024 13:35:27 +0000 (19:35 +0600)
[Issue] TNINE-371

[Problem] When opening in vertical orientation the window border is positioned on the left side not centered.
[Cause & Measure]
 Cause : Window size and positions were not calculated properly.
 Measure : Window size and positions are applied accordingly to the GUI guide.

Change-Id: Ia4aa0f5cf81ff203226e73d394bab6211da690b7
Signed-off-by: Azijur Rahman Sheatu <azijur.r@samsung.com>
Notifications/Common/AppConstants.cs
Notifications/Common/DeviceInfo.cs
Notifications/Notifications.cs
Notifications/core/WindowManager.cs [new file with mode: 0644]
packaging/org.tizen.notifications-1.0.1.tpk

index 4131ae5bc019554f69fdc40cb9b81b6e41da757c..1801f06b39e6da45cc3c129d4e8dae649041fe3b 100644 (file)
@@ -38,5 +38,8 @@ namespace Notifications.Common
         public static Extents BaseViewPadding = new Extents(0, 0, 20, 20);
         public static Extents HeaderPadding = new Extents(16, 16, 8, 8);
         public static Extents DetailContentMargin = new Extents(64, 64, 8, 8);
+
+        public static float windowHeightRatio = 540f / 1080;
+        public static float windowWidthRation = 960f / 1920;
     }
 }
index aa17f4231b012096db35d287ace1fe5ba82fb0c3..d66c401f2c79c9bb01ffab5d57df28e67db9c9bc 100644 (file)
@@ -1,5 +1,20 @@
-using Tizen.NUI;
-using Tizen.System;
+/*
+ *  Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+using Tizen.NUI;
 
 namespace Notifications.Common
 {
@@ -8,19 +23,13 @@ namespace Notifications.Common
         private static int width;
         private static int height;
         private static Window.WindowOrientation orientation;
-        private const string WidthKey = "tizen.org/feature/screen.width";
-        private const string HeightKey = "tizen.org/feature/screen.height";
 
         static DeviceInfo()
         {
-            bool isWidthAvailable = Information.TryGetValue(WidthKey, out width);
-            bool isHeightAvailable = Information.TryGetValue(HeightKey, out height);
-            if (isHeightAvailable == false || isWidthAvailable == false)
-            {
-                width = 1280;
-                height = 720;
-                Tizen.Log.Debug(AppConstants.LogTag, "Width and height are not available , setting default size as 1280 x 720");
-            }
+            Size displaySize = NUIApplication.GetScreenSize();
+            width = (int)displaySize.Width;
+            height = (int)displaySize.Height;
+
             orientation = Window.Instance.GetCurrentOrientation();
             IsPortrait = orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse;
         }
index 9bb26868799d876c75b01164b2902ad7c84a979c..03709e316233502bab7d339bf671a39df02d43c1 100644 (file)
@@ -19,6 +19,7 @@ using System.Collections.Generic;
 using System.Globalization;
 using Tizen.NUI;
 using Notifications.Common;
+using Notifications.Core;
 
 namespace Notifications
 {
@@ -54,46 +55,19 @@ namespace Notifications
             };
 
             window.SetAvailableOrientations(list);
-            UpdateWindowSize();
-            UpdateWindowPosition();
+
+            WindowManager.UpdateWindowPositionSize();
+
             window.BackgroundColor = Color.Transparent;
             window.OrientationChanged += OnWindowOrientationChanged;
             viewManager = new ViewManager();
         }
 
-        private void UpdateWindowSize()
-        {
-            int width, height;
-            if (DeviceInfo.IsPortrait)
-            {
-                width = DeviceInfo.DisplayHeight / 2;
-                height = DeviceInfo.DisplayWidth / 2;
-            }
-            else
-            {
-                width = DeviceInfo.DisplayWidth / 2;
-                height = DeviceInfo.DisplayHeight / 2;
-            }
-            window.WindowSize = new Size2D(width, height - AppConstants.BorderHeight.SpToPx());
-            Tizen.Log.Info(AppConstants.LogTag, "width is: " + window.WindowSize.Width);
-            Tizen.Log.Info(AppConstants.LogTag, "height is: " + window.WindowSize.Height);
-        }
-
-        private void UpdateWindowPosition()
-        {
-            int positionX = (DeviceInfo.DisplayWidth - window.WindowSize.Width) / 2;
-            int positionY = (DeviceInfo.DisplayHeight - window.WindowSize.Height) / 2;
-            window.WindowPosition = new Position2D(positionX, positionY);
-            Tizen.Log.Info(AppConstants.LogTag, "position X is: " + window.WindowPosition.X);
-            Tizen.Log.Info(AppConstants.LogTag, "position Y is: " + window.WindowPosition.Y);
-        }
-
         private void OnWindowOrientationChanged(object sender, WindowOrientationChangedEventArgs e)
         {
             Tizen.Log.Debug(AppConstants.LogTag, "orientation changed" + e.WindowOrientation);
-            DeviceInfo.UpdateDeviceInfo();
-            UpdateWindowSize();
-            UpdateWindowPosition();
+
+            WindowManager.UpdateWindowPositionSize();
         }
 
         private void SetupLanguage()
diff --git a/Notifications/core/WindowManager.cs b/Notifications/core/WindowManager.cs
new file mode 100644 (file)
index 0000000..f39f18f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+using Notifications.Common;
+using Tizen.NUI;
+
+namespace Notifications.Core
+{
+    public static class WindowManager
+    {
+        private static Window window;
+
+        static WindowManager()
+        {
+            window = Window.Instance;
+        }
+
+        public static void UpdateWindowPositionSize()
+        {
+            DeviceInfo.UpdateDeviceInfo();
+
+            int positionX, positionY;
+            int width, height;
+
+            width = (int)(DeviceInfo.DisplayWidth * AppConstants.windowWidthRation);
+            height = (int)(DeviceInfo.DisplayHeight * AppConstants.windowHeightRatio);
+
+            positionX = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) - width) / 2;
+            positionY = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayWidth : DeviceInfo.DisplayHeight) - height) / 2;
+
+            if (DeviceInfo.IsPortrait)
+            {
+                (width, height) = (height, width);
+                (positionX, positionY) = (positionY, positionX);
+            }
+
+            window.WindowPositionSize = new Rectangle(positionX, positionY, width, height);
+
+            Tizen.Log.Info(AppConstants.LogTag, "width is: " + window.WindowSize.Width);
+            Tizen.Log.Info(AppConstants.LogTag, "height is: " + window.WindowSize.Height);
+            Tizen.Log.Info(AppConstants.LogTag, "position X is: " + window.WindowPosition.X);
+            Tizen.Log.Info(AppConstants.LogTag, "position Y is: " + window.WindowPosition.Y);
+        }
+    }
+}
index acdea9151139539093b48217dd783e0878b5df13..19ea1e6fef17618716895dc1b6e9252034227e16 100644 (file)
Binary files a/packaging/org.tizen.notifications-1.0.1.tpk and b/packaging/org.tizen.notifications-1.0.1.tpk differ