From: Md. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics Date: Tue, 9 Jul 2024 12:01:34 +0000 (+0600) Subject: Fix window position and size issue in low resolution. X-Git-Tag: accepted/tizen/unified/20240715.155415~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F70%2F314270%2F1;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. [Cause & Measure] Cause : Base NUIApplication window size and position is being initialized with default value due to Tizen.System.TryGetValue giving static resolution. Measure : NUIApplication is initialized with smaller initial window size and postion and later resized according to resolution in OnCreate. Change-Id: Ie233a18f14a8abcec11b3eec160291b7278ce0be Signed-off-by: Md. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics --- diff --git a/Notifications/CustomBorder.cs b/Notifications/CustomBorder.cs index c2625d5..69290d0 100644 --- a/Notifications/CustomBorder.cs +++ b/Notifications/CustomBorder.cs @@ -47,6 +47,16 @@ namespace Notifications int minHeight = (int)(screenSize.Height * minHeightRatio); MinSize = new Size2D(minWidth, minHeight); } + + public void UpdateMinSize(Size2D screenSize) + { + 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 857b146..c4dd842 100644 --- a/Notifications/Notifications.cs +++ b/Notifications/Notifications.cs @@ -20,7 +20,6 @@ using System.Globalization; using Tizen.NUI; using Notifications.Common; using Notifications.Core; -using Tizen.System; namespace Notifications { @@ -28,6 +27,7 @@ namespace Notifications { private Window window; private ViewManager viewManager; + private static CustomBorder appBorder; public Program(Size2D windowSize, Position2D windowPosition, CustomBorder appBorder) : base(windowSize, windowPosition, ThemeOptions.PlatformThemeEnabled, appBorder) { @@ -56,9 +56,8 @@ namespace Notifications }; window.SetAvailableOrientations(list); - + appBorder.UpdateMinSize(GetScreenSize()); WindowManager.UpdateWindowPositionSize(); - window.BackgroundColor = Color.Transparent; window.OrientationChanged += OnWindowOrientationChanged; viewManager = new ViewManager(); @@ -101,26 +100,8 @@ namespace Notifications static void Main(string[] args) { - 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); + appBorder = new CustomBorder(new Size2D(800, 480)); + var app = new Program(new Size2D(10, 10), new Position2D(0,0), appBorder); app.Run(args); } diff --git a/packaging/org.tizen.notifications-1.0.1.tpk b/packaging/org.tizen.notifications-1.0.1.tpk index 10bb2f9..4326f5a 100644 Binary files a/packaging/org.tizen.notifications-1.0.1.tpk and b/packaging/org.tizen.notifications-1.0.1.tpk differ