Implement Move icons in Home subpanel
authorHyerim Kim <rimi.kim@samsung.com>
Sat, 15 Apr 2017 06:23:12 +0000 (15:23 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:52 +0000 (18:34 +0900)
Change-Id: If0a882ea66773600b26f58b23370587fea437cc1
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
14 files changed:
LibTVRefCommonPortable/Utils/IPlatformNotification.cs
TVApps/TVApps/TVApps.cs
TVHome/TVHome.TizenTV/TVHome.TizenTV.cs
TVHome/TVHome/Controls/MainPanelButton.xaml.cs
TVHome/TVHome/Controls/PanelButton.cs
TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml.cs
TVHome/TVHome/Controls/SubPanelButton.xaml
TVHome/TVHome/Controls/SubPanelButton.xaml.cs
TVHome/TVHome/Controls/SubPanelReservedButton.xaml.cs
TVHome/TVHome/Controls/SubPanelSettingButton.xaml.cs
TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs
TVHome/TVHome/TVHome.cs
TVHome/TVHome/Views/MainPage.xaml.cs
TVHome/TVHome/Views/SubPanel.xaml.cs

index c816f1d..2198c3f 100755 (executable)
@@ -54,5 +54,11 @@ namespace LibTVRefCommonPortable.Utils
         /// </summary>
         /// <param name="appID">A pinned app ID</param>
         void OnAppPinnedNotificationReceived(string appID);
+
+        /// <summary>
+        /// A method will be called when the Nativation remote control key is pressed.
+        /// </summary>
+        /// <param name="apkeyNamepID">A pressed remote control key name</param>
+        void OnNavigationKeyPressed(string keyName);
     }
 }
index 2df3aa7..1263ddd 100755 (executable)
@@ -202,5 +202,9 @@ namespace TVApps
             });
         }
 
+        public void OnNavigationKeyPressed(string keyName)
+        {
+
+        }
     }
 }
index d9fcd5c..ac184ee 100755 (executable)
@@ -81,6 +81,10 @@ namespace TVHome.TizenTV
             // Grab key events
             MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName, true);
             MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, true);
+            MainWindow.KeyGrab("Up", false);
+            MainWindow.KeyGrab("Down", false);
+            MainWindow.KeyGrab("Left", false);
+            MainWindow.KeyGrab("Right", false);
             windowPort.SetKeyGrabExclusively(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName);
         }
 
@@ -106,6 +110,13 @@ namespace TVHome.TizenTV
                     notification.OnMenuKeyPressed();
                 }
             }
+            else if (e.KeyName.Equals("Up") || e.KeyName.Equals("Down") || e.KeyName.Equals("Left") || e.KeyName.Equals("Right"))
+            {
+                if (notification != null)
+                {
+                    notification.OnNavigationKeyPressed(e.KeyName);
+                }
+            }
         }
 
         /// <summary>
@@ -119,6 +130,10 @@ namespace TVHome.TizenTV
             PackageManagerPort.UnregisterCallbacks();
             MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName);
             MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName);
+            MainWindow.KeyUngrab("Up");
+            MainWindow.KeyUngrab("Down");
+            MainWindow.KeyUngrab("Left");
+            MainWindow.KeyUngrab("Right");
         }
 
         /// <summary>
index 86c645c..b7f5fb4 100755 (executable)
@@ -139,7 +139,8 @@ namespace TVHome.Controls
         /// A method for handling the button when button is changed to move mode
         /// </summary>
         /// <param name="isMoveMode">A flag indicates whether the button is move mode or not</param>
-        public override void ChangeMoveMode(bool isMoveMode)
+        /// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
+        public override void ChangeMoveMode(bool isMoveMode, bool isDefault)
         {
 
         }
index 4f310e8..84fa5b6 100755 (executable)
@@ -88,7 +88,8 @@ namespace TVHome.Controls
         /// A method for handling the button when button is changed to move mode
         /// </summary>
         /// <param name="isMoveMode">A flag indicates whether the button is move mode or not</param>
-        public abstract void ChangeMoveMode(bool isMoveMode);
+        /// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
+        public abstract void ChangeMoveMode(bool isMoveMode, bool isDefault);
 
         /// <summary>
         /// A method for changing the button's LayoutOptions according to parameter
index c8e8d22..173cdce 100755 (executable)
@@ -37,8 +37,8 @@ namespace TVHome.Controls
         {
             InitializeComponent();
 
-            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(236);
-            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(240);
+            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(182);
+            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(230);
             ButtonTitle.FontSize = SizeUtils.GetFontSize(26);
         }
 
