Implement new SetBinding in Notifications with XAML off to improve launch time and... 08/323108/3
authorMd. Shahrukh Islam <shahrukhi.i@samsung.com>
Wed, 23 Apr 2025 06:10:27 +0000 (12:10 +0600)
committerMd. Shahrukh Islam <shahrukhi.i@samsung.com>
Fri, 2 May 2025 10:21:21 +0000 (16:21 +0600)
[Cause & Measure]
1. Implemented SetBinding with creating new BindingSession
2. Set IsUsingXaml variable to false.
3. Launch time improved by on avg 30 ms
4. SptoPx is obsolete.
5. Window.Instance is now obsolete. So used GetDefaultWindow().
6. Optimized division operation with bitwise operation.
7. Removed unnecessary and redundant code

Change-Id: Ifedaecf60c5fb52a82986729e6e6a0c395a3fd40
Signed-off-by: Md. Shahrukh Islam <shahrukhi.i@samsung.com>
13 files changed:
Notifications/Common/AppConstants.cs
Notifications/Common/DeviceInfo.cs
Notifications/CustomBorder.cs
Notifications/Directory.Build.targets
Notifications/Notifications.cs
Notifications/Notifications.csproj
Notifications/ViewManager.cs
Notifications/ViewModels/NotificationsDetailViewModel.cs
Notifications/ViewModels/NotificationsViewModel.cs
Notifications/Views/BaseView.cs
Notifications/Views/ItemLayout.cs
Notifications/core/WindowManager.cs
packaging/org.tizen.notifications-1.0.4.tpk

index c9bdc2bdfc35c478618d665d05cb346edf5e1642..0ecb86b941f8b2bfaa7113948272981d47184033 100644 (file)
@@ -44,5 +44,8 @@ namespace Notifications.Common
 
         public static float windowHeightRatio = 540f / 1080;
         public static float windowWidthRatio = 960f / 1920;
+
+        public static readonly float MinWidthRatio = 704.0f / 1920;
+        public static readonly float MinHeightRatio = 436.0f / 1080;
     }
 }
index d66c401f2c79c9bb01ffab5d57df28e67db9c9bc..162e9d4bb4b56deedc7ce84a9bb70dc9d4ef3d31 100644 (file)
@@ -30,13 +30,13 @@ namespace Notifications.Common
             width = (int)displaySize.Width;
             height = (int)displaySize.Height;
 
