From: shivamv Date: Wed, 5 Oct 2022 13:39:43 +0000 (+0530) Subject: Adding Color Extraction to Tray Icons Background. X-Git-Tag: accepted/tizen/unified/20221006.065333^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb08dd61bab7b3ad4f7e6e249b2db3ba24ca2a7f;p=profile%2Fiot%2Fapps%2Fdotnet%2Ftray.git Adding Color Extraction to Tray Icons Background. Change-Id: I655f34e8125e636c251444bdfa30f11d22a0972d Signed-off-by: shivamv --- diff --git a/TrayApplication/Models/AppInfoModel.cs b/TrayApplication/Models/AppInfoModel.cs old mode 100644 new mode 100755 index b16a870..8dbee75 --- a/TrayApplication/Models/AppInfoModel.cs +++ b/TrayApplication/Models/AppInfoModel.cs @@ -9,7 +9,10 @@ using TrayApplication.Core; namespace TrayApplication.Models { class AppInfoModel : PropertyNotifier - { + { + 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"); + SetDefaultImageVisual(); + IconBackground = defaultVisual.OutputVisualMap; } else { Tizen.Log.Info(Resources.LogTag, "setting palette color"); - SetGradientBackground(stopColor); + SetGradientVisual(stopColor); + IconBackground = gradientVisual.OutputVisualMap; } + } + + ~AppInfoModel() + { + Tizen.Log.Info(Resources.LogTag, "Clearing NUI PropertyMap resources"); + defaultVisual?.Dispose(); + defaultVisual = null; + gradientVisual?.Dispose(); + gradientVisual = null; + IconBackground?.Dispose(); + IconBackground = null; } } } diff --git a/TrayApplication/ViewModels/ApplicationViewModel.cs b/TrayApplication/ViewModels/ApplicationViewModel.cs index 813ab84..20589f8 100755 --- a/TrayApplication/ViewModels/ApplicationViewModel.cs +++ b/TrayApplication/ViewModels/ApplicationViewModel.cs @@ -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(); } diff --git a/TrayApplication/Views/ApplicationsView.cs b/TrayApplication/Views/ApplicationsView.cs index 4ddcc9c..7c862b8 100755 --- a/TrayApplication/Views/ApplicationsView.cs +++ b/TrayApplication/Views/ApplicationsView.cs @@ -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) diff --git a/packaging/org.tizen.TrayApplication-1.0.0.tpk b/packaging/org.tizen.TrayApplication-1.0.0.tpk index 58a440b..cd02a95 100755 Binary files a/packaging/org.tizen.TrayApplication-1.0.0.tpk and b/packaging/org.tizen.TrayApplication-1.0.0.tpk differ