@@ -96,7 +96,8 @@ namespace TVHome.Controls
         /// A method for handling the button when button is changed to move mode
         /// </summary>
         /// <param name="isMoveMode">A flag indicates whether the button is move mode or not</param>
-        public override void ChangeMoveMode(bool isMoveMode)
+        /// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
+        public override void ChangeMoveMode(bool isMoveMode, bool isDefault)
         {
 
         }
index 269ec4b..cbd9f3c 100755 (executable)
            Opacity="0" />
     <Image x:Name="LeftBtnImg"
            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.369565}"
+           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.326923}"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.156521}"
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.06044}"
            Source="btn_tizen_home_list_move_left_focused.png"
            Opacity="0"/>
     <Image x:Name="RightBtnImg"
            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.93956}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.369565}"
+           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.326923}"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.156521}"
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.06044}"
             Source="btn_tizen_home_list_move_right_focused.png"
            Opacity="0"/>
-    <Button x:Name="LeftBtn"
-           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.369565}"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.156521}"
-           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.06044}"
-            Clicked="OnMoveToLeftClicked"
-            Opacity="0"/>
-    <Button x:Name="RightBtn"
-           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.93956}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.369565}"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.156521}"
-           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.06044}"
-            Clicked="OnMoveToRightClicked"
-            Opacity="0"/>
   </RelativeLayout>
 </Controls:PanelButton>
\ No newline at end of file
index 764e660..002ef9d 100755 (executable)
@@ -15,7 +15,6 @@
  */
 
 using System;
-using System.Windows.Input;
 using LibTVRefCommonPortable.Utils;
 using Xamarin.Forms;
 using Tizen.Xamarin.Forms.Extension;
@@ -49,10 +48,18 @@ namespace TVHome.Controls
         {
             InitializeComponent();
 
-            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(236);
-            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(240);
+            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(182);
+            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(230);
             ButtonTitle.FontSize = SizeUtils.GetFontSize(26);
 
+            MessagingCenter.Subscribe<App, string>(this, "NavigationKeyPressed", (sender, e) =>
+            {
+                if (isMoveMode && IsEnabled)
+                {
+                    OnMoveCommand.Execute(e);
+                }
+            });
+
             //InitializeLongTapGesture();
         }
 
@@ -88,20 +95,20 @@ namespace TVHome.Controls
                 DirectionPriorities = new ContextPopupDirectionPriorities(ContextPopupDirection.Down, ContextPopupDirection.Up, ContextPopupDirection.Right, ContextPopupDirection.Left)
             };
 
-            popup.Items.Add(new ContextPopupItem("UNPIN"));
             popup.Items.Add(new ContextPopupItem("MOVE"));
+            popup.Items.Add(new ContextPopupItem("UNPIN"));
 
             popup.SelectedIndexChanged += (sender, args) =>
             {
                 var ctxPopup = sender as ContextPopup;
                 if (ctxPopup.SelectedIndex == 0)
                 {
-                    OnUnpinCommand.Execute("");
+                    OnMoveFinishedCommand.Execute("");
                     ctxPopup.Dismiss();
                 }
                 else if (ctxPopup.SelectedIndex == 1)
                 {
-                    OnMoveFinishedCommand.Execute("");
+                    OnUnpinCommand.Execute("");
                     ctxPopup.Dismiss();
                 }
             };
@@ -142,7 +149,8 @@ namespace TVHome.Controls
         /// A method for handling the button when button is changed to move mode
         /// </summary>
         /// <param name="moveMode">A flag indicates whether the button is move mode or not</param>
-        public override async void ChangeMoveMode(bool moveMode)
+        /// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
+        public override async void ChangeMoveMode(bool moveMode, bool isDefault)
         {
 #pragma warning disable CS4014
             if (moveMode)
@@ -159,16 +167,22 @@ namespace TVHome.Controls
                     LeftBtnImg.FadeTo(0, 300);
                     await RightBtnImg.FadeTo(0, 300);
                 }
-
-                LeftBtnImg.FadeTo(1, 300);
-                await RightBtnImg.FadeTo(1, 300);
             }
             else
             {
                 isMoveMode = false;
+                if (!isDefault)
+                {
+                    View.TranslateTo(SizeUtils.GetWidthSize((int)View.TranslationX), 0, 300);
+                }
+                else
+                {
+                    View.TranslateTo(0, 0, 300);
+                }
 
+                OnFocused(null, null);
                 LeftBtnImg.FadeTo(0, 300);
-                RightBtnImg.FadeTo(0, 300);
+                await RightBtnImg.FadeTo(0, 300);
             }
 #pragma warning restore CS4014
         }
