From: Hyerim Kim Date: Mon, 10 Jul 2017 07:09:01 +0000 (+0900) Subject: Implements delete contents in Music tab X-Git-Tag: accepted/tizen/unified/20170811.133302~7^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=004646744890b3a0cfe2b4f938c375e558faf09b;p=profile%2Ftv%2Fapps%2Fdotnet%2Fmediahub.git Implements delete contents in Music tab Changes the IsDeleteStatus property to the TabStatus property according to review comment Change-Id: Ic67ebf2baa26a2f5907c8d829da359da9cb3965a Signed-off-by: Hyerim Kim --- diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/MediaShortcutInfo.cs b/TVMediaHub/TVMediaHub.Tizen/Models/MediaShortcutInfo.cs index 0ddca92..dc49f5f 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Models/MediaShortcutInfo.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/MediaShortcutInfo.cs @@ -17,6 +17,7 @@ using System.ComponentModel; using TVMediaHub.Tizen.DataModels; using Tizen.Content.MediaContent; +using TVMediaHub.Tizen.ViewModels; namespace TVMediaHub.Tizen.Models { @@ -44,26 +45,25 @@ namespace TVMediaHub.Tizen.Models } /// - /// A flag that whether the content is delete mode or not + /// An enumeration value indicates current tab's status /// - private bool isDeleteStatus; - + private TabStatus currentTabStatus = TabStatus.Default; /// - /// Gets or sets the isDeleteStatus + /// Gets or sets the CurrentTabStatus /// - public bool IsDeleteStatus + public TabStatus CurrentTabStatus { get { - return isDeleteStatus; + return currentTabStatus; } set { - if (isDeleteStatus != value) + if (currentTabStatus != value) { - isDeleteStatus = value; - OnPropertyChanged("IsDeleteStatus"); + currentTabStatus = value; + OnPropertyChanged("CurrentTabStatus"); } } } @@ -106,7 +106,7 @@ namespace TVMediaHub.Tizen.Models public MediaShortcutInfo(MediaInformationEx information) { Information = information; - IsDeleteStatus = false; + CurrentTabStatus = TabStatus.Default; } /// diff --git a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj index 3f8a617..3ea1520 100755 --- a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj +++ b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj @@ -90,6 +90,7 @@ + diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs index 29869fe..94e310a 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs @@ -157,26 +157,26 @@ namespace TVMediaHub.Tizen.ViewModels public ICommand SelectAllContentCommand { get; set; } /// - /// A flag that whether the content is delete mode or not + /// An enumeration value indicates current image tab's status /// - private bool isDeleteStatus; + private TabStatus imageTabStatus = TabStatus.Default; /// - /// Gets or sets the isDeleteStatus + /// Gets or sets the ImageTabStatus /// - public bool IsDeleteStatus + public TabStatus ImageTabStatus { get { - return isDeleteStatus; + return imageTabStatus; } set { - if (isDeleteStatus != value) + if (imageTabStatus != value) { - isDeleteStatus = value; - OnPropertyChanged("IsDeleteStatus"); + imageTabStatus = value; + OnPropertyChanged("ImageTabStatus"); } } } @@ -320,13 +320,21 @@ namespace TVMediaHub.Tizen.ViewModels { SelectedList.Clear(); OnPropertyChanged("SelectedCount"); - IsDeleteStatus = !IsDeleteStatus; + + if (ImageTabStatus == TabStatus.Default) + { + ImageTabStatus = TabStatus.Delete; + } + else + { + ImageTabStatus = TabStatus.Default; + } foreach (var group in ImageList) { foreach (var info in group.Contents) { - info.IsDeleteStatus = IsDeleteStatus; + info.CurrentTabStatus = ImageTabStatus; } } }); @@ -363,7 +371,7 @@ namespace TVMediaHub.Tizen.ViewModels SetCurrentImageInfo = new Command((info) => { - if (IsDeleteStatus) + if (ImageTabStatus == TabStatus.Delete) { if (SelectedList.Contains(info)) { diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs index 215ce89..bb4607a 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs @@ -14,9 +14,11 @@ * limitations under the License. */ +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using System.IO; using System.Threading; using System.Windows.Input; using TVMediaHub.Tizen.DataModels; @@ -67,16 +69,77 @@ namespace TVMediaHub.Tizen.ViewModels public ICommand GetInformationsCommand { get; set; } /// + /// A command for deleting a video content + /// + public ICommand DeleteContentCommand { get; set; } + + /// + /// A command for selecting all video contents + /// + public ICommand SelectAllContentCommand { get; set; } + + /// + /// A command to set current music information + /// + public ICommand SelectMusicItem { get; set; } + + /// /// A command for changing Source /// public ICommand ChangeSourceCommand { get; set; } /// + /// A command for changing tab's status + /// + public ICommand ChangeTabStatusCommand { get; set; } + + /// /// The information of the current music /// public MediaInformationEx CurrentMusic { get; set; } /// + /// A value indicates current Music tab's status + /// + private TabStatus musicTabStatus = TabStatus.Default; + + /// + /// Gets or sets the MusicTabStatus + /// + public TabStatus MusicTabStatus + { + get + { + return musicTabStatus; + } + + set + { + if (musicTabStatus != value) + { + musicTabStatus = value; + OnPropertyChanged("MusicTabStatus"); + } + } + } + + /// + /// A list of video contents to be displayed + /// + public List SelectedList { get; set; } + + /// + /// A count of SelectedList + /// + public int SelectedCount + { + get + { + return SelectedList.Count; + } + } + + /// /// The sort option to display items of the music tab /// private SortOption option = SortOption.Title; @@ -111,6 +174,7 @@ namespace TVMediaHub.Tizen.ViewModels { MusicList = new ObservableCollection(); sourcePairList = new Dictionary(); + SelectedList = new List(); InitializeFooterItemsSource(); InitializeCommands(); @@ -193,10 +257,94 @@ namespace TVMediaHub.Tizen.ViewModels } /// - /// A method for initializing commands that are used in Image tab + /// A method for initializing commands that are used in Music tab /// private void InitializeCommands() { + ChangeTabStatusCommand = new Command(() => + { + SelectedList.Clear(); + OnPropertyChanged("SelectedCount"); + + if (MusicTabStatus.Equals(TabStatus.Default)) + { + MusicTabStatus = TabStatus.Delete; + } + else + { + MusicTabStatus = TabStatus.Default; + } + }); + + SelectAllContentCommand = new Command((IsSelectedAll) => + { + if (IsSelectedAll) + { + foreach (var group in MusicList) + { + foreach (var info in group.Contents) + { + if (!SelectedList.Contains(info.Information)) + { + SelectedList.Add(info.Information); + } + } + } + } + else + { + SelectedList.Clear(); + } + + OnPropertyChanged("SelectedCount"); + }); + + DeleteContentCommand = new Command((SelectedItem) => + { + if (SelectedItem != null) + { + SelectedList.Clear(); + SelectedList.Add(SelectedItem); + } + + foreach (var info in SelectedList) + { + try + { + File.Delete(info.MediaContentInformation.FilePath); + } + catch (Exception exception) + { + // TODO: Handling exceptions + DbgPort.E("Exception - " + exception.Message); + return; + } + + MediaHubImpl.GetInstance.MusicProviderInstance.Delete(info); + } + }); + + SelectMusicItem = new Command((info) => + { + if (MusicTabStatus == TabStatus.Delete) + { + if (SelectedList.Contains(info)) + { + SelectedList.Remove(info); + } + else + { + SelectedList.Add(info); + } + + OnPropertyChanged("SelectedCount"); + } + else + { + SetCurrentMusic(info); + } + }); + ChangeSortOptionCommand = new Command((opt) => { var optionString = opt.ToLower(); @@ -243,6 +391,7 @@ namespace TVMediaHub.Tizen.ViewModels }, ""); }); + OnPropertyChanged("ChangeTabStatusCommand"); OnPropertyChanged("ChangeSortOptionCommand"); } diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/TabStatus.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/TabStatus.cs new file mode 100755 index 0000000..5925cbf --- /dev/null +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/TabStatus.cs @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace TVMediaHub.Tizen.ViewModels +{ + public enum TabStatus + { + Default, + Delete + } +} diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs index 480aad2..58bbca0 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs @@ -127,11 +127,6 @@ namespace TVMediaHub.Tizen.ViewModels } /// - /// A flag that whether the content is delete mode or not - /// - private bool isDeleteStatus; - - /// /// A sort option /// private SortOption option = SortOption.Title; @@ -157,21 +152,26 @@ namespace TVMediaHub.Tizen.ViewModels } /// - /// Gets or sets the DeleteStatus + /// An enumeration value indicates current video tab's status + /// + private TabStatus videoTabStatus = TabStatus.Default; + + /// + /// Gets or sets the VideoTabStatus /// - public bool IsDeleteStatus + public TabStatus VideoTabStatus { get { - return isDeleteStatus; + return videoTabStatus; } set { - if (isDeleteStatus != value) + if (videoTabStatus != value) { - isDeleteStatus = value; - OnPropertyChanged("IsDeleteStatus"); + videoTabStatus = value; + OnPropertyChanged("VideoTabStatus"); } } } @@ -245,13 +245,20 @@ namespace TVMediaHub.Tizen.ViewModels { SelectedList.Clear(); OnPropertyChanged("SelectedCount"); - IsDeleteStatus = !IsDeleteStatus; + if (VideoTabStatus == TabStatus.Default) + { + VideoTabStatus = TabStatus.Delete; + } + else + { + VideoTabStatus = TabStatus.Default; + } foreach (var group in VideoList) { foreach (var info in group.Contents) { - info.IsDeleteStatus = IsDeleteStatus; + info.CurrentTabStatus = VideoTabStatus; } } }); @@ -320,7 +327,7 @@ namespace TVMediaHub.Tizen.ViewModels }); SetCurrentVideoInfo = new Command((info) => { - if (IsDeleteStatus) + if (VideoTabStatus == TabStatus.Delete) { if (SelectedList.Contains(info)) { diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/ImageItem.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/ImageItem.xaml index 1c056c3..9eacdb9 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/ImageItem.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/ImageItem.xaml @@ -5,7 +5,7 @@ xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils" xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views" ImageInfo="{Binding Information}" - IsDeleteMode="{Binding IsDeleteStatus}"> + ImageTabStatus="{Binding CurrentTabStatus}"> - 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);