Fixed CachedData popup navigation issue. 12/318512/3
authorCORP\mobaswirul.i <mobaswirul.i@samsung.com>
Tue, 1 Oct 2024 07:42:06 +0000 (13:42 +0600)
committerCORP\mobaswirul.i <mobaswirul.i@samsung.com>
Tue, 1 Oct 2024 08:06:04 +0000 (14:06 +0600)
[Problem]: [TNINE-4716] Error in navigating from cached data window

[Cause & Measure]
 Cause  : Using DialogPage. DialogPage has issues.
 Measure : Used AlertDialog

Change-Id: I0629056ec5c00669c7106e133a0b4b71cb42c86b

SettingMainGadget/SettingMainGadget/AboutGadget.cs
SettingMainGadget/SettingMainGadget/Common/AppAttributes.cs
SettingMainGadget/SettingMainGadget/StorageGadget.cs

index e4b96412506cfe0677281d5bec525f516978f1bf..21f25836137d7330fd4b9ff8fdbc0de86dc32ecb 100644 (file)
@@ -326,38 +326,37 @@ namespace Setting.Menu
                 BackgroundColor = Color.Transparent,
                 HeightSpecification = LayoutParamPolicies.WrapContent,
                 WidthSpecification = LayoutParamPolicies.MatchParent,
-                Layout = new RelativeLayout()
+                Layout = new FlexLayout()
                 {
-                    Margin = new Extents(0, 0, 0, 0).SpToPx(),
-                    Padding = new Extents(8, 8, 8, 8).SpToPx(),
-                }
-            }; ;
+                    Direction = FlexLayout.FlexDirection.Row,
+                    Justification = FlexLayout.FlexJustification.SpaceBetween,
+                },
+            };
 
             Button cancelButton = new Button("Tizen.NUI.Components.Button.Outlined")
             {
-                Size2D = AppAttributes.PopupActionButtonSize,
                 Name = "AlertDialogCreateButton",
+                Text = "Cancel",
+                WidthResizePolicy = ResizePolicyType.FitToChildren,
+                HeightResizePolicy = ResizePolicyType.FitToChildren,
                 CornerRadius = AppAttributes.PopupActionButtonCornerRadius,
-                Text = "Cancel"
+                Size2D = AppAttributes.PopupActionButtonSize,
+                Margin = AppAttributes.PopupActionButtonMargin,
             };
             buttonArea.Add(cancelButton);
-            RelativeLayout.SetLeftRelativeOffset(cancelButton, 0.0f);
-            RelativeLayout.SetHorizontalAlignment(cancelButton, RelativeLayout.Alignment.Start);
-            RelativeLayout.SetVerticalAlignment(cancelButton, RelativeLayout.Alignment.Start);
 
             renameButton= new Button()
             {
-                Size2D = AppAttributes.PopupActionButtonSize,
                 Name = "AlertDialogCreateButton",
-                CornerRadius = AppAttributes.PopupActionButtonCornerRadius,
                 Text = "Rename",
+                WidthResizePolicy = ResizePolicyType.FitToChildren,
+                HeightResizePolicy = ResizePolicyType.FitToChildren,
+                Size2D = AppAttributes.PopupActionButtonSize,
+                CornerRadius = AppAttributes.PopupActionButtonCornerRadius,
+                Margin = AppAttributes.PopupActionButtonMargin,
             };
             buttonArea.Add(renameButton);
 