@@ -234,25 +248,5 @@ namespace TVHome.Controls
                 await ButtonImage.ScaleTo(1, 300);
             }
         }
-
-        /// <summary>
-        /// A method is called when right navigation button is clicked
-        /// </summary>
-        /// <param name="sender">The source of the event</param>
-        /// <param name="e">The event that is occurred when right navigation button is clicked</param>
-        private void OnMoveToRightClicked(object sender, EventArgs e)
-        {
-            OnMoveCommand.Execute("right");
-        }
-
-        /// <summary>
-        /// A method is called when left navigation button is clicked
-        /// </summary>
-        /// <param name="sender">The source of the event</param>
-        /// <param name="e">The event that is occurred when left navigation button is clicked</param>
-        private void OnMoveToLeftClicked(object sender, EventArgs e)
-        {
-            OnMoveCommand.Execute("left");
-        }
     }
 }
\ No newline at end of file
index 2b18a44..5013cde 100755 (executable)
@@ -38,8 +38,8 @@ namespace TVHome.Controls
         {
             InitializeComponent();
 
-            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(236);
-            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(240);
+            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(182);
+            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(230);
             ButtonTitle.FontSize = SizeUtils.GetFontSize(26);
         }
 
@@ -97,7 +97,8 @@ namespace TVHome.Controls
         /// A method for handling the button when button is changed to move mode
         /// </summary>
         /// <param name="isMoveMode">A flag indicates whether the button is move mode or not</param>
-        public override void ChangeMoveMode(bool isMoveMode)
+        /// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
+        public override void ChangeMoveMode(bool isMoveMode, bool isDefault)
         {
 
         }
index a298c49..632d8d8 100755 (executable)
@@ -37,8 +37,8 @@ namespace TVHome.Controls
         {
             InitializeComponent();
 
-            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(236);
-            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(240);
+            ButtonBox.WidthRequest = SizeUtils.GetWidthSize(182);
+            ButtonBox.HeightRequest = SizeUtils.GetHeightSize(230);
             ButtonTitle.FontSize = SizeUtils.GetFontSize(26);
         }
 
@@ -94,7 +94,8 @@ namespace TVHome.Controls
         /// A method for handling the button when button is changed to move mode
         /// </summary>
         /// <param name="isMoveMode">A flag indicates whether the button is move mode or not</param>
-        public override void ChangeMoveMode(bool isMoveMode)
+        /// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
+        public override void ChangeMoveMode(bool isMoveMode, bool isDefault)
         {
 
         }
index a91eb4e..571a615 100755 (executable)
@@ -172,7 +172,8 @@ namespace TVHome.Controls
         /// A method for handling the button when button is changed to move mode
         /// </summary>
         /// <param name="isMoveMode">A flag indicates whether the button is move mode or not</param>
-        public override void ChangeMoveMode(bool isMoveMode)
+        /// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
+        public override void ChangeMoveMode(bool isMoveMode, bool isDefault)
         {
 
         }
index f0ea4ec..e40033c 100755 (executable)
@@ -192,6 +192,11 @@ namespace TVHome
             MessagingCenter.Send<App>(this, "MenuKeyPressed");
         }
 
+        public void OnNavigationKeyPressed(string keyName)
+        {
+            MessagingCenter.Send<App, string>(this, "NavigationKeyPressed", keyName);
+        }
+
         /// <summary>
         /// A method for handling application installed event
         /// </summary>
index f1c3b9b..abe0b8a 100755 (executable)
@@ -139,13 +139,13 @@ namespace TVHome.Views
                 }
                 else
                 {
-                    PageMainPanel.FadeTo(1, 300);
                     PageMainPanel.IsVisible = true;
+                    PageMainPanel.FadeTo(1, 300);
                     bounds.Height -= 300;
                     bounds.Y += 300;
                 }
 
