update storage gadget
authorYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Tue, 18 Apr 2023 14:46:38 +0000 (16:46 +0200)
committerYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Mon, 24 Apr 2023 12:50:02 +0000 (14:50 +0200)
SettingMainGadget/SettingMainGadget/StorageGadget.cs
SettingMainGadget/SettingMainGadget/TextResources/Resources.Designer.cs
SettingView/TextResources/Resources.Designer.cs

index 30e57e90b3b0596e8ef27cb69568d67fa6206f3f..f5154cda317d63791a1e069fc1ae0d32fa055246 100644 (file)
@@ -1,22 +1,17 @@
 using SettingMainGadget.TextResources;
 using SettingCore;
+using SettingCore.Views;
+using SettingMainGadget;
 using System;
 using System.Collections.Generic;
-using System.Text;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI;
-using SettingCore.Views;
-using SettingMainGadget.DateTime;
 using System.Linq;
-using Tizen.NUI.Components;
-using Tizen.System;
-using SettingMainGadget;
-using Tizen.Pims.Contacts.ContactsViews;
 using System.Threading.Tasks;
 using Tizen.Applications;
 using Tizen.Content.MediaContent;
-using static System.Collections.Specialized.BitVector32;
-using Tizen;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using Tizen.System;
 
 namespace Setting.Menu
 {
@@ -61,7 +56,15 @@ namespace Setting.Menu
 
             CreateView();
 
-            StartCalculatingAppCacheSize();
+            var calculating = StartCalculatingAppCacheSize();
+
+            content.Relayout += (s, e) =>
+            {
+                if (calculating.IsCompleted)
+                {
+                    storageIndicator.Update();
+                }
+            };
 
             return content;
         }
@@ -80,14 +83,24 @@ namespace Setting.Menu
             sections.Add(MainMenuProvider.Storage_InternalUsage, internalUsageItem);
 
             GetStorageStatus(out int InternalCount, out double InternalTotal, out int ExternalCount, out double InternalAvailable, out double ExternalTotal, out double ExternalAvailable);
+            GetMediaInfo(out double sizeImage, out double sizeVideo, out double sizeAudio);
+            GetMiscInfo(out double sizeMisc);
+
+            nonSystemSpace = InternalTotal - InternalAvailable - sizeImage - sizeVideo - sizeAudio - sizeMisc;
 
             if (InternalCount > 0)
             {
                 var usedItem = TextListItem.CreatePrimaryTextItem(GetMediaSizeString(InternalTotal - InternalAvailable));
                 sections.Add(MainMenuProvider.Storage_Used, usedItem);
 
-                // TODO : add size dependency
-                storageIndicator = new StorageIndicator();
+                storageIndicator = new StorageIndicator(InternalTotal);
+                storageIndicator.AddItem("apps", new Color("#FFC700"), 0);
+                storageIndicator.AddItem("images", new Color("#FF8A00"), sizeImage);
+                storageIndicator.AddItem("video", new Color("#FF6200"), sizeVideo);
+                storageIndicator.AddItem("audio", new Color("#A40404"), sizeAudio);
+                storageIndicator.AddItem("misc", new Color("#28262B"), sizeMisc);
+                storageIndicator.AddItem("cache", new Color("#3641FA"), 0);
+                storageIndicator.AddItem("system", new Color("#17234D"), 0);
                 sections.Add(MainMenuProvider.Storage_UsageIndicator, storageIndicator);
 
                 var totalItem = TextListItem.CreatePrimaryTextItemWithSecondaryText($"{Resources.IDS_ST_HEADER_TOTAL_SPACE}:", GetMediaSizeString(InternalTotal));
@@ -97,11 +110,6 @@ namespace Setting.Menu
                 sections.Add(MainMenuProvider.Storage_FreeInternal, freeItem);
             }
 
