Add Context popup in Apps SubPanel
authorHyerim Kim <rimi.kim@samsung.com>
Wed, 5 Apr 2017 10:27:15 +0000 (19:27 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:52 +0000 (18:34 +0900)
Change-Id: Id30c5b4a1df0a5aacacff068a7e1f83cb18b351d
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
14 files changed:
TVHome/TVHome.TizenTV/TVHome.TizenTV.cs
TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json [changed mode: 0644->0755]
TVHome/TVHome/Controls/MainPanelButton.xaml.cs
TVHome/TVHome/Controls/PanelButton.cs
TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml.cs
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/TVHome.csproj
TVHome/TVHome/Views/MainPage.xaml.cs
TVHome/TVHome/Views/SubPanel.xaml.cs
TVHome/TVHome/packages.config [changed mode: 0644->0755]

index 86336ec8e7edafbde293b3cffabe2b8ddfb24007..db194e34235be4b81e017661cfff7ec2fc75adce 100755 (executable)
@@ -17,7 +17,7 @@
 using Tizen.Applications;
 using LibTVRefCommonPortable.Utils;
 using LibTVRefCommonTizen.Ports;
-
+using Tizen.Xamarin.Forms.Extension.Renderer;
 
 namespace TVHome.TizenTV
 {
@@ -161,6 +161,7 @@ namespace TVHome.TizenTV
             global::Xamarin.Forms.DependencyService.Register<ApplicationManagerPort>();
             global::Xamarin.Forms.DependencyService.Register<FileSystemPort>();
             global::Xamarin.Forms.DependencyService.Register<WindowPort>();
+            TizenFormsExtension.Init();
             global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
             app.Run(args);
         }
old mode 100644 (file)
new mode 100755 (executable)
index 927c4fe..4489f13
@@ -9,6 +9,7 @@
     "ElmSharp": "1.1.0-beta-018",
     "Microsoft.NETCore.App": "1.1.0",
     "Tizen.Library": "1.0.0-pre3",
+    "Tizen.Xamarin.Forms.Extension": "2.3.4-r214-001",
     "Xamarin.Forms": "2.3.4.214-pre5",
     "Xamarin.Forms.Platform.Tizen": "2.3.4-r214-002"
   },
index 32e899f9fab90a6cf00b17a8a3f1d028e330b6bb..6b0937670268e2dd84fd1ed1d5e45ca7be2e0e3e 100755 (executable)
@@ -145,5 +145,12 @@ namespace TVHome.Controls
         public override void ChangeLayoutOptions(bool isMoveMode)
         {
         }
+
+        /// <summary>
+        /// A method for showing context popup
+        /// </summary>
+        public override void ShowContextPopup()
+        {
+        }
     }
 }
index 56eaa9a7552e7c7ae0c6e6b822b2e96f785724f3..5b84efed4114bd2b30b204fe9e0a4cf5ff5d9087 100755 (executable)
@@ -27,6 +27,7 @@ namespace TVHome.Controls
     public abstract class PanelButton : ViewCell
     {
         public bool isMoveMode;
+        public bool isFocused;
         /// <summary>
         /// A Command will be executed the button is focused.
         /// </summary>
@@ -42,6 +43,11 @@ namespace TVHome.Controls
         /// </summary>
         public ICommand OnMoveCommand { get; set; }
 
+        /// <summary>
+        /// A Command will be executed when the button moving is finished
+        /// </summary>
+        public ICommand OnMoveFinishedCommand { get; set; }
+
         /// <summary>
         /// A Command will be executed the button is unpinned.
         /// </summary>
@@ -79,5 +85,10 @@ namespace TVHome.Controls
         /// </summary>
         /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
         public abstract void ChangeLayoutOptions(bool isMoveMode);
+
+        /// <summary>
+        /// A method for showing context popup
+        /// </summary>
+        public abstract void ShowContextPopup();
     }
 }
