-using Tizen.System;
+using Tizen.NUI;
+using Tizen.System;
namespace TrayApplication.Common
{
{
private static int width;
private static int height;
+ private static Window.WindowOrientation orientation;
private const string WidthKey = "tizen.org/feature/screen.width";
private const string HeightKey = "tizen.org/feature/screen.height";
bool isHeightAvailable = Information.TryGetValue(HeightKey, out height);
if (isHeightAvailable == false || isWidthAvailable == false)
{
- width = 1920;
- height = 1080;
- Tizen.Log.Debug(Resources.LogTag, "Width and height are not available , setting default size as 1920 x 1080");
+ width = 1280;
+ height = 720;
+ Tizen.Log.Debug(Resources.LogTag, "Width and height are not available , setting default size as 1280 x 720");
}
- IsPortrait = width < height;
+ orientation = Window.Instance.GetCurrentOrientation();
+ IsPortrait = orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse;
+ }
+
+ public static void UpdateDeviceInfo()
+ {
+ Window.WindowOrientation currentOrientation = Window.Instance.GetCurrentOrientation();
+ if (orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse)
+ {
+ if (currentOrientation == Window.WindowOrientation.Landscape || currentOrientation == Window.WindowOrientation.LandscapeInverse)
+ {
+ ToggleOrientation();
+ }
+ }
+ else
+ {
+ if (currentOrientation == Window.WindowOrientation.Portrait || currentOrientation == Window.WindowOrientation.PortraitInverse)
+ {
+ ToggleOrientation();
+ }
+ }
+ orientation = currentOrientation;
+ }
+
+ private static void ToggleOrientation()
+ {
+ (width, height) = (height, width);
+ IsPortrait = !IsPortrait;
}
public static bool IsPortrait { get; private set; }
-using Tizen.Applications;
+using System;
+using Tizen.Applications;
namespace TrayApplication.Core
{
static class AppLauncher
{
+
+ public static event EventHandler<EventArgs> AppLaunched;
+
public static void LaunchApplication(string id)
{
AppControl appControl = new AppControl()
Operation = id == "org.tizen.homescreen-efl" ? AppControlOperations.Main : AppControlOperations.Default,
};
AppControl.SendLaunchRequest(appControl);
+ AppLaunched.Invoke(new object(), new EventArgs());
}
}
}
-using System.Windows.Input;
+using System;
+using System.Collections.Generic;
+using System.Windows.Input;
+using Tizen.NUI;
using Tizen.NUI.Binding;
using TrayApplication.Common;
using TrayApplication.Core;
set => SetProperty(ref iconUrl, value);
}
+ private PropertyMap iconBackground;
+ public PropertyMap IconBackground
+ {
+ get => iconBackground;
+ set => SetProperty(ref iconBackground, value);
+ }
+
private ICommand appSelectCommand;
public ICommand AppSelectCommand
{
{
AppLauncher.LaunchApplication(ApplicationId);
}
+
+ private void SetDefaultBackground()
+ {
+ ImageVisual imageVisual = new ImageVisual()
+ {
+ URL = Resources.GetImagePath() + "default_gradient.png",
+ };
+ IconBackground = imageVisual.OutputVisualMap;
+ }
+
+ private void SetGradientBackground(PropertyArray stopColor)
+ {
+ 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;
+ }
+
+ 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 async void SetExtractedBackground(string path)
+ {
+ Tizen.Log.Debug(Resources.LogTag, "Path for the color image thumbnail" + path);
+ PixelBuffer pixelBuffer = ImageLoader.LoadImageFromFile(path);
+ Palette palette = null;
+ try
+ {
+ palette = await Palette.GenerateAsync(pixelBuffer);
+ }
+ catch( ArgumentNullException e)
+ {
+ Tizen.Log.Error(Resources.LogTag, "ArgumentNullException: " + e.Message);
+ }
+ PropertyArray stopColor = GetGradientStopColors(palette);
+ if (stopColor.Count() < 2)
+ {
+ Tizen.Log.Info(Resources.LogTag, "Palette or palatte values not valid, adding default gradient");
+ SetDefaultBackground();
+ }
+ else
+ {
+ Tizen.Log.Info(Resources.LogTag, "setting palette color");
+ SetGradientBackground(stopColor);
+ }
+ }
}
}
using System;
+using System.Collections.Generic;
+using System.Text;
using Tizen.NUI;
using Tizen.NUI.WindowSystem.Shell;
using TrayApplication.Views;
}
private const int WindowHeight = 313;
+ private const int SwipeUpLength = 5;
+ private const int SwipeDownLength = 60;
+ private const int MinimizedWindowHeight = 36;
+ private const int BottomMargin = 48;
private int positionX;
private int positionY;
private bool isTrayVisible = true;
private Window window;
private MainView mainView;
- private TizenShell tzShell;
+ private TizenShell tizenShell;
private SoftkeyService softkeyService;
+ private Window.WindowOrientation windowOrientation;
private float touchStartPosition;
protected override void OnCreate()
{
Tizen.Log.Info(Resources.LogTag, "Program OnCreate");
base.OnCreate();
+
window = GetDefaultWindow();
- int sizeWidth = (int)((DeviceInfo.IsPortrait ? 0.6 : 0.5) * DeviceInfo.DisplayWidth);
- int sizeHeight = WindowHeight.SpToPx();
- positionX = (int)((DeviceInfo.IsPortrait ? 0.2 : 0.25) * DeviceInfo.DisplayWidth);
- positionY = DeviceInfo.DisplayHeight;
- window.WindowSize = new Size2D(sizeWidth, sizeHeight);
- window.WindowPosition = new Position2D(positionX, positionY);
+ List<Window.WindowOrientation> list = new List<Window.WindowOrientation>
+ {
+ Window.WindowOrientation.Landscape,
+ Window.WindowOrientation.LandscapeInverse,
+ Window.WindowOrientation.NoOrientationPreference,
+ Window.WindowOrientation.Portrait,
+ Window.WindowOrientation.PortraitInverse
+ };
+ window.SetAvailableOrientations(list);
+ windowOrientation = window.GetCurrentOrientation();
+ Tizen.Log.Info(Resources.LogTag, "Orientation: " + windowOrientation);
+
+ UpdateWindowDimensions();
window.BackgroundColor = Color.Transparent;
window.SetTransparency(true);
- tzShell = new TizenShell();
- softkeyService = new SoftkeyService(tzShell, window);
+ tizenShell = new TizenShell();
+ softkeyService = new SoftkeyService(tizenShell, window);
softkeyService.Show();
window.KeyEvent += OnKeyEvent;
window.TouchEvent += OnTouch;
+ window.Resized += OnWindowResized;
AppScoreDataBase.InitializeDataBase();
mainView = new MainView();
window.Add(mainView);
mainView.RemovedFromWindow += MainViewRemovedFromWindow;
mainView.VisibilityChanged += MainViewVisibilityChanged;
+ AppLauncher.AppLaunched += OnAppLaunched;
mainView.HideView();
Tizen.Log.Info(Resources.LogTag, "Tray Application Created");
}
base.OnTerminate();
}
+ private void UpdateWindowDimensions()
+ {
+ int sizeWidth = (int)((DeviceInfo.IsPortrait ? 0.6 : 0.5) * DeviceInfo.DisplayWidth);
+ int sizeHeight = WindowHeight.SpToPx();
+ positionX = (int)((DeviceInfo.IsPortrait ? 0.2 : 0.25) * DeviceInfo.DisplayWidth);
+ positionY = isTrayVisible ? DeviceInfo.DisplayHeight - (WindowHeight + BottomMargin).SpToPx() : DeviceInfo.DisplayHeight - MinimizedWindowHeight.SpToPx();
+ window.WindowPosition = new Position2D(positionX, positionY);
+ window.WindowSize = new Size2D(sizeWidth, sizeHeight);
+ }
+
+ private void OnAppLaunched(object sender, EventArgs e)
+ {
+ mainView?.HideView();
+ }
+
+ private void OnWindowResized(object sender, Window.ResizedEventArgs e)
+ {
+ Tizen.Log.Info(Resources.LogTag, "Tray Resized");
+ Window.WindowOrientation currentWindowOrientation = window.GetCurrentOrientation();
+ if (windowOrientation != currentWindowOrientation)
+ {
+ DeviceInfo.UpdateDeviceInfo();
+ windowOrientation = currentWindowOrientation;
+ UpdateWindowDimensions();
+ mainView.UpdateView();
+ }
+ }
+
private void MainViewRemovedFromWindow(object sender, EventArgs e)
{
Tizen.Log.Info(Resources.LogTag, "Main View Removed");
private void MainViewVisibilityChanged(object sender, Tizen.NUI.BaseComponents.View.VisibilityChangedEventArgs e)
{
Tizen.Log.Info(Resources.LogTag, "Main View Visibility Changed");
- if (isTrayVisible == true)
- {
- positionY = DeviceInfo.DisplayHeight - 36.SpToPx();
- window.WindowPosition = new Position2D(positionX, positionY);
- }
- else
- {
- positionY = DeviceInfo.DisplayHeight - (WindowHeight + 48).SpToPx();
- window.WindowPosition = new Position2D(positionX, positionY);
- }
isTrayVisible = !isTrayVisible;
+ positionY = isTrayVisible ? DeviceInfo.DisplayHeight - (WindowHeight + BottomMargin).SpToPx() : DeviceInfo.DisplayHeight - MinimizedWindowHeight.SpToPx();
+ window.WindowPosition = new Position2D(positionX, positionY);
}
private void OnTouch(object sender, Window.TouchEventArgs e)
if (e.Touch.GetState(0) == PointStateType.Finished)
{
float touchEndPosition = e.Touch.GetScreenPosition(0).Y;
- if (touchEndPosition - touchStartPosition >= 60.SpToPx())
+ if (touchEndPosition - touchStartPosition >= SwipeDownLength.SpToPx())
{
if (mainView != null)
{
if (e.Touch.GetState(0) == PointStateType.Motion || e.Touch.GetState(0) == PointStateType.Finished)
{
float touchEndPosition = e.Touch.GetScreenPosition(0).Y;
- if (touchStartPosition - touchEndPosition >= 5.SpToPx())
+ if (touchStartPosition - touchEndPosition >= SwipeUpLength.SpToPx())
{
if (mainView != null)
{
mainView.ShowView();
}
- touchStartPosition = 313.SpToPx();
+ touchStartPosition = WindowHeight.SpToPx();
}
}
}
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.7" />
- <PackageReference Include="Tizen.NET" Version="10.0.0.17357" />
+ <PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.8" />
+ <PackageReference Include="Tizen.NET" Version="10.0.0.17411" />
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.8" />
</ItemGroup>
using System.Collections;
using System.Collections.Generic;
+using System.Threading;
using System.Windows.Input;
using Tizen.Applications;
using Tizen.NUI;
class ApplicationViewModel : PropertyNotifier
{
Dictionary<string, int> appScoreData;
- private readonly int appsCount;
+ Dictionary<string, AppInfoModel> appInfoModelDictionary;
+ private const string AppsId = "org.tizen.Apps";
+ private const int maxAppsPortrait = 4;
+ private const int maxAppsLandscape = 6;
+ private int appsCount;
+ private int maxAppsCount;
public ApplicationViewModel(int appsCount)
{
- this.appsCount = appsCount;
+ maxAppsCount = DeviceInfo.IsPortrait ? maxAppsPortrait : maxAppsLandscape;
+ this.appsCount = appsCount < maxAppsCount ? appsCount : maxAppsCount;
appScoreData = AppScoreDataBase.ReadData(appsCount - 1);
BackgroundColor = ThemeManager.PlatformThemeId == Resources.DarkPlatformThemeId ? Resources.DarkApplicationsBackground : Resources.LightApplicationsBackground;
+ appInfoModelDictionary = new Dictionary<string, AppInfoModel>();
+ AddAppsApplication();
AddButtonsInfo();
AppRemoveCommand = new Command(OnAppRemove);
AppScoreDataBase.OnDatabaseUpdate += OnDatabaseUpdate;
UpdateButtonsInfo();
}
+ private void AddAppsApplication()
+ {
+ AppInfoModel appsApp = new AppInfoModel("Apps", AppsId, Resources.GetCurrentThemePath() + "apps.png");
+ appsApp.SetExtractedBackground(string.Empty);
+ Thread.Sleep(100);
+ appInfoModelDictionary.Add(AppsId, appsApp);
+ }
+
+ private void CreateAppInfoModel(string appId)
+ {
+ ApplicationInfo appInfo = new ApplicationInfo(appId);
+ AppInfoModel appInfoModel = new AppInfoModel(appInfo.Label, appId, appInfo.IconPath);
+ appInfoModel.SetExtractedBackground(appInfoModel.IconUrl);
+ appInfoModelDictionary.Add(appId, appInfoModel);
+ appInfo.Dispose();
+ }
+
private void AddButtonsInfo()
{
List<object> buttons = new List<object>();
foreach (var item in appScoreData)
{
- ApplicationInfo appInfo = new ApplicationInfo(item.Key);
- buttons.Add(new AppInfoModel(appInfo.Label, item.Key, appInfo.IconPath));
- appInfo.Dispose();
+ if (appInfoModelDictionary.ContainsKey(item.Key) == false)
+ {
+ CreateAppInfoModel(item.Key);
+ }
+ Thread.Sleep(100);
+ buttons.Add(appInfoModelDictionary[item.Key]);
}
- buttons.Add(new AppInfoModel("Apps", "org.tizen.Apps", Resources.GetCurrentThemePath() + "apps.png"));
+ buttons.Add(appInfoModelDictionary[AppsId]);
ButtonsInfo = buttons;
}
- public void UpdateButtonsInfo()
+ private void UpdateButtonsInfo()
{
appScoreData.Clear();
appScoreData = AppScoreDataBase.ReadData(appsCount - 1);
AddButtonsInfo();
}
+ public void UpdateViewModel(int count)
+ {
+ maxAppsCount = DeviceInfo.IsPortrait ? maxAppsPortrait : maxAppsLandscape;
+ appsCount = count < maxAppsCount ? count : maxAppsCount;
+ UpdateButtonsInfo();
+ }
+
public void UpdateTheme()
{
BackgroundColor = ThemeManager.PlatformThemeId == Resources.DarkPlatformThemeId ? Resources.DarkApplicationsBackground : Resources.LightApplicationsBackground;
new AppInfoModel(AppNames[0], "org.tizen.homescreen-efl", imagePath + AppNames[0] + ".png"),
new AppInfoModel(AppNames[1], "org.tizen.setting", imagePath + AppNames[1] + ".png"),
new AppInfoModel(AppNames[2], "org.tizen.volume", imagePath + AppNames[2] + ".png"),
- new AppInfoModel(AppNames[3], "org.tizen.quickpanel", imagePath + AppNames[3] + ".png"),
- new AppInfoModel(AppNames[5], "org.tizen.powerkey-syspopup", imagePath + AppNames[5] + ".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
};
ButtonsInfo = buttons;
Tizen.Log.Info(Resources.LogTag, "Done Adding ButtonsInfo");
using System;
using System.Collections.Generic;
using System.Collections;
+using System.Threading;
using System.Windows.Input;
using Tizen.NUI;
using Tizen.NUI.BaseComponents;
public event EventHandler<EventArgs> RemoveModeToggled;
private const int ApplicationViewHeight = 189;
+ private const int IconGap = 16;
private List<AppItemView> appIcons;
- private readonly int maxAppsCount;
private int currentAppsCount;
private AlertDialog removePopup;
private Window removePopupWindow;
+ private Window.WindowOrientation popupOrientation;
+ private bool removeMode;
+ private int removePopupWidth;
+ private int removePopupHeight;
public static readonly BindableProperty AppListProperty = BindableProperty.Create(nameof(AppList), typeof(IEnumerable), typeof(ApplicationsView), null, propertyChanged: (bindable, oldValue, newValue) =>
{
public static readonly BindableProperty AppRemoveCommandProperty = BindableProperty.Create(nameof(AppRemoveCommand), typeof(ICommand), typeof(ApplicationsView), null, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (ApplicationsView)bindable;
+ ApplicationsView instance = (ApplicationsView)bindable;
if (oldValue != newValue)
{
instance.appRemoveCommand = (ICommand)newValue;
},
defaultValueCreator: (bindable) => ((ApplicationsView)bindable).appRemoveCommand);
- public ApplicationsView(int appsCount) : base()
+ public ApplicationsView() : base()
{
Name = "ApplicationsView";
WidthSpecification = LayoutParamPolicies.MatchParent;
LinearOrientation = LinearLayout.Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
- CellPadding = new Size2D(16, 0).SpToPx()
+ CellPadding = new Size2D(IconGap, 0).SpToPx()
};
- maxAppsCount = appsCount;
currentAppsCount = 0;
appList = new List<object>();
- CreateDefaultAppItems();
+ appIcons = new List<AppItemView>();
+ removeMode = false;
Tizen.Log.Info(Resources.LogTag, "ApplicationsView");
}
appIcons[^1].AddTouchEvent();
appIcons[^1].Opacity = 1.0f;
}
- }
-
- private void CreateDefaultAppItems()
- {
- appIcons = new List<AppItemView>();
- for (int i = 0; i < maxAppsCount; i++)
- {
- AppItemView itemView = new AppItemView();
- itemView.Hide();
- itemView.LongPressed += (object sender, EventArgs e) =>
- {
- RemoveModeToggled.Invoke(this, new EventArgs());
- };
- appIcons.Add(itemView);
- }
- Tizen.Log.Info(Resources.LogTag, "Icons Added");
+ this.removeMode = removeMode;
}
private IEnumerable appList;
set => SetValue(AppRemoveCommandProperty, value);
}
- private void UpdateAppIcons()
+ private void RemoveAppIcons()
+ {
+ while (appIcons.Count > 0)
+ {
+ AppItemView item = appIcons[0];
+ Remove(item);
+ appIcons.RemoveAt(0);
+ item.Dispose();
+ }
+ }
+
+ private void AddAppIcons()
{
List<object> appDataList = (List<object>)appList;
int totalCount = appDataList.Count;
-
- if (totalCount <= currentAppsCount)
+ foreach (object item in appDataList)
{
- for (int i = 0; i < totalCount; i++)
- {
- appIcons[i].BindingContext = appDataList[i];
- }
- for (int i = totalCount; i < currentAppsCount; i++)
+ AppItemView itemView = new AppItemView();
+ itemView.LongPressed += (object sender, EventArgs e) =>
{
- AppItemView appItemView = appIcons[i];
- appItemView.Hide();
- Remove(appItemView);
- }
+ RemoveModeToggled.Invoke(this, new EventArgs());
+ };
+ appIcons.Add(itemView);
+ itemView.Show();
+ Add(itemView);
+ itemView.BindingContext = item;
+ itemView.Icon.SetBinding(ImageView.ResourceUrlProperty, "IconUrl");
+ itemView.Label.SetBinding(TextLabel.TextProperty, "Name");
+ itemView.SetBinding(AppItemView.AppSelectCommandProperty, "AppSelectCommand");
+ itemView.IconBackground.SetBinding(BackgroundProperty, "IconBackground");
}
- else
+ currentAppsCount = totalCount;
+ if (removeMode == true)
{
- for (int i = 0; i < currentAppsCount; i++)
- {
- appIcons[i].BindingContext = appDataList[i];
- }
- for (int i = currentAppsCount; i < totalCount; i++)
- {
- AppItemView itemView = appIcons[i];
- itemView.Show();
- Add(itemView);
- itemView.BindingContext = appDataList[i];
- itemView.Icon.SetBinding(ImageView.ResourceUrlProperty, "IconUrl");
- itemView.Label.SetBinding(TextLabel.TextProperty, "Name");
- itemView.SetBinding(AppItemView.AppSelectCommandProperty, "AppSelectCommand");
- }
+ AddDeleteOption();
+ appIcons[^1].RemoveTouchEvent();
+ appIcons[^1].Opacity = 0.4f;
}
- currentAppsCount = totalCount;
+ }
+
+ private void UpdateAppIcons()
+ {
+ RemoveAppIcons();
+ AddAppIcons();
Tizen.Log.Info(Resources.LogTag, "Icons Updated");
}
}
}
+ private void UpdateRemovePopupWindowDimensions()
+ {
+ Thread.Sleep(100);
+ removePopupWidth = (int)((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) * 0.36f);
+ removePopupHeight = 256.SpToPx();
+ int windowPositionX = ((DeviceInfo.DisplayWidth - removePopupWidth) / 2) - 144.SpToPx();
+ int windowPositionY = ((DeviceInfo.DisplayHeight - removePopupHeight) / 2) - 32.SpToPx();
+ removePopupWindow.WindowPosition = new Position2D(windowPositionX, windowPositionY);
+ removePopupWindow.WindowSize = new Size2D(removePopupWidth + 144.SpToPx(), removePopupHeight + 32.SpToPx());
+ }
+
private void AddConfirmationPopup(object appIcon)
{
Tizen.Log.Info(Resources.LogTag, "Popup Added");
if (removePopupWindow == null)
{
- int popupWidth = (int)((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) * 0.36f);
- int popupHeight = 256.SpToPx();
- int windowPositionX = ((DeviceInfo.DisplayWidth - popupWidth) / 2) - 144.SpToPx();
- int windowPositionY = ((DeviceInfo.DisplayHeight - popupHeight) / 2) - 32.SpToPx();
+ removePopupWindow = new Window();
+ List<Window.WindowOrientation> list = new List<Window.WindowOrientation>
+ {
+ Window.WindowOrientation.Landscape,
+ Window.WindowOrientation.LandscapeInverse,
+ Window.WindowOrientation.NoOrientationPreference,
+ Window.WindowOrientation.Portrait,
+ Window.WindowOrientation.PortraitInverse
+ };
+ removePopupWindow.SetAvailableOrientations(list);
+ popupOrientation = removePopupWindow.GetCurrentOrientation();
+ UpdateRemovePopupWindowDimensions();
+
+ removePopupWindow.SetTransparency(true);
+ removePopupWindow.BackgroundColor = Color.Transparent;
+
Button cancelButton = new Button("CancelButton");
Button deleteButton = new Button()
{
removePopup = new AlertDialog()
{
StyleName = "AlertDialogBackground",
- Size2D = new Size2D(popupWidth, popupHeight),
+ Size2D = new Size2D(removePopupWidth, removePopupHeight),
Title = "Delete App from the Tray",
Message = "Do you want to delete this app from the Tray? App won't be uninstalled from your device",
Actions = new List<Button>() { cancelButton, deleteButton },
};
}
- removePopupWindow = new Window
- {
- WindowPosition = new Position2D(windowPositionX, windowPositionY),
- WindowSize = new Size2D(popupWidth + 144.SpToPx(), popupHeight + 32.SpToPx()),
- };
- removePopupWindow.SetTransparency(true);
- removePopupWindow.BackgroundColor = Color.Transparent;
removePopupWindow.Add(removePopup);
+ removePopupWindow.Resized += OnRemovePopupWindowResized;
+
cancelButton.Clicked += (object sender, ClickedEventArgs e) =>
{
RemoveConfirmationPopup();
}
}
+ private void OnRemovePopupWindowResized(object sender, Window.ResizedEventArgs e)
+ {
+ UpdateRemovePopupWindowDimensions();
+ popupOrientation = removePopupWindow.GetCurrentOrientation();
+ Tizen.Log.Info(Resources.LogTag, "Orientation: " + popupOrientation);
+ }
+
private void RemoveConfirmationPopup()
{
removePopupWindow.Remove(removePopup);
{
public class MainView : View
{
+ private const int appIconWidth = 154;
+
+ private ApplicationViewModel applicationViewModel;
+ private QuickAccessViewModel quickAccessViewModel;
private ApplicationsView applicationsView;
private QuickAccessView quickAccessView;
private Animation animation;
public MainView() : base()
{
Name = "MainView";
- WidthSpecification = LayoutParamPolicies.MatchParent;
- HeightSpecification = LayoutParamPolicies.MatchParent;
+ Size2D = new Size2D(Window.Instance.Size.Width, Window.Instance.Size.Height);
CornerRadius = new Vector4(20, 20, 20, 20);
BackgroundColor = Color.Transparent;
Layout = new LinearLayout()
LinearOrientation = LinearLayout.Orientation.Vertical
};
UpdateTheme(ThemeManager.PlatformThemeId);
- int appsCount = Window.Instance.Size.Width / 154.SpToPx();
- ApplicationViewModel applicationViewModel = new ApplicationViewModel(appsCount);
- applicationsView = new ApplicationsView(appsCount);
+ int appsCount = Window.Instance.Size.Width / appIconWidth.SpToPx();
+
+ applicationViewModel = new ApplicationViewModel(appsCount);
+ applicationsView = new ApplicationsView();
Add(applicationsView);
applicationsView.BindingContext = applicationViewModel;
applicationsView.SetBinding(BackgroundColorProperty, "BackgroundColor");
applicationsView.SetBinding(ApplicationsView.AppListProperty, "ButtonsInfo");
applicationsView.SetBinding(ApplicationsView.AppRemoveCommandProperty, "AppRemoveCommand");
- QuickAccessViewModel quickAccessViewModel = new QuickAccessViewModel();
+
+ quickAccessViewModel = new QuickAccessViewModel();
quickAccessView = new QuickAccessView();
Add(quickAccessView);
quickAccessView.BindingContext = quickAccessViewModel;
quickAccessView.SetBinding(BackgroundColorProperty, "BackgroundColor");
quickAccessView.SetBinding(QuickAccessView.AppListProperty, "ButtonsInfo");
+
ThemeManager.ThemeChanged += OnThemeUpdated;
removeMode = false;
applicationsView.RemoveModeToggled += ApplicationsViewRemoveModeToggled;
Hide();
}
+ public void UpdateView()
+ {
+ Size2D = new Size2D(Window.Instance.Size.Width, Window.Instance.Size.Height);
+ int appsCount = Window.Instance.Size.Width / 154.SpToPx();
+ applicationViewModel.UpdateViewModel(appsCount);
+ }
+
private void SetTheme(string path)
{
try