update app manager
authorYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Tue, 12 Sep 2023 13:49:45 +0000 (15:49 +0200)
committerPiotr Czaja/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <p.czaja@samsung.com>
Wed, 13 Sep 2023 15:42:52 +0000 (17:42 +0200)
SettingMainGadget/SettingMainGadget/Apps/AppManager.cs
SettingMainGadget/SettingMainGadget/Apps/AppsManagerGadget.cs
SettingMainGadget/SettingMainGadget/Storage/AppsStorageGadget.cs

index c0fd2f2aea9f0415ef588337ba93617c0e2c03e6..7e4675d2d7d9f6b7042ce2aa39921a9e6b2f85e9 100644 (file)
@@ -19,7 +19,7 @@ namespace SettingMainGadget.Apps
             }
             catch (Exception ex)
             {
-                Logger.Warn($"Cann't get application running context: {ex.Message}");
+                Logger.Warn($"Can't get application running context: {ex.Message}");
                 return null;
             }
         }
index cb9c5be5764b9527b0762fadd3bcc80207999938..0ac1e221ad735ae19c58114cb336b5eed101a4c5 100644 (file)
@@ -1,5 +1,6 @@
 using SettingCore;
 using SettingCore.Views;
+using SettingMainGadget.Apps;
 using SettingMainGadget.TextResources;
 using System;
 using System.Collections.Generic;
@@ -242,7 +243,7 @@ namespace Setting.Menu.Apps
             foreach (var package in packages)
             {
                 packageSizeInfo = await package.Key.GetSizeInformationAsync();
-                package.Value.SubText = GetSizeString(packageSizeInfo.AppSize);
+                package.Value.SubText = AppManager.GetSizeString(packageSizeInfo.AppSize);
             }
         }
 
@@ -253,24 +254,10 @@ namespace Setting.Menu.Apps
                 var appContext = new ApplicationRunningContext(info.Key.ApplicationId);
                 var processMemmory = new Tizen.System.ProcessMemoryUsage(new List<int> { appContext.ProcessId });
                 processMemmory.Update(new List<int> { appContext.ProcessId });
-                info.Value.SubText = GetSizeString(processMemmory.GetVsz(appContext.ProcessId));
+                info.Value.SubText = AppManager.GetSizeString(processMemmory.GetVsz(appContext.ProcessId));
             }
         }
 
-        private string GetSizeString(double size)
-        {
-            string[] suffixes = { "Bytes", "KB", "MB", "GB" };
-            int counter = 0;
-
-            while (Math.Round(size / 1024, 2) >= 1)
-            {
-                size = size / 1024;
-                counter++;
-            }
-
-            return string.Format("{0:0.##} {1}", size, suffixes[counter]);
-        }
-
         private ScrollableBase CreateScrollableBase()
         {
             return new ScrollableBase()
index 899058e195542c3093710edc2cb0f905b308f06e..7a7d13437cb839f06e32c812674c73ad425b56ce 100644 (file)
@@ -1,5 +1,6 @@
 using SettingCore;
 using SettingCore.Views;
+using SettingMainGadget.Apps;
 using SettingMainGadget.TextResources;
 using System;
 using System.Collections.Generic;
@@ -148,7 +149,7 @@ namespace Setting.Menu.Storage
 
             foreach (var app in applicationInfos)
             {
-                var item = new TextWithIconListItem(app.Name, Color.Transparent, iconPath: app.IconPath, subText: GetSizeString(app.AppSize));
+                var item = new TextWithIconListItem(app.Name, Color.Transparent, iconPath: app.IconPath, subText: AppManager.GetSizeString(app.AppSize));
                 content.Add(item);
 
                 if (app.AppSize == 0)
@@ -175,7 +176,7 @@ namespace Setting.Menu.Storage
                 if (app != null)
                 {
                     app.AppSize = packageSizeInfo.AppSize;
-                    item.Value.SubText = GetSizeString(packageSizeInfo.AppSize);
+                    item.Value.SubText = AppManager.GetSizeString(packageSizeInfo.AppSize);
                 }
             }
 
@@ -186,20 +187,6 @@ namespace Setting.Menu.Storage
             }
         }
 
-        private string GetSizeString(double size)
-        {
-            string[] suffixes = { "Bytes", "KB", "MB", "GB" };
-            int counter = 0;
-
-            while (Math.Round(size / 1024, 2) >= 1)
-            {
-                size = size / 1024;
-                counter++;
-            }
-
-            return string.Format("{0:0.##} {1}", size, suffixes[counter]);
-        }
-
         private class ApplicationInfo
         {
             public string AppId { get; }