index 22575b64db60c6627065abcdd53337210a14e601..b7a8170c78152cdaa39021dfdbd4dd77aea26b5e 100755 (executable)
@@ -109,5 +109,12 @@ namespace TVHome.Controls
 
             View.TranslateTo(0, 0, 0);
         }
+
+        /// <summary>
+        /// A method for showing context popup
+        /// </summary>
+        public override void ShowContextPopup()
+        {
+        }
     }
 }
index dc5ace21d7b4c1926ba54ac02e3cc8152e15ca98..fde5f5ec347b36c08d66bfbc56fbda510961338f 100755 (executable)
@@ -18,6 +18,7 @@ using System;
 using System.Windows.Input;
 using LibTVRefCommonPortable.Utils;
 using Xamarin.Forms;
+using Tizen.Xamarin.Forms.Extension;
 
 namespace TVHome.Controls
 {
@@ -32,7 +33,67 @@ namespace TVHome.Controls
         public SubPanelButton()
         {
             InitializeComponent();
+            //InitializeLongTapGesture();
         }
+        /*
+        private void InitializeLongTapGesture()
+        {
+            var longTapGesture = new LongTapGestureRecognizer
+            {
+                Timeout = 0.5
+            };
+            longTapGesture.TapCompleted += (sender, args) =>
+            {
+                ShowContextPopup();
+            };
+
+            View.GestureRecognizers.Add(longTapGesture);
+        }
+        */
+        /// <summary>
+        /// A method for showing Context popup
+        /// </summary>
+        public override void ShowContextPopup()
+        {
+            if (isPopupShowing)
+            {
+                return;
+            }
+
+            ContextPopup popup = new ContextPopup
+            {
+                IsAutoHidingEnabled = true,
+                Orientation = ContextPopupOrientation.Vertical,
+                DirectionPriorities = new ContextPopupDirectionPriorities(ContextPopupDirection.Down, ContextPopupDirection.Up, ContextPopupDirection.Right, ContextPopupDirection.Left)
+            };
+
+            popup.Items.Add(new ContextPopupItem("UNPIN"));
+            popup.Items.Add(new ContextPopupItem("MOVE"));
+
+            popup.SelectedIndexChanged += (sender, args) =>
+            {
+                var ctxPopup = sender as ContextPopup;
+                if (ctxPopup.SelectedIndex == 0)
+                {
+                    OnUnpinCommand.Execute("");
+                    ctxPopup.Dismiss();
+                }
+                else if (ctxPopup.SelectedIndex == 1)
+                {
+                    OnMoveFinishedCommand.Execute("");
+                    ctxPopup.Dismiss();
+                }
+            };
+
+            popup.Dismissed += (sender, args) =>
+            {
+                isPopupShowing = false;
+            };
+
+            popup.Show(View);
+            isPopupShowing = true;
+        }
+
 
         /// <summary>
         /// Handles Button Clicked event
@@ -41,12 +102,19 @@ namespace TVHome.Controls
         /// <param name="e">The event that is occurred when button is clicked</param>
         public override async void OnClicked(object sender, EventArgs e)
         {
-            if (OnClickedCommand != null)
+            if (!isMoveMode)
             {
-                OnClickedCommand.Execute("");
-            }
+                if (OnClickedCommand != null)
+                {
+                    OnClickedCommand.Execute("");
+                }
 
-            await View.FadeTo(0.99, 300);
+                await View.FadeTo(0.99, 300);
+            }
+            else
+            {
+                OnMoveFinishedCommand.Execute("");
+            }
         }
 
         /// <summary>