-            orientation = Window.Instance.GetCurrentOrientation();
+            orientation = NUIApplication.GetDefaultWindow().GetCurrentOrientation();
             IsPortrait = orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse;
         }
 
         public static void UpdateDeviceInfo()
         {
-            Window.WindowOrientation currentOrientation = Window.Instance.GetCurrentOrientation();
+            Window.WindowOrientation currentOrientation = NUIApplication.GetDefaultWindow().GetCurrentOrientation();
             if (orientation == Window.WindowOrientation.Portrait || orientation == Window.WindowOrientation.PortraitInverse)
             {
                 if (currentOrientation == Window.WindowOrientation.Landscape || currentOrientation == Window.WindowOrientation.LandscapeInverse)
index ef8ec6def258145aec29519a637cfa7e0e187ca3..260a0ae1f48b8e4f2d094028372b1b1a7c4031cb 100644 (file)
@@ -42,19 +42,15 @@ namespace Notifications
         public CustomBorder(Size2D screenSize)
         {
             ResizePolicy = Window.BorderResizePolicyType.Free;
-            float minWidthRatio = 704.0f / 1920;
-            float minHeightRatio = 436.0f / 1080;
-            int minWidth = (int)(screenSize.Width * minWidthRatio);
-            int minHeight = (int)(screenSize.Height * minHeightRatio);
+            int minWidth = (int)(screenSize.Width * AppConstants.MinWidthRatio);
+            int minHeight = (int)(screenSize.Height * AppConstants.MinHeightRatio);
             MinSize = new Size2D(minWidth, minHeight);
         }
 
         public void UpdateMinSize(Size2D screenSize)
         {
-            float minWidthRatio = 704.0f / 1920;
-            float minHeightRatio = 436.0f / 1080;
-            int minWidth = (int)(screenSize.Width * minWidthRatio);
-            int minHeight = (int)(screenSize.Height * minHeightRatio);
+            int minWidth = (int)(screenSize.Width * AppConstants.MinWidthRatio);
+            int minHeight = (int)(screenSize.Height * AppConstants.MinHeightRatio);
             MinSize = new Size2D(minWidth, minHeight);
         }
 
@@ -90,37 +86,37 @@ namespace Notifications
             {
                 return false;
             }
-            BorderLineThickness = (uint)BorderThickness.SpToPx();
-            bottomView.HeightSpecification = BottomViewHeight.SpToPx();
+            BorderLineThickness = (uint)BorderThickness;
+            bottomView.HeightSpecification = BottomViewHeight;
             bottomView.Layout = new RelativeLayout()
             {
-                Padding = new Extents(0, 24, 0, 0).SpToPx(),
+                Padding = new Extents(0, 24, 0, 0),
             };
 
             minimalizeIcon = new ImageView()
             {
-                Size2D = IconSize.SpToPx(),
+                Size2D = IconSize,
                 ResourceUrl = Resources.GetImagePath() + "/minimalize.png",
                 AccessibilityHighlightable = true,
             };
 
             maximalizeIcon = new ImageView()
             {
-                Size2D = IconSize.SpToPx(),
+                Size2D = IconSize,
                 ResourceUrl = Resources.GetImagePath() + "/maximalize.png",
                 AccessibilityHighlightable = true,
             };
 
             closeIcon = new ImageView()
             {
-                Size2D = IconSize.SpToPx(),
+                Size2D = IconSize,
                 ResourceUrl = Resources.GetImagePath() + "/close.png",
                 AccessibilityHighlightable = true,
             };
 
             leftCornerIcon = new ImageView()
             {
-                Size2D = IconSize.SpToPx(),
+                Size2D = IconSize,
                 ResourceUrl = Resources.GetImagePath() + "/leftCorner.png",
                 AccessibilityHighlightable = true,
             };
@@ -180,10 +176,10 @@ namespace Notifications
             {
                 e.Name = "Resize";
             };
-            minimalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
-            maximalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
-            closeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
-            leftCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
+            minimalizeIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
+            maximalizeIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
+            closeIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
+            leftCornerIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
             return true;
         }
 
@@ -224,7 +220,7 @@ namespace Notifications
                 return;
             }
             borderView.CornerRadiusPolicy = VisualTransformPolicyType.Absolute;
