Adding Color Extraction to Tray Icons Background. 54/282554/1 accepted/tizen/unified/20221006.065333 accepted/tizen/unified/20221006.065408
authorshivamv <shivam.v2@samsung.com>
Wed, 5 Oct 2022 13:39:43 +0000 (19:09 +0530)
committershivamv <shivam.v2@samsung.com>
Wed, 5 Oct 2022 13:39:43 +0000 (19:09 +0530)
Change-Id: I655f34e8125e636c251444bdfa30f11d22a0972d
Signed-off-by: shivamv <shivam.v2@samsung.com>
TrayApplication/Models/AppInfoModel.cs [changed mode: 0644->0755]
TrayApplication/ViewModels/ApplicationViewModel.cs
TrayApplication/Views/ApplicationsView.cs
packaging/org.tizen.TrayApplication-1.0.0.tpk

old mode 100644 (file)
new mode 100755 (executable)
index b16a870..8dbee75
@@ -9,7 +9,10 @@ using TrayApplication.Core;
 namespace TrayApplication.Models
 {
     class AppInfoModel : PropertyNotifier
-    {
+    {\r
+        private ImageVisual defaultVisual;
+        private GradientVisual gradientVisual;
+
         public AppInfoModel(string name, string applicationId, string url)
         {
             Name = name;
@@ -66,27 +69,23 @@ namespace TrayApplication.Models
             }
         }
 
-        private void SetDefaultBackground()
+        private void SetDefaultImageVisual()
         {
-            ImageVisual imageVisual = new ImageVisual()
+            defaultVisual = new ImageVisual()
             {
                 URL = Resources.GetImagePath() + "default_gradient.png",
             };
-            IconBackground = imageVisual.OutputVisualMap;
-            imageVisual.Dispose();
         }
 
-        private void SetGradientBackground(PropertyArray stopColor)
+        private void SetGradientVisual(PropertyArray stopColor)
         {
-            GradientVisual gradientVisual = new GradientVisual()
+            gradientVisual = new GradientVisual()
             {
                 StartPosition = new Vector2(0.0f, -1.0f),
                 EndPosition = new Vector2(0.0f, 1.0f),
                 StopColor = stopColor,
                 SpreadMethod = GradientVisualSpreadMethodType.Pad,
             };
-            IconBackground = gradientVisual.OutputVisualMap;
-            gradientVisual.Dispose();
         }
 
         private PropertyArray GetGradientStopColors(Palette palette)
@@ -156,14 +155,27 @@ namespace TrayApplication.Models
             PropertyArray stopColor = GetGradientStopColors(palette);
             if (stopColor.Count() < 2)
             {
-                Tizen.Log.Info(Resources.LogTag, "Palette or palatte values not valid, adding default gradient");
-                SetDefaultBackground();
+                Tizen.Log.Info(Resources.LogTag, "Palette or palatte values not valid, adding default gradient");\r
+                SetDefaultImageVisual();
+                IconBackground = defaultVisual.OutputVisualMap;
             }
             else
             {
                 Tizen.Log.Info(Resources.LogTag, "setting palette color");
-                SetGradientBackground(stopColor);
+                SetGradientVisual(stopColor);\r
+                IconBackground = gradientVisual.OutputVisualMap;
             }
+        }\r
+\r
+        ~AppInfoModel()\r
+        {\r
+            Tizen.Log.Info(Resources.LogTag, "Clearing NUI PropertyMap resources");\r
+            defaultVisual?.Dispose();\r
+            defaultVisual = null;\r
+            gradientVisual?.Dispose();\r
+            gradientVisual = null;\r
+            IconBackground?.Dispose();\r
+            IconBackground = null;\r
         }
     }
 }
index 813ab849702dcf002eec2fcfe1b8de6059ac835a..20589f81e369e4c0dc5d44c6a3e9aabc1ef415ed 100755 (executable)
@@ -50,7 +50,7 @@ namespace TrayApplication.ViewModels
         private void AddAppsApplication()
         {
             AppInfoModel appsApp = new AppInfoModel("Apps", AppsId, Resources.GetCurrentThemePath() + "apps.png");
-            //appsApp.SetExtractedBackground(string.Empty);
+            appsApp.SetExtractedBackground(string.Empty);
             Thread.Sleep(100);
             appInfoModelDictionary.Add(AppsId, appsApp);
         }
@@ -59,7 +59,7 @@ namespace TrayApplication.ViewModels
         {
             ApplicationInfo appInfo = new ApplicationInfo(appId);
             AppInfoModel appInfoModel = new AppInfoModel(appInfo.Label, appId, appInfo.IconPath);
-            //appInfoModel.SetExtractedBackground(appInfoModel.IconUrl);
+            appInfoModel.SetExtractedBackground(appInfoModel.IconUrl);
             appInfoModelDictionary.Add(appId, appInfoModel);
             appInfo.Dispose();
         }
index 4ddcc9cdf77f4285aaa951cbcaf972d340c5932f..7c862b8a1e4aed53b6c08e76c5149d0d8da4e4e0 100755 (executable)
@@ -135,7 +135,7 @@ namespace TrayApplication.Views
                 itemView.Icon.SetBinding(ImageView.ResourceUrlProperty, "IconUrl");
                 itemView.Label.SetBinding(TextLabel.TextProperty, "Name");
                 itemView.SetBinding(AppItemView.AppSelectCommandProperty, "AppSelectCommand");
-                //itemView.IconBackground.SetBinding(BackgroundProperty, "IconBackground");
+                itemView.IconBackground.SetBinding(BackgroundProperty, "IconBackground");
             }
             currentAppsCount = totalCount;
             if (removeMode == true)
index 58a440b9f4f9fd784a444d21b9a999336b8803dc..cd02a951465fb1d27166a5f5e95086c2aba1c131 100755 (executable)
Binary files a/packaging/org.tizen.TrayApplication-1.0.0.tpk and b/packaging/org.tizen.TrayApplication-1.0.0.tpk differ