From e39818488f603c56e35f8662fb2da5977e3fe52b Mon Sep 17 00:00:00 2001 From: jjie Date: Fri, 7 Jul 2017 13:07:59 +0900 Subject: [PATCH 01/16] ElmSharp API Name changed. Change-Id: I70f2eb050582155c39ffce3b226404fce407b4f8 Signed-off-by: jjie --- TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.project.json | 8 ++++---- TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerZoom.xaml.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.project.json b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.project.json index 542d989..32e02cd 100755 --- a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.project.json +++ b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.project.json @@ -6,15 +6,15 @@ "preserveCompilationContext": true }, "dependencies": { - "ElmSharp": "1.1.0-beta-021", + "ElmSharp": "1.2.2", "Microsoft.NETCore.App": "1.1.1", - "Tizen.Applications": "1.5.7", - "Tizen.Content.MediaContent": "1.0.19", + "Tizen.Applications": "1.5.8", + "Tizen.Content.MediaContent": "1.0.20", "Tizen.Multimedia": "1.2.0", "Tizen.Multimedia.MediaPlayer": "1.0.0", "Tizen.Xamarin.Forms.Extension": "2.3.5-r233-004", "Xamarin.Forms": "2.3.5-r233-004", - "Xamarin.Forms.Platform.Tizen": "2.3.5-r233-008" + "Xamarin.Forms.Platform.Tizen": "2.3.5-r233-012" }, "runtimes": { "win": {}, diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerZoom.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerZoom.xaml.cs index 6d068b7..55e6220 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerZoom.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/ImageViewerZoom.xaml.cs @@ -307,7 +307,7 @@ namespace TVMediaHub.Tizen.Views return; } - ElmSharp.EcoreAnimator.AddAmimator(delegate () + ElmSharp.EcoreAnimator.AddAnimator(delegate () { clipper.Move(clipper.Geometry.X, clipper.Geometry.Y - 2); if (clipper.Geometry.Y <= toY) @@ -338,7 +338,7 @@ namespace TVMediaHub.Tizen.Views return; } - ElmSharp.EcoreAnimator.AddAmimator(delegate () + ElmSharp.EcoreAnimator.AddAnimator(delegate () { clipper.Move(clipper.Geometry.X, clipper.Geometry.Y + 2); if (clipper.Geometry.Y >= toY) @@ -369,7 +369,7 @@ namespace TVMediaHub.Tizen.Views return; } - ElmSharp.EcoreAnimator.AddAmimator(delegate () + ElmSharp.EcoreAnimator.AddAnimator(delegate () { clipper.Move(clipper.Geometry.X - 2, clipper.Geometry.Y); if (clipper.Geometry.X <= toX) @@ -399,7 +399,7 @@ namespace TVMediaHub.Tizen.Views return; } - ElmSharp.EcoreAnimator.AddAmimator(delegate () + ElmSharp.EcoreAnimator.AddAnimator(delegate () { clipper.Move(clipper.Geometry.X + 2, clipper.Geometry.Y); if (clipper.Geometry.X >= toX) -- 2.7.4 From e17178f709977d329eda6da13e0d51cc7c23edc5 Mon Sep 17 00:00:00 2001 From: hjjang Date: Mon, 3 Jul 2017 18:25:06 +0900 Subject: [PATCH 02/16] Implement mediahub music player GUI Change-Id: Ibc7e6149fbf2eeec244f2f4fbc9c6801ee59ffcf Signed-off-by: hjjang --- .../TVMediaHub.Tizen/Models/MusicPlayerModel.cs | 90 ++++++++++++++++++++- .../ViewModels/MusicPlayerViewModel.cs | 40 ++++++++- TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml | 4 +- TVMediaHub/TVMediaHub.Tizen/Views/MusicPlayer.xaml | 32 +++++--- .../TVMediaHub.Tizen/Views/MusicPlayer.xaml.cs | 82 ++++++++++++++++++- TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml | 56 +++++++------ TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs | 7 +- .../TVMediaHub.Tizen/res/btn_music_info_pause.png | Bin 0 -> 2712 bytes .../TVMediaHub.Tizen/res/btn_music_info_play.png | Bin 0 -> 3555 bytes .../res/img_music_list_focused_shadow.9.png | Bin 0 -> 8225 bytes 10 files changed, 263 insertions(+), 48 deletions(-) create mode 100644 TVMediaHub/TVMediaHub.Tizen/res/btn_music_info_pause.png create mode 100644 TVMediaHub/TVMediaHub.Tizen/res/btn_music_info_play.png create mode 100644 TVMediaHub/TVMediaHub.Tizen/res/img_music_list_focused_shadow.9.png diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/MusicPlayerModel.cs b/TVMediaHub/TVMediaHub.Tizen/Models/MusicPlayerModel.cs index 74c1294..abf8e63 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Models/MusicPlayerModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/MusicPlayerModel.cs @@ -32,6 +32,15 @@ namespace TVMediaHub.Tizen.Models public string Title; public string Artist; public string AlbumCover; + public string AlbumName; + } + + /// + /// A custom EventArgs with bool field + /// + public class MusicPlayerStateEventArgs : EventArgs + { + public bool IsPlaying; } /// @@ -73,6 +82,11 @@ namespace TVMediaHub.Tizen.Models private EventHandler MusicPlayerInfoListener; /// + /// An event handler for handling music player state change event + /// + private EventHandler MusicPlayerStateChanged; + + /// /// An event handler for handling the percentage of the progressbar /// private EventHandler MusicPlayerProgressListener; @@ -99,13 +113,13 @@ namespace TVMediaHub.Tizen.Models currentMusic = value; /// 1. Stop the player - if (playerInstance.State == PlayerState.Playing) + if (playerInstance.State == PlayerState.Playing || playerInstance.State == PlayerState.Paused) { StopPlayer(); } /// 2. Play the current music - StartPlayerAsync((currentMusic.MediaContentInformation as AudioInformation).FilePath); + StartPlayerAsync((currentMusic.MediaContentInformation as AudioInformation).FilePath); /// 3. Update the information of the current music MusicPlayerInfoListener?.Invoke(this, new MusicPlayerInfoEventArgs() @@ -113,6 +127,7 @@ namespace TVMediaHub.Tizen.Models Title = (currentMusic.MediaContentInformation as AudioInformation).Title, Artist = (currentMusic.MediaContentInformation as AudioInformation).Artist, AlbumCover = ((currentMusic.MediaContentInformation as AudioInformation).ThumbnailPath.Length != 0) ? (currentMusic.MediaContentInformation as AudioInformation).ThumbnailPath : "img_media_no_contents.png", + AlbumName = (currentMusic.MediaContentInformation as AudioInformation).Album }); /// 4. Update the progressbar of the current music @@ -120,6 +135,11 @@ namespace TVMediaHub.Tizen.Models { Progress = (playerInstance.State == PlayerState.Idle || playerInstance.State == PlayerState.Preparing) ? 0 : Convert.ToDouble(playerInstance.GetPlayPosition()) / (currentMusic.MediaContentInformation as AudioInformation).Duration, }); + + MusicPlayerStateChanged?.Invoke(this, new MusicPlayerStateEventArgs() + { + IsPlaying = true + }); } } } @@ -151,10 +171,14 @@ namespace TVMediaHub.Tizen.Models private void InitializePlayer() { playerInstance = new Player(); - playerInstance.PlaybackCompleted += ((s, e) => { StopPlayer(); + + MusicPlayerStateChanged?.Invoke(this, new MusicPlayerStateEventArgs() + { + IsPlaying = false + }); }); playerInstance.PlaybackInterrupted += ((s, e) => @@ -162,6 +186,11 @@ namespace TVMediaHub.Tizen.Models DbgPort.E("Error : " + Enum.GetName(typeof(PlayerError), e.Reason)); StopPlayer(); + + MusicPlayerStateChanged?.Invoke(this, new MusicPlayerStateEventArgs() + { + IsPlaying = false + }); }); playerInstance.ErrorOccurred += ((s, e) => @@ -169,6 +198,11 @@ namespace TVMediaHub.Tizen.Models DbgPort.E("Error : " + Enum.GetName(typeof(PlayerError), e.Error)); StopPlayer(); + + MusicPlayerStateChanged?.Invoke(this, new MusicPlayerStateEventArgs() + { + IsPlaying = false + }); }); } @@ -222,6 +256,47 @@ namespace TVMediaHub.Tizen.Models } /// + /// Toggles pause and play the current music + /// + public void TogglePausePlay() + { + if (playerInstance.State == PlayerState.Playing) + { + try + { + playerInstance.Pause(); + + MusicPlayerStateChanged?.Invoke(this, new MusicPlayerStateEventArgs() + { + IsPlaying = false + }); + } + catch (Exception e) + { + DbgPort.E("Error : " + e.Message); + } + StopProgressbarTimer(); + } + else if (playerInstance.State == PlayerState.Paused) + { + try + { + playerInstance.Start(); + + MusicPlayerStateChanged?.Invoke(this, new MusicPlayerStateEventArgs() + { + IsPlaying = true + }); + } + catch (Exception e) + { + DbgPort.E("Error : " + e.Message); + } + StartProgressbarTimer(); + } + } + + /// /// Stops the current music /// public void StopPlayer() @@ -256,5 +331,14 @@ namespace TVMediaHub.Tizen.Models { MusicPlayerProgressListener += listener; } + + /// + /// A method adds EventHandler to SetCurrentMusicProgressListener + /// + /// The EventHandler for adding + public void SetMusicPlayerStateChangedListener(EventHandler listener) + { + MusicPlayerStateChanged += listener; + } } } diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs index b4d39d9..e1148ba 100644 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs @@ -16,6 +16,8 @@ using System.ComponentModel; using TVMediaHub.Tizen.Models; +using TVMediaHub.Tizen.Utils; +using Xamarin.Forms; namespace TVMediaHub.Tizen.ViewModels { @@ -40,10 +42,19 @@ namespace TVMediaHub.Tizen.ViewModels public string AlbumArtist { get; private set; } /// + /// The album name to be shown + /// + public string AlbumName { get; private set; } + + /// /// The album cover to be shown /// public string AlbumCover { get; private set; } + public Command MusicPlayerButtonClickCommand { get; private set; } + + public string IconPath { get; private set; } + /// /// An event that is occurred when property of ViewModel is changed /// @@ -71,6 +82,14 @@ namespace TVMediaHub.Tizen.ViewModels AlbumTitle = "Title"; AlbumArtist = "Artist"; AlbumCover = "img_media_no_contents.png"; + AlbumName = "Album"; + + MusicPlayerButtonClickCommand = new Command(() => + { + MusicPlayerModel.Instance.TogglePausePlay(); + }); + + IconPath = "btn_music_info_play.png"; MusicPlayerModel.Instance.SetCurrentMusicInfoListener((e, args) => { @@ -87,6 +106,9 @@ namespace TVMediaHub.Tizen.ViewModels AlbumCover = args.AlbumCover; OnPropertyChanged("AlbumCover"); + + AlbumName = args.AlbumName; + OnPropertyChanged("AlbumName"); }); MusicPlayerModel.Instance.SetCurrentMusicProgressListener((e, arg) => @@ -97,9 +119,25 @@ namespace TVMediaHub.Tizen.ViewModels } ProgressBarPercentage = arg.Progress; - OnPropertyChanged("ProgressBarPercentage"); }); + + MusicPlayerModel.Instance.SetMusicPlayerStateChangedListener((e, arg) => { + if(arg == null) + { + return; + } + + if (arg.IsPlaying) + { + IconPath = "btn_music_info_pause.png"; + } + else + { + IconPath = "btn_music_info_play.png"; + } + OnPropertyChanged("IconPath"); + }); } } } diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml index 1b9dbad..34277cc 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml @@ -11,6 +11,6 @@ - + RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.0737}"> + \ No newline at end of file diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicPlayer.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicPlayer.xaml index 3667788..cfe5a23 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicPlayer.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicPlayer.xaml @@ -1,18 +1,26 @@  - + + + Source="{Binding AlbumCover}" /> + + - public static readonly BindableProperty IsDeleteModeProperty = BindableProperty.Create("IsDeleteMode", typeof(bool), typeof(ImageItem), false); + public static readonly BindableProperty ImageTabStatusProperty = BindableProperty.Create("ImageTabStatus", typeof(TabStatus), typeof(ImageItem), TabStatus.Default); /// - /// Gets or sets the value whether item is delete mode or not + /// Gets or sets ImageTabStatus /// - public bool IsDeleteMode + public TabStatus ImageTabStatus { set { - SetValue(IsDeleteModeProperty, value); + SetValue(ImageTabStatusProperty, value); } get { - return (bool)GetValue(IsDeleteModeProperty); + return (TabStatus)GetValue(ImageTabStatusProperty); } } @@ -248,7 +249,7 @@ namespace TVMediaHub.Tizen.Views ImageArea.LayoutTo(ImageAreaFocusedBounds, 167); #pragma warning restore CS4014 OnItemClickedHandler?.Invoke(SelectedImage); - if (IsDeleteMode) + if (ImageTabStatus == TabStatus.Delete) { if (CurStatus == ItemStatus.Normal) { @@ -308,9 +309,9 @@ namespace TVMediaHub.Tizen.Views /// A propertyChanged event argument private void ImageTabPropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName.CompareTo("IsDeleteMode") == 0) + if (e.PropertyName.CompareTo("ImageTabStatus") == 0) { - if (!IsDeleteMode) + if (ImageTabStatus == TabStatus.Default) { CurStatus = ItemStatus.Normal; UpdateView(); @@ -378,7 +379,7 @@ namespace TVMediaHub.Tizen.Views UnavailableIcon.LayoutTo(ImageFocusedBounds, 500, easing); } - if (IsDeleteMode) + if (ImageTabStatus == TabStatus.Delete) { ImgCheckDimmed.LayoutTo(ImageAreaFocusedBounds, 500, easing); ImgCheck.LayoutTo(ImageAreaFocusedBounds, 500, easing); @@ -411,7 +412,7 @@ namespace TVMediaHub.Tizen.Views ImgFocused.LayoutTo(ShadowNormalBounds, 167, easing); ImgDimmed.LayoutTo(ImageAreaNormalBounds, 167, easing); - if (IsDeleteMode) + if (ImageTabStatus == TabStatus.Delete) { ImgCheckDimmed.LayoutTo(ImageAreaNormalBounds, 167, easing); ImgCheck.LayoutTo(ImageAreaNormalBounds, 167, easing); diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml index b87e6d7..47cf795 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml @@ -6,7 +6,7 @@ xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views" xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels" ItemsSource="{Binding ImageList}" - IsDeleteStatus="{Binding IsDeleteStatus}" + ImageTabStatus="{Binding ImageTabStatus}" GetInformationsCommand="{Binding GetInformationsCommand}" ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}" ChangeSourceCommand="{Binding ChangeSourceCommand}" diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs index 81b7d10..da44b5b 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs @@ -173,17 +173,17 @@ namespace TVMediaHub.Tizen.Views } /// - /// Identifies the IsDeleteStatus bindable property + /// Identifies the ImageTabStatus bindable property /// - public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(ImageTab), false); + public static readonly BindableProperty ImageTabStatusProperty = BindableProperty.Create("ImageTabStatus", typeof(TabStatus), typeof(ImageTab), TabStatus.Default); /// - /// Gets or sets IsDeleteStatus + /// Gets or sets ImageTabStatus /// - public bool IsDeleteStatus + public TabStatus ImageTabStatus { - get { return (bool)GetValue(IsDeleteStatusProperty); } - set { SetValue(IsDeleteStatusProperty, value); } + get { return (TabStatus)GetValue(ImageTabStatusProperty); } + set { SetValue(ImageTabStatusProperty, value); } } /// @@ -320,7 +320,7 @@ namespace TVMediaHub.Tizen.Views ItemsSource.Clear(); GalleryContentView.Children.Clear(); BottomButtonList.Clear(); - if (IsDeleteStatus) + if (ImageTabStatus == TabStatus.Delete) { DeleteModeChangeCommand?.Execute(""); FooterNormal.IsVisible = true; @@ -431,7 +431,7 @@ namespace TVMediaHub.Tizen.Views var btn = list[buttonIndex].Value; if (buttonIndex == 0) { - if (IsDeleteStatus) + if (ImageTabStatus == TabStatus.Delete) { btn.On().SetNextFocusDownView(FooterDelete.GetSelectAllButton()); // TODO : FooterDelete.GetSelectAllButton().DropdownSource.ButtonOption.On().SetNextFocusUpView(btn); @@ -444,7 +444,7 @@ namespace TVMediaHub.Tizen.Views } else if (buttonIndex == list.Count - 1) { - if (IsDeleteStatus) + if (ImageTabStatus == TabStatus.Delete) { btn.On().SetNextFocusDownView(FooterDelete.GetCancelButton()); FooterDelete.GetCancelButton().On().SetNextFocusUpView(btn); @@ -458,7 +458,7 @@ namespace TVMediaHub.Tizen.Views } else { - if (IsDeleteStatus) + if (ImageTabStatus == TabStatus.Delete) { btn.On().SetNextFocusDownView(FooterDelete.GetOkButton()); // TODO :FooterDelete.GetCancelAllButton().ButtonOption.On().SetNextFocusUpView(btn); diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs old mode 100644 new mode 100755 index 2056a21..34ea731 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs @@ -20,6 +20,7 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; using TVMediaHub.Tizen.Models; using TVMediaHub.Tizen.Utils; using Xamarin.Forms; @@ -48,16 +49,35 @@ namespace TVMediaHub.Tizen.Views } /// + /// A list of music items + /// + public List MusicItemList { get; set; } + + /// + /// A command will be executed when item is clicked + /// + private ICommand ItemClickCommand; + + /// /// A constructor /// public MusicGroup() { InitializeComponent(); InitializeSize(); + Init(); PropertyChanged += MusicGroupPropertyChanged; } /// + /// A method for initializing several lists and properties that are used in this class + /// + private void Init() + { + MusicItemList = new List(); + } + + /// /// A method for initializing sizes /// private void InitializeSize() @@ -76,6 +96,15 @@ namespace TVMediaHub.Tizen.Views } /// + /// A method for setting the command to ItemClickCommand + /// + /// A command to be set + public void SetClickCommand(ICommand command) + { + ItemClickCommand = command; + } + + /// /// This method is called when the properties is changed /// /// The source of the event @@ -85,14 +114,21 @@ namespace TVMediaHub.Tizen.Views if (e.PropertyName.Equals("ItemsSource")) { var index = 0; + MusicItemList.Clear(); foreach (var item in ItemsSource) { var itemView = new MusicItem(); itemView.BindingContext = item; + MusicItemList.Add(itemView); itemView.OnFocusedEventHandler += (se, ev) => { GroupContentArea.RaiseChild(itemView); }; + itemView.OnItemClickedHandler += (info) => + { + ItemClickCommand?.Execute(info); + }; + GroupContentArea.Children.Add(itemView, index / 4, index % 4); index++; } diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs index 92b2cad..cf11f6b 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs @@ -65,6 +65,16 @@ namespace TVMediaHub.Tizen.Views public EventHandler OnUnfocusedEventHandler; /// + /// A delegate will be executed when the item is clicked + /// + /// A clicked item's MediaInformation + public delegate void ItemEventHandler(MediaInformationEx info); + /// + /// A ClickEventHandler for click event of the item + /// + public ItemEventHandler OnItemClickedHandler; + + /// /// Bounds for TextArea when item is unfocused /// private Rectangle TextAreaNormalBounds; @@ -154,9 +164,7 @@ namespace TVMediaHub.Tizen.Views /// A Focus event's argument private void OnItemClicked(object sender, EventArgs e) { - DbgPort.D("MusicItem is clicked : " + (MusicInfo.MediaContentInformation as AudioInformation).Title); - - MusicTabViewModelLocator.ViewModel.SetCurrentMusic(MusicInfo); + OnItemClickedHandler?.Invoke(MusicInfo); } /// diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml index c1fdee6..28b6afc 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml @@ -8,7 +8,13 @@ ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}" GetInformationsCommand="{Binding GetInformationsCommand}" ChangeSourceCommand="{Binding ChangeSourceCommand}" - ItemsSource="{Binding MusicList}"> + ItemsSource="{Binding MusicList}" + ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}" + OnClickCommand="{Binding SelectMusicItem}" + DeleteContentCommand="{Binding DeleteContentCommand}" + SelectAllContentCommand="{Binding SelectAllContentCommand}" + SelectedCount="{Binding SelectedCount}" + MusicTabStatus="{Binding MusicTabStatus}"> + SelectedCount="{Binding SelectedCount}" + ContentType="Music"/> + /// The flag that whether all contents are selected or not + /// + private bool IsSelectedAll { get; set; } + + /// /// Identifies the ItemsSource bindable property /// public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection), typeof(MusicTab), default(ObservableCollection)); @@ -67,6 +74,97 @@ namespace TVMediaHub.Tizen.Views } /// + /// Identifies the ChangeTabStatusCommand bindable property + /// + public static readonly BindableProperty ChangeTabStatusCommandProperty = BindableProperty.Create("ChangeTabStatusCommand", typeof(ICommand), typeof(MusicTab), default(ICommand)); + + /// + /// Gets or sets ChangeTabStatus Command + /// + public ICommand ChangeTabStatusCommand + { + get { return (ICommand)GetValue(ChangeTabStatusCommandProperty); } + set { SetValue(ChangeTabStatusCommandProperty, value); } + } + + /// + /// Identifies the MusicTabStatus bindable property + /// + public static readonly BindableProperty MusicTabStatusProperty = BindableProperty.Create("MusicTabStatus", typeof(TabStatus), typeof(MusicTab), TabStatus.Default); + + /// + /// Gets or sets MusicTabStatus + /// + public TabStatus MusicTabStatus + { + get { return (TabStatus)GetValue(MusicTabStatusProperty); } + set { SetValue(MusicTabStatusProperty, value); } + } + + /// + /// Identifies the DeleteContentCommand bindable property + /// + public static readonly BindableProperty DeleteContentCommandProperty = BindableProperty.Create("DeleteContentCommand", typeof(ICommand), typeof(MusicTab), default(ICommand)); + + /// + /// Gets or sets DeleteContent Command + /// + public ICommand DeleteContentCommand + { + get { return (ICommand)GetValue(DeleteContentCommandProperty); } + set { SetValue(DeleteContentCommandProperty, value); } + } + + /// + /// Identifies the DeleteContentCommand bindable property + /// + public static readonly BindableProperty SelectAllContentCommandProperty = BindableProperty.Create("SelectAllContentCommand", typeof(ICommand), typeof(MusicTab), default(ICommand)); + + /// + /// Gets or sets SelectAllContent Command + /// + public ICommand SelectAllContentCommand + { + get { return (ICommand)GetValue(SelectAllContentCommandProperty); } + set { SetValue(SelectAllContentCommandProperty, value); } + } + + /// + /// Identifies the OnClickCommand bindable property + /// + public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(MusicTab), default(ICommand)); + + /// + /// Gets or sets OnClick Command + /// + public ICommand OnClickCommand + { + get + { + return (ICommand)GetValue(OnClickCommandProperty); + } + + set + { + SetValue(OnClickCommandProperty, value); + } + } + + /// + /// Identifies the SelectedCount bindable property + /// + public static readonly BindableProperty SelectedCountProperty = BindableProperty.Create("SelectedCount", typeof(int), typeof(MusicTab), 0); + + /// + /// Gets or sets count of selected item + /// + public int SelectedCount + { + get { return (int)GetValue(SelectedCountProperty); } + set { SetValue(SelectedCountProperty, value); } + } + + /// /// Identifies the GetInformationsCommand bindable property /// public static readonly BindableProperty GetInformationsCommandProperty = BindableProperty.Create("GetInformationsCommand", typeof(ICommand), typeof(MusicTab), default(ICommand)); @@ -138,11 +236,12 @@ namespace TVMediaHub.Tizen.Views private void InitializeFooter() { FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged; - FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged; - FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected; + FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked; + FooterDelete.OKButtonEvent += OnOKClicked; + FooterDelete.CancelButtonEvent += OnCancelClicked; } /// @@ -198,6 +297,7 @@ namespace TVMediaHub.Tizen.Views var groupItem = e.NewItems[0]; groupView.BindingContext = groupItem; + groupView.SetClickCommand(OnClickCommand); MusicContentView.Children.Add(groupView); } else if (e.Action.ToString().Equals(NotifyCollectionChangedAction.Reset.ToString())) @@ -243,6 +343,76 @@ namespace TVMediaHub.Tizen.Views /// A SelectedItemChanged event's argument private void OnOptionSelected(object sender, ContextPopupSelectedEventArgs e) { + var label = e.Item.Label.Trim().ToLower(); + if (label.Equals("delete")) + { + ChangeTabStatusCommand?.Execute(""); + FooterNormal.IsVisible = false; + FooterDelete.IsVisible = true; + } + else if (label.Equals("detail info")) + { + // TODO : Display the alert popup + } + } + + /// + /// This method is called when cancel button is clicked + /// + /// The source of the event + /// An event's argument + private void OnCancelClicked(object sender, EventArgs e) + { + ChangeTabStatusCommand?.Execute(""); + FooterNormal.IsVisible = true; + FooterDelete.IsVisible = false; + } + + /// + /// This method is called when SelectAll button is clicked + /// + /// The source of the event + /// An event's argument + private void OnSelectAllClicked(object sender, EventArgs e) + { + IsSelectedAll = FooterDelete.IsSelectedAll; + SelectAllContentCommand?.Execute(IsSelectedAll); + } + + /// + /// This method is called when OK button is clicked + /// + /// The source of the event + /// An event's argument + private async void OnOKClicked(object sender, EventArgs e) + { + string title = "Delete"; + + if (SelectedCount < 1) + { + return; + } + else if (SelectedCount > 1) + { + title = "Delete Selected"; + + if (IsSelectedAll) + { + title = "Delete All"; + } + } + + bool answer = await DisplayAlert(title, "Do you want to delete?", "YES", "NO"); + + if (answer) + { + DeleteContentCommand?.Execute(null); + GetInformationsCommand?.Execute(""); + } + + ChangeTabStatusCommand?.Execute(""); + FooterNormal.IsVisible = true; + FooterDelete.IsVisible = false; } } } diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml old mode 100644 new mode 100755 index 95562da..2f3e09c --- a/TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml @@ -5,7 +5,7 @@ x:Class="TVMediaHub.Tizen.Views.VideoItem" xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views" VideoInfo="{Binding Information}" - IsDeleteMode="{Binding IsDeleteStatus}"> + VideoTabStatus="{Binding CurrentTabStatus}"> - public static readonly BindableProperty IsDeleteModeProperty = BindableProperty.Create("IsDeleteMode", typeof(bool), typeof(VideoItem), false); + public static readonly BindableProperty VideoTabStatusProperty = BindableProperty.Create("VideoTabStatus", typeof(TabStatus), typeof(VideoItem), TabStatus.Default); /// - /// Gets or sets the value whether item is delete mode or not + /// Gets or sets VideoTabStatus /// - public bool IsDeleteMode + public TabStatus VideoTabStatus { set { - SetValue(IsDeleteModeProperty, value); + SetValue(VideoTabStatusProperty, value); } get { - return (bool)GetValue(IsDeleteModeProperty); + return (TabStatus)GetValue(VideoTabStatusProperty); } } @@ -315,7 +316,7 @@ namespace TVMediaHub.Tizen.Views PlayImage.FadeTo(0.0, 167); } - if (IsDeleteMode) + if (VideoTabStatus == TabStatus.Delete) { CheckDimImage.LayoutTo(NormalBounds, 167, easing); CheckImage.LayoutTo(NormalBounds, 167, easing); @@ -363,7 +364,7 @@ namespace TVMediaHub.Tizen.Views PlayImage.FadeTo(0.99, 167); } - if (IsDeleteMode) + if (VideoTabStatus == TabStatus.Delete) { CheckDimImage.LayoutTo(FocusedBounds, 167, easing); CheckImage.LayoutTo(FocusedBounds, 167, easing); @@ -400,7 +401,8 @@ namespace TVMediaHub.Tizen.Views CheckImage.LayoutTo(FocusedBounds, 167); ImageArea.LayoutTo(FocusedBounds, 167); OnItemClickedHandler?.Invoke(VideoInfo); - if (IsDeleteMode) + + if (VideoTabStatus == TabStatus.Delete) { if (CurStatus == ItemStatus.Normal) { @@ -470,9 +472,9 @@ namespace TVMediaHub.Tizen.Views /// A propertyChanged event argument private void VideoItemPropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName.CompareTo("IsDeleteMode") == 0) + if (e.PropertyName.CompareTo("VideoTabStatus") == 0) { - if (!IsDeleteMode) + if (VideoTabStatus == TabStatus.Default) { CurStatus = ItemStatus.Normal; UpdateView(); diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml index b408c9b..b9554a0 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml @@ -7,7 +7,7 @@ xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels" Title="Movie" ItemsSource="{Binding VideoList}" - IsDeleteStatus="{Binding IsDeleteStatus}" + VideoTabStatus="{Binding VideoTabStatus}" ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}" ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}" ChangeSourceCommand="{Binding ChangeSourceCommand}" diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs index 9f27157..68df208 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs @@ -75,17 +75,17 @@ namespace TVMediaHub.Tizen.Views } /// - /// Identifies the IsDeleteStatus bindable property + /// Identifies the VideoTabStatus bindable property /// - public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(VideoTab), false); + public static readonly BindableProperty VideoTabStatusProperty = BindableProperty.Create("VideoTabStatus", typeof(TabStatus), typeof(VideoTab), TabStatus.Default); /// - /// Gets or sets IsDeleteStatus + /// Gets or sets VideoTabStatus /// - public bool IsDeleteStatus + public TabStatus VideoTabStatus { - get { return (bool)GetValue(IsDeleteStatusProperty); } - set { SetValue(IsDeleteStatusProperty, value); } + get { return (TabStatus)GetValue(VideoTabStatusProperty); } + set { SetValue(VideoTabStatusProperty, value); } } /// @@ -310,7 +310,7 @@ namespace TVMediaHub.Tizen.Views ItemsSource.Clear(); VideoTabList.Children.Clear(); BottomButtonList.Clear(); - if (IsDeleteStatus) + if (VideoTabStatus == TabStatus.Delete) { ChangeTabStatusCommand?.Execute(""); FooterNormal.IsVisible = true; @@ -427,7 +427,7 @@ namespace TVMediaHub.Tizen.Views var btn = list[buttonIndex].Value; if (buttonIndex == 0) { - if (IsDeleteStatus) + if (VideoTabStatus == TabStatus.Delete) { btn.On().SetNextFocusDownView(FooterDelete.GetSelectAllButton()); // TODO : FooterDelete.GetSelectAllButton().DropdownSource.ButtonOption.On().SetNextFocusUpView(btn); @@ -440,7 +440,7 @@ namespace TVMediaHub.Tizen.Views } else if (buttonIndex == list.Count - 1) { - if (IsDeleteStatus) + if (VideoTabStatus == TabStatus.Delete) { btn.On().SetNextFocusDownView(FooterDelete.GetCancelButton()); FooterDelete.GetCancelButton().On().SetNextFocusUpView(btn); @@ -454,7 +454,7 @@ namespace TVMediaHub.Tizen.Views } else { - if (IsDeleteStatus) + if (VideoTabStatus == TabStatus.Delete) { btn.On().SetNextFocusDownView(FooterDelete.GetOkButton()); // TODO :FooterDelete.GetCancelAllButton().ButtonOption.On().SetNextFocusUpView(btn); -- 2.7.4 From 113eb56492a1239e040a7cbbd2e493e5db862045 Mon Sep 17 00:00:00 2001 From: hjjang Date: Tue, 11 Jul 2017 18:57:02 +0900 Subject: [PATCH 06/16] Implements focus chain in Music Tab (without footer) Change-Id: Iad2e706a18e4fc692366dcd1679815ee937f6968 Signed-off-by: hjjang --- .../TVMediaHub.Tizen/Views/MusicGroup.xaml.cs | 129 +++++++++++++++++++++ .../TVMediaHub.Tizen/Views/MusicItem.xaml.cs | 8 ++ .../TVMediaHub.Tizen/Views/MusicPlayer.xaml.cs | 8 ++ TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs | 38 +++++- 4 files changed, 181 insertions(+), 2 deletions(-) diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs index 34ea731..2cb3fdd 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs @@ -25,6 +25,7 @@ using TVMediaHub.Tizen.Models; using TVMediaHub.Tizen.Utils; using Xamarin.Forms; using Xamarin.Forms.Xaml; +using Xamarin.Forms.PlatformConfiguration.TizenSpecific; namespace TVMediaHub.Tizen.Views { @@ -59,6 +60,29 @@ namespace TVMediaHub.Tizen.Views private ICommand ItemClickCommand; /// + /// A list of children's button objects of group + /// + private List private void Init() { + ChildrenFocusList = new List