-            borderView.CornerRadius = BorderCornerRadius.SpToPx();
+            borderView.CornerRadius = BorderCornerRadius;
 
             if (maximalizeIcon == null)
             {
index a468954a9ba6e9f6832eb54ce258228566757038..e418e4cf5c73fa5d81f616834cb18dbaf10bd8b2 100644 (file)
@@ -16,6 +16,6 @@ WARNING:  DO NOT MODIFY this file. Incorrect changes to this file will make it
         </PropertyGroup>
         <Message Text="Workspace: '$(WorkspaceFolder)'"  Importance="high" />
 
-               <Exec Command="C:\tizen-studio\tools\tizen-core\tz.exe pack  -S $(ProjectDir) $(WorkspaceFolder)"> </Exec>
+               <Exec Command="D:\tizensdk\tools\tizen-core\tz.exe pack-chain  -S $(ProjectDir) $(ProjectDir)"> </Exec>
     </Target>
 </Project>
index c4dd842fe071077cfdbdb93c90099cfb7c76a6ad..ad0cd6907f8e0d48d629c7379a70e6f20456595a 100644 (file)
@@ -33,6 +33,12 @@ namespace Notifications
         {
         }
 
+        protected override void OnPreCreate()
+        {
+            IsUsingXaml = false;
+            base.OnPreCreate();
+        }
+
         protected override void OnCreate()
         {
             base.OnCreate();
@@ -44,7 +50,7 @@ namespace Notifications
             Tizen.Log.Info(AppConstants.LogTag, "Program OnCreate");
             SetupLanguage();
 
-            window = Window.Instance;
+            window = GetDefaultWindow();
             window.SetTransparency(true);
             List<Window.WindowOrientation> list = new List<Window.WindowOrientation>
             {
index a12d1362b85713dc10b76245de7cebb6e8cf4f20..ce0e6c42331f26fe68a68c057d4d93269f5ad5f8 100644 (file)
@@ -13,7 +13,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Tizen.NET" Version="12.0.0.18428" />
+    <PackageReference Include="Tizen.NET.API13" Version="13.0.0.18710" />
   </ItemGroup>
 
   <ItemGroup>
index 40724940c6f8fea4da73a78563287154f976dbdf..1a97ab23ff90756b0549b3be4bf79b7233426a3c 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 using System;
-using System.Timers;
 using Tizen.Applications.NotificationEventListener;
 using Tizen.NUI;
 using Notifications.Common;
@@ -39,12 +38,12 @@ namespace Notifications
             baseView.BindingContext = notificationsViewModel;
             baseView.BackKeyPressed += OnBackKeyPressed;
 
-            Window.Instance.Add(baseView);
+            NUIApplication.GetDefaultWindow().Add(baseView);
 
             timer = new System.Timers.Timer(500);
             timer.Elapsed += (s, e) =>
             {
-                Window.Instance.Resized += OnWindowResized;
+                NUIApplication.GetDefaultWindow().Resized += OnWindowResized;
                 timer.Stop();
             };
             timer.Start();
index 7ce881eb553bd14831ee716cb45132b7f856d7c6..a4685c3f37a5ee84f7f0e3974b3e90d5e8ad951c 100644 (file)
@@ -48,8 +48,11 @@ namespace Notifications.ViewModels
             get => detailContent;
             set
             {
-                detailContent = value;
-                OnPropertyChanged("DetailContent");
+                if (detailContent != value)
+                {
+                    detailContent = value;
+                    OnPropertyChanged("DetailContent");
+                }
             }
         }
 
@@ -59,8 +62,11 @@ namespace Notifications.ViewModels
             get => backCommand;
             set
             {
-                backCommand = value;
-                OnPropertyChanged("BackCommand");
+                if (backCommand != value)
+                {
+                    backCommand = value;
+                    OnPropertyChanged("BackCommand");
+                }
             }
         }
 
@@ -75,20 +81,24 @@ namespace Notifications.ViewModels
             get => appLaunchCommand;
             set
             {
-                appLaunchCommand = value;
-                OnPropertyChanged("AppLaunchCommand");
+                if (appLaunchCommand != value)
+                {
+                    appLaunchCommand = value;
+                    OnPropertyChanged("AppLaunchCommand");
+                }
             }
         }
 
         private void OnAppLaunched()
         {
-            AppControl appControl = new AppControl()
-            {
-                ApplicationId = AppId,
-                Operation = AppControlOperations.Default,
-            };
             try
             {
+                AppControl appControl = new AppControl()
+                {
+                    ApplicationId = AppId,
+                    Operation = AppControlOperations.Default,
+                };
+
                 AppControl.SendLaunchRequest(appControl);
             }
             catch (Exception ex)
index 5ce982a66233f04a356822bc54bd808040a2a3ef..05620df5118047c39e66049101b816c7631ba2f3 100644 (file)
@@ -51,8 +51,11 @@ namespace Notifications.ViewModels
             get => isNotificationsPresent;
             set
             {
-                isNotificationsPresent = value;
-                OnPropertyChanged("IsNotificationsPresent");
+                if (isNotificationsPresent != value)
+                {
+                    isNotificationsPresent = value;
+                    OnPropertyChanged("IsNotificationsPresent");
+                }
             }
         }
 
index 4b189492050036edffa9008228b8ceaddc9f027a..930294e349e2bc2664bfd81c14adbe966b322342 100644 (file)
@@ -19,9 +19,65 @@ using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Binding;
 using Tizen.NUI.Components;
 using Notifications.Common;
