Exchanges menu key handling from MessageCenter to EventHandler
authorHyerim Kim <rimi.kim@samsung.com>
Wed, 10 May 2017 09:47:53 +0000 (18:47 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:55 +0000 (18:34 +0900)
Fixed a bug on scaling dimmed backgound image of SubPanelAllAppsButton / SettingSubPanelButton
Scrolling when recent list item is focused
Changes sort comparer to descending of recent list

Change-Id: If1419f57946a46266c93f02023acb6798d5fc06c
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
LibTVRefCommonPortable/DataModels/RecentShortcutInfo.cs
TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml.cs
TVHome/TVHome/Controls/SubPanelSettingButton.xaml.cs
TVHome/TVHome/TVHome.cs
TVHome/TVHome/ViewModels/MainPageViewModel.cs
TVHome/TVHome/Views/MainPage.xaml.cs
TVHome/TVHome/Views/MainPanel.xaml.cs
TVHome/TVHome/Views/Panel.cs
TVHome/TVHome/Views/SubPanel.xaml.cs
TVHome/TVHome/Views/SubThumbnailPanel.xaml.cs

index 05a0180..3d853ef 100755 (executable)
@@ -63,7 +63,7 @@ namespace LibTVRefCommonPortable.DataModels
         int IComparable.CompareTo(object target)
         {
             var rightShortcutInfo = target as RecentShortcutInfo;
-            return Date.CompareTo(rightShortcutInfo.Date);
+            return Date.CompareTo(rightShortcutInfo.Date) * -1;
         }
     }
 }
index 5beba18..7a51c49 100755 (executable)
@@ -77,6 +77,7 @@ namespace TVHome.Controls
             ButtonTitle.TranslateTo(0, selectTransitionHeight, 300);
 #pragma warning restore CS4014
             await ButtonImage.ScaleTo(1.3, 300);
+            ButtonDimmedImage.Scale = 1.3;
         }
 
         /// <summary>
@@ -92,6 +93,7 @@ namespace TVHome.Controls
             ButtonTitle.TranslateTo(0, 0, 300);
 #pragma warning restore CS4014
             await ButtonImage.ScaleTo(1.0, 300);
+            ButtonDimmedImage.Scale = 1.0;
         }
 
         /// <summary>
index 0969367..83eb814 100755 (executable)
@@ -77,6 +77,7 @@ namespace TVHome.Controls
             ButtonTitle.TranslateTo(0, selectTransitionHeight, 300);
 #pragma warning restore CS4014
             await ButtonImage.ScaleTo(1.3, 300);
+            ButtonDimmedImage.Scale = 1.3;
         }
 
         /// <summary>
@@ -92,6 +93,7 @@ namespace TVHome.Controls
             ButtonTitle.TranslateTo(0, 0, 300);
 #pragma warning restore CS4014
             await ButtonImage.ScaleTo(1, 300);
+            ButtonDimmedImage.Scale = 1;
         }
 
         /// <summary>
index e614b25..213a24a 100755 (executable)
@@ -192,11 +192,10 @@ namespace TVHome
         public void OnMenuKeyPressed()
         {
             DebuggingUtils.Dbg("\" Menu Key \" ");
-            /* MenuKeyListener.Invoke(this, new TVHomeEventArgs()
-             {
-                 arg = "",
-             });*/
-            MessagingCenter.Send<App>(this, "MenuKeyPressed");
+            MenuKeyListener.Invoke(this, new TVHomeEventArgs()
+            {
+                arg = "",
+            });
         }
 
         public void OnNavigationKeyPressed(string keyName)
index eff83cc..e6a5955 100755 (executable)
@@ -164,7 +164,7 @@ namespace TVHome.ViewModels
         {
             get
             {
-                return new Thickness(SizeUtils.GetHeightSize(223), SizeUtils.GetWidthSize(32));
+                return new Thickness(SizeUtils.GetWidthSize(96), SizeUtils.GetWidthSize(32));
             }
         }
 
index 4175824..f95992e 100755 (executable)
@@ -134,6 +134,18 @@ namespace TVHome.Views
                 ToggleIconified();
             });
 
+            App.SetMenuKeyListener((e, arg) =>
+            {
+                if (AppsSubPanel.isFocused)
+                {
+                    AppsSubPanel.MenuKeyPressed();
+                }
+                else if (RecentSubPanel.isFocused)
+                {
+                    RecentSubPanel.MenuKeyPressed();
+                }
+            });
+
             AppsSubPanel.OnShowOptionsCommand = new Command<bool>((isShowOptions) =>
             {
                 var bounds = AppsSubPanel.Bounds;
index 254187e..79b4687 100755 (executable)
@@ -138,5 +138,10 @@ namespace TVHome.Views
             var button = PanelButtonGrid.Children[idx];
             button.FindByName<Button>("ButtonFocusArea").Focus();
         }
+
+        public override void MenuKeyPressed()
+        {
+
+        }
     }
 }
\ No newline at end of file
index fbd7eff..fe8cfbe 100755 (executable)
@@ -156,5 +156,10 @@ namespace TVHome.Views
 
         public delegate void ItemClickEventHandler();
         public ItemClickEventHandler OnItemClickEventHandler;
+
+        /// <summary>
+        /// A method for handling when menu key is pressed
+        /// </summary>
+        public abstract void MenuKeyPressed();
     }
 }
index ebdf9c7..8692bd6 100755 (executable)
@@ -69,28 +69,29 @@ namespace TVHome.Views
             ButtonList = new List<PanelButton>();
             ButtonViewList = new List<View>();
             PropertyChanged += OnItemsSourcePropertyChanged;
+        }
 
