From 0b0da7e09c61388016533a210698ff297293ea7c Mon Sep 17 00:00:00 2001 From: Hyerim Kim Date: Wed, 14 Jun 2017 17:24:57 +0900 Subject: [PATCH 01/16] Implements the method for showing toast popup source is removed Change-Id: Iff30201064801f39a2244402153ff97b6b421471 Signed-off-by: Hyerim Kim --- .../TVMediaHub.Tizen/Models/ContentProvider.cs | 1 - .../TVMediaHub.Tizen/Models/ImageProvider.cs | 1 - .../TVMediaHub.Tizen/Models/StorageProvider.cs | 72 +++++++++++++++++++-- .../ViewModels/ImageTabViewModel.cs | 21 +++--- .../ViewModels/MediaHubMainPageViewModel.cs | 74 +++------------------- .../ViewModels/VideoTabViewModel.cs | 22 ++++--- .../TVMediaHub.Tizen/Views/MediaHubMainPage.xaml | 3 +- .../Views/MediaHubMainPage.xaml.cs | 39 +++++++++++- 8 files changed, 137 insertions(+), 96 deletions(-) diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs index 3ffb646..264090d 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Tizen; using Tizen.Content.MediaContent; using TVMediaHub.Tizen.Utils; using TVMediaHub.Tizen.DataModels; diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/ImageProvider.cs b/TVMediaHub/TVMediaHub.Tizen/Models/ImageProvider.cs index 1db692b..ea3aa87 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Models/ImageProvider.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/ImageProvider.cs @@ -16,7 +16,6 @@ using System; using System.IO; -using Tizen.Content.MediaContent; using TVMediaHub.Tizen.Utils; using TVMediaHub.Tizen.DataModels; diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/StorageProvider.cs b/TVMediaHub/TVMediaHub.Tizen/Models/StorageProvider.cs index 39a80d1..6dbc012 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Models/StorageProvider.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/StorageProvider.cs @@ -14,12 +14,22 @@ * limitations under the License. */ +using System; using System.Collections.Generic; +using System.Linq; using Tizen.Content.MediaContent; namespace TVMediaHub.Tizen.Models { /// + /// A custom EventArgs with string fields + /// + public class StorageInfoEventArgs : EventArgs + { + public string storageName; + } + + /// /// A StorageProvider for the media hub /// public class StorageProvider @@ -30,32 +40,82 @@ namespace TVMediaHub.Tizen.Models private IEnumerable storageList = new List(); /// - /// A list of storage id + /// A dictionary list of storage name and storage id + /// Keeps the values when the media hub application is terminated. + /// + private Dictionary storageTable = new Dictionary(); + private static int index = 1; + + /// + /// A dictionary list of storage name and storage id /// - public List StorageId { get; protected set; } + public Dictionary StoragePairList { get; protected set; } + + /// + /// An EventHandler that is occured when source is removed + /// + public EventHandler SourceRemovedEvent; /// /// A constructor /// public StorageProvider() { - StorageId = new List(); + StoragePairList = new Dictionary(); CheckStorage(); } /// /// Returns the list of the storage id of the media storage. /// - /// Task with the list of the ContentCollection public void CheckStorage() { - StorageId.Clear(); storageList = ContentManager.Database.SelectAll(null); + if (storageList.Count() < storageTable.Count) + { + CheckRemoveStorage(); + } + StoragePairList.Clear(); foreach (var item in storageList) { - StorageId.Add(item.Id); + if (!storageTable.ContainsKey(item.Id)) + { + storageTable.Add(item.Id, "USB " + index++); + } + + StoragePairList.Add(item.Id, storageTable[item.Id]); } + + StoragePairList = StoragePairList.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); + } + + /// + /// Checks the removed storage name and invokes the SourceRemoveedEvent with storage name. + /// + private void CheckRemoveStorage() + { + foreach (var item in storageTable) + { + Storage storage = ContentManager.Database.Select(item.Key); + + if (storage == null) + { + StorageInfoEventArgs args = new StorageInfoEventArgs(); + args.storageName = item.Value; + + SourceRemovedEvent?.Invoke(this, args); + } + } + } + + /// + /// A method for handling SourceRemoveEvent + /// + /// A handling method + public void SetSourceRemoveEventListener(EventHandler listener) + { + this.SourceRemovedEvent += listener; } } } diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs index 4e8371f..29869fe 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs @@ -57,6 +57,11 @@ namespace TVMediaHub.Tizen.ViewModels private SortOption option = SortOption.Date; /// + /// A storage id + /// + private string storageId = null; + + /// /// Gets or sets the displayingImageIndex /// private int DisplayingImageIndex @@ -381,14 +386,13 @@ namespace TVMediaHub.Tizen.ViewModels { if (name == null) { - DbgPort.D("name is null"); return; } - string id = sourcePairList[name]; + storageId = sourcePairList[name]; SynchronizationContext.Current.Post((o) => { - ReadImageList(option, id); + ReadImageList(option, storageId); }, ""); }); @@ -455,7 +459,7 @@ namespace TVMediaHub.Tizen.ViewModels { SynchronizationContext.Current.Post((o) => { - ReadImageList(option); + ReadImageList(option, storageId); }, ""); }); @@ -493,7 +497,6 @@ namespace TVMediaHub.Tizen.ViewModels /// private void AddSourceListItem() { - int index = 1; sourcePairList.Clear(); List tempList = new List(); @@ -503,15 +506,13 @@ namespace TVMediaHub.Tizen.ViewModels tempList.Add("ALL SOURCE"); tempList.Add("DEVICE"); - foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StorageId) + foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StoragePairList) { - sourcePairList.Add("USB " + index, item); - tempList.Add("USB " + index); - index++; + sourcePairList.Add(item.Value, item.Key); + tempList.Add(item.Value); } SourceList = tempList; - OnPropertyChanged("SourceList"); } diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs index 2529331..8ed51f2 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MediaHubMainPageViewModel.cs @@ -15,8 +15,9 @@ */ using System.ComponentModel; -using Xamarin.Forms; using System.Runtime.CompilerServices; +using TVMediaHub.Tizen.Models; +using TVMediaHub.Tizen.Utils; namespace TVMediaHub.Tizen.ViewModels { @@ -26,13 +27,9 @@ namespace TVMediaHub.Tizen.ViewModels class MediaHubMainPageViewModel : INotifyPropertyChanged { /// - /// A flag that whether footer is normal mode or not + /// A name of source /// - bool isFooterNor; - /// - /// A flag that whether footer is select mode or not - /// - bool isFooterSel; + public string SourceName { get; set; } /// /// An event that is occurred when property of MediaHubMainPageViewModel is changed @@ -40,53 +37,11 @@ namespace TVMediaHub.Tizen.ViewModels public event PropertyChangedEventHandler PropertyChanged; /// - /// Gets or sets the isFooterNor - /// - public bool IsFooterNorStatus - { - set - { - if (isFooterNor != value) - { - isFooterNor = value; - OnPropertyChanged(); - IsFooterSelStatus = !IsFooterNorStatus; - } - } - - get - { - return isFooterNor; - } - } - - /// - /// Gets or sets the isFooterSel - /// - public bool IsFooterSelStatus - { - set - { - if (isFooterSel != value) - { - isFooterSel = value; - OnPropertyChanged(); - } - } - - get - { - return isFooterSel; - } - } - - /// /// A method for invoking PropertyChanged event /// /// The name of property protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { - PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) @@ -96,27 +51,16 @@ namespace TVMediaHub.Tizen.ViewModels } /// - /// A Command for changing footer's status to select mode. - /// - public Command OnSeleteModeCommand { get; set; } - - /// /// A consturctor - /// Initializes OnSelectModeCommand that is called to change the footer to select mode + /// Implements the SourceRemoveEventListener /// public MediaHubMainPageViewModel() { - IsFooterNorStatus = true; - OnSeleteModeCommand = new Command(() => + MediaHubImpl.GetInstance.StorageProviderInstance.SetSourceRemoveEventListener((sender, arg) => { - if (IsFooterNorStatus) - { - IsFooterNorStatus = false; - } - else - { - IsFooterNorStatus = true; - } + StorageInfoEventArgs e = arg as StorageInfoEventArgs; + SourceName = e.storageName; + OnPropertyChanged("SourceName"); }); } } diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs index 5b75e26..480aad2 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs @@ -25,6 +25,7 @@ using TVMediaHub.Tizen.Models; using TVMediaHub.Tizen.Utils; using TVMediaHub.Tizen.DataModels; using Xamarin.Forms; +using Tizen.Xamarin.Forms.Extension; namespace TVMediaHub.Tizen.ViewModels { @@ -136,6 +137,11 @@ namespace TVMediaHub.Tizen.ViewModels private SortOption option = SortOption.Title; /// + /// A storage id + /// + private string storageId = null; + + /// /// Gets or sets the MediaInformationEx of current video /// public MediaInformationEx CurrentVideo { get; set; } @@ -296,21 +302,20 @@ namespace TVMediaHub.Tizen.ViewModels { SynchronizationContext.Current.Post((o) => { - ReadVideoList(option); + ReadVideoList(option, storageId); }, ""); }); ChangeSourceCommand = new Command((name) => { if (name == null) { - DbgPort.D("name is null"); return; } - string id = sourcePairList[name]; + storageId = sourcePairList[name]; SynchronizationContext.Current.Post((o) => { - ReadVideoList(option, id); + ReadVideoList(option, storageId); }, ""); }); SetCurrentVideoInfo = new Command((info) => @@ -403,7 +408,6 @@ namespace TVMediaHub.Tizen.ViewModels /// private void AddSourceListItem() { - int index = 1; sourcePairList.Clear(); List tempList = new List(); @@ -413,15 +417,13 @@ namespace TVMediaHub.Tizen.ViewModels tempList.Add("ALL SOURCE"); tempList.Add("DEVICE"); - foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StorageId) + foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StoragePairList) { - sourcePairList.Add("USB " + index, item); - tempList.Add("USB " + index); - index++; + sourcePairList.Add(item.Value, item.Key); + tempList.Add(item.Value); } SourceList = tempList; - OnPropertyChanged("SourceList"); } diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml index aa5f343..90bb86d 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml @@ -3,7 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="TVMediaHub.Tizen.Views.MediaHubMainPage" xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views" - Title="MEDIA HUB"> + Title="MEDIA HUB" + SourceName="{Binding SourceName}"> diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs index ad222cd..9ba4c5d 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs @@ -17,7 +17,9 @@ using System; using System.Threading; using System.Threading.Tasks; +using Tizen.Xamarin.Forms.Extension; using TVMediaHub.Tizen.Controls; +using TVMediaHub.Tizen.ViewModels; using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -30,6 +32,20 @@ namespace TVMediaHub.Tizen.Views public partial class MediaHubMainPage : TabbedPage { /// + /// Identifies the SourceName bindable property + /// + public static readonly BindableProperty SourceNameProperty = BindableProperty.Create("SourceName", typeof(string), typeof(MediaHubMainPage), null, BindingMode.TwoWay); + + /// + /// Gets or sets the source name + /// + public string SourceName + { + get { return (string)GetValue(SourceNameProperty); } + set { SetValue(SourceNameProperty, value); } + } + + /// /// A flag that whether app is loaded or not /// private bool IsAppLoaded; @@ -41,9 +57,28 @@ namespace TVMediaHub.Tizen.Views { IsAppLoaded = false; InitializeComponent(); + BindingContext = new MediaHubMainPageViewModel(); NavigationPage.SetHasBackButton(this, false); NavigationPage.SetHasNavigationBar(this, true); - CurrentPageChanged += MediaHubMainPage_CurrentPageChanged; + CurrentPageChanged += MediaHubMainPageCurrentPageChanged; + PropertyChanged += MediaHubMainPagePropertyChanged; + } + + /// + /// This method is called when the properties is changed + /// + /// The source of the event + /// A propertyChanged event argument + private void MediaHubMainPagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName.Equals("SourceName")) + { + if (SourceName != null) + { + Toast.DisplayText(SourceName + " Disconnected."); + SourceName = null; + } + } } /// @@ -51,7 +86,7 @@ namespace TVMediaHub.Tizen.Views /// /// The source of event /// An event argument - private void MediaHubMainPage_CurrentPageChanged(object sender, EventArgs e) + private void MediaHubMainPageCurrentPageChanged(object sender, EventArgs e) { var page = CurrentPage as ContentPageEx; page.RunShowAnimation(); -- 2.7.4 From 3d782429c5b3f01ecb2f1420b1a684be5d6bbf89 Mon Sep 17 00:00:00 2001 From: "Geunsun, Lee" Date: Thu, 15 Jun 2017 07:16:36 +0900 Subject: [PATCH 02/16] Fix build error : Change the file name in the csproj file Change-Id: I85d3049d28851811a18adc2a7051fd111f8f1884 --- TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj index 0666f86..3f8a617 100755 --- a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj +++ b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj @@ -48,10 +48,10 @@ - - CustomImageButton.xaml + + ZoomNaviButton.xaml - + MediaHubButton.xaml @@ -287,7 +287,7 @@ - + MSBuild:UpdateDesignTimeXaml -- 2.7.4 From 400811e0695b706a9ab4ec5de31478c5b9460dcd Mon Sep 17 00:00:00 2001 From: jjie Date: Wed, 28 Jun 2017 15:32:57 +0900 Subject: [PATCH 03/16] Implment mediahub musictab list GUI Change-Id: Ie82580a2d01ced295ddfe333f0cbcde6ab20d3b9 Signed-off-by: jjie --- .../TVMediaHub.Tizen/Views/MusicGroup.xaml.cs | 14 +++++---- TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml | 35 ++++++++++----------- .../TVMediaHub.Tizen/Views/MusicItem.xaml.cs | 30 +++++++++++++----- TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml | 2 +- TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs | 2 ++ .../res/img_music_nocover_focused.png | Bin 0 -> 5492 bytes 6 files changed, 49 insertions(+), 34 deletions(-) create mode 100644 TVMediaHub/TVMediaHub.Tizen/res/img_music_nocover_focused.png diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs index 34a465f..307f1b5 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs @@ -64,14 +64,16 @@ namespace TVMediaHub.Tizen.Views { GroupTitle.FontSize = Utils.SizeUtils.GetFontSize(28); GroupTitle.HeightRequest = Utils.SizeUtils.GetHeightSize(50); - GroupTitle.Margin = new Thickness(SizeUtils.GetWidthSize(12), 0, 0, 0); + GroupTitle.Margin = new Thickness(SizeUtils.GetWidthSize(60), 0, 0, 0); TitleFocusArea.WidthRequest = SizeUtils.GetWidthSize(180); - GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(134) }); - GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(134) }); - GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(134) }); - GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(134) }); - GroupContentArea.RowSpacing = SizeUtils.GetHeightSize(2); + GroupContentArea.RowSpacing = SizeUtils.GetHeightSize(-134); + GroupContentArea.ColumnSpacing = SizeUtils.GetWidthSize(-136); + GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(270) }); + GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(270) }); + GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(270) }); + GroupContentArea.RowDefinitions.Add(new RowDefinition { Height = SizeUtils.GetHeightSize(270) }); + GroupContentArea.Margin = new Thickness(SizeUtils.GetWidthSize(-64), SizeUtils.GetHeightSize(-64), SizeUtils.GetWidthSize(-64), SizeUtils.GetHeightSize(-64)); } /// diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml index c74e79f..1c262e0 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml @@ -5,29 +5,26 @@ xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils" xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views" MusicInfo="{Binding Information}"> - - - - - - - + + + FontFamily="BreezeSans" + LineBreakMode="TailTruncation" + Opacity="0.6"/> + + private void InitializeSize() { - WidthRequest = SizeUtils.GetWidthSize(400); - HeightRequest = SizeUtils.GetHeightSize(134); + WidthRequest = SizeUtils.GetWidthSize(716); + HeightRequest = SizeUtils.GetHeightSize(270); AlbumCover.WidthRequest = SizeUtils.GetWidthSize(134); AlbumCover.HeightRequest = SizeUtils.GetHeightSize(134); - SongTitle.WidthRequest = SizeUtils.GetWidthSize(266); - SongTitle.FontSize = SizeUtils.GetFontSize(20); - Artist.WidthRequest = SizeUtils.GetWidthSize(266); - Artist.FontSize = SizeUtils.GetFontSize(17); - AlbumTitle.WidthRequest = SizeUtils.GetWidthSize(266); - AlbumTitle.FontSize = SizeUtils.GetFontSize(17); + TextArea.WidthRequest = SizeUtils.GetWidthSize(446); + TextArea.HeightRequest = SizeUtils.GetHeightSize(134); + SongTitle.WidthRequest = SizeUtils.GetWidthSize(382); + SongTitle.HeightRequest = SizeUtils.GetHeightSize(32); + SongTitle.FontSize = SizeUtils.GetFontSize(28); + SongTitle.Margin = new Thickness(SizeUtils.GetWidthSize(32), SizeUtils.GetHeightSize(18), SizeUtils.GetWidthSize(32), 0); + SongTitle.On().SetFontWeight(FontWeight.Normal); + Artist.WidthRequest = SizeUtils.GetWidthSize(382); + Artist.HeightRequest = SizeUtils.GetHeightSize(32); + Artist.Margin = new Thickness(SizeUtils.GetWidthSize(32), SizeUtils.GetHeightSize(12), SizeUtils.GetWidthSize(32), 0); + Artist.FontSize = SizeUtils.GetFontSize(28); + Artist.On().SetFontWeight(FontWeight.Normal); + AlbumTitle.WidthRequest = SizeUtils.GetWidthSize(382); + AlbumTitle.HeightRequest = SizeUtils.GetHeightSize(28); + AlbumTitle.Margin = new Thickness(SizeUtils.GetWidthSize(32), SizeUtils.GetHeightSize(4), SizeUtils.GetWidthSize(32), 0); + AlbumTitle.FontSize = SizeUtils.GetFontSize(24); + AlbumTitle.On().SetFontWeight(FontWeight.Light); } /// diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml index 7a13d16..09e1a6c 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml @@ -32,7 +32,7 @@ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.0}"> diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs index 918b62e..7c5956e 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs @@ -108,6 +108,8 @@ namespace TVMediaHub.Tizen.Views ImgNoContents.WidthRequest = SizeUtils.GetWidthSize(68); LabelNoContents.HeightRequest = SizeUtils.GetHeightSize(32); LabelNoContents.FontSize = SizeUtils.GetFontSize(28); + MusicContentView.Padding = new Thickness(0, SizeUtils.GetHeightSize(74)); + MusicContentView.Spacing = SizeUtils.GetWidthSize(60); } /// diff --git a/TVMediaHub/TVMediaHub.Tizen/res/img_music_nocover_focused.png b/TVMediaHub/TVMediaHub.Tizen/res/img_music_nocover_focused.png new file mode 100644 index 0000000000000000000000000000000000000000..901ea5f3455185d5d982c31d33a18e6726bc0806 GIT binary patch literal 5492 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 Date: Thu, 29 Jun 2017 17:28:24 +0900 Subject: [PATCH 04/16] Modifies Music tab to get the contents according to sources Change-Id: I5ac54c21d52c4df8c29a116a8b019a85fe489191 Signed-off-by: Hyerim Kim --- .../ViewModels/MusicTabViewModel.cs | 66 ++++++++++++++++++++-- .../TVMediaHub.Tizen/Views/MusicItem.xaml.cs | 3 +- TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml | 1 + TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs | 20 ++++++- 4 files changed, 83 insertions(+), 7 deletions(-) mode change 100644 => 100755 TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs index 29298a4..215ce89 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs @@ -37,6 +37,11 @@ namespace TVMediaHub.Tizen.ViewModels public ObservableCollection MusicList { get; set; } /// + /// Gets or sets the SourceList + /// + public IEnumerable SourceList { get; set; } + + /// /// Gets or sets the SortOption list /// public IEnumerable SortOptions { get; set; } @@ -62,6 +67,11 @@ namespace TVMediaHub.Tizen.ViewModels public ICommand GetInformationsCommand { get; set; } /// + /// A command for changing Source + /// + public ICommand ChangeSourceCommand { get; set; } + + /// /// The information of the current music /// public MediaInformationEx CurrentMusic { get; set; } @@ -72,6 +82,11 @@ namespace TVMediaHub.Tizen.ViewModels private SortOption option = SortOption.Title; /// + /// A storage id + /// + private string storageId = null; + + /// /// An event that is occurred when property of ViewModel is changed /// public event PropertyChangedEventHandler PropertyChanged; @@ -95,13 +110,14 @@ namespace TVMediaHub.Tizen.ViewModels public MusicTabViewModel() { MusicList = new ObservableCollection(); + sourcePairList = new Dictionary(); InitializeFooterItemsSource(); InitializeCommands(); OnPropertyChanged("MusicList"); - MediaHubImpl.GetInstance.MusicProviderInstance.SetContentUpdatedEventListener((s, e) => + MediaHubImpl.GetInstance.MusicProviderInstance.SetContentUpdatedEventListener((sender, arg) => { - DbgPort.D("Content updated"); + AddSourceListItem(); }); } @@ -109,10 +125,10 @@ namespace TVMediaHub.Tizen.ViewModels /// A method for reading music contents through MusicProvider and updating MusicList ///
/// A current sort option - private async void ReadMusicList(SortOption option) + private async void ReadMusicList(SortOption option, string storageID = null) { MusicList.Clear(); - IEnumerable templist = await MediaHubImpl.GetInstance.MusicProviderInstance.ReadAsync(option); + IEnumerable templist = await MediaHubImpl.GetInstance.MusicProviderInstance.ReadAsync(option, storageID); foreach (var group in templist) { await MediaHubImpl.GetInstance.MusicProviderInstance.CheckThumbnail(group.Contents); @@ -129,6 +145,8 @@ namespace TVMediaHub.Tizen.ViewModels ///
private void InitializeFooterItemsSource() { + AddSourceListItem(); + var list = new List { "SONG", @@ -142,7 +160,7 @@ namespace TVMediaHub.Tizen.ViewModels list = new List { - "DETAIL INFO", + " DETAIL INFO ", "DELETE" }; @@ -151,6 +169,30 @@ namespace TVMediaHub.Tizen.ViewModels } /// + /// A method for making the source list + /// + private void AddSourceListItem() + { + sourcePairList.Clear(); + List tempList = new List(); + + sourcePairList.Add("ALL SOURCE", null); + sourcePairList.Add("DEVICE", "media"); + + tempList.Add("ALL SOURCE"); + tempList.Add("DEVICE"); + + foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StoragePairList) + { + sourcePairList.Add(item.Value, item.Key); + tempList.Add(item.Value); + } + + SourceList = tempList; + OnPropertyChanged("SourceList"); + } + + /// /// A method for initializing commands that are used in Image tab /// private void InitializeCommands() @@ -187,6 +229,20 @@ namespace TVMediaHub.Tizen.ViewModels }, ""); }); + ChangeSourceCommand = new Command((name) => + { + if (name == null) + { + return; + } + + storageId = sourcePairList[name]; + SynchronizationContext.Current.Post((o) => + { + ReadMusicList(option, storageId); + }, ""); + }); + OnPropertyChanged("ChangeSortOptionCommand"); } diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs old mode 100644 new mode 100755 index 1567b87..abf663e --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs @@ -137,7 +137,8 @@ namespace TVMediaHub.Tizen.Views if (e.PropertyName.Equals("MusicInfo")) { AudioInformation info = MusicInfo.MediaContentInformation as AudioInformation; - AlbumCover.Source = (info.ThumbnailPath.Length != 0) ? info.ThumbnailPath : "img_media_no_contents.png"; + AlbumCover.Source = !(string.IsNullOrEmpty(info.ThumbnailPath)) ? info.ThumbnailPath : "img_media_no_contents.png"; + SongTitle.Text = info.Title; Artist.Text = info.Artist; AlbumTitle.Text = info.Album; diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml index 09e1a6c..de3b73f 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml @@ -7,6 +7,7 @@ Title="Music" ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}" GetInformationsCommand="{Binding GetInformationsCommand}" + ChangeSourceCommand="{Binding ChangeSourceCommand}" ItemsSource="{Binding MusicList}"> diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs index 7c5956e..c89ba88 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs @@ -84,6 +84,20 @@ namespace TVMediaHub.Tizen.Views } /// + /// Identifies the ChangeSourceCommand bindable property + /// + public static readonly BindableProperty ChangeSourceCommandProperty = BindableProperty.Create("ChangeSourceCommand", typeof(ICommand), typeof(MusicTab), default(ICommand)); + + /// + /// Gets or sets ChangeSourceCommand Command + /// + public ICommand ChangeSourceCommand + { + get { return (ICommand)GetValue(ChangeSourceCommandProperty); } + set { SetValue(ChangeSourceCommandProperty, value); } + } + + /// /// A constructor /// Initializes the size of the items that are used in Music tab /// @@ -208,7 +222,11 @@ namespace TVMediaHub.Tizen.Views /// A SelectedItemChanged event's argument private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e) { - // TODO : Source Change + String storageName = e.SelectedItem as String; + + //BottomButtonList.Clear(); + ChangeSourceCommand?.Execute(storageName); + //SetFooterFocusChain(ImageTabScrollView.ScrollX); } /// -- 2.7.4 From f0b854e90857c29f8b83a6f6fbbd4e2e641a5c1f Mon Sep 17 00:00:00 2001 From: jjie Date: Fri, 30 Jun 2017 12:55:20 +0900 Subject: [PATCH 05/16] Implement mediahub music list gui Change-Id: Id966973933b2334ae481eacdc2aa1d88fe90b768 Signed-off-by: jjie --- TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml | 6 +- .../TVMediaHub.Tizen/Views/MusicGroup.xaml.cs | 7 +- TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml | 15 ++- .../TVMediaHub.Tizen/Views/MusicItem.xaml.cs | 130 ++++++++++++++++++--- TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml | 6 +- 5 files changed, 132 insertions(+), 32 deletions(-) diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml index 41301b1..1b9dbad 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml @@ -4,13 +4,13 @@ x:Class="TVMediaHub.Tizen.Views.MusicGroup" ItemsSource="{Binding Contents}"> + public EventHandler OnFocusedEventHandler; + /// + /// An EventHandler for unfocus event of the item + /// + public EventHandler OnUnfocusedEventHandler; + + /// + /// Bounds for TextArea when item is unfocused + /// + private Rectangle TextAreaNormalBounds; + /// + /// Bounds for TextArea when item is focused + /// + private Rectangle TextAreaFocusedBounds; /// /// A constructor @@ -64,35 +82,69 @@ namespace TVMediaHub.Tizen.Views { InitializeComponent(); InitializeSize(); + InitializeLabel(); PropertyChanged += MusicItemPropertyChanged; } /// + /// A method for initializing font and slide effect + /// + public void InitializeLabel() + { + SongTitle.On().SetFontWeight(FontWeight.Normal); + Artist.On().SetFontWeight(FontWeight.Normal); + AlbumTitle.On().SetFontWeight(FontWeight.Light); + + SlideEffect.SetSlideDuration(SongTitle, 15000); + SlideEffect.SetSlideMode(SongTitle, SlideMode.Auto); + + SlideEffect.SetSlideDuration(Artist, 15000); + SlideEffect.SetSlideMode(Artist, SlideMode.Auto); + + SlideEffect.SetSlideDuration(AlbumTitle, 15000); + SlideEffect.SetSlideMode(AlbumTitle, SlideMode.Auto); + } + + /// /// A method for initializing size of the items that are used in this class /// private void InitializeSize() { + int h28 = SizeUtils.GetHeightSize(28); + int h32 = SizeUtils.GetHeightSize(32); + int w32 = SizeUtils.GetWidthSize(32); + int h134 = SizeUtils.GetHeightSize(134); + int w134 = SizeUtils.GetWidthSize(134); + int w382 = SizeUtils.GetWidthSize(382); + int w446 = SizeUtils.GetWidthSize(446); + WidthRequest = SizeUtils.GetWidthSize(716); HeightRequest = SizeUtils.GetHeightSize(270); - AlbumCover.WidthRequest = SizeUtils.GetWidthSize(134); - AlbumCover.HeightRequest = SizeUtils.GetHeightSize(134); - TextArea.WidthRequest = SizeUtils.GetWidthSize(446); - TextArea.HeightRequest = SizeUtils.GetHeightSize(134); - SongTitle.WidthRequest = SizeUtils.GetWidthSize(382); - SongTitle.HeightRequest = SizeUtils.GetHeightSize(32); + + TextAreaNormalBounds = new Rectangle(SizeUtils.GetWidthSize(202), SizeUtils.GetHeightSize(68), w446, SizeUtils.GetHeightSize(134)); + TextAreaFocusedBounds = new Rectangle(SizeUtils.GetWidthSize(206), SizeUtils.GetHeightSize(64), w446, SizeUtils.GetHeightSize(142)); + + AlbumCover.WidthRequest = w134; + AlbumCover.HeightRequest = h134; + + TextArea.WidthRequest = w446; + TextArea.HeightRequest = h134; + + SongTitle.WidthRequest = w382; + SongTitle.HeightRequest = h32; SongTitle.FontSize = SizeUtils.GetFontSize(28); - SongTitle.Margin = new Thickness(SizeUtils.GetWidthSize(32), SizeUtils.GetHeightSize(18), SizeUtils.GetWidthSize(32), 0); - SongTitle.On().SetFontWeight(FontWeight.Normal); - Artist.WidthRequest = SizeUtils.GetWidthSize(382); - Artist.HeightRequest = SizeUtils.GetHeightSize(32); - Artist.Margin = new Thickness(SizeUtils.GetWidthSize(32), SizeUtils.GetHeightSize(12), SizeUtils.GetWidthSize(32), 0); - Artist.FontSize = SizeUtils.GetFontSize(28); - Artist.On().SetFontWeight(FontWeight.Normal); - AlbumTitle.WidthRequest = SizeUtils.GetWidthSize(382); - AlbumTitle.HeightRequest = SizeUtils.GetHeightSize(28); - AlbumTitle.Margin = new Thickness(SizeUtils.GetWidthSize(32), SizeUtils.GetHeightSize(4), SizeUtils.GetWidthSize(32), 0); + SongTitle.Margin = new Thickness(w32, SizeUtils.GetHeightSize(18), w32, 0); + + Artist.WidthRequest = w382; + Artist.HeightRequest = h28; + Artist.Margin = new Thickness(w32, SizeUtils.GetHeightSize(12), w32, 0); + Artist.FontSize = SizeUtils.GetFontSize(24); + + AlbumTitle.WidthRequest = w382; + AlbumTitle.HeightRequest = h28; + AlbumTitle.Margin = new Thickness(w32, SizeUtils.GetHeightSize(4), w32, 0); AlbumTitle.FontSize = SizeUtils.GetFontSize(24); - AlbumTitle.On().SetFontWeight(FontWeight.Light); + } /// @@ -114,7 +166,28 @@ namespace TVMediaHub.Tizen.Views /// A Focus event's argument private void OnItemFocused(object sender, FocusEventArgs e) { - DbgPort.D("MusicItem is focused : " + (MusicInfo.MediaContentInformation as AudioInformation).Title); + Easing easing = new Easing(EasingFunction.EasyIn1); + TextArea.LayoutTo(TextAreaFocusedBounds, 300, easing); + + AlbumCover.ScaleTo(1.0597, 300, easing); + TextArea.BackgroundColor = Color.FromHex("ffffff"); + + SongTitle.On().SetFontWeight(FontWeight.Medium); + SongTitle.TextColor = Color.FromHex("000000"); + SlideEffect.SetHasSlide(SongTitle, true); + + + Artist.On().SetFontWeight(FontWeight.Medium); + Artist.Opacity = 0.8; + Artist.TextColor = Color.FromHex("000000"); + SlideEffect.SetHasSlide(Artist, true); + + AlbumTitle.On().SetFontWeight(FontWeight.Normal); + AlbumTitle.Opacity = 0.7; + AlbumTitle.TextColor = Color.FromHex("000000"); + SlideEffect.SetHasSlide(AlbumTitle, true); + + OnFocusedEventHandler?.Invoke(sender, e); } /// @@ -124,7 +197,25 @@ namespace TVMediaHub.Tizen.Views /// A Focus event's argument private void OnItemUnfocused(object sender, FocusEventArgs e) { - DbgPort.D("MusicItem is unfocused : " + (MusicInfo.MediaContentInformation as AudioInformation).Title); + Easing easing = new Easing(EasingFunction.EasyIn2); + TextArea.LayoutTo(TextAreaNormalBounds, 300, easing); + + AlbumCover.ScaleTo(1.0, 300, easing); + TextArea.BackgroundColor = Color.FromHex("171717"); + + SongTitle.On().SetFontWeight(FontWeight.Normal); + SongTitle.TextColor = Color.FromHex("ffffff"); + SlideEffect.SetHasSlide(SongTitle, false); + + Artist.On().SetFontWeight(FontWeight.Normal); + Artist.Opacity = 0.6; + Artist.TextColor = Color.FromHex("ffffff"); + SlideEffect.SetHasSlide(Artist, false); + + AlbumTitle.On().SetFontWeight(FontWeight.Light); + AlbumTitle.Opacity = 0.5; + AlbumTitle.TextColor = Color.FromHex("ffffff"); + SlideEffect.SetHasSlide(AlbumTitle, false); } /// @@ -144,5 +235,6 @@ namespace TVMediaHub.Tizen.Views AlbumTitle.Text = info.Album; } } + } } \ No newline at end of file diff --git a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml index de3b73f..445a45d 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml +++ b/TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml @@ -33,9 +33,9 @@ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.0}"> Date: Mon, 3 Jul 2017 17:57:54 +0900 Subject: [PATCH 06/16] Implement mediahub music player gui Change-Id: If969abca91b1759ffcbb16203c0df6908b306c05 Signed-off-by: hjjang --- .../TVMediaHub.Tizen/Models/MusicPlayerModel.cs | 36 ++++++++- .../TVMediaHub.Tizen/TVMediaHub.Tizen.csproj | 5 +- .../ViewModels/MusicPlayerViewModel.cs | 17 +++++ 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 11 files changed, 192 insertions(+), 47 deletions(-) mode change 100755 => 100644 TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml 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..b38b31e 100644 --- a/TVMediaHub/TVMediaHub.Tizen/Models/MusicPlayerModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/MusicPlayerModel.cs @@ -32,6 +32,7 @@ namespace TVMediaHub.Tizen.Models public string Title; public string Artist; public string AlbumCover; + public string AlbumName; } /// @@ -99,7 +100,7 @@ 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(); } @@ -113,6 +114,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 @@ -151,7 +153,6 @@ namespace TVMediaHub.Tizen.Models private void InitializePlayer() { playerInstance = new Player(); - playerInstance.PlaybackCompleted += ((s, e) => { StopPlayer(); @@ -222,6 +223,37 @@ namespace TVMediaHub.Tizen.Models } /// + /// Toggles pause and play the current music + /// + public void TogglePausePlay() + { + if (playerInstance.State == PlayerState.Playing) + { + try + { + playerInstance.Pause(); + } + catch (Exception e) + { + DbgPort.E("Error : " + e.Message); + } + StopProgressbarTimer(); + } + else if (playerInstance.State == PlayerState.Paused) + { + try + { + playerInstance.Start(); + } + catch (Exception e) + { + DbgPort.E("Error : " + e.Message); + } + StartProgressbarTimer(); + } + } + + /// /// Stops the current music /// public void StopPlayer() diff --git a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj index 3f8a617..edff850 100755 --- a/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj +++ b/TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj @@ -184,6 +184,8 @@ + + @@ -228,6 +230,7 @@ + @@ -365,4 +368,4 @@ - + \ No newline at end of file diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs index b4d39d9..ee9d2d6 100644 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicPlayerViewModel.cs @@ -16,6 +16,7 @@ using System.ComponentModel; using TVMediaHub.Tizen.Models; +using Xamarin.Forms; namespace TVMediaHub.Tizen.ViewModels { @@ -40,10 +41,17 @@ 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; } + /// /// An event that is occurred when property of ViewModel is changed /// @@ -71,6 +79,12 @@ namespace TVMediaHub.Tizen.ViewModels AlbumTitle = "Title"; AlbumArtist = "Artist"; AlbumCover = "img_media_no_contents.png"; + AlbumName = "Album"; + + MusicPlayerButtonClickCommand = new Command(() => + { + MusicPlayerModel.Instance.TogglePausePlay(); + }); MusicPlayerModel.Instance.SetCurrentMusicInfoListener((e, args) => { @@ -87,6 +101,9 @@ namespace TVMediaHub.Tizen.ViewModels AlbumCover = args.AlbumCover; OnPropertyChanged("AlbumCover"); + + AlbumName = args.AlbumName; + OnPropertyChanged("AlbumName"); }); MusicPlayerModel.Instance.SetCurrentMusicProgressListener((e, arg) => 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..ca8f177 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 13/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