+using Notifications.ViewModels;
+using System.Windows.Input;
+using System.Collections;
+using Notifications.Models;
 
 namespace Notifications.Views
 {
+    static class ViewBindings
+    {
+        public static BindingProperty<BaseView, bool> IsContentAvailableProperty { get; } = new BindingProperty<BaseView, bool>
+        {
+            Setter = (v, value) => v.IsContentAvailable = value,
+        };
+
+        public static BindingProperty<View, ICommand> CommandProperty { get; } = new BindingProperty<View, ICommand>
+        {
+            Setter = (v, value) => ((Control)v).Command = value,
+        };
+    }
+
+    static class RecyclerViewBindings
+    {
+        public static BindingProperty<RecyclerView, IEnumerable> ItemsSourceProperty { get; } = new BindingProperty<RecyclerView, IEnumerable>
+        {
+            Setter = (v, value) => v.ItemsSource = value,
+        };
+    }
+
+    static class CollectionViewBindings
+    {
+        public static BindingProperty<CollectionView, ICommand> SelectionChangedCommandProperty { get; } = new BindingProperty<CollectionView, ICommand>
+        {
+            Setter = (v, value) => v.SelectionChangedCommand = value,
+        };
+    }
+
+    static class ButtonBindings
+    {
+        public static BindingProperty<Button, bool> IsSelectedProperty { get; } = new BindingProperty<Button, bool>
+        {
+            Setter = (v, value) => v.IsSelected = value,
+        };
+
+        public static BindingProperty<Button, string> TextProperty { get; } = new BindingProperty<Button, string>
+        {
+            Setter = (v, value) => v.Text = value,
+        };
+
+        public static BindingProperty<Button, ICommand> CommandProperty { get; } = new BindingProperty<Button, ICommand>
+        {
+            Setter = (v, value) => v.Command = value,
+        };
+
+        public static BindingProperty<Button, bool> IsEnabledProperty { get; } = new BindingProperty<Button, bool>
+        {
+            Setter = (v, value) => v.IsEnabled = value,
+        };
+    }
+
     class BaseView : View
     {
         public static BindableProperty IsContentAvailableProperty = BindableProperty.Create(nameof(IsContentAvailable), typeof(bool), typeof(BaseView), false, propertyChanged: (bindable, oldValue, newValue) =>
@@ -49,8 +105,8 @@ namespace Notifications.Views
         public BaseView() : base()
         {
             ThemeChangeSensitive = true;
-            Size2D = Window.Instance.Size;
-            CornerRadius = (AppConstants.BorderCornerRadius - AppConstants.BorderWindowPadding).SpToPx();
+            Size2D = NUIApplication.GetDefaultWindow().Size;
+            CornerRadius = (AppConstants.BorderCornerRadius - AppConstants.BorderWindowPadding);
             Layout = new LinearLayout()
             {
                 LinearOrientation = LinearLayout.Orientation.Vertical,
@@ -61,7 +117,17 @@ namespace Notifications.Views
 
             AddTopView();
             UpdateContent();
-            this.SetBinding(IsContentAvailableProperty, "IsNotificationsPresent");
+
+            var session = new BindingSession <NotificationsViewModel>();
+
+            this.BindingContextChanged += (sender, e) =>
+            {
+                if (this.BindingContext is NotificationsViewModel model)
+                {
+                    session.ViewModel = model;
+                }
+            };
+            this.SetBinding(session, ViewBindings.IsContentAvailableProperty, "IsNotificationsPresent");
         }
 
         public void UpdateContent()
@@ -82,38 +148,47 @@ namespace Notifications.Views
 
         public void AddDetailContentView()
         {
-
             RemoveContent();
             if (detailContentView == null)
             {
-                ButtonStyle buttonStyle = new ButtonStyle()
+                var text = new TextLabel()
                 {
                     BackgroundColor = Color.Transparent,
-                    Text = new TextLabelStyle()
-                    {
-                        BackgroundColor = Color.Transparent,
-                        MultiLine = true,
-                        FontFamily = "BreezeSans",
-                        HorizontalAlignment = HorizontalAlignment.Begin,
-                    },
-                    Margin = AppConstants.DetailContentMargin.SpToPx(),
-                    IsEnabled = true,
-                    IsSelectable = false,
+                    MultiLine = true,
+                    FontFamily = "BreezeSans",
+                    HorizontalAlignment = HorizontalAlignment.Begin,
                 };
-                detailContentView = new Button(buttonStyle)
+                detailContentView = new Button()
                 {
+                    BackgroundColor = Color.Transparent,
+
+                    Margin = AppConstants.DetailContentMargin,
+                    IsEnabled = true,
+                    IsSelectable = false,
                     WidthSpecification = LayoutParamPolicies.MatchParent,
                     HeightSpecification = LayoutParamPolicies.WrapContent,
                 };
-                detailContentView.SetBinding(Button.TextProperty, "DetailContent");
-                detailContentView.SetBinding(Control.CommandProperty, "AppLaunchCommand");
+                detailContentView.Add(text);
+
+                var session = new BindingSession<NotificationsDetailViewModel>();
+
+                detailContentView.BindingContextChanged += (sender, e) =>
+                {
+                    if (detailContentView.BindingContext is NotificationsDetailViewModel viewModel)
+                    {
+                        session.ViewModel = viewModel;
+                    }
+                };
+
+                detailContentView.SetBinding(session, ButtonBindings.TextProperty, "DetailContent");
+                detailContentView.SetBinding(session, ButtonBindings.CommandProperty, "AppLaunchCommand");
             }
             Add(detailContentView);
         }
 
         public void UpdateSize()
         {
-            Size2D = Window.Instance.Size;
+            Size2D = NUIApplication.GetDefaultWindow().Size;
             UpdateNotificationsViewItemTemplate();
         }
 
@@ -157,10 +232,10 @@ namespace Notifications.Views
             {
                 ThemeChangeSensitive = true,
                 WidthSpecification = LayoutParamPolicies.MatchParent,
-                HeightSpecification = AppConstants.HeaderHeight.SpToPx(),
+                HeightSpecification = AppConstants.HeaderHeight,
                 Layout = new RelativeLayout()
                 {
-                    Padding = AppConstants.HeaderPadding.SpToPx(),
+                    Padding = AppConstants.HeaderPadding,
                 },
             };
             Add(topView);
@@ -169,22 +244,36 @@ namespace Notifications.Views
 
         private void AddTopViewElements()
         {
-            ButtonStyle buttonStyle = new ButtonStyle()
+            var buttonSize = AppConstants.BackButtonSize;
+
+            ImageView icon = new ImageView
             {
                 BackgroundColor = Color.Transparent,
-                Size = AppConstants.BackButtonSize.SpToPx(),
-                Icon = new ImageViewStyle()
-                {
-                    BackgroundColor = Color.Transparent,
-                    Size = AppConstants.BackButtonSize.SpToPx(),
-                },
+                Size = buttonSize,
+            };
+
+            backButton = new Button()
+            {
+                BackgroundColor = Color.Transparent,
+                Size = buttonSize,
+
                 IsEnabled = true,
                 IsSelectable = false,
             };
-            backButton = new Button(buttonStyle);
+            backButton.Add(icon);
+
             RelativeLayout.SetVerticalAlignment(backButton, RelativeLayout.Alignment.Center);
             RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start);
-            backButton.SetBinding(Control.CommandProperty, "BackCommand");
+
+            var session = new BindingSession<NotificationsDetailViewModel>();
+            backButton.BindingContextChanged += (sender, e) =>
+            {
+                if (backButton.BindingContext is NotificationsDetailViewModel model)
+                {
+                    session.ViewModel = model;
+                }
+            };
+            backButton.SetBinding(session, ButtonBindings.CommandProperty, "BackCommand");
             topView.Add(backButton);
 
             titleText = new TextLabel()
@@ -193,7 +282,7 @@ namespace Notifications.Views
                 TranslatableText = "IDS_ST_HEADER_NOTIFICATIONS",
                 HeightSpecification = LayoutParamPolicies.MatchParent,
                 VerticalAlignment = VerticalAlignment.Center,
-                PixelSize = AppConstants.TextPixelSize.SpToPx(),
+                PixelSize = AppConstants.TextPixelSize,
                 FontFamily = "BreezeSans",
             };
             RelativeLayout.SetLeftTarget(titleText, backButton);
@@ -221,8 +310,19 @@ namespace Notifications.Views
                     SelectionMode = ItemSelectionMode.Single,
                 };
                 UpdateNotificationsViewItemTemplate();
-                notificationsView.SetBinding(RecyclerView.ItemsSourceProperty, "NotificationsListSource");
-                notificationsView.SetBinding(CollectionView.SelectionChangedCommandProperty, "SelectionChangedCommand");
+
+                var session = new BindingSession<NotificationsViewModel>();
+
+                notificationsView.BindingContextChanged += (sender, e) =>
+                {
+                    if (notificationsView.BindingContext is NotificationsViewModel model)
+                    {
+                        session.ViewModel = model;
+                    }
+                };
+
+                notificationsView.SetBinding(session, RecyclerViewBindings.ItemsSourceProperty, "NotificationsListSource");
+                notificationsView.SetBinding(session, CollectionViewBindings.SelectionChangedCommandProperty, "SelectionChangedCommand");
             }
             notificationsView.SelectedItem = null;
             Add(notificationsView);
@@ -234,13 +334,24 @@ namespace Notifications.Views
             {
                 return;
             }
-            notificationsView.SizeWidth = Window.Instance.Size.Width;
+            notificationsView.SizeWidth = NUIApplication.GetDefaultWindow().Size.Width;
             notificationsView.ItemTemplate = new DataTemplate(() =>
             {
                 ItemLayout item = new ItemLayout();
-                item.Label.SetBinding(TextLabel.TextProperty, "Title");
-                item.SubLabel.SetBinding(TextLabel.TextProperty, "SubTitle");
-                item.Extra.SetBinding(Control.CommandProperty, "ClearNotificationCommand");
+
+                var session = new BindingSession<NotificationsModel>();
+
+                item.BindingContextChanged += (sender, e) =>
+                {
+                    if (item.BindingContext is NotificationsModel model)
+                    {
+                        session.ViewModel = model;
+                    }
+                };
+
+                item.Label.SetBinding(session, TextLabelBindings.TextProperty, "Title");
+                item.SubLabel.SetBinding(session, TextLabelBindings.TextProperty, "SubTitle");
+                item.Extra.SetBinding(session, ViewBindings.CommandProperty, "ClearNotificationCommand");
                 return item;
             });
         }