@@ -108,6 +176,12 @@ namespace TVHome.Controls
         /// <param name="e">The event that is occurred when button is focused</param>
         public override async void OnFocused(object sender, FocusEventArgs e)
         {
+            isFocused = true;
+            if (isMoveMode)
+            {
+                return;
+            }
+
             if (OnFocusedCommand != null)
             {
                 OnFocusedCommand.Execute("");
@@ -127,6 +201,8 @@ namespace TVHome.Controls
         /// <param name="e">The event that is occurred when button is unfocused</param>
         public override async void OnUnfocused(object sender, FocusEventArgs e)
         {
+            isFocused = false;
+
             if (!isMoveMode)
             {
 #pragma warning disable CS4014
index f29ed59306d6dcd6421a013999f30688b2370a14..cbc791cfc12909f0937ed23cb63241bed05aed2b 100755 (executable)
@@ -110,5 +110,12 @@ namespace TVHome.Controls
 
             View.TranslateTo(0, 0, 0);
         }
+
+        /// <summary>
+        /// A method for showing Context popup
+        /// </summary>
+        public override void ShowContextPopup()
+        {
+        }
     }
 }
\ No newline at end of file
index b9e737abc533e163711ac0a6ff281ec5684b6334..d491734bbb6bb9d8037f0a05781d1b9e17e01de8 100755 (executable)
@@ -96,5 +96,12 @@ namespace TVHome.Controls
         public override void ChangeLayoutOptions(bool isMoveMode)
         {
         }
+
+        /// <summary>
+        /// A method for showing Context popup
+        /// </summary>
+        public override void ShowContextPopup()
+        {
+        }
     }
 }
index aa4444a2318b148b5fbed62206279e2835693b79..a34ce2d09d15cb345d7db8a093f0bbdcd9a95b92 100755 (executable)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 using System;
+using Tizen.Xamarin.Forms.Extension;
 using Xamarin.Forms;
 
 namespace TVHome.Controls
@@ -126,5 +127,38 @@ namespace TVHome.Controls
         public override void ChangeLayoutOptions(bool isMoveMode)
         {
         }
+
+        /// <summary>
+        /// A method for showing Context popup
+        /// </summary>
+        public override void ShowContextPopup()
+        {
+            ContextPopup popup = new ContextPopup
+            {
+                IsAutoHidingEnabled = true,
+                Orientation = ContextPopupOrientation.Vertical,
+                DirectionPriorities = new ContextPopupDirectionPriorities(ContextPopupDirection.Down, ContextPopupDirection.Up, ContextPopupDirection.Right, ContextPopupDirection.Left)
+            };
+
+            popup.Items.Add(new ContextPopupItem("REMOVE"));
+            popup.Items.Add(new ContextPopupItem("CLEAR ALL"));
+
+            popup.SelectedIndexChanged += (sender, args) =>
+            {
+                var ctxPopup = sender as ContextPopup;
+                if (ctxPopup.SelectedIndex == 0)
+                {
+                    OnMoveFinishedCommand.Execute("");
+                    ctxPopup.Dismiss();
+                }
+                else if (ctxPopup.SelectedIndex == 1)
+                {
+                    OnUnpinCommand.Execute("");
+                    ctxPopup.Dismiss();
+                }
+            };
+
+            popup.Show(View);
+        }
     }
 }
\ No newline at end of file
index 0627e07d746e1e70b0bd006088c0a6781c4a8716..21e8325404201b84d5035833f39f7b3e4add4ad4 100755 (executable)
@@ -170,10 +170,11 @@ namespace TVHome
         public void OnMenuKeyPressed()
         {
             DebuggingUtils.Dbg("\" Menu Key \" ");
-            MenuKeyListener.Invoke(this, new TVHomeEventArgs()
-            {
-                arg = "",
-            });
+            /* MenuKeyListener.Invoke(this, new TVHomeEventArgs()
+             {
+                 arg = "",
+             });*/
+            MessagingCenter.Send<App>(this, "MenuKeyPressed");
         }
 
         /// <summary>
index eb8e82797de4142fd8d913c68e499253b0ad62fa..ec20bf2b789702734f47d06d59019fb5e0691372 100755 (executable)
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
+    <Reference Include="Tizen.Xamarin.Forms.Extension, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Tizen.Xamarin.Forms.Extension.2.3.4-r214-001\lib\portable-win+net45+wp80+win81+wpa81\Tizen.Xamarin.Forms.Extension.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
     <Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <HintPath>..\..\packages\Xamarin.Forms.2.3.4.214-pre5\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll</HintPath>
       <Private>True</Private>
