summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj@nicesj.com>2017-09-27 13:57:53 +0900
committerSung-jae Park <nicesj@nicesj.com>2017-09-27 14:21:15 +0900
commit6633e99af796188e456aff4995e57afa2a16ac4b (patch)
treee7a308f44c1e11a567b1839239a76804b499c881
parentea1232fba852afd3737f96825a7ad2968674bc7a (diff)
downloadmediahub-6633e99af796188e456aff4995e57afa2a16ac4b.tar.gz
mediahub-6633e99af796188e456aff4995e57afa2a16ac4b.tar.bz2
mediahub-6633e99af796188e456aff4995e57afa2a16ac4b.zip
[TPLAPP-4006] Implemented BackKey event handler for the DropDownSort.
The "exit" popup has not to be displayed if the DropDownSort is expanded. The BackKey event is handled from the MediaHubMainPage, and the DropDownSort is implemented in the FooterNormalStatus. I added a flag named "DisableBackKeyHandler" to the MediaHubMainPage to control the BackKey event handler. and the "DisableBackKeyHandler" is toggled by the FooterNormalStatus instance. The FooterNormalStatus instance was able to access the MediaHubMainPage via the AppMainPage object of the App instance, so I added event handlers such as the collased and the expanded for the DropDownSort instance. When DropDownSort is expanded, I set true to the "DisableBackKeyHandler" then the BackKey would blocked. I also added KeyDown event handler in the FooterNormalStatus instance. In the event handler, if the DropDownSort is expanded, I collased it. The KeyDown event handler is added and removed from the Expanded and Collapsed event handler of the DropDownSort instance. Change-Id: I106d53569471a66c6ff867d92c3d012d3b34f80b Signed-off-by: Sung-jae Park <nicesj@nicesj.com>
-rwxr-xr-xTVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs12
-rwxr-xr-xTVMediaHub/TVMediaHub.Tizen/Views/FooterNormalStatus.xaml.cs33
-rwxr-xr-xTVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml3
-rwxr-xr-xTVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs12
4 files changed, 59 insertions, 1 deletions
diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs
index 8ed51f2..309bc1c 100755
--- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs
+++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs
@@ -31,6 +31,18 @@ namespace TVMediaHub.Tizen.ViewModels
/// </summary>
public string SourceName { get; set; }
+ private bool disableBackKeyHandler;
+
+ public bool DisableBackKeyHandler
+ {
+ set
+ {
+ disableBackKeyHandler = value;
+ OnPropertyChanged();
+ }
+ get => disableBackKeyHandler;
+ }
+
/// <summary>
/// An event that is occurred when property of MediaHubMainPageViewModel is changed
/// </summary>
diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/FooterNormalStatus.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/FooterNormalStatus.xaml.cs
index 5a986cd..27fbd1d 100755
--- a/TVMediaHub/TVMediaHub.Tizen/Views/FooterNormalStatus.xaml.cs
+++ b/TVMediaHub/TVMediaHub.Tizen/Views/FooterNormalStatus.xaml.cs
@@ -149,6 +149,19 @@ namespace TVMediaHub.Tizen.Views
}
}
+ private void KeyDownHandler(object sender, EventArgs e)
+ {
+ ElmSharp.EcoreKeyEventArgs arg = e as ElmSharp.EcoreKeyEventArgs;
+
+ if (arg != null && arg.KeyName.Contains("Back"))
+ {
+ if (DropdownSort.IsExpanded == true)
+ {
+ DropdownSort.Collapse();
+ }
+ }
+ }
+
/// <summary>
/// A method for initializing footer items
/// </summary>
@@ -163,6 +176,26 @@ namespace TVMediaHub.Tizen.Views
DropdownSource.ItemsSource = SourceList;
DropdownSort.ItemsSource = SortOptions;
+ DropdownSort.Collapsed += (s, e) =>
+ {
+ if (App.AppMainPage != null && App.AppMainPage.RootPage != null)
+ {
+ (App.AppMainPage.RootPage as MediaHubMainPage).DisableBackKeyHandler = false;
+
+ App.KeyDownEvent.On -= KeyDownHandler;
+ }
+ };
+
+ DropdownSort.Expanded += (s, e) =>
+ {
+ if (App.AppMainPage != null && App.AppMainPage.RootPage != null)
+ {
+ (App.AppMainPage.RootPage as MediaHubMainPage).DisableBackKeyHandler = true;
+
+ App.KeyDownEvent.On += KeyDownHandler;
+ }
+ };
+
DropdownSource.ItemSelected += (s, e) =>
{
OnDropdownSourceItemSelected?.Invoke(s, e);
diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml
index 90bb86d..e3dfbfe 100755
--- a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml
+++ b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml
@@ -4,7 +4,8 @@
x:Class="TVMediaHub.Tizen.Views.MediaHubMainPage"
xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
Title="MEDIA HUB"
- SourceName="{Binding SourceName}">
+ SourceName="{Binding SourceName}"
+ DisableBackKeyHandler="{Binding DisableBackKeyHandler}">
<Views:VideoTab/>
<Views:ImageTab/>
<Views:MusicTab/>
diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs
index 9ba4c5d..d7d4e55 100755
--- a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs
+++ b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs
@@ -31,6 +31,13 @@ namespace TVMediaHub.Tizen.Views
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MediaHubMainPage : TabbedPage
{
+ public static readonly BindableProperty DisableBackKeyHandlerProperty = BindableProperty.Create("DisableBackKeyHandler", typeof(bool), typeof(MediaHubMainPage), false, BindingMode.OneWayToSource);
+ public bool DisableBackKeyHandler
+ {
+ get { return (bool)GetValue(DisableBackKeyHandlerProperty); }
+ set { SetValue(DisableBackKeyHandlerProperty, value); }
+ }
+
/// <summary>
/// Identifies the SourceName bindable property
/// </summary>
@@ -115,6 +122,11 @@ namespace TVMediaHub.Tizen.Views
/// <returns>Always returns true</returns>
protected override bool OnBackButtonPressed()
{
+ if (DisableBackKeyHandler == true)
+ {
+ return true;
+ }
+
SynchronizationContext.Current.Post((o) =>
{
#pragma warning disable CS4014