@@ -249,24 +360,34 @@ namespace Notifications.Views
         {
             if (clearAllButton == null)
             {
-                ButtonStyle buttonStyle = new ButtonStyle()
+                var textLabel = new TextLabel()
                 {
-                    Size = AppConstants.ClearAllButtonSize.SpToPx(),
                     BackgroundColor = Color.Transparent,
-                    Text = new TextLabelStyle()
-                    {
-                        BackgroundColor = Color.Transparent,
-                        TranslatableText = "IDS_ST_BUTTON_CLEAR_ALL",
-                        FontFamily = "BreezeSans",
-                        VerticalAlignment = VerticalAlignment.Center,
-                        HorizontalAlignment = HorizontalAlignment.Center,
-                    },
+                    TranslatableText = "IDS_ST_BUTTON_CLEAR_ALL",
+                    FontFamily = "BreezeSans",
+                    VerticalAlignment = VerticalAlignment.Center,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                };
+
+                clearAllButton = new Button()
+                {
+                    Size = AppConstants.ClearAllButtonSize,
+                    BackgroundColor = Color.Transparent,
                 };
-                clearAllButton = new Button(buttonStyle);
+                clearAllButton.Add(textLabel);
 
                 RelativeLayout.SetVerticalAlignment(clearAllButton, RelativeLayout.Alignment.Center);
                 RelativeLayout.SetHorizontalAlignment(clearAllButton, RelativeLayout.Alignment.End);
-                clearAllButton.SetBinding(Control.CommandProperty, "ClearAllNotificationsCommand");
+
+                var session = new BindingSession<NotificationsViewModel>();
+                clearAllButton.BindingContextChanged += (sender, e) =>
+                {
+                    if (clearAllButton.BindingContext is NotificationsViewModel model)
+                    {
+                        session.ViewModel = model;
+                    }
+                };
+                clearAllButton.SetBinding(session, ButtonBindings.CommandProperty, "ClearAllNotificationsCommand");
             }
             topView?.Add(clearAllButton);
         }
