<Content Include="res\img_media_no_contents.png" />
<Content Include="res\img_movie_unavailable.png" />
<Content Include="res\img_music_list_focused_shadow.9.png" />
+ <Content Include="res\img_music_nocover.png" />
<Content Include="res\img_photozoom_gradient.9.png" />
<Content Include="res\img_stroke.9.png" />
<Content Include="res\img_stroke2.9.png" />
* limitations under the License.
*/
-using System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Input;
+using TVMediaHub.Tizen.DataModels;
using TVMediaHub.Tizen.Models;
using TVMediaHub.Tizen.Utils;
using Xamarin.Forms;
-using Xamarin.Forms.Xaml;
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Xamarin.Forms.Xaml;
+using static TVMediaHub.Tizen.Views.MusicItem;
namespace TVMediaHub.Tizen.Views
{
public List<Button> RightFocusList { get; protected set; }
/// <summary>
+ /// A delegate will be executed when the context popup item selected
+ /// </summary>
+ /// <param name="info">A clicked item's MediaInformation</param>
+ /// <param name="item">A clicked context popup item</param>
+ public delegate void ContextPopupItemSelectedEventHandler(MediaInformationEx info, MusicContextPopupItem item);
+
+ /// <summary>
+ /// A ContextPopupItemSelectedEventHandler for select event of context popup
+ /// </summary>
+ public ContextPopupItemSelectedEventHandler ContextPopupItemSelectedHandler;
+
+
+ /// <summary>
+ /// The focused MusicItem in this group
+ /// </summary>
+ private MusicItem focusedItem;
+
+ /// <summary>
/// A constructor
/// </summary>
public MusicGroup()
itemView.OnFocusedEventHandler += (se, ev) =>
{
GroupContentArea.RaiseChild(itemView);
+ focusedItem = itemView;
+ };
+ itemView.OnUnfocusedEventHandler += (se, ev) =>
+ {
+ focusedItem = null;
};
itemView.OnItemClickedHandler += (info) =>
{
ItemClickCommand?.Execute(info);
};
+ itemView.ContextPopupItemSelectedHandler += (info, selectedItem) =>
+ {
+ ContextPopupItemSelectedHandler?.Invoke(info, selectedItem);
+ };
GroupContentArea.Children.Add(itemView, index / 4, index % 4);
ChildrenFocusList.Add(itemView.GetFocusArea());
}
}
}
+
+ /// <summary>
+ /// If there is focused image item, notify the menu key pressed event to focused music item for show context popup
+ /// </summary>
+ /// <returns>If group has a focused item, true; otherwise, false</returns>
+ public bool NotifyMenuKeyPressedToFocusedItem()
+ {
+ if (focusedItem != null)
+ {
+ focusedItem.ShowContextPopup();
+ return true;
+ }
+
+ return false;
+ }
}
}
\ No newline at end of file
private Rectangle TextAreaFocusedBounds;
/// <summary>
+ /// An enumeration for context popup selectable items
+ /// </summary>
+ public enum MusicContextPopupItem
+ {
+ FileInfo = 0,
+ Delete,
+ }
+
+ /// <summary>
+ /// A delegate will be executed when the context popup item selected
+ /// </summary>
+ /// <param name="info">A clicked item's MediaInformation</param>
+ /// <param name="item">A clicked context popup item</param>
+ public delegate void ContextPopupItemSelectedEventHandler(MediaInformationEx info, MusicContextPopupItem item);
+
+ /// <summary>
+ /// A ContextPopupItemSelectedEventHandler for select event of context popup
+ /// </summary>
+ public ContextPopupItemSelectedEventHandler ContextPopupItemSelectedHandler;
+
+ /// <summary>
/// Gets FocusArea for focus chain
/// </summary>
public Button GetFocusArea()
SlideEffect.SetHasSlide(AlbumTitle, false);
TextBackground.Source = "img_music_list_normal.9.png";
Shadow.IsVisible = false;
+ OnUnfocusedEventHandler.Invoke(sender, e);
}
/// <summary>
if (e.PropertyName.Equals("MusicInfo"))
{
AudioInformation info = MusicInfo.MediaContentInformation as AudioInformation;
- AlbumCover.Source = !(string.IsNullOrEmpty(info.ThumbnailPath)) ? info.ThumbnailPath : "img_media_no_contents.png";
+ AlbumCover.Source = !(string.IsNullOrEmpty(info.ThumbnailPath)) ? info.ThumbnailPath : "img_music_nocover.png";
SongTitle.Text = info.Title;
Artist.Text = info.Artist;
AlbumTitle.Text = info.Album;
}
}
+ /// <summary>
+ /// A method showing context popup
+ /// </summary>
+ public void ShowContextPopup()
+ {
+ if (!FocusArea.IsFocused)
+ {
+ return;
+ }
+
+ ContextPopup popup = new ContextPopup();
+
+ popup.Items.Add(new ContextPopupItem("FILE INFO"));
+ popup.Items.Add(new ContextPopupItem("DELETE"));
+ popup.SelectedIndexChanged += SelectedIndexChanged;
+ popup.Show(this, this.Width / 2 - SizeUtils.GetWidthSize(290 - 104), this.Height + SizeUtils.GetHeightSize(72));
+
+ }
+
+ /// <summary>
+ /// This method is called when the context popup item selected
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">Changed event's argument</param>
+ private void SelectedIndexChanged(object sender, EventArgs e)
+ {
+ var ctxPopup = sender as ContextPopup;
+ switch (ctxPopup.SelectedIndex)
+ {
+ case 0:
+ ContextPopupItemSelectedHandler?.Invoke(MusicInfo, MusicContextPopupItem.FileInfo);
+ break;
+ case 1:
+ ContextPopupItemSelectedHandler?.Invoke(MusicInfo, MusicContextPopupItem.Delete);
+ break;
+ }
+
+ ctxPopup.Dismiss();
+ }
+
}
}
SortOptions="{Binding SortOptions}"
OptionList="{Binding OptionList}" />
</RelativeLayout>
-
<StackLayout x:Name="MusicTabContents"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.855}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
Orientation="Horizontal">
- <Views:MusicPlayer x:Name="MusicPlayer" />
+ <Views:MusicPlayer x:Name="MusicPlayer" />
<ScrollView x:Name="MusicTabScrollView"
Orientation="Horizontal"
IsVisible="False">
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Windows.Input;
+using Tizen.Xamarin.Forms.Extension;
using TVMediaHub.Tizen.Controls;
using TVMediaHub.Tizen.DataModels;
using TVMediaHub.Tizen.Models;
using TVMediaHub.Tizen.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using static TVMediaHub.Tizen.Views.MusicItem;
namespace TVMediaHub.Tizen.Views
{
MusicContentView.Children.Add(groupView);
groupView.BindingContext = groupItem;
groupView.SetClickCommand(OnClickCommand);
+ groupView.ContextPopupItemSelectedHandler += (info, item) =>
+ {
+ ShowPopup(info, item);
+ };
if (MusicContentView.Children.Count > 1)
{
FooterNormal.IsVisible = true;
FooterDelete.IsVisible = false;
}
+
+ /// <summary>
+ /// this method is for customizing behavior when the Page becoming visible
+ /// </summary>
+ protected override void OnAppearing()
+ {
+ base.OnAppearing();
+ App.MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, false);
+ App.MainWindow.KeyUp += MenuKeyListener;
+ }
+
+ /// <summary>
+ /// this method is for customizing behavior when the Page becoming invisible
+ /// </summary>
+ protected override void OnDisappearing()
+ {
+ base.OnDisappearing();
+ App.MainWindow.KeyUp -= MenuKeyListener;
+ App.MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName);
+ }
+
+ /// <summary>
+ /// KeyDown will be triggered when key is menu
+ /// </summary>
+ /// <param name="sender">The object that raised the event</param>
+ /// <param name="e">The information about the event</param>
+ private void MenuKeyListener(object sender, ElmSharp.EvasKeyEventArgs e)
+ {
+ if (e.KeyName.Equals(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName))
+ {
+ NotifyMenuKeyPressed();
+ }
+ }
+
+ /// <summary>
+ /// A method notifies menu key pressed event
+ /// </summary>
+ private void NotifyMenuKeyPressed()
+ {
+ if (MusicContentView.Children.Count > 0)
+ {
+ foreach (MusicGroup group in MusicContentView.Children)
+ {
+ if (group.NotifyMenuKeyPressedToFocusedItem())
+ {
+ break;
+ }
+ }
+
+ }
+ }
+
+ /// <summary>
+ /// A method displaying pop-ups
+ /// </summary>
+ /// <param name="info">A focused item's MediaInformation</param>
+ /// <param name="item">A clicked context popup item</param>
+ private async void ShowPopup(MediaInformationEx info, MusicContextPopupItem item)
+ {
+ switch (item)
+ {
+ case MusicContextPopupItem.FileInfo:
+ string message = "File name : " + info.MediaContentInformation.Title + "\n";
+ message += "File size : " + info.MediaContentInformation.Size + "\n";
+ message += "File format : " + info.MediaContentInformation.MimeType + "\n";
+ message += "File size : " + info.MediaContentInformation.Size + "\n";
+ message += "File path : " + info.MediaContentInformation.FilePath;
+
+ await DisplayAlert("File Information", message, "Close");
+ Dialog dialog = new Dialog();
+ break;
+ case MusicContextPopupItem.Delete:
+ bool answer = await DisplayAlert("Delete", "Delete '" + info.MediaContentInformation.Title + "'?", "Yes", "No");
+ if (answer)
+ {
+ DeleteContentCommand?.Execute(info);
+ GetInformationsCommand?.Execute("");
+ }
+
+ break;
+ }
+
+ }
}
}
\ No newline at end of file