-            RelativeLayout.SetRightRelativeOffset(renameButton, 1.0f);
-            RelativeLayout.SetHorizontalAlignment(renameButton, RelativeLayout.Alignment.End);
-            RelativeLayout.SetVerticalAlignment(renameButton, RelativeLayout.Alignment.Start);
-
             warning = new TextLabel(NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_TPOP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED)))
             {
                 PixelSize = 16.SpToPx(),
index b4778fb0c3ddfa688d5cdbfa7e89b7027bdbce69..24b4e9ce3871e032e6dbc6b541e24c1965978c70 100644 (file)
@@ -5,18 +5,21 @@ namespace SettingMainGadget.Common
 {
     public static class AppAttributes
     {
-        public static readonly Window DefaultWindow = NUIApplication.GetDefaultWindow();
+        public static Window DefaultWindow { get => NUIApplication.GetDefaultWindow(); }
 
-        public static readonly Size2D WindowSize = DefaultWindow.Size;
-        public static readonly int WindowWidth = WindowSize.Width;
-        public static readonly int WindowHeight = WindowSize.Height;
+        public static Size2D WindowSize { get => DefaultWindow.Size; }
+        public static int WindowWidth { get => WindowSize.Width; }
+        public static int WindowHeight { get => WindowSize.Height; }
 
-        public static readonly bool IsPortrait = WindowWidth < WindowHeight;
+        public static bool IsPortrait { get => WindowWidth < WindowHeight; }
 
-        public static readonly bool IsLightTheme = ThemeManager.PlatformThemeId == "org.tizen.default-light-theme";
+        public static bool IsLightTheme { get => ThemeManager.PlatformThemeId == "org.tizen.default-light-theme";  }
 
-        public static readonly Size2D PopupActionButtonSize = new (252, 48);
+        public static readonly Size2D PopupActionButtonSize = new(252, 48);
         public static readonly Vector4 PopupActionButtonCornerRadius = 24.SpToPx();
+        public static readonly Extents PopupActionButtonMargin = new Extents(4, 4, 4, 4).SpToPx();
+
         public static readonly Shadow PopupBoxShadow = IsLightTheme ? new Shadow(8.0f, new Color(0.0f, 0.0f, 0.0f, 0.16f), new Vector2(0.0f, 2.0f)) : new Shadow(6.0f, new Color("#FFFFFF29"), new Vector2(0.0f, 1.0f));
+
     }
 }
index 5779c8c73fc6e986b0b0fed1e3ce020065835425..233f3d333db9b05046499671204190957639ad4e 100644 (file)
@@ -13,6 +13,7 @@ using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Components;
 using Tizen.System;
 using Tizen;
+using SettingMainGadget.Common;
 
 namespace Setting.Menu
 {
@@ -31,6 +32,8 @@ namespace Setting.Menu
         private View content;
         private View externalStorage;
 
+        private AlertDialog cachedDataPopupDialog;
+
         private TextWithIconListItem appsItem;
         private TextWithIconListItem cacheItem;
         private TextWithIconListItem systemItem;
@@ -89,14 +92,28 @@ namespace Setting.Menu
                 {
                     storageIndicator.Update();
                 }
+                ContentRelayout();
             };
 
             CreateView();
             Vconf.Notify(VconfCardStatus, OnCardStatusChanged);
 
+            AppAttributes.DefaultWindow.Resized += (o, e) =>
+            {
+                ContentRelayout();
+            };
             return content;
         }
 
+        private void ContentRelayout()
+        {
+            if(cachedDataPopupDialog != null && cachedDataPopupDialog.IsOnWindow)
+            {
+                RemoveCachedDataPopup();
+                ShowCachePopup();
+            }
+        }
+
         protected override void OnDestroy()
         {
             Vconf.Ignore(VconfCardStatus, OnCardStatusChanged);
@@ -521,19 +538,6 @@ namespace Setting.Menu
 
         private void ShowCachePopup()
         {
-            var content = new View()
-            {
-                BackgroundColor = isLightTheme ? new Color("#FAFAFA") : new Color("#16131A"),
-                SizeWidth = 690.SpToPx(),
-                HeightSpecification = LayoutParamPolicies.WrapContent,
-                Layout = new FlexLayout()
-                {
-                    Justification = FlexLayout.FlexJustification.Center,
-                    Direction = FlexLayout.FlexDirection.Column,
-                    Alignment = FlexLayout.AlignmentType.Center,
-                },
-            };
-
             //title text
             var textTitle = new TextLabel(NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_CLEAR_CACHE_DATA)))
             {
@@ -541,20 +545,36 @@ namespace Setting.Menu
                 PixelSize = 24.SpToPx(),
                 Margin = new Extents(0, 0, 24, 16).SpToPx(),
             };
-            FlexLayout.SetFlexAlignmentSelf(textTitle, FlexLayout.AlignmentType.Center);
 
-            content.Add(textTitle);
+            View contentArea = new View()
+            {
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.WrapContent,
+                BackgroundColor = Color.Transparent,
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Vertical,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Top,
+                    Margin = new Extents(0, 0, 8, 16),
+                }
+            };
 
             // main text