@@ -283,7 +404,7 @@ namespace Notifications.Views
                     HorizontalAlignment = HorizontalAlignment.Center,
                     VerticalAlignment = VerticalAlignment.Center,
                     FontFamily = "BreezeSans",
-                    PixelSize = AppConstants.TextPixelSize.SpToPx(),
+                    PixelSize = AppConstants.TextPixelSize,
                 };
             }
             Add(noNotificationsText);
@@ -333,6 +454,7 @@ namespace Notifications.Views
                 topView?.Dispose();
                 topView = null;
             }
+
             Tizen.Log.Info(AppConstants.LogTag, "Dispose BaseView");
             base.Dispose(type);
         }
index 392e04b29a6551df8f842657710fad95a96cc0a3..c665b252258fe9b5b714a0e03cea39754b1bfe44 100644 (file)
@@ -10,31 +10,35 @@ namespace Notifications.Views
         public ItemLayout() : base()
         {
             WidthSpecification = LayoutParamPolicies.MatchParent;
-            HeightSpecification = AppConstants.NotificationItemHeight.SpToPx();
+            HeightSpecification = AppConstants.NotificationItemHeight;
+
+            var textSizePx = AppConstants.TextPixelSize;
 
             Label.HorizontalAlignment = HorizontalAlignment.Begin;
             Label.VerticalAlignment = VerticalAlignment.Bottom;
             Label.FontFamily = "BreezeSans";
-            Label.PixelSize = AppConstants.TextPixelSize.SpToPx();
+            Label.PixelSize = textSizePx;
 
             SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
             SubLabel.VerticalAlignment = VerticalAlignment.Top;
             SubLabel.FontFamily = "BreezeSans";
-            SubLabel.PixelSize = AppConstants.TextPixelSize.SpToPx();
+            SubLabel.PixelSize = textSizePx;
+
+            var clearBinSizePx = AppConstants.ClearBinSize;
 
-            ButtonStyle buttonStyle = new ButtonStyle()
+            var icon = new ImageView()
+            {
+                BackgroundColor = Color.Transparent,
+                Size = clearBinSizePx,
+            };
+            Extra = new Button()
             {
-                Size = AppConstants.ClearBinSize.SpToPx(),
+                Size = clearBinSizePx,
                 BackgroundColor = Color.Transparent,
-                Icon = new ImageViewStyle()
-                {
-                    BackgroundColor = Color.Transparent,
-                    Size = AppConstants.ClearBinSize.SpToPx(),
-                },
                 IsEnabled = true,
                 IsSelectable = false,
             };
-            Extra = new Button(buttonStyle);
+            Extra.Add(icon);
 
             UpdateTheme();
             ThemeManager.ThemeChanged += OnItemThemeChanged;
@@ -66,4 +70,4 @@ namespace Notifications.Views
             base.Dispose(type);
         }
     }
