From: aman.jeph Date: Tue, 5 Oct 2021 09:37:23 +0000 (+0530) Subject: Implemented back key handling for all the views X-Git-Tag: submit/tizen/20211109.094344~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85fa8e2148d79865c0ec977de7b015969bc26756;p=profile%2Fiot%2Fapps%2Fdotnet%2Fmusic-player.git Implemented back key handling for all the views Change-Id: I624f06e6711f05f0d7e10d2792213f220f206ead Signed-off-by: aman.jeph --- diff --git a/music-player/Core/PlaybackHelper.cs b/music-player/Core/PlaybackHelper.cs index a593a16..2e27ae0 100755 --- a/music-player/Core/PlaybackHelper.cs +++ b/music-player/Core/PlaybackHelper.cs @@ -20,6 +20,7 @@ namespace MusicPlayer.Core { playerViewModel = new PlayerViewModel(); playerView = new PlayerView(playerViewModel); + playerView.BackKeyPressed += OnBackKeyPressed; } public static PlaybackHelper Instance @@ -62,5 +63,10 @@ namespace MusicPlayer.Core playerViewModel.SetCurrentTrack(currentTrack); playerViewModel.SetRepeatAndShuffle(Common.RepeatMode.Off, Common.ShuffleMode.Off); } + + private void OnBackKeyPressed(object sender, EventArgs e) + { + HidePlayer(); + } } } diff --git a/music-player/MusicPlayer.cs b/music-player/MusicPlayer.cs index 84ecc5a..4bcbccd 100755 --- a/music-player/MusicPlayer.cs +++ b/music-player/MusicPlayer.cs @@ -13,21 +13,12 @@ namespace MusicPlayer AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnHandledException; } - public void OnKeyEvent(object sender, Window.KeyEventArgs e) - { - if (e.Key.State == Key.StateType.Up && (e.Key.KeyPressedName == AppConstants.BackKeyCode || e.Key.KeyPressedName == AppConstants.EscapeKeyCode)) - { - Exit(); - } - } - protected override void OnCreate() { Tizen.Log.Info(AppConstants.LogTag, "OnCreate statrted"); base.OnCreate(); Window window = Window.Instance; window.BackgroundColor = Color.White; - window.KeyEvent += OnKeyEvent; Size2D size = window.Size; Tizen.Log.Info(AppConstants.LogTag, "Window Size: " + size.Width + "x" + size.Height); diff --git a/music-player/ViewModels/PlayingListViewModel.cs b/music-player/ViewModels/PlayingListViewModel.cs index debbc99..d8199f1 100755 --- a/music-player/ViewModels/PlayingListViewModel.cs +++ b/music-player/ViewModels/PlayingListViewModel.cs @@ -61,7 +61,7 @@ namespace MusicPlayer.ViewModels private void UpdateShuffleList(int count) { shuffleList.Clear(); - shuffleList.AddRange(Enumerable.Range(0, count - 1)); + shuffleList.AddRange(Enumerable.Range(0, count)); } private void OnItemsSourceChanged(EventArgs eventArgs) diff --git a/music-player/Views/BaseView.cs b/music-player/Views/BaseView.cs index a51fa6b..b78f120 100755 --- a/music-player/Views/BaseView.cs +++ b/music-player/Views/BaseView.cs @@ -1,347 +1,362 @@ -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; -using Tizen.NUI.Binding; -using MusicPlayer.Common; - -namespace MusicPlayer.Views -{ - class BaseView : View - { - private View topView; - private View bottomView; // TODO Used this for MiniController UI - private View contentView; - private TextLabel titleLabel; - private Button backButton; - private Button moreButton; - private Button searchButton; - private Tab tabs; - private BaseContentView baseContentView; - - // TODO these name strings are temporary...once the po files are added - // need to use Translatable names. - private static string[] TabNames = new string[] - { - "Playlists", - "Tracks", - "Albums", - "Artists", - }; - public BaseView() : base() - { - ThemeChangeSensitive = true; - WidthSpecification = LayoutParamPolicies.MatchParent; - HeightSpecification = LayoutParamPolicies.MatchParent; - Layout = new FlexLayout() - { - Direction = FlexLayout.FlexDirection.Column, - ItemsAlignment = FlexLayout.AlignmentType.FlexStart, - Justification = FlexLayout.FlexJustification.FlexStart, - }; - topView = new View() - { - ThemeChangeSensitive = true, - WidthSpecification = LayoutParamPolicies.MatchParent, - HeightSpecification = 120, - Layout = new RelativeLayout() - { - Padding = new Extents(64, 64, 30, 30), - }, - }; - base.Add(topView); - FlexLayout.SetFlexGrow(topView, 0); - FlexLayout.SetFlexShrink(topView, 0); - titleLabel = new TextLabel() - { - StyleName = "PageLabel", - ThemeChangeSensitive = true, - Text = "Music", - PixelSize = 40, - FontFamily = "BreezeSans", - HorizontalAlignment = HorizontalAlignment.Begin, - VerticalAlignment = VerticalAlignment.Center, - Ellipsis = true, - FontStyle = UIFontStyles.NormalLight, - }; - topView.Add(titleLabel); - titleLabel.SetBinding(TextLabel.TextProperty, "Title"); - RelativeLayout.SetLeftTarget(titleLabel, topView); - RelativeLayout.SetLeftRelativeOffset(titleLabel, 0.0f); - RelativeLayout.SetRightTarget(titleLabel, topView); - RelativeLayout.SetRightRelativeOffset(titleLabel, 1.0f); - RelativeLayout.SetFillHorizontal(titleLabel, true); - - contentView = new View() - { - ThemeChangeSensitive = true, - WidthSpecification = LayoutParamPolicies.MatchParent, - HeightSpecification = 876, - }; - base.Add(contentView); - FlexLayout.SetFlexGrow(contentView, 1); - FlexLayout.SetFlexShrink(contentView, 1); - - tabs = new Tab() - { - ThemeChangeSensitive = true, - Size2D = new Size2D(Window.Instance.Size.Width, 84), - WidthSpecification = LayoutParamPolicies.MatchParent, - HeightSpecification = 84, - UnderLineBackgroundColor = Color.Blue, - UnderLineSize = new Size2D(1, 3), - PointSize = 25, - BackgroundColor = Color.White, - }; - tabs.TextColorSelector = new ColorSelector - { - Normal = Color.Black, - Selected = Color.Magenta, - }; - base.Add(tabs); - for(int i = 0; i<4; ++i) - { - Tab.TabItemData item = new Tab.TabItemData(); - item.Text = TabNames[i]; - tabs.AddItem(item); - } - tabs.SelectedItemIndex = 1; - - backButton = null; - moreButton = null; - searchButton = null; - } - - public Tab Tabs - { - get => tabs; - } - - public string Title - { - get => titleLabel.Text; - set { titleLabel.Text = value;} - } - - public bool BackButton - { - set - { - if (value) - { - if (backButton == null) - { - backButton = new Button("BackButton") - { - ThemeChangeSensitive = true, - Size2D = new Size2D(48, 48), - Margin = new Extents(0, 24, 6, 6), - }; - - backButton.Clicked += OnBackButtonClicked; - } - topView.Add(backButton); - backButton.Show(); - RelativeLayout.SetLeftRelativeOffset(backButton, 0.0f); - RelativeLayout.SetRightRelativeOffset(backButton, 0.0f); - RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start); - - RelativeLayout.SetLeftTarget(titleLabel, backButton); - RelativeLayout.SetLeftRelativeOffset(titleLabel, 1.0f); - } - else - { - if(backButton) - { - topView.Remove(backButton); - backButton.Hide(); - RelativeLayout.SetLeftTarget(titleLabel, topView); - RelativeLayout.SetLeftRelativeOffset(titleLabel, 0.0f); - } - } - } - } - - public bool MoreButton - { - set - { - moreButton = new Button("MoreButton") - { - ThemeChangeSensitive = true, - Margin = new Extents(32, 0, 6, 6), - }; - topView.Add(moreButton); - RelativeLayout.SetLeftRelativeOffset(moreButton, 1.0f); - RelativeLayout.SetRightRelativeOffset(moreButton, 1.0f); - RelativeLayout.SetHorizontalAlignment(moreButton, RelativeLayout.Alignment.End); - - RelativeLayout.SetRightTarget(titleLabel, moreButton); - RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f); - moreButton.Clicked += OnMoreButtonClicked; - } - } - - public bool SearchButton - { - set - { - if (value) - { - ButtonStyle buttonStyle = new ButtonStyle() - { - Icon = new ImageViewStyle() - { - ResourceUrl = Resources.GetImagePath() + "search_icon.png", - }, - IsSelectable = false, - IsEnabled = true, - }; - searchButton = new Button(buttonStyle) - { - ThemeChangeSensitive = true, - Size2D = new Size2D(96, 60), - BackgroundImage = Resources.GetImagePath() + "search_button_bg.png", - Margin = new Extents(24, 0, 0, 0), - }; - topView.Add(searchButton); - RelativeLayout.SetRightTarget(searchButton, moreButton); - RelativeLayout.SetRightRelativeOffset(searchButton, 0.0f); - RelativeLayout.SetHorizontalAlignment(searchButton, RelativeLayout.Alignment.End); - - RelativeLayout.SetLeftTarget(titleLabel, RelativeLayout.GetLeftTarget(titleLabel)); - RelativeLayout.SetLeftRelativeOffset(titleLabel, RelativeLayout.GetLeftRelativeOffset(titleLabel)); - RelativeLayout.SetRightTarget(titleLabel, searchButton); - RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f); - } - } - } - - public Button GetSearchButton() - { - return searchButton; - } - - public void SetContent(BaseContentView view) - { - if(view == null) - { - Tizen.Log.Error(AppConstants.LogTag, "BaseContentView is null, provide correct object"); - return; - } - - if(baseContentView != null) - { - Tizen.Log.Error(AppConstants.LogTag, "ContentView is already added, remove it first"); - return; - } - if (view.IsSubViewAdded) - { - BackButton = true; - Title = view.GetSubContentTitle(); - } - else - { - BackButton = false; - Title = "Music"; - } - contentView.Add(view); - baseContentView = view; - } - - public void RemoveContent(BaseContentView view) - { - if(view == null) - { - Tizen.Log.Error(AppConstants.LogTag, "BaseContentView is null, provide correct object"); - return; - } - contentView.Remove(view); - baseContentView = null; - } - - public void AddSubViewContent(string titleText, BaseSubContentView subContentView) - { - if(baseContentView != null) - { - baseContentView.AddSubContentView(subContentView); - BackButton = true; - Title = titleText; - } - } - - protected override void Dispose(DisposeTypes type) - { - if (Disposed) - { - return; - } - if (type == DisposeTypes.Explicit) - { - if (topView != null) - { - List children = topView.Children; - foreach (View child in children) - { - topView.Remove(child); - child?.Dispose(); - } - base.Remove(topView); - topView.Dispose(); - topView = null; - } - - // Do not delete the children of contentview as they are not owned by BaseView - base.Remove(contentView); - contentView?.Dispose(); - contentView = null; - - base.Remove(tabs); - tabs?.Dispose(); - tabs = null; - - base.Remove(bottomView); - bottomView?.Dispose(); - bottomView = null; - } - - base.Dispose(type); - } - - private void RemoveSubViewContent() - { - if (baseContentView != null) - { - BackButton = false; - Title = "Music"; - baseContentView.RemoveSubContentView(); - } - } - - private void OnBackButtonClicked(object sender, ClickedEventArgs e) - { - RemoveSubViewContent(); - } - - private Menu CreateMenu() - { - Menu moreMenu = new Menu() - { - Anchor = moreButton, - HorizontalPositionToAnchor = Menu.RelativePosition.End, - VerticalPositionToAnchor = Menu.RelativePosition.End, - }; - return moreMenu; - } - - private void OnMoreButtonClicked(object sender, ClickedEventArgs e) - { - if(baseContentView != null) - { - Menu moreMenu = CreateMenu(); - baseContentView.UpdateButtonMoreItems(moreMenu); - moreMenu.Post(); - } - } - } +using System.Collections.Generic; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using Tizen.NUI.Binding; +using MusicPlayer.Common; + +namespace MusicPlayer.Views +{ + class BaseView : View + { + private View topView; + private View bottomView; // TODO Used this for MiniController UI + private View contentView; + private TextLabel titleLabel; + private Button backButton; + private Button moreButton; + private Button searchButton; + private Tab tabs; + private BaseContentView baseContentView; + + // TODO these name strings are temporary...once the po files are added + // need to use Translatable names. + private static string[] TabNames = new string[] + { + "Playlists", + "Tracks", + "Albums", + "Artists", + }; + public BaseView() : base() + { + ThemeChangeSensitive = true; + WidthSpecification = LayoutParamPolicies.MatchParent; + HeightSpecification = LayoutParamPolicies.MatchParent; + Layout = new FlexLayout() + { + Direction = FlexLayout.FlexDirection.Column, + ItemsAlignment = FlexLayout.AlignmentType.FlexStart, + Justification = FlexLayout.FlexJustification.FlexStart, + }; + topView = new View() + { + ThemeChangeSensitive = true, + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = 120, + Layout = new RelativeLayout() + { + Padding = new Extents(64, 64, 30, 30), + }, + }; + base.Add(topView); + FlexLayout.SetFlexGrow(topView, 0); + FlexLayout.SetFlexShrink(topView, 0); + titleLabel = new TextLabel() + { + StyleName = "PageLabel", + ThemeChangeSensitive = true, + Text = "Music", + PixelSize = 40, + FontFamily = "BreezeSans", + HorizontalAlignment = HorizontalAlignment.Begin, + VerticalAlignment = VerticalAlignment.Center, + Ellipsis = true, + FontStyle = UIFontStyles.NormalLight, + }; + topView.Add(titleLabel); + titleLabel.SetBinding(TextLabel.TextProperty, "Title"); + RelativeLayout.SetLeftTarget(titleLabel, topView); + RelativeLayout.SetLeftRelativeOffset(titleLabel, 0.0f); + RelativeLayout.SetRightTarget(titleLabel, topView); + RelativeLayout.SetRightRelativeOffset(titleLabel, 1.0f); + RelativeLayout.SetFillHorizontal(titleLabel, true); + + contentView = new View() + { + ThemeChangeSensitive = true, + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = 876, + }; + base.Add(contentView); + FlexLayout.SetFlexGrow(contentView, 1); + FlexLayout.SetFlexShrink(contentView, 1); + + tabs = new Tab() + { + ThemeChangeSensitive = true, + Size2D = new Size2D(Window.Instance.Size.Width, 84), + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = 84, + UnderLineBackgroundColor = Color.Blue, + UnderLineSize = new Size2D(1, 3), + PointSize = 25, + BackgroundColor = Color.White, + }; + tabs.TextColorSelector = new ColorSelector + { + Normal = Color.Black, + Selected = Color.Magenta, + }; + base.Add(tabs); + for(int i = 0; i<4; ++i) + { + Tab.TabItemData item = new Tab.TabItemData(); + item.Text = TabNames[i]; + tabs.AddItem(item); + } + tabs.SelectedItemIndex = 1; + + backButton = null; + moreButton = null; + searchButton = null; + } + + public Tab Tabs + { + get => tabs; + } + + public string Title + { + get => titleLabel.Text; + set { titleLabel.Text = value;} + } + + public bool BackButton + { + set + { + if (value) + { + if (backButton == null) + { + backButton = new Button("BackButton") + { + ThemeChangeSensitive = true, + Size2D = new Size2D(48, 48), + Margin = new Extents(0, 24, 6, 6), + }; + + backButton.Clicked += OnBackButtonClicked; + } + topView.Add(backButton); + backButton.Show(); + RelativeLayout.SetLeftRelativeOffset(backButton, 0.0f); + RelativeLayout.SetRightRelativeOffset(backButton, 0.0f); + RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start); + + RelativeLayout.SetLeftTarget(titleLabel, backButton); + RelativeLayout.SetLeftRelativeOffset(titleLabel, 1.0f); + } + else + { + if(backButton) + { + topView.Remove(backButton); + backButton.Hide(); + RelativeLayout.SetLeftTarget(titleLabel, topView); + RelativeLayout.SetLeftRelativeOffset(titleLabel, 0.0f); + } + } + } + } + + public bool MoreButton + { + set + { + moreButton = new Button("MoreButton") + { + ThemeChangeSensitive = true, + Margin = new Extents(32, 0, 6, 6), + }; + topView.Add(moreButton); + RelativeLayout.SetLeftRelativeOffset(moreButton, 1.0f); + RelativeLayout.SetRightRelativeOffset(moreButton, 1.0f); + RelativeLayout.SetHorizontalAlignment(moreButton, RelativeLayout.Alignment.End); + + RelativeLayout.SetRightTarget(titleLabel, moreButton); + RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f); + moreButton.Clicked += OnMoreButtonClicked; + } + } + + public bool SearchButton + { + set + { + if (value) + { + ButtonStyle buttonStyle = new ButtonStyle() + { + Icon = new ImageViewStyle() + { + ResourceUrl = Resources.GetImagePath() + "search_icon.png", + }, + IsSelectable = false, + IsEnabled = true, + }; + searchButton = new Button(buttonStyle) + { + ThemeChangeSensitive = true, + Size2D = new Size2D(96, 60), + BackgroundImage = Resources.GetImagePath() + "search_button_bg.png", + Margin = new Extents(24, 0, 0, 0), + }; + topView.Add(searchButton); + RelativeLayout.SetRightTarget(searchButton, moreButton); + RelativeLayout.SetRightRelativeOffset(searchButton, 0.0f); + RelativeLayout.SetHorizontalAlignment(searchButton, RelativeLayout.Alignment.End); + + RelativeLayout.SetLeftTarget(titleLabel, RelativeLayout.GetLeftTarget(titleLabel)); + RelativeLayout.SetLeftRelativeOffset(titleLabel, RelativeLayout.GetLeftRelativeOffset(titleLabel)); + RelativeLayout.SetRightTarget(titleLabel, searchButton); + RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f); + } + } + } + + public Button GetSearchButton() + { + return searchButton; + } + + public void SetContent(BaseContentView view) + { + if(view == null) + { + Tizen.Log.Error(AppConstants.LogTag, "BaseContentView is null, provide correct object"); + return; + } + + if(baseContentView != null) + { + Tizen.Log.Error(AppConstants.LogTag, "ContentView is already added, remove it first"); + return; + } + if (view.IsSubViewAdded) + { + BackButton = true; + Title = view.GetSubContentTitle(); + } + else + { + BackButton = false; + Title = "Music"; + } + contentView.Add(view); + baseContentView = view; + } + + public void RemoveContent(BaseContentView view) + { + if(view == null) + { + Tizen.Log.Error(AppConstants.LogTag, "BaseContentView is null, provide correct object"); + return; + } + contentView.Remove(view); + baseContentView = null; + } + + public void AddSubViewContent(string titleText, BaseSubContentView subContentView) + { + if(baseContentView != null) + { + baseContentView.AddSubContentView(subContentView); + BackButton = true; + Title = titleText; + } + } + + public bool BackKeyEventEmitted() + { + if (baseContentView != null && baseContentView.IsSubViewAdded) + { + OnBack(); + return true; + } + return false; + } + + protected override void Dispose(DisposeTypes type) + { + if (Disposed) + { + return; + } + if (type == DisposeTypes.Explicit) + { + if (topView != null) + { + List children = topView.Children; + foreach (View child in children) + { + topView.Remove(child); + child?.Dispose(); + } + base.Remove(topView); + topView.Dispose(); + topView = null; + } + + // Do not delete the children of contentview as they are not owned by BaseView + base.Remove(contentView); + contentView?.Dispose(); + contentView = null; + + base.Remove(tabs); + tabs?.Dispose(); + tabs = null; + + base.Remove(bottomView); + bottomView?.Dispose(); + bottomView = null; + } + + base.Dispose(type); + } + + private void RemoveSubViewContent() + { + if (baseContentView != null) + { + BackButton = false; + Title = "Music"; + baseContentView.RemoveSubContentView(); + } + } + + private void OnBack() + { + RemoveSubViewContent(); + } + + private void OnBackButtonClicked(object sender, ClickedEventArgs e) + { + OnBack(); + } + + private Menu CreateMenu() + { + Menu moreMenu = new Menu() + { + Anchor = moreButton, + HorizontalPositionToAnchor = Menu.RelativePosition.End, + VerticalPositionToAnchor = Menu.RelativePosition.End, + }; + return moreMenu; + } + + private void OnMoreButtonClicked(object sender, ClickedEventArgs e) + { + if(baseContentView != null) + { + Menu moreMenu = CreateMenu(); + baseContentView.UpdateButtonMoreItems(moreMenu); + moreMenu.Post(); + } + } + } } \ No newline at end of file diff --git a/music-player/Views/PlaylistSelectorView.cs b/music-player/Views/PlaylistSelectorView.cs index e223281..7e94ed0 100755 --- a/music-player/Views/PlaylistSelectorView.cs +++ b/music-player/Views/PlaylistSelectorView.cs @@ -59,6 +59,12 @@ namespace MusicPlayer.Views TextLabel textLabel = (TextLabel)selectPlaylistDialog.TitleContent; textLabel.FontStyle = UIFontStyles.AllNormal; Window.Instance.Add(selectPlaylistDialog); + selectPlaylistDialog.BackKeyPressed += OnBackKeyPressed; + } + + private void OnBackKeyPressed(object sender, EventArgs e) + { + OnBackKey(); } private void AddSelectPlaylistContentArea() @@ -138,6 +144,12 @@ namespace MusicPlayer.Views TextLabel textLabel = (TextLabel)selectPlaylistDialog.TitleContent; textLabel.FontStyle = UIFontStyles.AllNormal; Window.Instance.Add(createPlaylistDialog); + createPlaylistDialog.BackKeyPressed += OnPlaylistCreateDialogBackKey; + } + + private void OnPlaylistCreateDialogBackKey(object sender, EventArgs e) + { + OnCreateDialogBackKeyPressed(); } private void AddCollectionView() @@ -223,13 +235,18 @@ namespace MusicPlayer.Views selectPlaylistCancelButton.Clicked += SelectPlaylistCancelButtonClicked; } - private void SelectPlaylistCancelButtonClicked(object sender, ClickedEventArgs e) + private void OnBackKey() { PlaylistMemberAdd?.Invoke(this, new PlaylistMemberAddEventArgs(PlaylistMemberAddStatus.Cancelled)); RemoveTheSelectPopup(); DeleteSelectorView(); } + private void SelectPlaylistCancelButtonClicked(object sender, ClickedEventArgs e) + { + OnBackKey(); + } + private void AddCreatePlaylistContentArea() { createPlaylistContentArea = new View() @@ -366,13 +383,18 @@ namespace MusicPlayer.Views createPlaylistCreateButton.Clicked += CreatePlaylistCreateButtonClicked; } - private void CreatePlaylistCancelButtonClicked(object sender, ClickedEventArgs e) + private void OnCreateDialogBackKeyPressed() { RemoveTheCreatePopup(); DeleteTheCreatePopup(); ShowTheSelectPopup(); } + private void CreatePlaylistCancelButtonClicked(object sender, ClickedEventArgs e) + { + OnCreateDialogBackKeyPressed(); + } + private void ShowInfoMessage(string message) { Notification.MakeToast(message, Notification.ToastCenter).Post(Notification.ToastShort); @@ -394,6 +416,12 @@ namespace MusicPlayer.Views private void DeleteTheCreatePopup() { + if(createPlaylistDialog == null) + { + Tizen.Log.Debug(AppConstants.LogTag, "CreatePlaylistDialog is not created yet"); + return; + } + createPlaylistDialog.BackKeyPressed -= OnPlaylistCreateDialogBackKey; inputArea?.Remove(textField); textField?.Dispose(); textField = null; @@ -413,7 +441,7 @@ namespace MusicPlayer.Views } inputArea = null; underText = null; - createPlaylistDialog?.Dispose(); + createPlaylistDialog.Dispose(); createPlaylistDialog = null; createPlaylistContentArea = null; createPlaylistCancelButton?.Dispose(); @@ -431,6 +459,11 @@ namespace MusicPlayer.Views if (type == DisposeTypes.Explicit) { DeleteTheCreatePopup(); + + if(selectPlaylistDialog != null) + { + selectPlaylistDialog.BackKeyPressed -= OnBackKeyPressed; + } if (selectPlaylistContentArea != null) { List children = selectPlaylistContentArea.Children; diff --git a/music-player/Views/SearchView.cs b/music-player/Views/SearchView.cs index 463c488..c4c8158 100755 --- a/music-player/Views/SearchView.cs +++ b/music-player/Views/SearchView.cs @@ -45,6 +45,12 @@ namespace MusicPlayer.Views AddSearchBox(); AddCollectionView(); Window.Instance.Add(this); + BackKeyPressed += OnBackKeyPressed; + } + + private void OnBackKeyPressed(object sender, EventArgs e) + { + DeleteSearchView(); } private void AddTopView() @@ -321,6 +327,7 @@ namespace MusicPlayer.Views } if (type == DisposeTypes.Explicit) { + BackKeyPressed -= OnBackKeyPressed; if (searchBox != null) { List children = searchBox.Children; diff --git a/music-player/Views/SelectorView.cs b/music-player/Views/SelectorView.cs index 42b645c..5cd240c 100755 --- a/music-player/Views/SelectorView.cs +++ b/music-player/Views/SelectorView.cs @@ -64,6 +64,12 @@ namespace MusicPlayer.Views itemCount = 0; TouchEvent += SelectorViewTouchEvent; Window.Instance.Add(this); + BackKeyPressed += OnBackKeyPressed; + } + + private void OnBackKeyPressed(object sender, System.EventArgs e) + { + OnCancel(); } private bool SelectorViewTouchEvent(object source, TouchEventArgs e) diff --git a/music-player/Views/ViewManager.cs b/music-player/Views/ViewManager.cs index 530708e..c7d5ffd 100755 --- a/music-player/Views/ViewManager.cs +++ b/music-player/Views/ViewManager.cs @@ -99,6 +99,16 @@ namespace MusicPlayer.Views } }; win.Add(rootView); + rootView.BackKeyPressed += OnBackKeyPressed; + } + + private void OnBackKeyPressed(object sender, EventArgs e) + { + if (baseView != null && baseView.BackKeyEventEmitted() == false) + { + Tizen.Log.Info(AppConstants.LogTag, "Application Exiting"); + Tizen.Applications.Application.Current.Exit(); + } } private void InitializeBaseView(View rootview) diff --git a/music-player/music-player.csproj b/music-player/music-player.csproj index 10a6880..54a9055 100755 --- a/music-player/music-player.csproj +++ b/music-player/music-player.csproj @@ -19,7 +19,7 @@ - + Runtime diff --git a/packaging/org.tizen.MusicPlayer-1.0.0.tpk b/packaging/org.tizen.MusicPlayer-1.0.0.tpk index 000ef08..a789bdc 100755 Binary files a/packaging/org.tizen.MusicPlayer-1.0.0.tpk and b/packaging/org.tizen.MusicPlayer-1.0.0.tpk differ