From ea0c9db6d532ad3e8928a238fd767930988a30ac Mon Sep 17 00:00:00 2001 From: "Yurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics" Date: Mon, 10 Oct 2022 15:58:04 +0200 Subject: [PATCH] update mainview Change-Id: Ie67940561be64490f1fb3770dcd291bc0e1ffed1 --- Oobe/Oobe.Common/Utils/ScreenSizeUtils.cs | 27 ++++++++++++++++++++++++ Oobe/Oobe.Common/ViewModels/BasePageViewModel.cs | 19 +---------------- Oobe/Oobe.Common/Views/TermsView.cs | 5 ----- Oobe/Oobe/OobeApp.cs | 14 +++++++----- Oobe/Oobe/ScalableUI/OrientationalView.cs | 1 - Oobe/Oobe/Views/MainView.cs | 15 +++++++++---- 6 files changed, 48 insertions(+), 33 deletions(-) diff --git a/Oobe/Oobe.Common/Utils/ScreenSizeUtils.cs b/Oobe/Oobe.Common/Utils/ScreenSizeUtils.cs index 23db12f..e5f9ba9 100644 --- a/Oobe/Oobe.Common/Utils/ScreenSizeUtils.cs +++ b/Oobe/Oobe.Common/Utils/ScreenSizeUtils.cs @@ -54,5 +54,32 @@ namespace Oobe.Common.Utils return (textLabel.LineCount - 1) * textLabel.SizeHeight / textLabel.LineCount; } } + + public static float GetScaleFactor() + { + var size = IsPortrait ? Window.Instance.Size.Width : Window.Instance.Size.Height; + switch (size) + { + case 720: + return 0.6f; + case 1080: + return 0.9f; + default: + { + if (size > 1080) + { + return 0.9f; + } + else if (size < 1080 && size > 720) + { + return 0.6f; + } + else + { + return 0.4f; + } + } + } + } } } diff --git a/Oobe/Oobe.Common/ViewModels/BasePageViewModel.cs b/Oobe/Oobe.Common/ViewModels/BasePageViewModel.cs index cec9faa..f5bc987 100644 --- a/Oobe/Oobe.Common/ViewModels/BasePageViewModel.cs +++ b/Oobe/Oobe.Common/ViewModels/BasePageViewModel.cs @@ -96,27 +96,10 @@ namespace Oobe.Common.ViewModels private void SetBackground() { var visualMap = new NPatchVisual(); - visualMap.URL = GetBackgroundUrl(); + visualMap.URL = NUIApplication.Current.DirectoryInfo.Resource + $"page/{fhdBackgroundFile}"; ViewBackground = visualMap.OutputVisualMap; } - private string GetBackgroundUrl() - { - string filename = hdBackgroundFile; - int biggerEdge = Math.Max(Window.Instance.WindowSize.Width, Window.Instance.WindowSize.Height); - if (biggerEdge > 3000) - { - filename = fhdBackgroundFile; - } - else if (biggerEdge < 1500) - { - filename = uhdBackgroundFile; - } - - string bgUrl = NUIApplication.Current.DirectoryInfo.Resource + $"page/{filename}"; - return bgUrl; - } - private void SetTheme(string name) { ThemeManager.ApplyTheme(new Theme(NUIApplication.Current.DirectoryInfo.Resource + $"theme/{name}Theme.xaml")); diff --git a/Oobe/Oobe.Common/Views/TermsView.cs b/Oobe/Oobe.Common/Views/TermsView.cs index daaaa93..957e525 100644 --- a/Oobe/Oobe.Common/Views/TermsView.cs +++ b/Oobe/Oobe.Common/Views/TermsView.cs @@ -85,11 +85,6 @@ namespace Oobe.Common.Views private void ConfigureSize() { var userScale = TextUtils.GetFontSizeScale(SystemSettings.FontSize); - float h2 = (48 * userScale) + (ScreenSizeUtils.IsPortrait ? 72 : 63); - float h1 = (48 * userScale) + 55; - int bounding_height = (int)((ScreenSizeUtils.IsPortrait ? 1616 : 760) - h2 - h1); - - Bounding.Size = SpUtils.ToPixels(ScreenSizeUtils.IsPortrait ? new Size2D(824, bounding_height) : new Size2D(1664, bounding_height)); Footnote.SizeWidth = SpUtils.ToPixels(ScreenSizeUtils.IsPortrait ? 680 : 1520); Linear.CellPadding = SpUtils.ToPixels(new Size2D(20, 20)); AgreeCheckBox.Size2D = SpUtils.ToPixels(new Size2D((int)(userScale * 24), (int)(userScale * 24))); diff --git a/Oobe/Oobe/OobeApp.cs b/Oobe/Oobe/OobeApp.cs index 660e305..dfe5223 100644 --- a/Oobe/Oobe/OobeApp.cs +++ b/Oobe/Oobe/OobeApp.cs @@ -88,10 +88,14 @@ namespace Oobe Window.Instance.Type = WindowType.Notification; Window.Instance.SetNotificationLevel(NotificationLevel.High); - var size = ScreenSizeUtils.IsPortrait ? Window.Instance.Size.Width : Window.Instance.Size.Height; - var scale = size >= 1080 ? 0.9f : 0.6f; - SpUtils.DefaultFactor = (Window.Instance.Dpi.Width / 160) / scale; - Tizen.Log.Debug("oobe", $"DefaultScaleFactor: {SpUtils.DefaultFactor}"); + SetupScaleFactor(); + + ProcessManager.Instance.Start(); + } + + private void SetupScaleFactor() + { + SpUtils.DefaultFactor = (float)SpTypeConverter.Instance.ConvertToPixel(1) / ScreenSizeUtils.GetScaleFactor(); if (Preference.Contains("scale")) { @@ -105,7 +109,7 @@ namespace Oobe } } - ProcessManager.Instance.Start(); + Tizen.Log.Debug("oobe", $"DefaultScaleFactor: {SpUtils.DefaultFactor}"); } private void Start() diff --git a/Oobe/Oobe/ScalableUI/OrientationalView.cs b/Oobe/Oobe/ScalableUI/OrientationalView.cs index 9973fd5..9e34ddd 100644 --- a/Oobe/Oobe/ScalableUI/OrientationalView.cs +++ b/Oobe/Oobe/ScalableUI/OrientationalView.cs @@ -28,7 +28,6 @@ namespace ScalableUI public OrientationalView() { - Size2D = Window.Instance.Size; PositionUsesPivotPoint = true; ParentOrigin = Tizen.NUI.ParentOrigin.Center; PivotPoint = Tizen.NUI.PivotPoint.Center; diff --git a/Oobe/Oobe/Views/MainView.cs b/Oobe/Oobe/Views/MainView.cs index 7ba7e89..0329e38 100644 --- a/Oobe/Oobe/Views/MainView.cs +++ b/Oobe/Oobe/Views/MainView.cs @@ -34,19 +34,26 @@ namespace Oobe.Views public MainView(Window win) : base() { - Size = Window.Instance.Size; - + WidthSpecification = LayoutParamPolicies.MatchParent; + HeightSpecification = LayoutParamPolicies.MatchParent; PositionUsesPivotPoint = true; ParentOrigin = Tizen.NUI.ParentOrigin.Center; PivotPoint = Tizen.NUI.PivotPoint.Center; - Tizen.Log.Debug("oobe", $"this.Size: {this.Size.Width} {this.Size.Height}"); + Layout = new LinearLayout + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }; + + var marginSize = (ScreenSizeUtils.IsPortrait ? win.WindowSize.Height : win.WindowSize.Width) * 0.08f; orientational = new ScalableUI.OrientationalView { - Size = SpUtils.ToPixels(ScreenSizeUtils.IsPortrait ? new Size2D(952, 1792) : new Size2D(1792, 952)), + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.MatchParent, Position2D = new Position2D(0, 0), ScrollDuration = TransitionTime, + Margin = SpUtils.ToPixels(new Extents(0, (ushort)marginSize, 0, (ushort)marginSize)), }; Add(orientational); -- 2.7.4