-}
+}
\ No newline at end of file
index e082828755b5035db0a29a8da438b554d4d79d31..6f736e47b7c4c84768bc2fb66ecc830f1e5549bb 100644 (file)
@@ -25,7 +25,7 @@ namespace Notifications.Core
 
         static WindowManager()
         {
-            window = Window.Instance;
+            window = NUIApplication.GetDefaultWindow();
         }
 
         public static void UpdateWindowPositionSize()
@@ -38,8 +38,8 @@ namespace Notifications.Core
             width = (int)(DeviceInfo.DisplayWidth * AppConstants.windowWidthRatio);
             height = (int)(DeviceInfo.DisplayHeight * AppConstants.windowHeightRatio);
 
-            positionX = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) - width) / 2;
-            positionY = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayWidth : DeviceInfo.DisplayHeight) - height) / 2;
+            positionX = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) - width) >> 1;
+            positionY = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayWidth : DeviceInfo.DisplayHeight) - height) >> 1;
 
             if (DeviceInfo.IsPortrait)
             {
index c43fcbfbb07bbe357daed004cd56d8bbd8a86834..f1c5dd30b1fd2f2d5b14f5bc66c0b77d726be38b 100644 (file)
Binary files a/packaging/org.tizen.notifications-1.0.4.tpk and b/packaging/org.tizen.notifications-1.0.4.tpk differ