-            MessagingCenter.Subscribe<App>(this, "MenuKeyPressed", (sender) =>
-            {
-                isShowOptions = true;
 
-                if (isFocused)
+        public override void MenuKeyPressed()
+        {
+            isShowOptions = true;
+
+            if (isFocused)
+            {
+                foreach (var item in ButtonList)
                 {
-                    foreach (var item in ButtonList)
+                    if (item is SubPanelButton)
                     {
-                        if (item is SubPanelButton)
+                        if (item.isFocused)
                         {
-                            if (item.isFocused)
-                            {
-                                OnShowOptionsCommand?.Execute(isShowOptions);
-                                item.ShowContextPopup();
-                                item.ChangeShowOptionsMode(isShowOptions);
-                                ChangeIsEnabledProperty(item.View, false);
-                            }
+                            OnShowOptionsCommand?.Execute(isShowOptions);
+                            item.ShowContextPopup();
+                            item.ChangeShowOptionsMode(isShowOptions);
+                            ChangeIsEnabledProperty(item.View, false);
                         }
                     }
                 }
-            });
+            }
         }
         /// <summary>
         /// A event handler for handling property changed event
index 3d9a4cb..383dd8c 100755 (executable)
@@ -68,20 +68,20 @@ namespace TVHome.Views
             NoContentInfoText.On<Tizen>().SetFontWeight(FontWeight.Light);
 
             ButtonList = new List<PanelButton>();
+        }
 
-            MessagingCenter.Subscribe<App>(this, "MenuKeyPressed", (sender) =>
+        public override void MenuKeyPressed()
+        {
+            if (isFocused)
             {
-                if (isFocused)
+                foreach (var item in ButtonList)
                 {
-                    foreach (var item in ButtonList)
+                    if (item.isFocused)
                     {
-                        if (item.isFocused)
-                        {
-                            item.ShowContextPopup();
-                        }
+                        item.ShowContextPopup();
                     }
                 }
-            });
+            }
         }
 
         /// <summary>
@@ -106,49 +106,66 @@ namespace TVHome.Views
                     NoContentInfo.IsVisible = false;
                 }
             }
-            else if (e.PropertyName != "ItemsSource")
-            {
-                return;
-            }
-
-            PanelButtonStack.Children.Clear();
-            ButtonList.Clear();
-            foreach (RecentShortcutInfo item in ItemsSource)
+            else if (e.PropertyName == "ItemsSource")
             {
-                PanelButton button = new SubPanelThumbnailButton();
-                button.View.BindingContext = item;
-                button.OnFocusedCommand = new Command(() =>
+                PanelButtonStack.Children.Clear();
+                ButtonList.Clear();
+                foreach (RecentShortcutInfo item in ItemsSource)
                 {
-                    FocusPanel();
-                });
-                button.OnClickedCommand = new Command(() =>
-                {
-                    item.DoAction();
-                    OnItemClickEventHandler?.Invoke();
-                });
-                button.OnClearCommand = new Command(() =>
+                    PanelButton button = new SubPanelThumbnailButton();
+                    button.View.BindingContext = item;
+                    button.OnFocusedCommand = new Command(() =>
+                    {
+                        FocusPanel();
+                        if (SizeUtils.GetWidthSize((int)button.View.X) - SizeUtils.GetWidthSize((int)PanelScrollView.ScrollX) < 0)
+                        {
+                            ScrollToLeft();
+                        }
+                        else if (SizeUtils.GetWidthSize((int)button.View.X) + SizeUtils.GetWidthSize(320) > SizeUtils.GetWidthSize(1920))
+                        {
+                            ScrollToRight();
+                        }
+                    });
+                    button.OnClickedCommand = new Command(() =>
+                    {
+                        item.DoAction();
+                    });
+                    button.OnClearCommand = new Command(() =>
+                    {
+                        OnClearVMCommand.Execute(item.Id);
+                    });
+                    button.OnClearAllCommand = new Command(() =>
+                    {
+                        OnClearAllVMCommand.Execute("");
+                    });
+                    PanelButtonStack.Children.Add(button.View);
+                    ButtonList.Add(button);
+                }
+
+                if (!isFocused)
                 {
-                    OnClearVMCommand.Execute(item.Id);
-                });
-                button.OnClearAllCommand = new Command(() =>
+                    HidePanel();
+                }
+                else
                 {
-                    OnClearAllVMCommand.Execute("");
-                });
-                PanelButtonStack.Children.Add(button.View);
-                ButtonList.Add(button);
+                    isFocused = false;
+                    FocusPanel();
+                }
             }
+        }
 
-            if (!isFocused)
-            {
-                HidePanel();
-            }
-            else
-            {
-                isFocused = false;
-                FocusPanel();
-            }
+        private async void ScrollToRight()
+        {
+            double distance = SizeUtils.GetWidthSize((int)PanelScrollView.ScrollX) + SizeUtils.GetWidthSize(320);
+            await Task.Delay(1);
+            await PanelScrollView.ScrollToAsync(distance, 0, true);
+        }
 
-            PanelScrollView.ScrollToAsync(110, 0, false);
+        private async void ScrollToLeft()
+        {
+            double distance = SizeUtils.GetWidthSize((int)PanelScrollView.ScrollX) - SizeUtils.GetWidthSize(320);
+            await Task.Delay(1);
+            await PanelScrollView.ScrollToAsync(distance, 0, true);
         }
 
         public IList<View> GetSubPanelButtons()
@@ -176,7 +193,7 @@ namespace TVHome.Views
                     item.IsEnabled = false;
                 }
 #pragma warning disable CS4014
-                PanelScrollView.ScrollToAsync(110, 0, true);
+                PanelScrollView.ScrollToAsync(0, 0, true);
                 this.TranslateTo(0, selectTransitionHeight, 300);
 #pragma warning restore CS4014
                 await this.FadeTo(0, 300);