-                AppsSubPanel.LayoutTo(bounds, 0);
+                AppsSubPanel.LayoutTo(bounds, 300);
             });
 
             MessagingCenter.Subscribe<App, TVHomeStatus>(this, App.AppStatus, (sender, arg) =>
@@ -216,12 +216,14 @@ namespace TVHome.Views
         /// <returns>Always returns true</returns>
         protected override bool OnBackButtonPressed()
         {
-            ToggleIconified();
-
             if (AppsSubPanel.isMoveMode)
             {
                 AppsSubPanel.ChangeToDefaultMode();
             }
+            else
+            {
+                ToggleIconified();
+            }
 
             return true;
         }
index 8917838..a767bcd 100755 (executable)
@@ -115,11 +115,11 @@ namespace TVHome.Views
                         button.OnMoveCommand = new Command<string>((direction) =>
                         {
                             int index = ButtonViewList.IndexOf(button.View);
-                            if (direction.Equals("right"))
+                            if (direction.Equals("Right"))
                             {
                                 MoveItemToRight(index);
                             }
-                            else if (direction.Equals("left"))
+                            else if (direction.Equals("Left"))
                             {
                                 MoveItemToLeft(index);
                             }
@@ -133,10 +133,15 @@ namespace TVHome.Views
                             OnMoveCommand.Execute(isMoveMode);
 
                             ChangeLayoutButtons(isMoveMode);
-                            button.ChangeMoveMode(isMoveMode);
+                            ChangeIsEnabledProperty(button.View);
+                            button.ChangeMoveMode(isMoveMode, false);
 
                             if (!isMoveMode)
                             {
+                                foreach (var viewItem in ButtonViewList)
+                                {
+                                    viewItem.TranslateTo(SizeUtils.GetWidthSize((int)viewItem.TranslationX), 0, 0);
+                                }
                                 OnMoveVMCommand.Execute(ButtonViewList);
                             }
                         });
@@ -179,6 +184,17 @@ namespace TVHome.Views
             }
         }
 
+        private void ChangeIsEnabledProperty(View selectedBtn)
+        {
+            foreach (var item in PanelButtonStack.Children)
+            {
+                if (item != selectedBtn)
+                {
+                    item.IsEnabled = !isMoveMode;
+                }
+            }
+        }
+
         /// <summary>
         /// A method for changing button's LayoutOptions in SubPanel according to parameter
         /// </summary>
@@ -234,6 +250,11 @@ namespace TVHome.Views
         {
             if (isFocused)
             {
+                if (!isMoveMode)
+                {
+                    OnFocusedCommand.Execute("");
+                }
+
                 return;
             }
 
@@ -260,17 +281,22 @@ namespace TVHome.Views
             if (isMoveMode)
             {
                 isMoveMode = !isMoveMode;
-                OnMoveCommand.Execute(isMoveMode);
-                ChangeLayoutButtons(isMoveMode);
 
                 foreach (var item in ButtonList)
                 {
                     if (item.isMoveMode)
                     {
-                        item.ChangeMoveMode(isMoveMode);
-                        break;
+                        ChangeIsEnabledProperty(item.View);
+                        item.ChangeMoveMode(isMoveMode, true);
+                    }
+                    else
+                    {
+                        item.View.TranslateTo(0, 0, 0);
                     }
                 }
+
+                OnMoveCommand.Execute(isMoveMode);
+                ChangeLayoutButtons(isMoveMode);
             }
         }
 
@@ -289,8 +315,11 @@ namespace TVHome.Views
 
             View nextItemView = ButtonViewList[nextIndex];
 
-            originItemView.TranslateTo(originItemView.TranslationX + 216, originItemView.TranslationY, 300);
-            nextItemView.TranslateTo(nextItemView.TranslationX - 216, 0, 300);
+            int translateX = SizeUtils.GetWidthSize((int)originItemView.TranslationX + 216);
+            int translateY = SizeUtils.GetWidthSize((int)originItemView.TranslationY);
+            originItemView.TranslateTo(translateX, translateY, 300);
+            translateX = SizeUtils.GetWidthSize((int)nextItemView.TranslationX - 216);
+            nextItemView.TranslateTo(translateX, 0, 300);
 
             ButtonViewList[index] = nextItemView;
             ButtonViewList[nextIndex] = originItemView;
@@ -312,8 +341,11 @@ namespace TVHome.Views
 
             View prevItemView = ButtonViewList[prevIndex];
 
-            originItemView.TranslateTo(originItemView.TranslationX - 216, originItemView.TranslationY, 300);
-            prevItemView.TranslateTo(prevItemView.TranslationX + 216, 0, 300);
+            int translateX = SizeUtils.GetWidthSize((int)originItemView.TranslationX - 216);
+            int translateY = SizeUtils.GetWidthSize((int)originItemView.TranslationY);
+            originItemView.TranslateTo(translateX, translateY, 300);
+            translateX = SizeUtils.GetWidthSize((int)prevItemView.TranslationX + 216);
+            prevItemView.TranslateTo(translateX, 0, 300);
 
             ButtonViewList[index] = prevItemView;
             ButtonViewList[prevIndex] = originItemView;