-            var textSubTitle = new TextLabel(NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_CACHED_DATA_WILL_BE_CLEARED)))
+            var textSubTitle = new TextLabel()
             {
+                StyleName = "LabelText",
+                ThemeChangeSensitive = true,
+                PixelSize = 18.SpToPx(),
                 FontFamily = "BreezeSans",
-                PixelSize = 24.SpToPx(),
-                Ellipsis = true,
-                Margin = new Extents(32, 32, 0, 40).SpToPx(),
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.WrapContent,
+                HorizontalAlignment = HorizontalAlignment.Center,
+                Text = NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_CACHED_DATA_WILL_BE_CLEARED)),
+                MultiLine = true,
             };
-            FlexLayout.SetFlexAlignmentSelf(textSubTitle, FlexLayout.AlignmentType.FlexStart);
-            content.Add(textSubTitle);
+
+            contentArea.Add(textSubTitle);
 
             // buttons
             View buttons = new View()
@@ -573,15 +593,15 @@ namespace Setting.Menu
                 WidthResizePolicy = ResizePolicyType.FitToChildren,
                 HeightResizePolicy = ResizePolicyType.FitToChildren,
                 Text = NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BODY_CLEAR)),
-                Size = new Size(252, 48).SpToPx(),
-                Margin = new Extents(61, 32, 0, 32).SpToPx(),
+                Size = AppAttributes.PopupActionButtonSize,
+                Margin = AppAttributes.PopupActionButtonMargin,
             };
             clearButton.Clicked += (s, e) =>
             {
                 PackageManager.ClearAllCacheDirectory();
                 // TODO : update cache info
 
-                NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+                RemoveCachedDataPopup();
             };
 
             var cancelButton = new Button("Tizen.NUI.Components.Button.Outlined")
@@ -589,21 +609,49 @@ namespace Setting.Menu
                 WidthResizePolicy = ResizePolicyType.FitToChildren,
                 HeightResizePolicy = ResizePolicyType.FitToChildren,
                 Text = NUIGadgetResourceManager.GetString(nameof(Resources.IDS_ST_BUTTON_CANCEL)),
-                Size = new Size(252, 48).SpToPx(),
-                Margin = new Extents(32, 61, 0, 32).SpToPx(),
+                Size = AppAttributes.PopupActionButtonSize,
+                Margin = AppAttributes.PopupActionButtonMargin,
             };
 
-            cancelButton.Clicked += (s, e) =>
+            buttons.Add(cancelButton);
+            buttons.Add(clearButton);
+
+            cachedDataPopupDialog = new AlertDialog()
             {
-                NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+                ThemeChangeSensitive = true,
+                StyleName = "Dialogs",
+                WidthSpecification = AppAttributes.IsPortrait ? AppAttributes.WindowWidth - 64.SpToPx() : (int)(AppAttributes.WindowWidth * 0.7f),
+                HeightSpecification = LayoutParamPolicies.WrapContent,
+                Layout = new LinearLayout()
+                {
+                    Padding = new Extents(80, 80, 40, 40).SpToPx(),
+                    Margin = new Extents(32, 32, 0, 0).SpToPx(),
+                    LinearOrientation = LinearLayout.Orientation.Vertical,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Top,
+                },
+                TitleContent = textTitle,
+                Content = contentArea,
+                ActionContent = buttons,
+                BoxShadow = AppAttributes.PopupBoxShadow,
             };
 
-            buttons.Add(cancelButton);
-            buttons.Add(clearButton);
+            AppAttributes.DefaultWindow.Add(cachedDataPopupDialog);
 
-            content.Add(buttons);
+            cancelButton.Clicked += (o, e) =>
+            {
+                RemoveCachedDataPopup();
+            };
+        }
 
-            RoundedDialogPage.ShowDialog(content);
+        private void RemoveCachedDataPopup()
+        {
+            if (cachedDataPopupDialog != null)
+            {
+                AppAttributes.DefaultWindow.Remove(cachedDataPopupDialog);
+                cachedDataPopupDialog.Hide();
+                cachedDataPopupDialog.Dispose();
+            }
         }
 
         private void OnMediaInfoUpdated(object sender, MediaInfoUpdatedEventArgs args)