-            GetMediaInfo(out double sizeImage, out double sizeVideo, out double sizeAudio);
-            GetMiscInfo(out double sizeMisc);
-
-            nonSystemSpace = InternalTotal - InternalAvailable - sizeImage - sizeVideo - sizeAudio - sizeMisc;
-
             var usageSummary = new View()
             {
                 WidthSpecification = LayoutParamPolicies.MatchParent,
@@ -231,7 +239,6 @@ namespace Setting.Menu
             {
                 NavigateTo(MainMenuProvider.Storage_DefaultSettings);
             };
-
             defaultSettings.Add(defaultSettingsItem);
             defaultSettings.Add(storageLocationItem);
             sections.Add(MainMenuProvider.Storage_DefaultSettings, defaultSettings);
@@ -298,29 +305,31 @@ namespace Setting.Menu
             return string.Format("{0:0.##} {1}", size, suffixes[counter]);
         }
 
-        private void StartCalculatingAppCacheSize()
+        private async Task StartCalculatingAppCacheSize()
         {
-            Task<PackageSizeInformation> task = PackageManager.GetTotalSizeInformationAsync();
-            task.ContinueWith(x =>
+            var sizeInfo = await PackageManager.GetTotalSizeInformationAsync();
+
+            long sizeApp = sizeInfo.AppSize;
+            long sizeCache = sizeInfo.CacheSize;
+
+            if (appsItem != null)
+            {
+                appsItem.SubText = GetMediaSizeString(sizeApp);
+            }
+            if (cacheItem != null)
+            {
+                cacheItem.SubText = GetMediaSizeString(sizeCache);
+            }
+            if (systemItem != null)
             {
-                PackageSizeInformation sizeinfo = x.Result;
-                long sizeApp = sizeinfo.AppSize;
-                long sizeCache = sizeinfo.CacheSize;
+                systemItem.SubText = GetMediaSizeString(nonSystemSpace - sizeApp - sizeCache);
+            }
 
-                if (appsItem != null)
-                {
-                    appsItem.SubText = GetMediaSizeString(sizeApp);
-                }
-                if (cacheItem != null)
-                {
-                    cacheItem.SubText = GetMediaSizeString(sizeCache);
-                }
-                if (systemItem != null)
-                {
-                    systemItem.SubText = GetMediaSizeString(nonSystemSpace - sizeApp - sizeCache);
-                }
+            storageIndicator.SizeInfoList.Where(x => x.Name == "apps").FirstOrDefault()?.SetSize(sizeApp);
+            storageIndicator.SizeInfoList.Where(x => x.Name == "cache").FirstOrDefault()?.SetSize(sizeCache);
+            storageIndicator.SizeInfoList.Where(x => x.Name == "system").FirstOrDefault()?.SetSize(nonSystemSpace - sizeApp - sizeCache);
 
-            }, TaskScheduler.FromCurrentSynchronizationContext());
+            storageIndicator.Update();
         }
 
         private void GetMediaInfo(out double sizeImage, out double sizeVideo, out double sizeAudio)
@@ -512,5 +521,11 @@ namespace Setting.Menu
         {
             Logger.Debug($"Folder updated: Id = {args.Id}, Operation = {args.OperationType}");
         }
+
+        protected override void OnCustomizationUpdate(IEnumerable<MenuCustomizationItem> items)
+        {
+            Logger.Verbose($"{nameof(DisplayGadget)} got customization with {items.Count()} items. Recreating view.");
+            CreateView();
+        }
     }
 }
index 064a7ae2a569fe1f6a4332e499ed0c45eff262af..2c57e77a59032685140ce11a0e086c7e47c3356e 100644 (file)
@@ -19,7 +19,7 @@ namespace SettingMainGadget.TextResources {
     // class via a tool like ResGen or Visual Studio.
     // To add or remove a member, edit your .ResX file then rerun ResGen
     // with the /str option, or rebuild your VS project.
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     public class Resources {
index 5ce24897f5339b6d5b432be5a9897e827ce6eeca..fb8923509706db3dc6cb61ee277f52932e629c0f 100644 (file)
@@ -19,7 +19,7 @@ namespace SettingView.TextResources {
     // class via a tool like ResGen or Visual Studio.
     // To add or remove a member, edit your .ResX file then rerun ResGen
     // with the /str option, or rebuild your VS project.
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     public class Resources {