From: Hyerim Kim Date: Wed, 5 Apr 2017 10:27:15 +0000 (+0900) Subject: Add Context popup in Apps SubPanel X-Git-Tag: submit/tizen/20170808.015446~125 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=216c88f20fadd0674164a794eafcf79bc3607e11;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Add Context popup in Apps SubPanel Change-Id: Id30c5b4a1df0a5aacacff068a7e1f83cb18b351d Signed-off-by: Hyerim Kim --- diff --git a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs index 86336ec..db194e3 100755 --- a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs +++ b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs @@ -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(); global::Xamarin.Forms.DependencyService.Register(); global::Xamarin.Forms.DependencyService.Register(); + TizenFormsExtension.Init(); global::Xamarin.Forms.Platform.Tizen.Forms.Init(app); app.Run(args); } diff --git a/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json b/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json old mode 100644 new mode 100755 index 927c4fe..4489f13 --- a/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json +++ b/TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json @@ -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" }, diff --git a/TVHome/TVHome/Controls/MainPanelButton.xaml.cs b/TVHome/TVHome/Controls/MainPanelButton.xaml.cs index 32e899f..6b09376 100755 --- a/TVHome/TVHome/Controls/MainPanelButton.xaml.cs +++ b/TVHome/TVHome/Controls/MainPanelButton.xaml.cs @@ -145,5 +145,12 @@ namespace TVHome.Controls public override void ChangeLayoutOptions(bool isMoveMode) { } + + /// + /// A method for showing context popup + /// + public override void ShowContextPopup() + { + } } } diff --git a/TVHome/TVHome/Controls/PanelButton.cs b/TVHome/TVHome/Controls/PanelButton.cs index 56eaa9a..5b84efe 100755 --- a/TVHome/TVHome/Controls/PanelButton.cs +++ b/TVHome/TVHome/Controls/PanelButton.cs @@ -27,6 +27,7 @@ namespace TVHome.Controls public abstract class PanelButton : ViewCell { public bool isMoveMode; + public bool isFocused; /// /// A Command will be executed the button is focused. /// @@ -42,6 +43,11 @@ namespace TVHome.Controls /// public ICommand OnMoveCommand { get; set; } + /// + /// A Command will be executed when the button moving is finished + /// + public ICommand OnMoveFinishedCommand { get; set; } + /// /// A Command will be executed the button is unpinned. /// @@ -79,5 +85,10 @@ namespace TVHome.Controls /// /// A flag indicates whether the SubPanel is MoveMode or not public abstract void ChangeLayoutOptions(bool isMoveMode); + + /// + /// A method for showing context popup + /// + public abstract void ShowContextPopup(); } } diff --git a/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml.cs b/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml.cs index 22575b6..b7a8170 100755 --- a/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml.cs +++ b/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml.cs @@ -109,5 +109,12 @@ namespace TVHome.Controls View.TranslateTo(0, 0, 0); } + + /// + /// A method for showing context popup + /// + public override void ShowContextPopup() + { + } } } diff --git a/TVHome/TVHome/Controls/SubPanelButton.xaml.cs b/TVHome/TVHome/Controls/SubPanelButton.xaml.cs index dc5ace2..fde5f5e 100755 --- a/TVHome/TVHome/Controls/SubPanelButton.xaml.cs +++ b/TVHome/TVHome/Controls/SubPanelButton.xaml.cs @@ -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); + } + */ + /// + /// A method for showing Context popup + /// + 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; + } + /// /// Handles Button Clicked event @@ -41,12 +102,19 @@ namespace TVHome.Controls /// The event that is occurred when button is clicked 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(""); + } } /// @@ -108,6 +176,12 @@ namespace TVHome.Controls /// The event that is occurred when button is focused 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 /// The event that is occurred when button is unfocused public override async void OnUnfocused(object sender, FocusEventArgs e) { + isFocused = false; + if (!isMoveMode) { #pragma warning disable CS4014 diff --git a/TVHome/TVHome/Controls/SubPanelReservedButton.xaml.cs b/TVHome/TVHome/Controls/SubPanelReservedButton.xaml.cs index f29ed59..cbc791c 100755 --- a/TVHome/TVHome/Controls/SubPanelReservedButton.xaml.cs +++ b/TVHome/TVHome/Controls/SubPanelReservedButton.xaml.cs @@ -110,5 +110,12 @@ namespace TVHome.Controls View.TranslateTo(0, 0, 0); } + + /// + /// A method for showing Context popup + /// + public override void ShowContextPopup() + { + } } } \ No newline at end of file diff --git a/TVHome/TVHome/Controls/SubPanelSettingButton.xaml.cs b/TVHome/TVHome/Controls/SubPanelSettingButton.xaml.cs index b9e737a..d491734 100755 --- a/TVHome/TVHome/Controls/SubPanelSettingButton.xaml.cs +++ b/TVHome/TVHome/Controls/SubPanelSettingButton.xaml.cs @@ -96,5 +96,12 @@ namespace TVHome.Controls public override void ChangeLayoutOptions(bool isMoveMode) { } + + /// + /// A method for showing Context popup + /// + public override void ShowContextPopup() + { + } } } diff --git a/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs b/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs index aa4444a..a34ce2d 100755 --- a/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs +++ b/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs @@ -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) { } + + /// + /// A method for showing Context popup + /// + 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 diff --git a/TVHome/TVHome/TVHome.cs b/TVHome/TVHome/TVHome.cs index 0627e07..21e8325 100755 --- a/TVHome/TVHome/TVHome.cs +++ b/TVHome/TVHome/TVHome.cs @@ -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(this, "MenuKeyPressed"); } /// diff --git a/TVHome/TVHome/TVHome.csproj b/TVHome/TVHome/TVHome.csproj index eb8e827..ec20bf2 100755 --- a/TVHome/TVHome/TVHome.csproj +++ b/TVHome/TVHome/TVHome.csproj @@ -138,6 +138,10 @@ + + ..\..\packages\Tizen.Xamarin.Forms.Extension.2.3.4-r214-001\lib\portable-win+net45+wp80+win81+wpa81\Tizen.Xamarin.Forms.Extension.dll + True + ..\..\packages\Xamarin.Forms.2.3.4.214-pre5\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll True diff --git a/TVHome/TVHome/Views/MainPage.xaml.cs b/TVHome/TVHome/Views/MainPage.xaml.cs index a15ec5f..eae6296 100755 --- a/TVHome/TVHome/Views/MainPage.xaml.cs +++ b/TVHome/TVHome/Views/MainPage.xaml.cs @@ -217,6 +217,11 @@ namespace TVHome.Views protected override bool OnBackButtonPressed() { ToggleIconified(); + + if (AppsSubPanel.isMoveMode) + { + AppsSubPanel.ChangeToDefaultMode(); + } return true; } } diff --git a/TVHome/TVHome/Views/SubPanel.xaml.cs b/TVHome/TVHome/Views/SubPanel.xaml.cs index 81c7bcc..21dece5 100755 --- a/TVHome/TVHome/Views/SubPanel.xaml.cs +++ b/TVHome/TVHome/Views/SubPanel.xaml.cs @@ -56,6 +56,20 @@ namespace TVHome.Views ButtonList = new List(); ButtonViewList = new List(); PropertyChanged += OnItemsSourcePropertyChanged; + + MessagingCenter.Subscribe(this, "MenuKeyPressed", (sender) => + { + if (isFocused) + { + foreach (var item in ButtonList) + { + if (item.isFocused) + { + item.ShowContextPopup(); + } + } + } + }); } /// /// 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; + } + } + } + } + /// /// A method for moving the selected item to right /// diff --git a/TVHome/TVHome/packages.config b/TVHome/TVHome/packages.config old mode 100644 new mode 100755 index 5d65ac0..ce50c6f --- a/TVHome/TVHome/packages.config +++ b/TVHome/TVHome/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file