From: Md. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics Date: Wed, 3 Jul 2024 06:16:06 +0000 (+0600) Subject: Fix window position and size issue in low resolution. X-Git-Tag: accepted/tizen/unified/20240704.075707^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F313882%2F2;p=profile%2Fiot%2Fapps%2Fdotnet%2Fnotifications.git Fix window position and size issue in low resolution. [Problem] When opening in low resolution the window border is positioned on the left side not centered and window size is not properly adjusted according to resolution. [Cause & Measure] Cause : Window size and position isn't properly initialized and inside CustomBorder Constructor, MinSize is set to default value. Measure : Window size, position and MinSize is properly calculated according to screen size. Change-Id: Ife04002276ae819f8314dcdc3b740f5f606ed9db Signed-off-by: Md. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics --- diff --git a/Notifications/Common/AppConstants.cs b/Notifications/Common/AppConstants.cs index 1801f06..618eb33 100644 --- a/Notifications/Common/AppConstants.cs +++ b/Notifications/Common/AppConstants.cs @@ -40,6 +40,6 @@ namespace Notifications.Common public static Extents DetailContentMargin = new Extents(64, 64, 8, 8); public static float windowHeightRatio = 540f / 1080; - public static float windowWidthRation = 960f / 1920; + public static float windowWidthRatio = 960f / 1920; } } diff --git a/Notifications/CustomBorder.cs b/Notifications/CustomBorder.cs index 2661908..c2625d5 100644 --- a/Notifications/CustomBorder.cs +++ b/Notifications/CustomBorder.cs @@ -38,6 +38,15 @@ namespace Notifications MinSize = new Size2D(704, 436); } + public CustomBorder(Size2D screenSize) + { + ResizePolicy = Window.BorderResizePolicyType.Free; + float minWidthRatio = 704.0f / 1920; + float minHeightRatio = 436.0f / 1080; + int minWidth = (int)(screenSize.Width * minWidthRatio); + int minHeight = (int)(screenSize.Height * minHeightRatio); + MinSize = new Size2D(minWidth, minHeight); + } private void OnThemeChanged(object sender, ThemeChangedEventArgs e) { if (e.IsPlatformThemeChanged) diff --git a/Notifications/Notifications.cs b/Notifications/Notifications.cs index 03709e3..857b146 100644 --- a/Notifications/Notifications.cs +++ b/Notifications/Notifications.cs @@ -20,6 +20,7 @@ using System.Globalization; using Tizen.NUI; using Notifications.Common; using Notifications.Core; +using Tizen.System; namespace Notifications { @@ -28,7 +29,7 @@ namespace Notifications private Window window; private ViewManager viewManager; - public Program() : base(AppConstants.DefaultWindowSize, AppConstants.DefaultWindowPosition, ThemeOptions.PlatformThemeEnabled, new CustomBorder()) + public Program(Size2D windowSize, Position2D windowPosition, CustomBorder appBorder) : base(windowSize, windowPosition, ThemeOptions.PlatformThemeEnabled, appBorder) { } @@ -100,7 +101,27 @@ namespace Notifications static void Main(string[] args) { - var app = new Program(); + int positionX, positionY; + int width, height; + + _ = Information.TryGetValue("http://tizen.org/feature/screen.width", out int screenWidth); + _ = Information.TryGetValue("http://tizen.org/feature/screen.height", out int screenHeight); + + Tizen.Log.Debug(AppConstants.LogTag, "screen width : " + screenWidth); + Tizen.Log.Debug(AppConstants.LogTag, "screen height : " + screenHeight); + + Size2D displaySize = new Size2D(screenWidth, screenHeight); + + width = (int)(displaySize.Width * AppConstants.windowWidthRatio); + height = (int)(displaySize.Height * AppConstants.windowHeightRatio); + + positionX = (displaySize.Width - width) / 2; + positionY = (displaySize.Height - height) / 2; + + + CustomBorder appBorder = new CustomBorder(displaySize); + var app = new Program(new Size2D(width, height), new Position2D(positionX, positionY), appBorder); + app.Run(args); } } diff --git a/Notifications/core/WindowManager.cs b/Notifications/core/WindowManager.cs index f39f18f..e082828 100644 --- a/Notifications/core/WindowManager.cs +++ b/Notifications/core/WindowManager.cs @@ -35,7 +35,7 @@ namespace Notifications.Core int positionX, positionY; int width, height; - width = (int)(DeviceInfo.DisplayWidth * AppConstants.windowWidthRation); + width = (int)(DeviceInfo.DisplayWidth * AppConstants.windowWidthRatio); height = (int)(DeviceInfo.DisplayHeight * AppConstants.windowHeightRatio); positionX = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) - width) / 2; diff --git a/packaging/org.tizen.notifications-1.0.1.tpk b/packaging/org.tizen.notifications-1.0.1.tpk index c975e98..10bb2f9 100644 Binary files a/packaging/org.tizen.notifications-1.0.1.tpk and b/packaging/org.tizen.notifications-1.0.1.tpk differ