index a15ec5f0e3083e53e2e4f0233f86d51a69ebca5b..eae6296378c8be85b8d4666780c1909a8e15374a 100755 (executable)
@@ -217,6 +217,11 @@ namespace TVHome.Views
         protected override bool OnBackButtonPressed()
         {
             ToggleIconified();
+
+            if (AppsSubPanel.isMoveMode)
+            {
+                AppsSubPanel.ChangeToDefaultMode();
+            }
             return true;
         }
     }
index 81c7bcc082c9cab34b562648fa1d8c9610feb2fa..21dece5838f90ab32b756a3f1426c7d99cab9914 100755 (executable)
@@ -56,6 +56,20 @@ namespace TVHome.Views
             ButtonList = new List<PanelButton>();
             ButtonViewList = new List<View>();
             PropertyChanged += OnItemsSourcePropertyChanged;
+
+            MessagingCenter.Subscribe<App>(this, "MenuKeyPressed", (sender) =>
+            {
+                if (isFocused)
+                {
+                    foreach (var item in ButtonList)
+                    {
+                        if (item.isFocused)
+                        {
+                            item.ShowContextPopup();
+                        }
+                    }
+                }
+            });
         }
         /// <summary>
         /// A event handler for handling property changed event
@@ -104,6 +118,22 @@ namespace TVHome.Views
                                 MoveItemToLeft(index);
                             }
                         });
+
+                        button.OnMoveFinishedCommand = new Command(() =>
+                        {
+                            // TODO : This is triggered by LongTap event.
+                            isMoveMode = !isMoveMode;
+
+                            OnMoveCommand.Execute(isMoveMode);
+
+                            ChangeLayoutButtons(isMoveMode);
+                            button.ChangeMoveMode(isMoveMode);
+
+                            if (!isMoveMode)
+                            {
+                                OnMoveVMCommand.Execute(ButtonViewList);
+                            }
+                        });
                     }
                     ButtonList.Add(button);
                 }
@@ -119,24 +149,7 @@ namespace TVHome.Views
                 });
                 button.OnClickedCommand = new Command(() =>
                 {
-                    if (!(item is AppShortcutInfo))
-                    {
-                        item.DoAction();
-                        return;
-                    }
-
-                    // TODO : This is triggered by LongTap event.
-                    isMoveMode = !isMoveMode;
-
-                    OnMoveCommand.Execute(isMoveMode);
-
-                    ChangeLayoutButtons(isMoveMode);
-                    button.ChangeMoveMode(isMoveMode);
-
-                    if (!isMoveMode)
-                    {
-                        OnMoveVMCommand.Execute(ButtonViewList);
-                    }
+                    item.DoAction();
                 });
                 button.OnUnpinCommand = new Command(() =>
                 {
@@ -235,6 +248,25 @@ namespace TVHome.Views
             await this.FadeTo(0.99, 300);
         }
 
+        public void ChangeToDefaultMode()
+        {
+            if (isMoveMode)
+            {
+                isMoveMode = !isMoveMode;
+                OnMoveCommand.Execute(isMoveMode);
+                ChangeLayoutButtons(isMoveMode);
+
+                foreach (var item in ButtonList)
+                {
+                    if (item.isMoveMode)
+                    {
+                        item.ChangeMoveMode(isMoveMode);
+                        break;
+                    }
+                }
+            }
+        }
+
         /// <summary>
         /// A method for moving the selected item to right
         /// </summary>
old mode 100644 (file)
new mode 100755 (executable)
index 5d65ac0..ce50c6f
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>\r
 <packages>\r
+  <package id="Tizen.Xamarin.Forms.Extension" version="2.3.4-r214-001" targetFramework="portable45-net45+win8+wp8+wpa81" />\r
   <package id="Xamarin.Forms" version="2.3.4.214-pre5" targetFramework="portable45-net45+win8+wp8+wpa81" />\r
 </packages>
\ No newline at end of file