{
class AppInfoModel : PropertyNotifier
{
- private ImageVisual defaultVisual;
- private GradientVisual gradientVisual;
-
public AppInfoModel(string name, string applicationId, string url)
{
Name = name;
set => SetProperty(ref iconUrl, value);
}
- private PropertyMap iconBackground;
- public PropertyMap IconBackground
+ private Color iconBackgroundColor;
+ public Color IconBackgroundColor
{
- get => iconBackground;
- set => SetProperty(ref iconBackground, value);
+ get => iconBackgroundColor;
+ set => SetProperty(ref iconBackgroundColor, value);
}
private ICommand appSelectCommand;
}
}
- private void SetDefaultImageVisual()
- {
- defaultVisual = new ImageVisual()
- {
- URL = Resources.GetImagePath() + "default_gradient.png",
- CornerRadius = new Vector4(12, 12, 12, 12),
- };
- }
-
- private void SetGradientVisual(PropertyArray stopColor)
- {
- gradientVisual = new GradientVisual()
- {
- StartPosition = new Vector2(0.0f, -1.0f),
- EndPosition = new Vector2(0.0f, 1.0f),
- StopColor = stopColor,
- SpreadMethod = GradientVisualSpreadMethodType.Pad,
- CornerRadius = new Vector4(12, 12, 12, 12),
- };
- }
-
- private PropertyArray GetGradientStopColors(Palette palette)
- {
- PropertyArray propertyArray = new PropertyArray();
- if (palette == null)
- {
- Tizen.Log.Error(Resources.LogTag, "Color palette from background is null");
- return propertyArray;
- }
-
- Palette.Swatch lightMutedSwatch = palette.GetLightMutedSwatch();
- Palette.Swatch darkMutedSwatch = palette.GetDarkMutedSwatch();
- if (lightMutedSwatch != null && darkMutedSwatch != null)
- {
- propertyArray.PushBack(new PropertyValue(lightMutedSwatch.GetRgb()));
- propertyArray.PushBack(new PropertyValue(darkMutedSwatch.GetRgb()));
- return propertyArray;
- }
-
- Palette.Swatch lightVibrantSwatch = palette.GetLightVibrantSwatch();
- Palette.Swatch darkVibrantSwatch = palette.GetDarkVibrantSwatch();
- if (lightVibrantSwatch != null && darkVibrantSwatch != null)
- {
- propertyArray.PushBack(new PropertyValue(lightVibrantSwatch.GetRgb()));
- propertyArray.PushBack(new PropertyValue(darkVibrantSwatch.GetRgb()));
- return propertyArray;
- }
-
- Palette.Swatch mutedSwatch = palette.GetMutedSwatch();
- Palette.Swatch vibrantSwatch = palette.GetVibrantSwatch();
- if (mutedSwatch != null && vibrantSwatch != null)
- {
- propertyArray.PushBack(new PropertyValue(mutedSwatch.GetRgb()));
- propertyArray.PushBack(new PropertyValue(vibrantSwatch.GetRgb()));
- return propertyArray;
- }
-
- IReadOnlyCollection<Palette.Swatch> swatches = palette.GetSwatches();
- foreach (Palette.Swatch swatch in swatches)
- {
- if (propertyArray.Count() >= 2)
- {
- return propertyArray;
- }
- if (swatch != null)
- {
- propertyArray.PushBack(new PropertyValue(swatch.GetRgb()));
- }
- }
- return propertyArray;
- }
-
- public void SetExtractedBackground(string path)
+ public void SetBackgroundColor(string path)
{
Tizen.Log.Debug(Resources.LogTag, "Path for the color image thumbnail" + path);
PixelBuffer pixelBuffer = ImageLoader.LoadImageFromFile(path);
{
palette = Palette.Generate(pixelBuffer);
}
- catch( ArgumentNullException e)
+ catch (ArgumentNullException e)
{
Tizen.Log.Error(Resources.LogTag, "ArgumentNullException: " + e.Message);
}
- PropertyArray stopColor = GetGradientStopColors(palette);
- if (stopColor.Count() < 2)
+ if (palette == null || palette.GetDominantSwatch() == null)
{
- Tizen.Log.Info(Resources.LogTag, "Palette or palatte values not valid, adding default gradient");
- SetDefaultImageVisual();
- IconBackground = defaultVisual.OutputVisualMap;
+ IconBackgroundColor = Color.Transparent;
}
else
{
- Tizen.Log.Info(Resources.LogTag, "setting palette color");
- SetGradientVisual(stopColor);
- IconBackground = gradientVisual.OutputVisualMap;
+ IconBackgroundColor = palette.GetDominantSwatch().GetRgb();
}
+ pixelBuffer.Dispose();
}
~AppInfoModel()
{
- Tizen.Log.Info(Resources.LogTag, "Clearing NUI PropertyMap resources");
- defaultVisual?.Dispose();
- defaultVisual = null;
- gradientVisual?.Dispose();
- gradientVisual = null;
- IconBackground?.Dispose();
- IconBackground = null;
+ if (Name == "back")
+ {
+ InputGeneratorBase.FinalizeInputGenerator();
+ }
}
}
}
((List<object>)ButtonsInfo).Clear();
List<object> buttons = new List<object>
{
- new AppInfoModel(AppNames[0], "org.tizen.homescreen-efl", imagePath + AppNames[0] + ".png"),
+ new AppInfoModel(AppNames[0], "org.tizen.homescreen-nui", imagePath + AppNames[0] + ".png"),
new AppInfoModel(AppNames[1], "org.tizen.SettingView", imagePath + AppNames[1] + ".png"),
- new AppInfoModel(AppNames[2], "org.tizen.volume", imagePath + AppNames[2] + ".png"),
+ new AppInfoModel(AppNames[2], "org.tizen.volume-nui", imagePath + AppNames[2] + ".png"),
new AppInfoModel(AppNames[3], string.Empty, imagePath + AppNames[3] + ".png"),
//new AppInfoModel(AppNames[3], "org.tizen.quickpanel", imagePath + AppNames[3] + ".png"), //Will be added Later
//new AppInfoModel(AppNames[5], "org.tizen.powerkey-syspopup", imagePath + AppNames[5] + ".png") //Will be added Later