public const string TimeFormat = @"mm\:ss";
public const string LightPlatformThemeId = "org.tizen.default-light-theme";
public const string DarkPlatformThemeId = "org.tizen.default-dark-theme";
+ public const string FavouritePlaylist = "Favourite";
+ public const string RecentlyAddedPlaylist = "Recently Added";
}
}
get => description;
}
}
+
+ public class PlayingListItemSelectedEvent : EventArgs
+ {
+
+ internal PlayingListItemSelectedEvent(object selectedItem)
+ {
+ CurrentSelectedItem = selectedItem;
+ }
+
+ public object CurrentSelectedItem { get; private set; }
+ }
}
public static readonly Color HEX000209 = new Color(0.0f, 0.0078f, 0.0353f, 1.0f);
public static readonly Color HEX001447 = new Color(0.0f, 0.0784f, 0.2784f, 1.0f);
public static readonly Color HEXEEEFF1 = new Color(0.9333f, 0.9373f, 0.9450f, 1.0f);
+ public static readonly Color HEX000C2B = new Color(0.0f, 0.0471f, 0.1686f, 1.0f);
public static readonly Color LyricsBackground = new Color(0.0f, 0.0f, 0.0f, 0.85f);
public static readonly Color ItemSeperator = new Color(0.75f, 0.79f, 0.82f, 1.0f);
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.NUI;
+
+namespace MusicPlayer.Common
+{
+ class UIFontStyles
+ {
+ public static readonly PropertyMap NormalLight = new PropertyMap().
+ Add("width", new PropertyValue("normal")).
+ Add("weight", new PropertyValue("light"));
+
+ public static readonly PropertyMap AllNormal = new PropertyMap().
+ Add("width", new PropertyValue("normal")).
+ Add("weight", new PropertyValue("normal")).
+ Add("slant", new PropertyValue("normal"));
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using MusicPlayer.Views;
+using MusicPlayer.ViewModels;
+using Tizen.NUI;
+using MusicPlayer.Models;
+
+namespace MusicPlayer.Core
+{
+ class PlaybackHelper
+ {
+
+ private static PlaybackHelper instance = new PlaybackHelper();
+
+ private PlayerView playerView;
+ private PlayerViewModel playerViewModel;
+
+ private PlaybackHelper()
+ {
+ playerViewModel = new PlayerViewModel();
+ playerView = new PlayerView(playerViewModel);
+ }
+
+ public static PlaybackHelper Instance
+ {
+ get => instance;
+ }
+
+ public void ShowPlayer()
+ {
+ Window.Instance.Add(playerView);
+ playerView.ShowView();
+ }
+
+ public void HidePlayer()
+ {
+ Window.Instance.Remove(playerView);
+ playerView.HideView();
+ }
+
+ public void PlayAll(ListViewModel<Track> trackList, Track startingTrack)
+ {
+ ShowPlayer();
+ playerViewModel.SetPlayingList(trackList);
+ playerViewModel.SetCurrentTrack(startingTrack);
+ playerViewModel.SetRepeatAndShuffle(Common.RepeatMode.RepeatAll, Common.ShuffleMode.Off);
+ }
+
+ public void PlayAllWithShuffle(ListViewModel<Track> trackList)
+ {
+ ShowPlayer();
+ playerViewModel.SetPlayingList(trackList);
+ playerViewModel.SetRepeatAndShuffle(Common.RepeatMode.RepeatAll, Common.ShuffleMode.On);
+ playerViewModel.StartShuffledTrack();
+ }
+
+ public void PlayCurrent(ListViewModel<Track> trackList, Track currentTrack)
+ {
+ ShowPlayer();
+ playerViewModel.SetPlayingList(trackList);
+ playerViewModel.SetCurrentTrack(currentTrack);
+ playerViewModel.SetRepeatAndShuffle(Common.RepeatMode.Off, Common.ShuffleMode.Off);
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.Content.MediaContent;
+using MusicPlayer.Common;
+using MusicPlayer.Media;
+
+
+namespace MusicPlayer.Core
+{
+ class PlaylistManager
+ {
+ public event EventHandler<EventArgs> PlaylistDataChanged;
+ private static PlaylistManager instance = new PlaylistManager();
+ private PlaylistManager()
+ {
+ Contents.MusicDBUpdate += OnMusicDBUpdate;
+ Contents.MusicItemUpdate += OnMusicItemDBUpdate;
+ }
+
+ public static PlaylistManager Instance
+ {
+ get => instance;
+ }
+
+ public List<Playlist> Playlists
+ {
+ get => Contents.GetPlaylists();
+ }
+
+ public Playlist GetPlaylist(int playlistId)
+ {
+ return Contents.GetPlaylistById(playlistId);
+ }
+
+ public Playlist GetPlaylist(string name)
+ {
+ return Contents.GetPlaylistByName(name);
+ }
+
+ public Playlist AddPlaylist(string name)
+ {
+ return Contents.CreatePlaylist(name);
+ }
+
+ public Playlist AddPlaylist(string name, string thumbnailPath)
+ {
+ return Contents.CreatePlaylist(name, thumbnailPath);
+ }
+
+ public int PlaylistTrackCount(int playlistId)
+ {
+ return Contents.GetMemberCount(playlistId);
+ }
+
+ public bool Delete(int playlistId)
+ {
+ return Contents.DeletePlaylist(playlistId);
+ }
+
+ // TODO untill we refactor the SelectorView this is requiered
+ public int DeletePlaylists(List<string> playlistIdList)
+ {
+ int count = 0;
+ foreach(string playlistId in playlistIdList)
+ {
+ if(Contents.DeletePlaylist(Int32.Parse(playlistId)))
+ {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public int DeletePlaylists(List<int> playlistIdList)
+ {
+ int count = 0;
+ foreach (int playlistId in playlistIdList)
+ {
+ if (Contents.DeletePlaylist(playlistId))
+ {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public List<PlaylistMember> GetMemberList(int playlistId)
+ {
+ return Contents.GetPlaylistMembers(playlistId);
+ }
+
+ public bool AddTrack(int playlistId, string trackId)
+ {
+ return Contents.AddMedia(playlistId, trackId);
+ }
+
+ public bool UpdateValues(int playlistId, PlaylistUpdateValues updatedValues)
+ {
+ return Contents.UpdatePlaylistValues(playlistId, updatedValues);
+ }
+
+ public bool DeleteTrack(int playlistId, int memberId)
+ {
+ return Contents.DeletePlaylistMember(playlistId, memberId);
+ }
+
+ public bool DeleteTrackList(int playlistId, List<int> memberList)
+ {
+ return Contents.DeletePlaylistMembers(playlistId, memberList);
+ }
+
+ private void OnMusicItemDBUpdate(object sender, MusicItemUpdateEventArgs e)
+ {
+ PlaylistDataChanged?.Invoke(this, new EventArgs());
+ }
+
+ private void OnMusicDBUpdate(object sender, MusicDBUpdateEventArgs e)
+ {
+ PlaylistDataChanged?.Invoke(this, new EventArgs());
+ }
+
+ }
+}
using System;\r
-using System.Collections.Specialized;\r
+using System.Collections.Generic;\r
using Tizen.Content.MediaContent;\r
using MusicPlayer.Common;\r
\r
{\r
public static partial class Contents\r
{\r
- public static OrderedDictionary GetAlbumList()\r
+ public static List<Album> GetAlbumList()\r
{\r
- OrderedDictionary albumList = new OrderedDictionary();\r
+ List<Album> albumList = new List<Album>();\r
\r
SelectArguments albumSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
\r
while (dataReader.Read())\r
{\r
- Album info = dataReader.Current;\r
+ Album album = dataReader.Current;\r
SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
- MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(info.Id, audioSelectArguments);\r
+ // TODO use countmember instead of select memeber.\r
+ MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(album.Id, audioSelectArguments);\r
if (albumDataReader.Read())\r
- albumList.Add(info.Id, info);\r
+ albumList.Add(album);\r
}\r
Tizen.Log.Debug(AppConstants.LogTag, "Total album retrived from database: " + albumList.Count);\r
dataReader.Dispose();\r
return albumInfo.CountMember(albumId);\r
}\r
\r
- public static OrderedDictionary GetAlbumMemberList(int albumId)\r
+ public static List<AudioInfo> GetAlbumMemberList(int albumId)\r
{\r
- OrderedDictionary mediaList = new OrderedDictionary();\r
- SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ List<AudioInfo> mediaList = new List<AudioInfo>();\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<MediaInfo> dataReader = albumInfo.SelectMember(albumId, audioSelectArguments);\r
\r
while (dataReader.Read())\r
{\r
- MediaInfo info = dataReader.Current;\r
- mediaList.Add(info.Id, info);\r
+ mediaList.Add((AudioInfo)dataReader.Current);\r
}\r
Tizen.Log.Debug(AppConstants.LogTag, "Total track retrived from currentAlbum: " + mediaList.Count);\r
dataReader.Dispose();\r
dataReader.Dispose();\r
return path;\r
}\r
+\r
+ public static List<Album> FindMatchingAlbums(string searchText)\r
+ {\r
+ List<Album> albumList = new List<Album>();\r
+ string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + AlbumColumns.Name + " LIKE "+ "'%" + searchText + "%' COLLATE NOCASE";\r
+ SelectArguments albumSelectArguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
+\r
+ while (dataReader.Read())\r
+ {\r
+ Album info = dataReader.Current;\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(info.Id, audioSelectArguments);\r
+ if (albumDataReader.Read())\r
+ albumList.Add(info);\r
+ albumDataReader.Dispose();\r
+ }\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total album retrived from database that match text: " + searchText + " are : " + albumList.Count);\r
+ dataReader.Dispose();\r
+ return albumList;\r
+ }\r
}\r
}\r
public static List<string> GetArtistList()\r
{\r
List<string> artistList = new List<string>();\r
-\r
- SelectArguments artistSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Artist + MEDIA_SORT_ORDER_ASC);\r
+ SelectArguments artistSelectArguments = CreateSelectArgument(MEDIA_TYPE_QUERY, MediaInfoColumns.Artist + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<string> dataReader = mediaInfo.SelectGroupBy(MediaInfoColumnKey.Artist, artistSelectArguments);\r
\r
while (dataReader.Read())\r
{\r
- string info = (string)dataReader.Current;\r
+ string info = dataReader.Current;\r
artistList.Add(info);\r
}\r
Tizen.Log.Debug(AppConstants.LogTag, "Total artists retrived from database: " + artistList.Count);\r
return artistList;\r
}\r
\r
- public static OrderedDictionary GetAlbumListForArtist(string artistName)\r
+ public static List<Album> GetAlbumListForArtist(string artistName)\r
{\r
- OrderedDictionary albumList = new OrderedDictionary();\r
+ List<Album> albumList = new List<Album>();\r
string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + AlbumColumns.Artist + "=\"" + artistName + "\"";\r
SelectArguments albumSelectArguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(info.Id, audioSelectArguments);\r
if(albumDataReader.Read())\r
- albumList.Add(info.Id, info);\r
+ albumList.Add(info);\r
}\r
dataReader.Dispose();\r
Tizen.Log.Debug(AppConstants.LogTag, "Total Albums retrived from Artist: " + albumList.Count);\r
return albumList;\r
}\r
\r
- public static OrderedDictionary GetTrackListForArtist(string artistName)\r
+ public static List<AudioInfo> GetTrackListForArtist(string artistName)\r
{\r
- OrderedDictionary mediaList = new OrderedDictionary();\r
+ List<AudioInfo> mediaList = new List<AudioInfo>();\r
string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + AlbumColumns.Artist + "=\"" + artistName + "\"";\r
SelectArguments albumSelectArguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
while (albumDataReader.Read())\r
{\r
MediaInfo mediaInfo = albumDataReader.Current;\r
- mediaList.Add(mediaInfo.Id, mediaInfo);\r
+ mediaList.Add((AudioInfo)mediaInfo);\r
}\r
albumDataReader.Dispose();\r
}\r
\r
return count;\r
}\r
+\r
+ public static List<string> FindMatchingArtists(string searchText)\r
+ {\r
+ List<string> artistList = new List<string>();\r
+ string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + MediaInfoColumns.Artist + " LIKE " + "'%" + searchText + "%' COLLATE NOCASE";\r
+ SelectArguments artistSelectArguments = CreateSelectArgument(expression, MediaInfoColumns.Artist + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<string> dataReader = mediaInfo.SelectGroupBy(MediaInfoColumnKey.Artist, artistSelectArguments);\r
+\r
+ while (dataReader.Read())\r
+ {\r
+ string info = (string)dataReader.Current;\r
+ artistList.Add(info);\r
+ }\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total artists retrived from database that match text: " + searchText + " are : " + artistList.Count);\r
+ dataReader.Dispose();\r
+ return artistList;\r
+ }\r
}\r
}\r
private static PlaylistCommand playlistInfo;\r
private const string MEDIA_STORAGE_TYPE_QUERY = " (( MEDIA_STORAGE_TYPE IS NOT 101 ) AND (MEDIA_TYPE = 3)) ";\r
private const string MEDIA_SORT_ORDER_ASC = " COLLATE NOCASE ASC ";\r
+ private static readonly string MEDIA_TYPE_QUERY = $"{MediaInfoColumns.MediaType}={(int)Media​Type.Music}";\r
\r
public static event EventHandler<MusicItemUpdateEventArgs> MusicItemUpdate;\r
public static event EventHandler<MusicDBUpdateEventArgs> MusicDBUpdate;\r
{\r
List<Playlist> playlists = new List<Playlist>();\r
SelectArguments arguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, PlaylistColumns.Name + MEDIA_SORT_ORDER_ASC);\r
- MediaDataReader<Playlist> dataReader = playlistInfo.Select(arguments);\r
+ MediaDataReader<Playlist> dataReader = playlistInfo.Select();\r
\r
while(dataReader.Read())\r
{\r
\r
public static Playlist GetPlaylistByName(string name)\r
{\r
- string filterExpression = MEDIA_STORAGE_TYPE_QUERY + " AND " + PlaylistColumns.Name + "=\"" + name + "\"";\r
+ string filterExpression = PlaylistColumns.Name + "=\"" + name + "\"";\r
SelectArguments arguments = CreateSelectArgument(filterExpression, PlaylistColumns.Name + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<Playlist> dataReader = playlistInfo.Select(arguments);\r
\r
return list;\r
}\r
\r
+ public static Playlist CreatePlaylist(string name)\r
+ {\r
+ return playlistInfo.Insert(name);\r
+ }\r
+\r
+ public static Playlist CreatePlaylist(string name, string thumbnailPath)\r
+ {\r
+ return playlistInfo.Insert(name, thumbnailPath);\r
+ }\r
+\r
+ public static void AddMediaList(int id, IEnumerable<string> trackList)\r
+ {\r
+ playlistInfo.AddMembers(id, trackList);\r
+ }\r
+\r
+ public static bool AddMedia(int id, string mediaId)\r
+ {\r
+ return playlistInfo.AddMember(id, mediaId);\r
+ }\r
+\r
+ public static List<PlaylistMember> GetPlaylistMembers(int playlistId)\r
+ {\r
+ List<PlaylistMember> memberList = new List<PlaylistMember>();\r
+ MediaDataReader<PlaylistMember> dataReader = playlistInfo.SelectMember(playlistId);\r
+ while (dataReader.Read())\r
+ {\r
+ PlaylistMember playlist = dataReader.Current;\r
+ memberList.Add(playlist);\r
+ }\r
+ return memberList;\r
+ }\r
+\r
+ public static int GetMemberCount(int playlistId)\r
+ {\r
+ return playlistInfo.CountMember(playlistId);\r
+ }\r
+\r
+ public static bool DeletePlaylist(int playlistId)\r
+ {\r
+ return playlistInfo.Delete(playlistId);\r
+ }\r
+\r
+ public static bool UpdatePlaylistValues(int playlistId, PlaylistUpdateValues values)\r
+ {\r
+ return playlistInfo.Update(playlistId, values);\r
+ }\r
+\r
+ public static bool DeletePlaylistMember(int playlistId, int mediaId)\r
+ {\r
+ return playlistInfo.RemoveMember(playlistId, mediaId);\r
+ }\r
+\r
+ public static bool DeletePlaylistMembers(int playlistId, List<int> memberIdList)\r
+ {\r
+ return playlistInfo.RemoveMembers(playlistId, memberIdList);\r
+ }\r
+\r
}\r
}\r
-using System.Collections.Specialized;\r
+using System;\r
+using System.IO;\r
+using System.Collections.Generic;\r
using Tizen.Content.MediaContent;\r
+using Tizen.Applications;\r
using MusicPlayer.Common;\r
\r
namespace MusicPlayer.Media\r
{\r
public static partial class Contents\r
{\r
- public static OrderedDictionary GetTrackList()\r
+ public static List<AudioInfo> GetTrackList()\r
{\r
- OrderedDictionary mediaList = new OrderedDictionary();\r
-\r
- SelectArguments argument = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ List<AudioInfo> mediaList = new List<AudioInfo>();\r
+ SelectArguments argument = CreateSelectArgument(MEDIA_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
MediaDataReader<MediaInfo> dataReader = mediaInfo.SelectMedia(argument);\r
\r
while (dataReader.Read())\r
{\r
MediaInfo info = dataReader.Current;\r
- mediaList.Add(info.Id, info);\r
+ mediaList.Add((AudioInfo)info);\r
}\r
Tizen.Log.Debug(AppConstants.LogTag, "Total track retrived from database: " + mediaList.Count);\r
dataReader.Dispose();\r
return mediaList;\r
}\r
+\r
+ public static bool IsTrackFavourite(string mediaId)\r
+ {\r
+ MediaInfo media = mediaInfo.SelectMedia(mediaId);\r
+ if (media == null)\r
+ return false;\r
+ return media.IsFavorite;\r
+ }\r
+\r
+ public static void SetFavourite(string mediaId, bool favourite)\r
+ {\r
+ mediaInfo.UpdateFavorite(mediaId, favourite);\r
+ }\r
+\r
+ public static int DeleteTracks(List<string> trackList)\r
+ {\r
+ int n = 0;\r
+ foreach (string id in trackList)\r
+ {\r
+ MediaInfo info = mediaInfo.SelectMedia(id);\r
+ string filePath = @info.Path;\r
+ try\r
+ {\r
+ FileInfo file = new FileInfo(filePath);\r
+ Tizen.Log.Debug(AppConstants.LogTag, "FileName: " + file.FullName);\r
+ file.Delete();\r
+ mediaInfo.Delete(id);\r
+ n++;\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "The deletion failed: " + e.Message);\r
+ }\r
+ }\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total tracks deleted from database: " + n);\r
+ return n;\r
+ }\r
+\r
+ //TODO need to create Seperate App control operation class\r
+ public static int ShareTracks(List<string> trackList)\r
+ {\r
+ int n = 0;\r
+ string shareOption;\r
+ List<string> shareList = new List<string>();\r
+\r
+ //TODO use const for all string literals\r
+ if (trackList.Count > 1)\r
+ shareOption = "http://tizen.org/appcontrol/operation/multi_share";\r
+ else\r
+ shareOption = "http://tizen.org/appcontrol/operation/share";\r
+\r
+ string key = "http://tizen.org/appcontrol/data/path";\r
+\r
+ AppControl appControl = new AppControl();\r
+ appControl.ApplicationId = "org.tizen.share-panel";\r
+ Tizen.Log.Debug(AppConstants.LogTag, "ApplicationId: " + appControl.ApplicationId);\r
+ appControl.Operation = shareOption;\r
+\r
+ foreach (string id in trackList)\r
+ {\r
+ MediaInfo info = mediaInfo.SelectMedia(id);\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Track Path: " + info.Path);\r
+ string filePath = @info.Path;\r
+ try\r
+ {\r
+ FileInfo file = new FileInfo(filePath);\r
+ Tizen.Log.Debug(AppConstants.LogTag, "FileName: " + file.FullName);\r
+ shareList.Add(file.FullName);\r
+ n++;\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "The sharing list creation failed: " + e.Message);\r
+ }\r
+ }\r
+\r
+ if (n > 1)\r
+ appControl.ExtraData.Add(key, shareList);\r
+ else\r
+ appControl.Uri = shareList[0];\r
+\r
+ AppControl.SendLaunchRequest(appControl);\r
+\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total tracks send to share " + n);\r
+ return n;\r
+ }\r
+\r
+ public static List<AudioInfo> FindMatchingTracks(string searchText)\r
+ {\r
+ List<AudioInfo> mediaList = new List<AudioInfo>();\r
+ string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + MediaInfoColumns.Title + " LIKE " + "'%" + searchText + "%' COLLATE NOCASE";\r
+ SelectArguments argument = CreateSelectArgument(expression, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> dataReader = mediaInfo.SelectMedia(argument);\r
+\r
+ while (dataReader.Read())\r
+ {\r
+ MediaInfo info = dataReader.Current;\r
+ mediaList.Add((AudioInfo)info);\r
+ }\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total track retrived from database that match text: " + searchText + " are : " + mediaList.Count);\r
+ dataReader.Dispose();\r
+ return mediaList;\r
+ }\r
}\r
}\r
-using System.Collections.Specialized;\r
+using System;\r
+using System.Collections.Generic;\r
using MusicPlayer.Media;\r
+using Tizen.Content.MediaContent;\r
\r
namespace MusicPlayer.Models\r
{\r
public static class AlbumDataProvider\r
{\r
- private static OrderedDictionary albumsList;\r
+ private static List<Album> albumsList;\r
+\r
+ public static event EventHandler<EventArgs> AlbumDataChanged;\r
\r
static AlbumDataProvider()\r
{\r
Contents.MusicDBUpdate += OnMusicDatabaseUpdate;\r
}\r
\r
- private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e)\r
+ public static List<Album> CurrentAlbumList()\r
{\r
- albumsList = Contents.GetAlbumList();\r
- // TODO implement database update event handler\r
- return;\r
+ return albumsList;\r
}\r
\r
- private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)\r
+ public static List<AudioInfo> GetAlbumTrackList(int albumId)\r
{\r
- // TODO implement database item update event handler\r
- return;\r
+ return Contents.GetAlbumMemberList(albumId);\r
}\r
\r
- public static OrderedDictionary CurrentAlbumList()\r
+ public static string GetAlbumArtFromTracks(int albumId)\r
{\r
- return albumsList;\r
+ return Contents.GetAlbumArtPath(albumId);\r
}\r
\r
- public static OrderedDictionary GetAlbumTrackList(int albumId)\r
+ public static List<Album> GetSearchedAlbumList(string searchText)\r
{\r
- return Contents.GetAlbumMemberList(albumId);\r
+ return Contents.FindMatchingAlbums(searchText);\r
}\r
\r
- public static string GetAlbumArtFromTracks(int albumId)\r
+ private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e)\r
{\r
- return Contents.GetAlbumArtPath(albumId);\r
+ UpdateAlbumList();\r
+ }\r
+\r
+ private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)\r
+ {\r
+ UpdateAlbumList();\r
+ }\r
+\r
+ private static void UpdateAlbumList()\r
+ {\r
+ albumsList = Contents.GetAlbumList();\r
+ AlbumDataChanged?.Invoke(null, new EventArgs());\r
}\r
}\r
}\r
+using System;
using System.Collections.Specialized;
using System.Collections.Generic;
+using Tizen.Content.MediaContent;
using MusicPlayer.Media;
namespace MusicPlayer.Models
{
private static List<string> artistsList;
+ public static event EventHandler<EventArgs> ArtistDataChanged;
+
static ArtistDataProvider()
{
artistsList = Contents.GetArtistList();
Contents.MusicDBUpdate += OnMusicDatabaseUpdate;
}
- private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e)
- {
- artistsList = Contents.GetArtistList();
- // TODO implement database update event handler
- return;
- }
-
- private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)
- {
- // TODO implement database item update event handler
- return;
- }
-
public static List<string> CurrentArtistList()
{
return artistsList;
return Contents.GetAlbumArtPathForArtist(artistName);
}
- public static OrderedDictionary GetArtistAlbumList(string artistName)
+ public static List<Album> GetArtistAlbumList(string artistName)
{
return Contents.GetAlbumListForArtist(artistName);
}
- public static OrderedDictionary GetArtistTrackList(string artistName)
+ public static List<AudioInfo> GetArtistTrackList(string artistName)
{
return Contents.GetTrackListForArtist(artistName);
}
+
+ public static List<string> GetSearchedArtistList(string searchText)
+ {
+ return Contents.FindMatchingArtists(searchText);
+ }
+
+ private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e)
+ {
+ UpdateArtistList();
+ }
+
+ private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)
+ {
+ UpdateArtistList();
+ }
+
+ private static void UpdateArtistList()
+ {
+ artistsList = Contents.GetArtistList();
+ ArtistDataChanged?.Invoke(null, new EventArgs());
+ }
+
}
}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Models
+{
+ struct PlaylistData
+ {
+ public PlaylistData(int id, string name, string count, string thumbPath)
+ {
+ Id = id;
+ Name = name;
+ Count = count;
+ ThumbPath = thumbPath;
+ }
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public string Count { get; private set; }
+
+ public string ThumbPath { get; private set; }
+ }
+
+ class PlaylistModel : PropertyNotifier
+ {
+ // No Parameter constructor is required for Activator.CreateInstance
+ public PlaylistModel()
+ {
+ }
+
+ public PlaylistModel(PlaylistData data)
+ {
+ PlaylistId = data.Id;
+ PlaylistName = data.Name;
+ PlaylistTrackCount = data.Count;
+ PlaylistThumbnailPath = data.ThumbPath;
+ }
+
+ private int playlistId;
+
+ public int PlaylistId
+ {
+ get => playlistId;
+ private set => playlistId = value;
+ }
+
+ private string playlistName;
+
+ public string PlaylistName
+ {
+ get => playlistName;
+ set => SetProperty(ref playlistName, value);
+ }
+
+ private string playlistTrackCount;
+
+ public string PlaylistTrackCount
+ {
+ get => playlistTrackCount;
+ set => SetProperty(ref playlistTrackCount, value);
+ }
+
+ private string playlistThumbnailPath;
+
+ public string PlaylistThumbnailPath
+ {
+ get => playlistThumbnailPath;
+ set => SetProperty(ref playlistThumbnailPath, value);
+ }
+
+ private bool playlistIsSelected;
+
+ public bool PlaylistIsSelected
+ {
+ get => playlistIsSelected;
+ set => SetProperty(ref playlistIsSelected, value);
+ }
+ }
+}
-using System.Collections.Specialized;\r
+using System;\r
+using System.Collections.Generic;\r
using MusicPlayer.Media;\r
+using Tizen.Content.MediaContent;\r
\r
namespace MusicPlayer.Models\r
{\r
public static class TrackDataProvider\r
{\r
- private static OrderedDictionary tracksList;\r
+ private static List<AudioInfo> tracksList;\r
+\r
+ public static event EventHandler<EventArgs> TrackDataChanged;\r
\r
static TrackDataProvider()\r
{\r
Contents.MusicDBUpdate += OnMusicDatabaseUpdate;\r
}\r
\r
+ public static List<AudioInfo> CurrentTrackList()\r
+ {\r
+ return tracksList;\r
+ }\r
+\r
private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e)\r
{\r
- tracksList = Contents.GetTrackList();\r
- // TODO implement database update event handler\r
- return;\r
+ UpdateTrackList();\r
}\r
\r
private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)\r
{\r
- // TODO implement database item update event handler\r
- return;\r
+ UpdateTrackList();\r
}\r
\r
- public static OrderedDictionary CurrentTrackList()\r
+ private static void UpdateTrackList()\r
{\r
- return tracksList;\r
+ tracksList = Contents.GetTrackList();\r
+ TrackDataChanged?.Invoke(null, new EventArgs());\r
+ }\r
+\r
+ public static bool GetFavouriteStatus(string mediaId)\r
+ {\r
+ return Contents.IsTrackFavourite(mediaId);\r
+ }\r
+\r
+ public static void SetFavouriteStatus(string mediaId, bool favourite)\r
+ {\r
+ Contents.SetFavourite(mediaId, favourite);\r
+ }\r
+\r
+ public static int DeleteTrackList(List<string> trackList)\r
+ {\r
+ return Contents.DeleteTracks(trackList);\r
+ }\r
+\r
+ public static int ShareTrackList(List<string> trackList)\r
+ {\r
+ return Contents.ShareTracks(trackList);\r
+ }\r
+\r
+ public static List<AudioInfo> GetSearchedTrackList(string searchText)\r
+ {\r
+ return Contents.FindMatchingTracks(searchText);\r
}\r
}\r
}\r
-using System.Collections.Specialized;\r
+using Tizen.Content.MediaContent;\r
+using System.Collections.Generic;\r
+using System.Collections.Specialized;\r
using MusicPlayer.Models;\r
using MusicPlayer.Common;\r
+using MusicPlayer.Core;\r
\r
namespace MusicPlayer.ViewModels\r
{\r
{\r
public AlbumDetailViewModel(MusicAlbum album)\r
{\r
+ AlbumDataProvider.AlbumDataChanged += OnAlbumDetailChanged;\r
Id = album.Id;\r
AlbumName = album.AlbumName;\r
ArtistName = album.ArtistName;\r
AlbumArtPath = album.AlbumArtPath;\r
- OrderedDictionary trackList = AlbumDataProvider.GetAlbumTrackList(album.Id);\r
- listViewModel = new ListViewModel<Track>();\r
- listViewModel.CreateData<AudioInfo>(trackList);\r
- listViewModel.CollectionChanged += OnAlbumDetailListChanges;\r
- TotalTracks = listViewModel.Count.ToString();\r
- }\r
\r
- private void OnAlbumDetailListChanges(object sender, NotifyCollectionChangedEventArgs e)\r
- {\r
- //TODO\r
+ listViewModel = new ListViewModel<Track>();\r
+ UpdateAlbumDetailData();\r
TotalTracks = listViewModel.Count.ToString();\r
+ listViewModel.CollectionChanged += OnCollectionChanged;\r
}\r
\r
private int id;\r
SetProperty(ref totalTracks, value + text);\r
}\r
}\r
+\r
+ // TODO do we really need this ?\r
+ public void OnViewDeleted()\r
+ {\r
+ AlbumDataProvider.AlbumDataChanged -= OnAlbumDetailChanged;\r
+ ListViewModel.CollectionChanged -= OnCollectionChanged;\r
+ ListViewModel.Clear();\r
+ }\r
+\r
+ public void PlayAll()\r
+ {\r
+ PlaybackHelper.Instance.PlayAll(ListViewModel, ListViewModel[0]);\r
+ }\r
+\r
+ public void PlayAllWithShuffle()\r
+ {\r
+ PlaybackHelper.Instance.PlayAllWithShuffle(ListViewModel);\r
+ }\r
+\r
+ public void PlayCurrent(object currentTrack)\r
+ {\r
+ PlaybackHelper.Instance.PlayCurrent(ListViewModel, (Track)currentTrack);\r
+ }\r
+\r
+ private void OnAlbumDetailChanged(object sender, System.EventArgs e)\r
+ {\r
+ UpdateAlbumDetailData();\r
+ }\r
+\r
+ private void UpdateAlbumDetailData()\r
+ {\r
+ listViewModel.Clear();\r
+ List<AudioInfo> trackList = AlbumDataProvider.GetAlbumTrackList(Id);\r
+ listViewModel.CreateData(trackList);\r
+ }\r
+\r
+ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)\r
+ {\r
+ TotalTracks = listViewModel.Count.ToString();\r
+ }\r
+\r
}\r
}\r
using System.Collections.Specialized;\r
+using System.Collections.Generic;\r
using MusicPlayer.Models;\r
using MusicPlayer.Common;\r
\r
using Album = Tizen.Content.MediaContent.Album;\r
class AlbumViewModel : PropertyNotifier\r
{\r
- private AlbumDetailViewModel albumDetailViewModel;\r
-\r
public AlbumViewModel()\r
{\r
- OrderedDictionary albumList = AlbumDataProvider.CurrentAlbumList();\r
+ AlbumDataProvider.AlbumDataChanged += OnAlbumDataChanged;\r
listViewModel = new ListViewModel<MusicAlbum>();\r
- listViewModel.CreateData<Album>(albumList);\r
- listViewModel.CollectionChanged += OnAlbumListChanges;\r
- AlbumCount = listViewModel.Count.ToString();\r
- }\r
-\r
- private void OnAlbumListChanges(object sender, NotifyCollectionChangedEventArgs e)\r
- {\r
+ CreateAlbumData();\r
+ listViewModel.CollectionChanged += OnCollectionChanged;\r
AlbumCount = listViewModel.Count.ToString();\r
}\r
\r
- public AlbumDetailViewModel getDetailViewModel(MusicAlbum musicAlbum)\r
- {\r
- if(albumDetailViewModel == null)\r
- albumDetailViewModel = new AlbumDetailViewModel(musicAlbum);\r
- else if (albumDetailViewModel.Id != musicAlbum.Id)\r
- albumDetailViewModel = new AlbumDetailViewModel(musicAlbum);\r
- return albumDetailViewModel;\r
- }\r
-\r
private ListViewModel<MusicAlbum> listViewModel;\r
\r
public ListViewModel<MusicAlbum> ListViewModel\r
SetProperty(ref albumCount, value + text);\r
}\r
}\r
+\r
+ private void CreateAlbumData()\r
+ {\r
+ listViewModel.Clear();\r
+ List<Album> albumList = AlbumDataProvider.CurrentAlbumList();\r
+ listViewModel.CreateData(albumList);\r
+ }\r
+\r
+ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)\r
+ {\r
+ AlbumCount = listViewModel.Count.ToString();\r
+ }\r
+\r
+ private void OnAlbumDataChanged(object sender, System.EventArgs e)\r
+ {\r
+ CreateAlbumData();\r
+ }\r
}\r
}\r
using System.Collections.Specialized;
using MusicPlayer.Models;
using MusicPlayer.Common;
+using MusicPlayer.Core;
+using System.Collections.Generic;
namespace MusicPlayer.ViewModels
{
using AudioInfo = Tizen.Content.MediaContent.AudioInfo;
class ArtistDetailViewModel : PropertyNotifier
{
-
public ArtistDetailViewModel(Artist artist)
{
+ ArtistDataProvider.ArtistDataChanged += OnArtistDetailChanged;
+
ArtistName = artist.ArtistName;
TotalCount = artist.TotalCount;
- string text = string.Equals(ArtistName, "Unknown") ? "" : ArtistName;
- OrderedDictionary albumList = ArtistDataProvider.GetArtistAlbumList(text);
albumListViewModel = new ListViewModel<MusicAlbum>();
- albumListViewModel.CreateData<Album>(albumList);
-
- OrderedDictionary trackList = ArtistDataProvider.GetArtistTrackList(text);
trackListViewModel = new ListViewModel<Track>();
- trackListViewModel.CreateData<AudioInfo>(trackList);
-
groupListViewModel = new ListViewModel<ArtistDetailAlbum>();
-
- foreach(MusicAlbum album in albumListViewModel)
- {
- ArtistDetailAlbum artistAlbum = new ArtistDetailAlbum(album);
- OrderedDictionary albumTrackList = AlbumDataProvider.GetAlbumTrackList(album.Id);
- ListViewModel<Track> albumTrackListViewModel = new ListViewModel<Track>();
- albumTrackListViewModel.CreateData<AudioInfo>(albumTrackList);
- foreach (Track track in albumTrackListViewModel)
- artistAlbum.Add(track);
- groupListViewModel.Add(artistAlbum);
- }
}
private string artistName;
set => SetProperty(ref totalCount, value);
}
+ // TODO do we really need this ?
+ public void OnViewDeleted()
+ {
+ ArtistDataProvider.ArtistDataChanged += OnArtistDetailChanged;
+ trackListViewModel.Clear();
+ albumListViewModel.Clear();
+ groupListViewModel.Clear();
+ }
+
+ public void PlayAll()
+ {
+ PlaybackHelper.Instance.PlayAll(TrackListViewModel, TrackListViewModel[0]);
+ }
+
+ public void PlayAllWithShuffle()
+ {
+ PlaybackHelper.Instance.PlayAllWithShuffle(TrackListViewModel);
+ }
+
+ public void PlayCurrent(object currentTrack)
+ {
+ PlaybackHelper.Instance.PlayCurrent(TrackListViewModel, (Track)currentTrack);
+ }
+
private readonly ListViewModel<ArtistDetailAlbum> groupListViewModel;
public ListViewModel<ArtistDetailAlbum> GroupListViewModel => groupListViewModel;
private readonly ListViewModel<Track> trackListViewModel;
public ListViewModel<Track> TrackListViewModel => trackListViewModel;
+
+ private void OnArtistDetailChanged(object sender, System.EventArgs e)
+ {
+ UpdateArtistDetailView();
+ }
+
+ //TODO update function to update count when change occured
+ private void UpdateArtistDetailView()
+ {
+ trackListViewModel.Clear();
+ albumListViewModel.Clear();
+ groupListViewModel.Clear();
+
+ string text = string.Equals(ArtistName, "Unknown") ? "" : ArtistName;
+
+ List<Album> albumList = ArtistDataProvider.GetArtistAlbumList(text);
+ albumListViewModel.CreateData<Album>(albumList);
+
+ List<AudioInfo> trackList = ArtistDataProvider.GetArtistTrackList(text);
+ trackListViewModel.CreateData<AudioInfo>(trackList);
+
+ foreach (MusicAlbum album in albumListViewModel)
+ {
+ ArtistDetailAlbum artistAlbum = new ArtistDetailAlbum(album);
+ List<AudioInfo> albumTrackList = AlbumDataProvider.GetAlbumTrackList(album.Id);
+ ListViewModel<Track> albumTrackListViewModel = new ListViewModel<Track>();
+ albumTrackListViewModel.CreateData(albumTrackList);
+ foreach (Track track in albumTrackListViewModel)
+ artistAlbum.Add(track);
+ groupListViewModel.Add(artistAlbum);
+ }
+ }
}
}
{
class ArtistViewModel : PropertyNotifier
{
- private ArtistDetailViewModel artistDetailViewModel;
-
public ArtistViewModel()
{
- List<string> artistList = ArtistDataProvider.CurrentArtistList();
+ ArtistDataProvider.ArtistDataChanged += OnArtistDataChanged;
listViewModel = new ListViewModel<Artist>();
- listViewModel.CreateData<string>(artistList);
- listViewModel.CollectionChanged += OnArtistListChanges;
+ CreateArtistData();
+ listViewModel.CollectionChanged += OnCollectionChanged;
ArtistCount = listViewModel.Count.ToString();
}
- private void OnArtistListChanges(object sender, NotifyCollectionChangedEventArgs e)
- {
- artistCount = listViewModel.Count.ToString();
- }
-
- public ArtistDetailViewModel getDetailViewModel(Artist artist)
- {
- if (artistDetailViewModel == null)
- artistDetailViewModel = new ArtistDetailViewModel(artist);
- else if (artistDetailViewModel.ArtistName != artist.ArtistName)
- artistDetailViewModel = new ArtistDetailViewModel(artist);
- return artistDetailViewModel;
- }
-
private ListViewModel<Artist> listViewModel;
public ListViewModel<Artist> ListViewModel
SetProperty(ref artistCount, value + text);
}
}
+
+ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ ArtistCount = listViewModel.Count.ToString();
+ }
+
+ private void CreateArtistData()
+ {
+ listViewModel.Clear();
+ List<string> artistList = ArtistDataProvider.CurrentArtistList();
+ listViewModel.CreateData(artistList);
+ }
+
+ private void OnArtistDataChanged(object sender, System.EventArgs e)
+ {
+ CreateArtistData();
+ }
+
}
}
\ No newline at end of file
using System.Collections;\r
using System.Collections.Specialized;\r
using System.Collections.ObjectModel;\r
-using MusicPlayer.Models;\r
-using Tizen.Content.MediaContent;\r
using MusicPlayer.Common;\r
using System;\r
using System.Collections.Generic;\r
}\r
Tizen.Log.Debug(AppConstants.LogTag, "Observable list item count: " + this.Count);\r
}\r
-\r
-\r
}\r
}\r
private string GetLyrics(string path)
{
- var metadataExtractor = new MetadataExtractor(path);
- Metadata metadata = metadataExtractor.GetMetadata();
- string lyrics = metadata.UnsyncLyrics;
+ string lyrics = string.Empty;
+ try
+ {
+ var metadataExtractor = new MetadataExtractor(path);
+ Metadata metadata = metadataExtractor.GetMetadata();
+ lyrics = metadata.UnsyncLyrics;
+ }
+ catch(System.IO.FileNotFoundException ex)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "File might be in external storage or, " + ex.Message);
+ }
+ catch(System.InvalidOperationException ex)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation: " + ex.Message);
+ }
+
if(string.IsNullOrEmpty(lyrics))
{
LyricsBackgroundColor = Color.Transparent;
{
lyricsViewModel = new LyricsViewModel();
playingListViewModel = new PlayingListViewModel();
+ playingListViewModel.ItemSelected += OnPlayingListItemSelected;
playerModel = new PlayerModel();
playerModel.ElapsedTime = 0.0f;
PlayingStatus = PlayingStatus.None;
AudioManager.VolumeController.Changed += OnVolumeLevelChanged;
HasPreviousTrack = playingListViewModel.HasPrev();
HasNextTrack = playingListViewModel.HasNext();
+ FavouriteButtonState = Favourite.Off.ToString();
}
internal PlayingListViewModel playingListViewModel;
get => playingListViewModel;
}
+ private string favouriteButtonState;
+
+ public string FavouriteButtonState
+ {
+ get => favouriteButtonState;
+ set => SetProperty(ref favouriteButtonState, value);
+ }
+
private string playButtonState;
public string PlayButtonState
// SetBackground
SetExtractedBackground(track.ThumbnailPath);
+ // Set Favourite Status
+ bool favouriteStatus = TrackDataProvider.GetFavouriteStatus(track.Id);
+ FavouriteButtonState = favouriteStatus ? Favourite.On.ToString() : Favourite.Off.ToString();
+
PlayerController.Instance.Uri = track.FilePath;
StartPlayback();
}
playingListViewModel.RepeatMode = new_mode;
}
+ public void FavouriteStatusChanged()
+ {
+ bool favouriteStatus = !(TrackDataProvider.GetFavouriteStatus(playerModel.CurrentTrack.Id));
+ FavouriteButtonState = favouriteStatus ? Favourite.On.ToString() : Favourite.Off.ToString();
+ TrackDataProvider.SetFavouriteStatus(playerModel.CurrentTrack.Id, favouriteStatus);
+ }
+
+ public void SetRepeatAndShuffle(RepeatMode repeatMode, ShuffleMode shuffleMode)
+ {
+ playingListViewModel.RepeatMode = repeatMode;
+ playingListViewModel.ShuffleMode = shuffleMode;
+ }
+
public void PlayingStatusChanged()
{
if (PlayingStatus == PlayingStatus.Playing)
AudioManager.VolumeController.Level[AudioVolumeType.Media] = value;
}
+ public void StartShuffledTrack()
+ {
+ SetCurrentTrack(playingListViewModel.FirstShuffledTrack());
+ }
+
private void UpdatePlayingStatus(PlayingStatus status)
{
playingStatus = status;
}
}
+ private void OnPlayingListItemSelected(object sender, PlayingListItemSelectedEvent e)
+ {
+ SetCurrentTrack((Track)e.CurrentSelectedItem);
+ }
+
private bool OnPlaybackTimerTick(object source, Timer.TickEventArgs e)
{
UpdatePlayingTime();
private string shuffleButtonUrl;
private string repeatButtonUrl;
+ public event EventHandler<PlayingListItemSelectedEvent> ItemSelected;
+
public PlayingListViewModel()
{
shuffleList = new List<int>();
set => SetProperty(ref repeatButtonUrl, value);
}
- public RepeatMode RepeatMode
- {
+ public RepeatMode RepeatMode
+ {
get => repeatMode;
set
{
repeatMode = value;
RepeatButtonState = repeatMode.ToString();
}
- }
+ }
+
+ public Track FirstShuffledTrack()
+ {
+ if(shuffleList.Count > 0)
+ {
+ return tracklistViewModel[shuffleList[0]];
+ }
+ return null;
+ }
+
+ public void OnItemSelected(object selectedItem)
+ {
+ SetPlayingTrack((Track)selectedItem);
+ ItemSelected?.Invoke(this, new PlayingListItemSelectedEvent(selectedItem));
+ }
public Track Next()
{
--- /dev/null
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using Tizen.Content.MediaContent;
+using MusicPlayer.Models;
+using MusicPlayer.Common;
+using MusicPlayer.Core;
+
+
+namespace MusicPlayer.ViewModels
+{
+ class PlaylistDetailViewModel : PropertyNotifier
+ {
+ private Playlist playlist;
+ private bool isDefaultPlaylist;
+ public PlaylistDetailViewModel(int playlistId)
+ {
+ PlaylistManager.Instance.PlaylistDataChanged += OnPlaylistDetailChanged;
+ playlist = PlaylistManager.Instance.GetPlaylist(playlistId);
+ PlaylistName = playlist.Name;
+ isDefaultPlaylist = false;
+ if(PlaylistName == AppConstants.RecentlyAddedPlaylist || PlaylistName == AppConstants.FavouritePlaylist)
+ {
+ isDefaultPlaylist = true;
+ }
+ listViewModel = new ListViewModel<Track>();
+ UpdatePlaylistDetails();
+ PlaylistTrackCount = listViewModel.Count.ToString();
+ ListViewModel.CollectionChanged += OnCollectionChanged;
+ }
+
+ public string PlaylistName { get; set; }
+
+ private ListViewModel<Track> listViewModel;
+
+ public ListViewModel<Track> ListViewModel
+ {
+ get => listViewModel;
+ }
+
+ private string playlistTrackCount;
+
+ public string PlaylistTrackCount
+ {
+ get => playlistTrackCount;
+ set
+ {
+ string count = string.Equals(value, "1") ? value + " Track" : value + " Tracks";
+ SetProperty(ref playlistTrackCount, count);
+ }
+ }
+
+ // TODO do we really need this ?
+ public void OnViewDeleted()
+ {
+ PlaylistManager.Instance.PlaylistDataChanged -= OnPlaylistDetailChanged;
+ ListViewModel.CollectionChanged -= OnCollectionChanged;
+ ListViewModel.Clear();
+ }
+
+ public void PlayAll()
+ {
+ PlaybackHelper.Instance.PlayAll(ListViewModel, ListViewModel[0]);
+ }
+
+ public void PlayAllWithShuffle()
+ {
+ PlaybackHelper.Instance.PlayAllWithShuffle(ListViewModel);
+ }
+
+ public void PlayCurrent(object currentTrack)
+ {
+ PlaybackHelper.Instance.PlayCurrent(ListViewModel, (Track)currentTrack);
+ }
+
+ private void OnPlaylistDetailChanged(object sender, System.EventArgs e)
+ {
+ UpdatePlaylistDetails();
+ }
+
+ private List<AudioInfo> CreatePlaylistAudioData(int playlistId)
+ {
+ List<PlaylistMember> playlistMembers = PlaylistManager.Instance.GetMemberList(playlistId);
+ List<AudioInfo> audioList = new List<AudioInfo>();
+ foreach (PlaylistMember member in playlistMembers)
+ {
+ MediaInfo mediaInfo = member.MediaInfo;
+ if (mediaInfo.MediaType == MediaType.Music)
+ {
+ audioList.Add((AudioInfo)mediaInfo);
+ }
+ }
+ return audioList;
+ }
+
+ private void UpdatePlaylistDetails()
+ {
+ // This is required because we delete and recreate default playlists on every database change event
+ if(isDefaultPlaylist)
+ {
+ Playlist updatedPlaylist = PlaylistManager.Instance.GetPlaylist(PlaylistName);
+ playlist = updatedPlaylist;
+ }
+ listViewModel.Clear();
+ listViewModel.CreateData(CreatePlaylistAudioData(playlist.Id));
+ }
+
+ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ PlaylistTrackCount = ListViewModel.Count.ToString();
+ }
+
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using Tizen.Content.MediaContent;
+using MusicPlayer.Models;
+using MusicPlayer.Core;
+using MusicPlayer.Common;
+using MusicPlayer.Media;
+
+namespace MusicPlayer.ViewModels
+{
+ class PlaylistViewModel : PropertyNotifier
+ {
+ public PlaylistViewModel()
+ {
+ PlaylistManager.Instance.PlaylistDataChanged += OnPlaylistDataChanged;
+ listViewModel = new ListViewModel<PlaylistModel>();
+ UpdatePlaylistData();
+ PlaylistCount = listViewModel.Count.ToString();
+ ListViewModel.CollectionChanged += OnCollectionChanged;
+ }
+
+ private ListViewModel<PlaylistModel> listViewModel;
+
+ public ListViewModel<PlaylistModel> ListViewModel
+ {
+ get => listViewModel;
+ }
+
+ public ListViewModel<PlaylistModel> UserPlaylistViewModel
+ {
+ get => CreateUserPlayListViewModel();
+ }
+
+ private string playlistCount;
+
+ public string PlaylistCount
+ {
+ get => playlistCount;
+ set
+ {
+ string countText = string.Equals(value, "1") ? value+" Playlist" : value+" Playlists";
+ SetProperty(ref playlistCount, countText);
+ }
+ }
+
+ private Playlist CreateDefaultPlaylist(string name, string thumbPath)
+ {
+ Playlist playlist = PlaylistManager.Instance.GetPlaylist(name);
+ if (playlist != null)
+ {
+ PlaylistManager.Instance.Delete(playlist.Id);
+ playlist = null;
+ }
+ playlist = PlaylistManager.Instance.AddPlaylist(name, thumbPath);
+ return playlist;
+ }
+
+
+ private Tuple<int, int> AddMemberToDefaultList(Playlist favourite, Playlist recentlyAdded)
+ {
+ List<AudioInfo> trackList = Contents.GetTrackList();
+ int recentAddedCount = trackList.Count;
+ int favouriteCount = 0;
+ foreach(AudioInfo track in trackList)
+ {
+ PlaylistManager.Instance.AddTrack(recentlyAdded.Id, track.Id);
+ if(track.IsFavorite)
+ {
+ PlaylistManager.Instance.AddTrack(favourite.Id, track.Id);
+ favouriteCount++;
+ }
+ }
+ return new Tuple<int, int>(recentAddedCount, favouriteCount);
+ }
+
+ private string GetTrackCountForPlaylist(int playlistId)
+ {
+ int trackCount = PlaylistManager.Instance.PlaylistTrackCount(playlistId);
+ return GetTrackCountText(trackCount);
+ }
+
+ private string GetTrackCountText(int trackCount)
+ {
+ return trackCount > 1 ? trackCount.ToString() + " tracks" : trackCount.ToString() + " track";
+ }
+
+ private void AddDefaultPlaylist(List<PlaylistData> list)
+ {
+ // Deleting the Favourite and Recently Added first always so that we can add member correctly again.
+ Playlist favouritePlaylist = CreateDefaultPlaylist(AppConstants.FavouritePlaylist, Resources.GetImagePath() + "favourite_playlist.png");
+ Playlist recentlyAddedPlaylist = CreateDefaultPlaylist(AppConstants.RecentlyAddedPlaylist, Resources.GetImagePath() + "recently_added_playlist.png");
+ Tuple<int, int> memberCounts = AddMemberToDefaultList(favouritePlaylist, recentlyAddedPlaylist);
+ list.Add(new PlaylistData(recentlyAddedPlaylist.Id, recentlyAddedPlaylist.Name, GetTrackCountText(memberCounts.Item1), recentlyAddedPlaylist.ThumbnailPath));
+ list.Add(new PlaylistData(favouritePlaylist.Id, favouritePlaylist.Name, GetTrackCountText(memberCounts.Item2), favouritePlaylist.ThumbnailPath));
+ }
+
+ private List<PlaylistData> GeneratePlaylistData()
+ {
+ List<PlaylistData> dataList = new List<PlaylistData>();
+ AddDefaultPlaylist(dataList);
+
+ List<Playlist> playlists = PlaylistManager.Instance.Playlists;
+ Tizen.Log.Error(AppConstants.LogTag, "Retrived playlistcount: " + playlists.Count);
+
+ foreach(Playlist playlist in playlists)
+ {
+ if (playlist.Name == AppConstants.FavouritePlaylist || playlist.Name == AppConstants.RecentlyAddedPlaylist)
+ continue;
+ Tizen.Log.Error(AppConstants.LogTag, playlist.Id + ": "+playlist.Name);
+ dataList.Add(new PlaylistData(playlist.Id, playlist.Name, GetTrackCountForPlaylist(playlist.Id), playlist.ThumbnailPath));
+ }
+ return dataList;
+ }
+
+ private void UpdatePlaylistData()
+ {
+ listViewModel.Clear();
+ List<PlaylistData> dataList = GeneratePlaylistData();
+ listViewModel.CreateData(dataList);
+ }
+
+ private void OnPlaylistDataChanged(object sender, System.EventArgs e)
+ {
+ UpdatePlaylistData();
+ }
+
+ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ PlaylistCount = ListViewModel.Count.ToString();
+ }
+
+ private ListViewModel<PlaylistModel> CreateUserPlayListViewModel()
+ {
+ ListViewModel<PlaylistModel> userListViewModel = new ListViewModel<PlaylistModel>();
+ if (ListViewModel.Count <= 2)
+ return userListViewModel;
+ for(int i = 2; i<ListViewModel.Count; ++i)
+ {
+ userListViewModel.Add(ListViewModel[i]);
+ }
+ return userListViewModel;
+ }
+
+ }
+}
using System.Collections.Specialized;\r
+using System.Collections.Generic;\r
using MusicPlayer.Models;\r
using MusicPlayer.Common;\r
+using MusicPlayer.Core;\r
\r
namespace MusicPlayer.ViewModels\r
{\r
{\r
public TrackViewModel()\r
{\r
- OrderedDictionary trackList = TrackDataProvider.CurrentTrackList();\r
+ TrackDataProvider.TrackDataChanged += OnTrackDataChanged;\r
listViewModel = new ListViewModel<Track>();\r
- listViewModel.CreateData<AudioInfo>(trackList);\r
- listViewModel.CollectionChanged += OnTrackListChanges;\r
- TrackCount = listViewModel.Count.ToString();\r
- }\r
-\r
- private void OnTrackListChanges(object sender, NotifyCollectionChangedEventArgs e)\r
- {\r
+ CreateTrackData();\r
+ listViewModel.CollectionChanged += OnCollectionChanged;\r
TrackCount = listViewModel.Count.ToString();\r
}\r
\r
SetProperty(ref trackCount, value + text);\r
}\r
}\r
+\r
+ public void OnTrackSelected(object selectedItem)\r
+ {\r
+ PlaybackHelper.Instance.PlayCurrent(ListViewModel, (Track)selectedItem);\r
+ }\r
+\r
+ public void PlayAll()\r
+ {\r
+ PlaybackHelper.Instance.PlayAll(ListViewModel, ListViewModel[0]);\r
+ }\r
+\r
+ public void PlayAllWithShuffle()\r
+ {\r
+ PlaybackHelper.Instance.PlayAllWithShuffle(ListViewModel);\r
+ }\r
+\r
+ private void OnTrackDataChanged(object sender, System.EventArgs e)\r
+ {\r
+ CreateTrackData();\r
+ }\r
+\r
+ private void CreateTrackData()\r
+ {\r
+ List<AudioInfo> trackList = TrackDataProvider.CurrentTrackList();\r
+ listViewModel.Clear();\r
+ listViewModel.CreateData(trackList);\r
+ }\r
+\r
+ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)\r
+ {\r
+ TrackCount = listViewModel.Count.ToString();\r
+ }\r
}\r
}\r
\r
private TextLabel CreateTitleLabel()\r
{\r
- TextLabel titleLabel = new TextLabel()\r
+ TextLabel titleLabel = new TextLabel("ItemLabel")\r
{\r
+ ThemeChangeSensitive = true,\r
Size2D = new Size2D(596, 40),\r
- TextColor = UIColors.HEX001447,\r
PixelSize = 32,\r
FontFamily = "BreezeSans",\r
+ HorizontalAlignment = HorizontalAlignment.Begin,\r
VerticalAlignment = VerticalAlignment.Center,\r
Padding=new Extents(LayoutPadding,0,0,0),\r
- IsCreateByXaml = true,\r
+ FontStyle = UIFontStyles.NormalLight,\r
Position2D = new Position2D(X , LayoutMargin),\r
};\r
base.Add(titleLabel);\r
\r
private TextLabel CreateSubTitleLabel()\r
{\r
- TextLabel subtitleLabel = new TextLabel()\r
+ TextLabel subtitleLabel = new TextLabel("ItemLabel")\r
{\r
+ ThemeChangeSensitive = true,\r
Size2D= new Size2D(596,36),\r
- TextColor = UIColors.HEX001447,\r
PixelSize = 28,\r
FontFamily = "BreezeSans",\r
+ HorizontalAlignment = HorizontalAlignment.Begin,\r
VerticalAlignment = VerticalAlignment.Center,\r
Padding = new Extents(LayoutPadding, 0, 0, 0),\r
- IsCreateByXaml = true,\r
+ FontStyle = UIFontStyles.AllNormal,\r
Position2D = new Position2D(X , LayoutMargin + 40)\r
};\r
base.Add(subtitleLabel);\r
\r
private TextLabel CreateAdditionalLabel(int width)\r
{\r
- TextLabel additionalLabel = new TextLabel()\r
+ TextLabel additionalLabel = new TextLabel("ItemLabel")\r
{\r
+ ThemeChangeSensitive = true,\r
Size2D= new Size2D(108,36),\r
- TextColor = UIColors.HEX001447,\r
PixelSize = 28,\r
FontFamily = "BreezeSans",\r
VerticalAlignment = VerticalAlignment.Center,\r
- HorizontalAlignment =HorizontalAlignment.End,\r
- IsCreateByXaml = true,\r
+ HorizontalAlignment = HorizontalAlignment.End,\r
+ FontStyle = UIFontStyles.AllNormal,\r
Position2D = new Position2D(width-LayoutPadding-LeftPadding-108, 36)\r
};\r
base.Add(additionalLabel);\r
-using MusicPlayer.ViewModels;\r
+using Tizen.NUI;\r
+using Tizen.NUI.Binding;\r
using Tizen.NUI.Components;\r
using Tizen.NUI.BaseComponents;\r
-using Tizen.NUI;\r
-using Tizen.NUI.Binding;\r
using MusicPlayer.Common;\r
+using MusicPlayer.ViewModels;\r
+using MusicPlayer.Views.Utils;\r
\r
namespace MusicPlayer.Views\r
{\r
- class AlbumDetailView : View\r
+ class AlbumDetailView : BaseSubContentView\r
{\r
- private const int LayoutPadding = 64;\r
- private const int IconSize = 48;\r
private const int AlbumArtSize = 520;\r
- private const int ControlViewWidth = 960;\r
private const int ControlViewHeight = 60;\r
- private const int ControlViewMargin = 6;\r
\r
- private BaseView baseView;\r
- private View contentView;\r
private View leftView;\r
private View rightView;\r
private ImageView albumArtIcon;\r
private TextLabel albumNameLabel;\r
private TextLabel albumArtistLabel;\r
- private View controlsView;\r
- private TextLabel trackCountLabel;\r
- private Button playAllIcon; // TODO need to implement playall feature\r
- private Button shuffleAndPlayAllIcon; // TODO need to implement playlist manager\r
- private CollectionView collectionView;\r
\r
private AlbumDetailViewModel viewModel;\r
public AlbumDetailView(AlbumDetailViewModel viewModel) : base()\r
{\r
+ Name = "AlbumDetailView";\r
this.viewModel = viewModel;\r
- BindingContext = viewModel;\r
- BackgroundColor = UIColors.HEXEEEFF1;\r
- WidthResizePolicy = ResizePolicyType.FillToParent;\r
- HeightResizePolicy = ResizePolicyType.FillToParent;\r
-\r
- //TODO need to change this part after implementation of Command Interface\r
- baseView = new BaseView()\r
- {\r
- Title = viewModel.AlbumName,\r
- BackButton = true,\r
- MoreButton = true,\r
- SearchButton = true,\r
- BackgroundColor = UIColors.HEXEEEFF1,\r
- };\r
- base.Add(baseView);\r
- contentView = new View()\r
- {\r
- WidthSpecification = LayoutParamPolicies.MatchParent,\r
- HeightSpecification = 876,\r
- Layout = new FlexLayout()\r
- {\r
- Direction = FlexLayout.FlexDirection.Row,\r
- ItemsAlignment = FlexLayout.AlignmentType.FlexStart,\r
- Justification = FlexLayout.FlexJustification.FlexStart,\r
- },\r
- };\r
- baseView.SetContent = contentView;\r
-\r
leftView = CreateLeftView();\r
rightView = CreateRightView();\r
- controlsView = AddControlView();\r
- AddControlElements();\r
- collectionView = AddCollectionView();\r
+ rightView.Add(listContainer);\r
+ countLabel.BindingContext = viewModel;\r
+ countLabel.SetBinding(TextLabel.TextProperty, "TotalTracks");\r
+ UpdateCollectionView();\r
AddAlbumArt();\r
AddAlbumInfo();\r
}\r
\r
- private void OnTrackSelection(object sender, SelectionChangedEventArgs e)\r
+ public override void UpdateSubContentMoreButtonItems(Menu moreMenu)\r
{\r
+ var addtoPlaylist = new MenuItem { Text = "Add to playlist" };\r
+ addtoPlaylist.Clicked += OnAddToPlaylistClick;\r
\r
+ var share = new MenuItem { Text = "Share" };\r
+ share.Clicked += OnShareClick;\r
+\r
+ var delete = new MenuItem { Text = "Delete" };\r
+ delete.Clicked += OnDeleteClick;\r
+\r
+ moreMenu.Items = new MenuItem[] { addtoPlaylist, share, delete };\r
}\r
\r
- private Button CreateButton(string url, int x, int y)\r
+ public override void DeleteSubView()\r
{\r
- ButtonStyle buttonStyle = new ButtonStyle()\r
- {\r
- Icon = new ImageViewStyle()\r
- {\r
- ResourceUrl = url,\r
- },\r
- IsSelectable = false,\r
- IsEnabled = true,\r
- };\r
+ base.DeleteSubView();\r
+ viewModel.OnViewDeleted();\r
+ }\r
\r
- Button button = new Button(buttonStyle)\r
- {\r
- Size2D = new Size2D(IconSize, IconSize),\r
- Position2D = new Position2D(x, y),\r
- };\r
- return button;\r
+ protected override void OnPlayAllClicked()\r
+ {\r
+ base.OnPlayAllClicked();\r
+ Tizen.Log.Error(AppConstants.LogTag, "AlbumDetailView OnPlayAllClicked");\r
+ viewModel.PlayAll();\r
+ }\r
+\r
+ protected override void OnPlayAllWithShuffleClicked()\r
+ {\r
+ base.OnPlayAllWithShuffleClicked();\r
+ Tizen.Log.Error(AppConstants.LogTag, "AlbumDetailView OnPlayAllWithShuffleClicked");\r
+ viewModel.PlayAllWithShuffle();\r
+ }\r
+\r
+ private void OnTrackSelection(object sender, SelectionChangedEventArgs e)\r
+ {\r
+ viewModel.PlayCurrent(collectionView.SelectedItem);\r
}\r
\r
private View CreateLeftView()\r
{\r
View leftView = new View()\r
{\r
- BackgroundColor = UIColors.HEXEEEFF1,\r
- Size2D = new Size2D(Window.Instance.WindowSize.Width / 2, 752),\r
+ BackgroundColor = Color.Transparent,\r
+ SizeWidth = Window.Instance.WindowSize.Width / 2,\r
+ HeightResizePolicy = ResizePolicyType.FillToParent,\r
Position2D = new Position2D(0, 0),\r
Layout = new FlexLayout\r
{\r
},\r
Padding = new Extents(0, 0, ControlViewHeight, 42),\r
};\r
- contentView.Add(leftView);\r
+ base.Add(leftView);\r
return leftView;\r
}\r
\r
{\r
View rightView = new View()\r
{\r
- BackgroundColor = UIColors.HEXEEEFF1,\r
- Size2D = new Size2D(Window.Instance.WindowSize.Width / 2, 752),\r
+ BackgroundColor = Color.Transparent,\r
+ SizeWidth = Window.Instance.WindowSize.Width / 2,\r
+ HeightResizePolicy = ResizePolicyType.FillToParent,\r
Position2D = new Position2D(Window.Instance.WindowSize.Width / 2, 0),\r
Layout = new FlexLayout\r
{\r
Justification = FlexLayout.FlexJustification.FlexStart,\r
},\r
};\r
- contentView.Add(rightView);\r
+ base.Add(rightView);\r
return rightView;\r
}\r
\r
BackgroundColor = UIColors.HEXEEEFF1,\r
Size2D = new Size2D(AlbumArtSize, AlbumArtSize),\r
};\r
+ albumArtIcon.BindingContext = viewModel;\r
albumArtIcon.SetBinding(ImageView.ResourceUrlProperty, "AlbumArtPath");\r
leftView.Add(albumArtIcon);\r
}\r
private void AddAlbumInfo()\r
{\r
- albumNameLabel = new TextLabel()\r
+ albumNameLabel = new TextLabel("LabelText")\r
{\r
- Text = "ALBUM NAME",\r
Size2D = new Size2D(640, 48),\r
PixelSize = 36,\r
Margin = new Extents(0, 0, 32, 0),\r
FontFamily = "BreezeSans",\r
- TextColor = UIColors.HEX001447,\r
HorizontalAlignment = HorizontalAlignment.Center,\r
VerticalAlignment = VerticalAlignment.Center,\r
Ellipsis = true,\r
+ FontStyle = UIFontStyles.NormalLight,\r
};\r
+ albumNameLabel.BindingContext = viewModel;\r
albumNameLabel.SetBinding(TextLabel.TextProperty, "AlbumName");\r
leftView.Add(albumNameLabel);\r
- albumArtistLabel = new TextLabel()\r
+ albumArtistLabel = new TextLabel("LabelText")\r
{\r
- Text = "ARTIST NAME",\r
Size2D = new Size2D(640, 36),\r
PixelSize = 28,\r
Margin = new Extents(0, 0, 14, 0),\r
FontFamily = "BreezeSans",\r
- TextColor = UIColors.HEX000209,\r
HorizontalAlignment = HorizontalAlignment.Center,\r
VerticalAlignment = VerticalAlignment.Center,\r
Ellipsis = true,\r
+ FontStyle = UIFontStyles.AllNormal,\r
};\r
+ albumArtistLabel.BindingContext = viewModel;\r
albumArtistLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
leftView.Add(albumArtistLabel);\r
-\r
}\r
- private View AddControlView()\r
+\r
+ private void UpdateCollectionView()\r
{\r
- View controlsView = new View()\r
+ collectionView.ItemTemplate = new DataTemplate(() =>\r
{\r
- BackgroundColor = UIColors.HEXEEEFF1,\r
- Size2D = new Size2D(ControlViewWidth, ControlViewHeight),\r
- Padding = new Extents(LayoutPadding, LayoutPadding, ControlViewMargin, ControlViewMargin),\r
- };\r
- rightView.Add(controlsView);\r
- return controlsView;\r
+ AlbumDetailLayout layout = new AlbumDetailLayout();\r
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");\r
+ layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
+ layout.AdditionalLabel.SetBinding(TextLabel.TextProperty, "Duration");\r
+ return layout;\r
+ });\r
+ collectionView.ItemsSource = viewModel.ListViewModel;\r
+ collectionView.SelectionChanged += OnTrackSelection;\r
}\r
\r
- private void AddControlElements()\r
+ private void OnDeleteClick(object sender, ClickedEventArgs e)\r
{\r
- trackCountLabel = new TextLabel()\r
- {\r
- Text = "TRACK COUNT",\r
- Size2D = new Size2D(664, 36),\r
- Position2D = new Position2D(LayoutPadding, 12),\r
- PixelSize = 28,\r
- Margin = new Extents(0, 0, ControlViewMargin, ControlViewMargin),\r
- FontFamily = "BreezeSans",\r
- TextColor = UIColors.HEX001447,\r
- HorizontalAlignment = HorizontalAlignment.Begin,\r
- VerticalAlignment = VerticalAlignment.Center,\r
- };\r
- trackCountLabel.SetBinding(TextLabel.TextProperty, "TotalTracks");\r
- controlsView.Add(trackCountLabel);\r
-\r
- playAllIcon = CreateButton(Resources.GetImagePath() + "playlist_active.png.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - IconSize, ControlViewMargin);\r
- playAllIcon.Margin = new Extents(40, 0, 0, 0);\r
- controlsView.Add(playAllIcon);\r
-\r
- shuffleAndPlayAllIcon = CreateButton(Resources.GetImagePath() + "shuffle_on.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - 2 * IconSize - 40, ControlViewMargin);\r
- playAllIcon.Margin = new Extents(32, 0, 0, 0);\r
- controlsView.Add(shuffleAndPlayAllIcon);\r
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Delete, ContentViewType.Track, viewModel.ListViewModel);\r
+ OnOperationViewAdd(operationEventArgs);\r
+ }\r
\r
+ private void OnShareClick(object sender, ClickedEventArgs e)\r
+ {\r
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Share, ContentViewType.Track, viewModel.ListViewModel);\r
+ OnOperationViewAdd(operationEventArgs);\r
}\r
\r
- private CollectionView AddCollectionView()\r
+ private void OnAddToPlaylistClick(object sender, ClickedEventArgs e)\r
{\r
- CollectionView collectionView = new CollectionView()\r
- {\r
- Size2D = new Size2D(832, 108),\r
- BackgroundImage = Resources.GetImagePath() + "list_view_bg.png",\r
- ItemsLayouter = new LinearLayouter(),\r
- ItemTemplate = new DataTemplate(() =>\r
- {\r
- AlbumDetailLayout layout = new AlbumDetailLayout();\r
- layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");\r
- layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
- layout.AdditionalLabel.SetBinding(TextLabel.TextProperty, "Duration");\r
- return layout;\r
- }),\r
- ScrollingDirection = ScrollableBase.Direction.Vertical,\r
- HeightSpecification = LayoutParamPolicies.WrapContent,\r
- SelectionMode = ItemSelectionMode.Single,\r
- };\r
- rightView.Add(collectionView);\r
- FlexLayout.SetFlexGrow(collectionView, 1);\r
- FlexLayout.SetFlexShrink(collectionView, 1);\r
- collectionView.ItemsSource = viewModel.ListViewModel;\r
- collectionView.SelectionChanged += OnTrackSelection;\r
- return collectionView;\r
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.AddToPlaylist, ContentViewType.Track, viewModel.ListViewModel);\r
+ OnOperationViewAdd(operationEventArgs);\r
}\r
}\r
}\r
using Tizen.NUI.Binding;\r
using MusicPlayer.Common;\r
using MusicPlayer.Models;\r
+using MusicPlayer.Views.Utils;\r
\r
namespace MusicPlayer.Views\r
{\r
private AlbumViewModel viewModel;\r
private TextLabel albumCountLabel;\r
\r
- public AlbumView(AlbumViewModel viewModel)\r
+ public AlbumView(AlbumViewModel viewModel) : base()\r
{\r
+ Name = "AlbumView";\r
this.viewModel = viewModel;\r
- BindingContext = viewModel;\r
collectionView.ItemsSource = viewModel.ListViewModel;\r
collectionView.ItemTemplate = new DataTemplate(() =>\r
{\r
layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
return layout;\r
});\r
- collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;\r
- collectionView.WidthSpecification = LayoutParamPolicies.WrapContent;\r
collectionView.SelectionMode = ItemSelectionMode.Single;\r
collectionView.SelectionChanged += OnAlbumSelection;\r
\r
- albumCountLabel = new TextLabel()\r
+ albumCountLabel = new TextLabel("LabelText")\r
{\r
+ ThemeChangeSensitive = true,\r
PixelSize = 28,\r
Text = "ALBUM COUNT",\r
- TextColor = UIColors.HEX001447,\r
+ HorizontalAlignment = HorizontalAlignment.Begin,\r
VerticalAlignment = VerticalAlignment.Center,\r
FontFamily = "BreezeSans",\r
- IsCreateByXaml = true,\r
+ FontStyle = UIFontStyles.AllNormal\r
};\r
titleView.Add(albumCountLabel);\r
+ albumCountLabel.BindingContext = viewModel;\r
albumCountLabel.SetBinding(TextLabel.TextProperty, "AlbumCount");\r
RelativeLayout.SetLeftTarget(albumCountLabel, titleView);\r
RelativeLayout.SetLeftRelativeOffset(albumCountLabel, 1.0f);\r
RelativeLayout.SetRightRelativeOffset(albumCountLabel, 0.0f);\r
RelativeLayout.SetFillHorizontal(albumCountLabel, true);\r
+\r
+ Tizen.Log.Error(AppConstants.LogTag, "AlbumView Exit <==");\r
}\r
- private void OnAlbumSelection(object sender, SelectionChangedEventArgs e)\r
+\r
+ public override void ShowView()\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "AlbumView Show View");\r
+ albumCountLabel.Show();\r
+ base.ShowView();\r
+ }\r
+\r
+ public override void HideView()\r
{\r
- MusicAlbum currentAlbum= (MusicAlbum)collectionView.SelectedItem;\r
- // viewModel.getDetailViewModel(currentAlbum) => need to replace direct function call on viewModel class with command interface\r
- AlbumDetailView view = new AlbumDetailView(viewModel.getDetailViewModel(currentAlbum));\r
- Window.Instance.Add(view);\r
+ Tizen.Log.Debug(AppConstants.LogTag, "AlbumView Hide View");\r
+ albumCountLabel.Hide();\r
+ base.HideView();\r
}\r
+\r
+ protected override void UpdateContentMoreButtonItems(Menu moreMenu)\r
+ {\r
+ var addToPlaylist = new MenuItem { Text = "Add to Playlist" };\r
+ addToPlaylist.Clicked += OnAddToPlaylistClick;\r
+ var delete = new MenuItem { Text = "Delete" };\r
+ delete.Clicked += OnDeleteClick;\r
+\r
+ moreMenu.Items = new MenuItem[] { addToPlaylist, delete };\r
+ }\r
+\r
protected override void Dispose(DisposeTypes type)\r
{\r
if (Disposed)\r
}\r
base.Dispose(type);\r
}\r
+\r
+ private void OnAlbumSelection(object sender, SelectionChangedEventArgs e)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "OnAlbumSelection Enter ==>");\r
+ MusicAlbum currentAlbum = (MusicAlbum)collectionView.SelectedItem;\r
+ SubContentViewAddEventArgs albumDetailViewArgs = new SubContentViewAddEventArgs(SubContentViewType.AlbumDetails, currentAlbum.AlbumName, currentAlbum);\r
+ OnSubViewAdd(albumDetailViewArgs);\r
+ Tizen.Log.Error(AppConstants.LogTag, "OnAlbumSelection Exit <==");\r
+ }\r
+\r
+ private void OnDeleteClick(object sender, ClickedEventArgs e)\r
+ {\r
+ DismissMoreMenu();\r
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Delete, ContentViewType.Album, viewModel.ListViewModel);\r
+ OnOperationViewAdd(operationEventArgs);\r
+ }\r
+\r
+ private void OnAddToPlaylistClick(object sender, ClickedEventArgs e)\r
+ {\r
+ DismissMoreMenu();\r
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.AddToPlaylist, ContentViewType.Album, viewModel.ListViewModel);\r
+ //OnOperationViewAdd(operationEventArgs);\r
+ }\r
+\r
}\r
}\r
private TextLabel CreateTitleLabel()
{
- TextLabel titleLabel = new TextLabel()
+ TextLabel titleLabel = new TextLabel("ItemLabel")
{
WidthSpecification = 1272,
HeightSpecification = 40,
- TextColor = UIColors.HEX001447,
PixelSize = 32,
FontFamily = "BreezeSans",
+ HorizontalAlignment = HorizontalAlignment.Begin,
VerticalAlignment = VerticalAlignment.Center,
- IsCreateByXaml = true,
+ FontStyle = UIFontStyles.NormalLight,
Position2D = new Position2D(x, 34),
};
base.Add(titleLabel);
private TextLabel CreateExtraLabel()
{
- TextLabel extraLabel = new TextLabel()
+ TextLabel extraLabel = new TextLabel("ItemLabel")
{
WidthSpecification = 360,
HeightSpecification = 36,
- TextColor = UIColors.HEX001447,
PixelSize = 28,
FontFamily = "BreezeSans",
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.End,
- IsCreateByXaml = true,
+ FontStyle = UIFontStyles.AllNormal,
Position2D = new Position2D((x + 1272 + LayoutPadding), 36)
};
base.Add(extraLabel);
using MusicPlayer.ViewModels;
using Tizen.NUI.Components;
using Tizen.NUI.BaseComponents;
-using Tizen.NUI;
using Tizen.NUI.Binding;
using MusicPlayer.Common;
-using MusicPlayer.Models;
+using MusicPlayer.Views.Utils;
namespace MusicPlayer.Views
{
- class ArtistDetailView : View //BaseContentView
+ class ArtistDetailView : BaseSubContentView
{
- private const int LayoutPadding = 64;
- private const int IconSize = 48;
-
- private BaseView baseView;
- private View contentView;
- private View topView;
- private TextLabel totalCountLabel;
- private Button playAllIcon; // TODO need to implement playall feature
- private Button shuffleAndPlayAllIcon; // TODO need to implement playlist manager
- private CollectionView collectionView;
-
private ArtistDetailViewModel viewModel;
public ArtistDetailView(ArtistDetailViewModel viewModel) : base()
{
this.viewModel = viewModel;
- BindingContext = viewModel;
- BackgroundColor = UIColors.HEXEEEFF1;
- WidthResizePolicy = ResizePolicyType.FillToParent;
- HeightResizePolicy = ResizePolicyType.FillToParent;
+ countLabel.BindingContext = viewModel;
+ countLabel.SetBinding(TextLabel.TextProperty, "TotalCount");
+ UpdateCollectionView();
+ Add(listContainer);
+ }
- //TODO need to change this part after implementation of Command Interface
- baseView = new BaseView()
- {
- Title = viewModel.ArtistName,
- BackButton = true,
- MoreButton = true,
- SearchButton = true,
- BackgroundColor = UIColors.HEXEEEFF1,
- };
- base.Add(baseView);
- contentView = new View()
- {
- WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = 876,
- Layout = new FlexLayout()
- {
- Direction = FlexLayout.FlexDirection.Column,
- Padding = new Extents(LayoutPadding, LayoutPadding, 0, 0),
- },
- };
- baseView.SetContent = contentView;
+ public override void UpdateSubContentMoreButtonItems(Menu moreMenu)
+ {
+ var addtoPlaylist = new MenuItem { Text = "Add to playlist" };
+ addtoPlaylist.Clicked += OnAddToPlaylistClick;
+
+ var share = new MenuItem { Text = "Share" };
+ share.Clicked += OnShareClick;
- topView = CreateTopView();
- AddTitle();
- AddButtons();
- collectionView = AddCollectionView();
+ var delete = new MenuItem { Text = "Delete" };
+ delete.Clicked += OnDeleteClick;
+
+ moreMenu.Items = new MenuItem[] { addtoPlaylist, share, delete };
}
- private void OnTrackSelection(object sender, SelectionChangedEventArgs e)
+ public override void DeleteSubView()
{
-
+ base.DeleteSubView();
+ viewModel.OnViewDeleted();
}
- private Button CreateButton(string url, int x, int y)
+ // TODO this needs to be done in viewmodel
+ protected override void OnPlayAllClicked()
{
- ButtonStyle buttonStyle = new ButtonStyle()
- {
- Icon = new ImageViewStyle()
- {
- ResourceUrl = url,
- },
- IsSelectable = false,
- IsEnabled = true,
- };
+ Tizen.Log.Debug(AppConstants.LogTag, "ArtistDetailView OnPlayAllClicked");
+ base.OnPlayAllClicked();
+ viewModel.PlayAll();
+ }
- Button button = new Button(buttonStyle)
- {
- Size2D = new Size2D(IconSize, IconSize),
- Position2D = new Position2D(x, y),
- };
- return button;
+ protected override void OnPlayAllWithShuffleClicked()
+ {
+ Tizen.Log.Debug(AppConstants.LogTag, "ArtistDetailView OnPlayAllWithShuffleClicked");
+ base.OnPlayAllWithShuffleClicked();
+ viewModel.PlayAllWithShuffle();
}
- private View CreateTopView()
+ private void OnTrackSelection(object sender, SelectionChangedEventArgs e)
{
- View topView = new View()
- {
- BackgroundColor = UIColors.HEXEEEFF1,
- Size2D = new Size2D(Window.Instance.WindowSize.Width - 2 * LayoutPadding, 60),
- };
- contentView.Add(topView);
- return topView;
+ viewModel.PlayCurrent(collectionView.SelectedItem);
}
- private void AddTitle()
+ private void UpdateCollectionView()
{
- totalCountLabel = new TextLabel()
+ collectionView.ItemsLayouter = new LinearLayouter();
+ collectionView.ItemTemplate = new DataTemplate(() =>
{
- Size2D = new Size2D(1624, 36),
- Position2D = new Position2D(0, 12),
- PixelSize = 28,
- Text = "TOTAL COUNT",
- TextColor = UIColors.HEX001447,
- VerticalAlignment = VerticalAlignment.Center,
- FontFamily = "BreezeSans",
- IsCreateByXaml = true,
- };
- topView.Add(totalCountLabel);
- totalCountLabel.SetBinding(TextLabel.TextProperty, "TotalCount");
+ ArtistDetailItemLayout layout = new ArtistDetailItemLayout();
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");
+ layout.ExtraLabel.SetBinding(TextLabel.TextProperty, "Duration");
+ return layout;
+ });
+ collectionView.GroupHeaderTemplate = new DataTemplate(() =>
+ {
+ ArtistDetailGroupLayout group = new ArtistDetailGroupLayout();
+ group.Icon.SetBinding(ImageView.ResourceUrlProperty, "AlbumArtPath");
+ group.TitleLabel.SetBinding(TextLabel.TextProperty, "AlbumName");
+ return group;
+ });
+ collectionView.IsGrouped = true;
+ collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;
+ collectionView.HeightSpecification = LayoutParamPolicies.WrapContent;
+ collectionView.SelectionMode = ItemSelectionMode.Single;
+
+ collectionView.ItemsSource = viewModel.GroupListViewModel;
+ collectionView.SelectionChanged += OnTrackSelection;
}
- private void AddButtons()
+ private void OnDeleteClick(object sender, ClickedEventArgs e)
{
- playAllIcon = CreateButton(Resources.GetImagePath() + "playlist_active.png", Window.Instance.WindowSize.Width - 2 * LayoutPadding - IconSize, 6);
- playAllIcon.Margin = new Extents(40, 0, 0, 0);
- topView.Add(playAllIcon);
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Delete, ContentViewType.Track, viewModel.TrackListViewModel);
+ OnOperationViewAdd(operationEventArgs);
+ }
- shuffleAndPlayAllIcon = CreateButton(Resources.GetImagePath() + "shuffle_on.png", Window.Instance.WindowSize.Width - 2 * LayoutPadding - 2 * IconSize - 40, 6);
- playAllIcon.Margin = new Extents(32, 0, 0, 0);
- topView.Add(shuffleAndPlayAllIcon);
+ private void OnShareClick(object sender, ClickedEventArgs e)
+ {
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Share, ContentViewType.Track, viewModel.TrackListViewModel);
+ OnOperationViewAdd(operationEventArgs);
}
- private CollectionView AddCollectionView()
+ private void OnAddToPlaylistClick(object sender, ClickedEventArgs e)
{
- CollectionView collectionView = new CollectionView()
- {
- Size2D = new Size2D(1792, 108),
- BackgroundImage = Resources.GetImagePath() + "list_view_bg.png",
- ItemsLayouter = new LinearLayouter(),
- ItemTemplate = new DataTemplate(() =>
- {
- ArtistDetailItemLayout layout = new ArtistDetailItemLayout();
- layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");
- layout.ExtraLabel.SetBinding(TextLabel.TextProperty, "Duration");
- return layout;
- }),
- GroupHeaderTemplate = new DataTemplate(() =>
- {
- ArtistDetailGroupLayout group = new ArtistDetailGroupLayout();
- group.Icon.SetBinding(ImageView.ResourceUrlProperty, "AlbumArtPath");
- group.TitleLabel.SetBinding(TextLabel.TextProperty, "AlbumName");
- return group;
- }),
- IsGrouped = true,
- ScrollingDirection = ScrollableBase.Direction.Vertical,
- HeightSpecification = LayoutParamPolicies.WrapContent,
- SelectionMode = ItemSelectionMode.Single,
- };
- contentView.Add(collectionView);
- FlexLayout.SetFlexGrow(collectionView, 1);
- FlexLayout.SetFlexShrink(collectionView, 1);
- collectionView.ItemsSource = viewModel.GroupListViewModel;
- collectionView.SelectionChanged += OnTrackSelection;
- return collectionView;
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.AddToPlaylist, ContentViewType.Track, viewModel.TrackListViewModel);
+ OnOperationViewAdd(operationEventArgs);
}
}
}
using Tizen.NUI.Binding;
using MusicPlayer.Common;
using MusicPlayer.Models;
+using MusicPlayer.Views.Utils;
namespace MusicPlayer.Views
{
public ArtistView(ArtistViewModel viewModel)
{
this.viewModel = viewModel;
- BindingContext = viewModel;
collectionView.ItemsSource = viewModel.ListViewModel;
collectionView.ItemTemplate = new DataTemplate(() =>
{
return layout;
});
collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;
- collectionView.WidthSpecification = LayoutParamPolicies.WrapContent;
+ collectionView.WidthSpecification = LayoutParamPolicies.MatchParent;
+ collectionView.HeightSpecification = LayoutParamPolicies.WrapContent;
collectionView.SelectionMode = ItemSelectionMode.Single;
collectionView.SelectionChanged += OnArtistSelection;
- artistCountLabel = new TextLabel()
+ artistCountLabel = new TextLabel("LabelText")
{
+ ThemeChangeSensitive = true,
PixelSize = 28,
Text = "ARTIST COUNT",
- TextColor = UIColors.HEX001447,
+ HorizontalAlignment = HorizontalAlignment.Begin,
VerticalAlignment = VerticalAlignment.Center,
FontFamily = "BreezeSans",
- IsCreateByXaml = true,
+ FontStyle = UIFontStyles.AllNormal,
};
+ artistCountLabel.BindingContext = viewModel;
titleView.Add(artistCountLabel);
artistCountLabel.SetBinding(TextLabel.TextProperty, "ArtistCount");
RelativeLayout.SetLeftTarget(artistCountLabel, titleView);
RelativeLayout.SetRightRelativeOffset(artistCountLabel, 0.0f);
RelativeLayout.SetFillHorizontal(artistCountLabel, true);
}
- private void OnArtistSelection(object sender, SelectionChangedEventArgs e)
+
+ protected override void UpdateContentMoreButtonItems(Menu moreMenu)
{
- Artist currentArtist = (Artist)collectionView.SelectedItem;
- ArtistDetailView view = new ArtistDetailView(viewModel.getDetailViewModel(currentArtist));
- Window.Instance.Add(view);
+ var addToPlaylist = new MenuItem { Text = "Add to Playlist" };
+ addToPlaylist.Clicked += OnAddToPlaylistClick;
+ var delete = new MenuItem { Text = "Delete" };
+ delete.Clicked += OnDeleteClick;
+
+ moreMenu.Items = new MenuItem[] { addToPlaylist, delete };
}
+
protected override void Dispose(DisposeTypes type)
{
if (Disposed)
}
base.Dispose(type);
}
+
+ private void OnArtistSelection(object sender, SelectionChangedEventArgs e)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "Artist Selection Started");
+ Artist currentArtist = (Artist)collectionView.SelectedItem;
+ SubContentViewAddEventArgs artistDetailViewArgs = new SubContentViewAddEventArgs(SubContentViewType.ArtistDetails, currentArtist.ArtistName, currentArtist);
+ OnSubViewAdd(artistDetailViewArgs);
+ Tizen.Log.Error(AppConstants.LogTag, "Artist Selection Ended");
+ }
+
+ private void OnDeleteClick(object sender, ClickedEventArgs e)
+ {
+ DismissMoreMenu();
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Delete, ContentViewType.Artist, viewModel.ListViewModel);
+ OnOperationViewAdd(operationEventArgs);
+ }
+
+ private void OnAddToPlaylistClick(object sender, ClickedEventArgs e)
+ {
+ DismissMoreMenu();
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.AddToPlaylist, ContentViewType.Artist, viewModel.ListViewModel);
+ //OnOperationViewAdd(operationEventArgs);
+ }
+
}
}
\ No newline at end of file
-using MusicPlayer.Common;\r
+using System;\r
using Tizen.NUI;\r
using Tizen.NUI.BaseComponents;\r
using Tizen.NUI.Components;\r
+using MusicPlayer.Common;\r
+using MusicPlayer.Views.Utils;\r
\r
namespace MusicPlayer.Views\r
{\r
- class BaseContentView : View\r
+ class BaseContentView : View, IViewStatus, IMoreButtonItems\r
{\r
+ protected BaseSubContentView subcontentView;\r
protected View titleView;\r
protected CollectionView collectionView;\r
+ protected View subContentViewContainer;\r
+ protected View contentViewContainer;\r
+\r
+ protected Menu moreMenu = null;\r
+\r
+ public event EventHandler<SubContentViewAddEventArgs> SubContentViewAdded;\r
+\r
+ public event EventHandler<OperationViewAddEventArgs> OperationViewAdded;\r
+\r
public BaseContentView() : base()\r
{\r
ThemeChangeSensitive = true;\r
WidthResizePolicy = ResizePolicyType.FillToParent;\r
HeightResizePolicy = ResizePolicyType.FillToParent;\r
- Layout = new FlexLayout()\r
+ contentViewContainer = new View()\r
{\r
- Direction = FlexLayout.FlexDirection.Column,\r
- Padding = new Extents(64, 64, 0, 0),\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ HeightResizePolicy = ResizePolicyType.FillToParent,\r
+ HeightSpecification = LayoutParamPolicies.MatchParent,\r
+ WidthSpecification = LayoutParamPolicies.MatchParent,\r
+ Layout = new FlexLayout()\r
+ {\r
+ Direction = FlexLayout.FlexDirection.Column,\r
+ Padding = new Extents(64, 64, 0, 0),\r
+ },\r
};\r
+ base.Add(contentViewContainer);\r
+\r
titleView = new View()\r
{\r
ThemeChangeSensitive = true,\r
HeightSpecification = 60,\r
Layout = new RelativeLayout()\r
{\r
- Padding = new Extents(0, 0, 13, 13),\r
+ Padding = new Extents(0, 0, 6, 6),\r
},\r
};\r
- base.Add(titleView);\r
+ contentViewContainer.Add(titleView);\r
FlexLayout.SetFlexGrow(titleView, 0);\r
FlexLayout.SetFlexShrink(titleView, 0);\r
\r
HeightSpecification = LayoutParamPolicies.WrapContent,\r
SelectionMode = ItemSelectionMode.Single,\r
};\r
- base.Add(collectionView);\r
+ contentViewContainer.Add(collectionView);\r
FlexLayout.SetFlexGrow(collectionView, 1);\r
FlexLayout.SetFlexShrink(collectionView, 1);\r
+\r
+ subContentViewContainer = new View()\r
+ {\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ HeightResizePolicy = ResizePolicyType.FillToParent,\r
+ };\r
+ base.Add(subContentViewContainer);\r
+ subContentViewContainer.Hide();\r
+ subcontentView = null;\r
}\r
\r
- private string GetBackgroundImagePath(string platformThemeId)\r
+ public void AddSubContentView(BaseSubContentView baseSubContentView)\r
{\r
- if(platformThemeId.Equals(AppConstants.DarkPlatformThemeId))\r
+ if (baseSubContentView == null)\r
{\r
- return Resources.GetImagePath() + "dark/list_view_bg.png";\r
+ Tizen.Log.Error(AppConstants.LogTag, "SubContentView object is null");\r
+ return;\r
}\r
- else\r
+ if(subcontentView != null)\r
{\r
- return Resources.GetImagePath() + "light/list_view_bg.png";\r
+ Tizen.Log.Error(AppConstants.LogTag, "subcontent view already added , remove it first");\r
+ return;\r
+ }\r
+ subContentViewContainer.Show();\r
+ subContentViewContainer.Add(baseSubContentView);\r
+ subcontentView = baseSubContentView;\r
+ subcontentView.SubContentOperationViewAdd += OnSubContentOperationViewAdd;\r
+ }\r
+\r
+ public void RemoveSubContentView()\r
+ {\r
+ if (subcontentView == null)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "SubContentView object is null");\r
+ return;\r
+ }\r
+ subContentViewContainer.Remove(subcontentView);\r
+ subContentViewContainer.Hide();\r
+ subcontentView.SubContentOperationViewAdd -= OnSubContentOperationViewAdd;\r
+ subcontentView.DeleteSubView();\r
+ subcontentView = null;\r
+ }\r
+\r
+ public virtual void ShowView()\r
+ {\r
+ titleView.Show();\r
+ collectionView.Show();\r
+ contentViewContainer.Show();\r
+ Show();\r
+ }\r
+\r
+ public virtual void HideView()\r
+ {\r
+ titleView.Hide();\r
+ collectionView.Hide();\r
+ contentViewContainer.Hide();\r
+ Hide();\r
+ }\r
+\r
+ public void UpdateButtonMoreItems(Menu moreMenu)\r
+ {\r
+ this.moreMenu = moreMenu;\r
+ if(subcontentView != null)\r
+ {\r
+ subcontentView.UpdateSubContentMoreButtonItems(moreMenu);\r
+ return;\r
}\r
+ UpdateContentMoreButtonItems(moreMenu);\r
+ }\r
+\r
+ protected virtual void UpdateContentMoreButtonItems(Menu moreMenu)\r
+ {\r
+\r
+ }\r
+\r
+ protected void DismissMoreMenu()\r
+ {\r
+ if (moreMenu == null)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Moremenu object is null");\r
+ return;\r
+ }\r
+ moreMenu.Dismiss();\r
+ moreMenu = null;\r
+ }\r
+\r
+ protected void OnSubViewAdd(SubContentViewAddEventArgs args)\r
+ {\r
+ SubContentViewAdded?.Invoke(this, args);\r
+ }\r
+\r
+ protected void OnOperationViewAdd(OperationViewAddEventArgs args)\r
+ {\r
+ OperationViewAdded?.Invoke(this, args);\r
}\r
\r
protected override void OnThemeChanged(object sender, ThemeChangedEventArgs e)\r
{\r
if (type == DisposeTypes.Explicit)\r
{\r
- base.Remove(titleView);\r
+ base.Remove(contentViewContainer);\r
+ contentViewContainer.Remove(titleView);\r
titleView.Dispose();\r
titleView = null;\r
\r
- base.Remove(collectionView);\r
+ contentViewContainer.Remove(collectionView);\r
collectionView.Dispose();\r
collectionView = null;\r
+\r
+ contentViewContainer.Dispose();\r
+ contentViewContainer = null;\r
+\r
+ base.Remove(subContentViewContainer);\r
+ subContentViewContainer.Dispose();\r
+ subContentViewContainer = null;\r
+\r
+ subcontentView = null;\r
+\r
+ moreMenu?.Dismiss();\r
+ moreMenu = null;\r
}\r
base.Dispose(type);\r
}\r
+\r
+ private string GetBackgroundImagePath(string platformThemeId)\r
+ {\r
+ if (platformThemeId.Equals(AppConstants.DarkPlatformThemeId))\r
+ {\r
+ return Resources.GetImagePath() + "dark/list_view_bg.png";\r
+ }\r
+ else\r
+ {\r
+ return Resources.GetImagePath() + "light/list_view_bg.png";\r
+ }\r
+ }\r
+ private void OnSubContentOperationViewAdd(object sender, OperationViewAddEventArgs e)\r
+ {\r
+ DismissMoreMenu();\r
+ OnOperationViewAdd(e);\r
+ }\r
}\r
}\r
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using Tizen.NUI;
+using MusicPlayer.Views.Utils;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Views
+{
+ class BaseSubContentView : View, ISubViewStatus
+ {
+ protected View listContainer;
+ protected View topView;
+ protected TextLabel countLabel;
+ protected Button playAll;
+ protected Button playAllWithShuffle;
+ protected CollectionView collectionView;
+
+ public event EventHandler<OperationViewAddEventArgs> SubContentOperationViewAdd;
+
+ public BaseSubContentView():base()
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "BaseSubContentView Enter ==>");
+ WidthResizePolicy = ResizePolicyType.FillToParent;
+ HeightResizePolicy = ResizePolicyType.FillToParent;
+ StyleName = "AppBackground";
+
+ listContainer = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ LinearAlignment = LinearLayout.Alignment.Top,
+ Padding = new Extents(64, 64, 0, 0),
+ },
+ BackgroundColor = Color.Transparent,
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ HeightResizePolicy = ResizePolicyType.FillToParent,
+ //HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ topView = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 60,
+ Layout = new RelativeLayout()
+ {
+ Padding = new Extents(0, 0, 6, 6),
+ },
+ };
+ listContainer.Add(topView);
+
+ countLabel = new TextLabel("LabelText")
+ {
+ ThemeChangeSensitive = true,
+ PixelSize = 28,
+ Text = "TRACK COUNT",
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ VerticalAlignment = VerticalAlignment.Center,
+ FontFamily = "BreezeSans",
+ FontStyle = UIFontStyles.AllNormal,
+ };
+ topView.Add(countLabel);
+ RelativeLayout.SetLeftTarget(countLabel, topView);
+ RelativeLayout.SetLeftRelativeOffset(countLabel, 0.0f);
+ RelativeLayout.SetRightRelativeOffset(countLabel, 0.0f);
+ RelativeLayout.SetFillHorizontal(countLabel, true);
+
+ playAll = new Button("PlayAll")
+ {
+ ThemeChangeSensitive = true,
+ };
+ topView.Add(playAll);
+ playAll.Clicked += (object sender, ClickedEventArgs e) =>
+ {
+ OnPlayAllClicked();
+ };
+ RelativeLayout.SetLeftRelativeOffset(playAll, 1.0f);
+ RelativeLayout.SetRightRelativeOffset(playAll, 1.0f);
+ RelativeLayout.SetHorizontalAlignment(playAll, RelativeLayout.Alignment.End);
+
+ playAllWithShuffle = new Button("ShuffleButton")
+ {
+ ThemeChangeSensitive = true,
+ Margin = new Extents(32, 40, 0, 0),
+ };
+ topView.Add(playAllWithShuffle);
+ playAllWithShuffle.Clicked += (object sender, ClickedEventArgs e) =>
+ {
+ OnPlayAllWithShuffleClicked();
+ };
+ RelativeLayout.SetRightTarget(playAllWithShuffle, playAll);
+ RelativeLayout.SetRightRelativeOffset(playAllWithShuffle, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(playAllWithShuffle, RelativeLayout.Alignment.End);
+
+ collectionView = new CollectionView()
+ {
+ ThemeChangeSensitive = true,
+ //Size2D = new Size2D(1792, 108),
+ Margin = new Extents(0, 0, 0, 2),
+ BackgroundImage = GetBackgroundImagePath(ThemeManager.PlatformThemeId),
+ ItemsLayouter = new LinearLayouter(),
+ ScrollingDirection = ScrollableBase.Direction.Vertical,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ SelectionMode = ItemSelectionMode.Single,
+ };
+ listContainer.Add(collectionView);
+ Tizen.Log.Error(AppConstants.LogTag, "BaseSubContentView Exit <==");
+ }
+
+ public virtual void UpdateSubContentMoreButtonItems(Menu moreMenu)
+ {
+
+ }
+
+ public virtual void DeleteSubView()
+ {
+ Dispose(DisposeTypes.Explicit);
+ }
+
+ protected void OnOperationViewAdd(OperationViewAddEventArgs eventArgs)
+ {
+ SubContentOperationViewAdd?.Invoke(this, eventArgs);
+ }
+
+ protected virtual void OnPlayAllClicked()
+ {
+
+ }
+
+ protected virtual void OnPlayAllWithShuffleClicked()
+ {
+
+ }
+
+ private string GetBackgroundImagePath(string platformThemeId)
+ {
+ if (platformThemeId.Equals(AppConstants.DarkPlatformThemeId))
+ {
+ return Resources.GetImagePath() + "dark/list_view_bg.png";
+ }
+ else
+ {
+ return Resources.GetImagePath() + "light/list_view_bg.png";
+ }
+ }
+
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (type == DisposeTypes.Explicit)
+ {
+ topView.Remove(countLabel);
+ topView.Remove(playAllWithShuffle);
+ topView.Remove(playAll);
+
+ listContainer.Remove(topView);
+ listContainer.Remove(collectionView);
+
+ countLabel.Dispose();
+ countLabel = null;
+ playAllWithShuffle.Dispose();
+ playAllWithShuffle = null;
+ playAll.Dispose();
+ playAll = null;
+ topView.Dispose();
+ topView = null;
+ collectionView.Dispose();
+ collectionView = null;
+ listContainer.Dispose();
+ listContainer = null;
+ }
+ base.Dispose(type);
+ }
+ }
+}
private Button moreButton;\r
private Button searchButton;\r
private Tab tabs;\r
+ private BaseContentView baseContentView;\r
\r
// TODO these name strings are temporary...once the po files are added\r
// need to use Translatable names.\r
base.Add(topView);\r
FlexLayout.SetFlexGrow(topView, 0);\r
FlexLayout.SetFlexShrink(topView, 0);\r
- titleLabel = new TextLabel()\r
+ titleLabel = new TextLabel("PageLabel")\r
{\r
ThemeChangeSensitive = true,\r
Text = "Music",\r
PixelSize = 40,\r
FontFamily = "BreezeSans",\r
- TextColor = UIColors.HEX000209,\r
HorizontalAlignment = HorizontalAlignment.Begin,\r
- Margin = new Extents(0, 0, 6, 6),\r
+ VerticalAlignment = VerticalAlignment.Center,\r
Ellipsis = true,\r
+ FontStyle = UIFontStyles.NormalLight,\r
};\r
topView.Add(titleLabel);\r
titleLabel.SetBinding(TextLabel.TextProperty, "Title");\r
{\r
if (value)\r
{\r
- ButtonStyle buttonStyle = new ButtonStyle()\r
+ if (backButton == null)\r
{\r
- Icon = new ImageViewStyle()\r
+ backButton = new Button("BackButton")\r
{\r
- ResourceUrl = Resources.GetImagePath() + "back_button.png",\r
- },\r
- IsSelectable = false,\r
- IsEnabled = true,\r
- };\r
+ ThemeChangeSensitive = true,\r
+ Size2D = new Size2D(48, 48),\r
+ Margin = new Extents(0, 24, 6, 6),\r
+ };\r
\r
- backButton = new Button(buttonStyle)\r
- {\r
- ThemeChangeSensitive = true,\r
- Size2D = new Size2D(48, 48),\r
- Margin = new Extents(0, 24, 6, 6),\r
- };\r
+ backButton.Clicked += OnBackButtonClicked;\r
+ }\r
topView.Add(backButton);\r
-\r
+ backButton.Show();\r
RelativeLayout.SetLeftRelativeOffset(backButton, 0.0f);\r
RelativeLayout.SetRightRelativeOffset(backButton, 0.0f);\r
RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start);\r
RelativeLayout.SetLeftTarget(titleLabel, backButton);\r
RelativeLayout.SetLeftRelativeOffset(titleLabel, 1.0f);\r
}\r
+ else\r
+ {\r
+ if(backButton)\r
+ {\r
+ topView.Remove(backButton);\r
+ backButton.Hide();\r
+ RelativeLayout.SetLeftTarget(titleLabel, topView);\r
+ RelativeLayout.SetLeftRelativeOffset(titleLabel, 0.0f);\r
+ }\r
+ }\r
+ Tizen.Log.Error(AppConstants.LogTag, "BackButton Exit <==");\r
}\r
}\r
\r
{\r
set\r
{\r
- if (value)\r
+ moreButton = new Button("MoreButton")\r
{\r
- ButtonStyle buttonStyle = new ButtonStyle()\r
- {\r
- Icon = new ImageViewStyle()\r
- {\r
- ResourceUrl = Resources.GetImagePath() + "more.png",\r
- },\r
- IsSelectable = false,\r
- IsEnabled = true,\r
- };\r
- moreButton = new Button(buttonStyle)\r
- {\r
- ThemeChangeSensitive = true,\r
- Size2D = new Size2D(48, 48),\r
- Margin = new Extents(32, 0, 6, 6),\r
- };\r
- topView.Add(moreButton);\r
- RelativeLayout.SetLeftRelativeOffset(moreButton, 1.0f);\r
- RelativeLayout.SetRightRelativeOffset(moreButton, 1.0f);\r
- RelativeLayout.SetHorizontalAlignment(moreButton, RelativeLayout.Alignment.End);\r
+ ThemeChangeSensitive = true,\r
+ Margin = new Extents(32, 0, 6, 6),\r
+ };\r
+ topView.Add(moreButton);\r
+ RelativeLayout.SetLeftRelativeOffset(moreButton, 1.0f);\r
+ RelativeLayout.SetRightRelativeOffset(moreButton, 1.0f);\r
+ RelativeLayout.SetHorizontalAlignment(moreButton, RelativeLayout.Alignment.End);\r
\r
- RelativeLayout.SetRightTarget(titleLabel, moreButton);\r
- RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f);\r
- }\r
+ RelativeLayout.SetRightTarget(titleLabel, moreButton);\r
+ RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f);\r
+ moreButton.Clicked += OnMoreButtonClicked;\r
}\r
}\r
\r
}\r
}\r
\r
- public View SetContent\r
+ public Button GetSearchButton()\r
{\r
- set\r
+ return searchButton;\r
+ }\r
+\r
+ public void SetContent(BaseContentView view)\r
+ {\r
+ if(view == null)\r
{\r
- contentView.Add(value);\r
+ Tizen.Log.Error(AppConstants.LogTag, "BaseContentView is null, provide correct object");\r
+ return;\r
+ }\r
+\r
+ if(baseContentView != null)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "ContentView is already added, remove it first");\r
+ return;\r
+ }\r
+ BackButton = false;\r
+ Title = "Music";\r
+ contentView.Add(view);\r
+ baseContentView = view;\r
+ }\r
+\r
+ public void RemoveContent(BaseContentView view)\r
+ {\r
+ if(view == null)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "BaseContentView is null, provide correct object");\r
+ return;\r
+ }\r
+ contentView.Remove(view);\r
+ baseContentView = null;\r
+ }\r
+\r
+ public void AddSubViewContent(string titleText, BaseSubContentView subContentView)\r
+ {\r
+ if(baseContentView != null)\r
+ {\r
+ baseContentView.AddSubContentView(subContentView);\r
+ BackButton = true;\r
+ Title = titleText;\r
}\r
}\r
\r
\r
base.Dispose(type);\r
}\r
+\r
+ private void RemoveSubViewContent()\r
+ {\r
+ if (baseContentView != null)\r
+ {\r
+ BackButton = false;\r
+ Title = "Music";\r
+ baseContentView.RemoveSubContentView();\r
+ }\r
+ }\r
+\r
+ private void OnBackButtonClicked(object sender, ClickedEventArgs e)\r
+ {\r
+ RemoveSubViewContent();\r
+ }\r
+\r
+ private Menu CreateMenu()\r
+ {\r
+ Menu moreMenu = new Menu()\r
+ {\r
+ Anchor = moreButton,\r
+ HorizontalPositionToAnchor = Menu.RelativePosition.End,\r
+ VerticalPositionToAnchor = Menu.RelativePosition.End,\r
+ };\r
+ return moreMenu;\r
+ }\r
+\r
+ private void OnMoreButtonClicked(object sender, ClickedEventArgs e)\r
+ {\r
+ Menu moreMenu = CreateMenu();\r
+ if(baseContentView != null)\r
+ {\r
+ baseContentView.UpdateButtonMoreItems(moreMenu);\r
+ moreMenu.Post();\r
+ }\r
+ else\r
+ {\r
+ moreMenu.Dismiss();\r
+ }\r
+ }\r
}\r
}
\ No newline at end of file
PixelSize = 32,\r
FontFamily = "BreezeSans",\r
VerticalAlignment = VerticalAlignment.Center,\r
- IsCreateByXaml = true,\r
Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin),\r
};\r
- // ToDo need to make this a readonly const\r
- PropertyMap titleFontStyle = new PropertyMap();\r
- titleFontStyle.Add("width", new PropertyValue("normal"));\r
- titleFontStyle.Add("weight", new PropertyValue("light"));\r
- titleLabel.FontStyle = titleFontStyle;\r
+ titleLabel.FontStyle = UIFontStyles.NormalLight;\r
base.Add(titleLabel);\r
\r
subtitleLabel = new TextLabel("ItemLabel")\r
PixelSize = 28,\r
FontFamily = "BreezeSans",\r
VerticalAlignment = VerticalAlignment.Center,\r
- IsCreateByXaml = true,\r
Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin + 40)\r
};\r
- // ToDo need to make this a readonly const\r
- PropertyMap subtitleFontStyle = new PropertyMap();\r
- subtitleFontStyle.Add("width", new PropertyValue("normal"));\r
- subtitleFontStyle.Add("weight", new PropertyValue("normal"));\r
- subtitleFontStyle.Add("slant", new PropertyValue("normal"));\r
- subtitleLabel.FontStyle = subtitleFontStyle;\r
+ subtitleLabel.FontStyle = UIFontStyles.AllNormal;\r
base.Add(subtitleLabel);\r
IsCreateByXaml = true;\r
}\r
-using Tizen.NUI;
+using System;
+using Tizen.NUI;
using Tizen.Multimedia;
using Tizen.NUI.Components;
using Tizen.NUI.BaseComponents;
namespace MusicPlayer.Views
{
- class PlayerView : View
+ class PlayerView : View, IViewStatus
{
private enum PlayerViewState
{
AddLyricsView();
}
+ public void ShowView()
+ {
+ Show();
+ }
+
+ public void HideView()
+ {
+ Hide();
+ }
+
private void AddPlayerBackground()
{
playerBackgroundView = new View();
backButton.ThemeChangeSensitive = true;
backButton.Position2D = new Position2D(LayoutPadding, TopBarButtonsY);
leftView.Add(backButton);
+ backButton.Clicked += (object sender, ClickedEventArgs clickedEventArgs) =>
+ {
+ Unparent();
+ HideView();
+ };
moreButton = new Button("MoreButton");
moreButton.ThemeChangeSensitive = true;
}
},
};
- favouriteButton.CusotmState = Favourite.Off.ToString();
+ favouriteButton.BindingContext = viewModel;
+ favouriteButton.SetBinding(MultiStateButton.CustomStateProperty, "FavouriteButtonState");
actionButtonView.Add(favouriteButton);
+ favouriteButton.Clicked += (object sender, ClickedEventArgs e) =>
+ {
+ viewModel.FavouriteStatusChanged();
+ };
}
private void AddThumbnail()
};
base.Add(collectionView);
viewModel.ItemsSourceChanged += ItemSourceChanged;
+ collectionView.SelectionChanged += OnItemSelected;
+ }
+
+ private void OnItemSelected(object sender, SelectionChangedEventArgs e)
+ {
+ viewModel.OnItemSelected(collectionView.SelectedItem);
}
private void ItemSourceChanged(object sender, EventArgs e)
--- /dev/null
+using System;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Components;
+using MusicPlayer.Common;
+using MusicPlayer.ViewModels;
+using MusicPlayer.Views.Utils;
+
+namespace MusicPlayer.Views
+{
+ class PlaylistDetailView : BaseSubContentView
+ {
+ private PlaylistDetailViewModel viewModel;
+
+ public PlaylistDetailView(PlaylistDetailViewModel playlistViewModel)
+ {
+ viewModel = playlistViewModel;
+ collectionView.ItemsSource = viewModel.ListViewModel;
+ collectionView.ItemTemplate = new DataTemplate(() =>
+ {
+ ListItemLayout layout = new ListItemLayout();
+ layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");
+ layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");
+ return layout;
+ });
+ collectionView.SelectionChanged += OnTrackSelection;
+ countLabel.BindingContext = viewModel;
+ countLabel.SetBinding(TextLabel.TextProperty, "PlaylistTrackCount");
+ Add(listContainer);
+ }
+
+ public override void DeleteSubView()
+ {
+ base.DeleteSubView();
+ viewModel.OnViewDeleted();
+ }
+
+ public override void UpdateSubContentMoreButtonItems(Menu moreMenu)
+ {
+ var share = new MenuItem { Text = "Share" };
+ share.Clicked += OnShareClick;
+
+ var delete = new MenuItem { Text = "Delete" };
+ delete.Clicked += OnDeleteClick;
+
+ moreMenu.Items = new MenuItem[] { share, delete };
+ }
+
+ protected override void OnPlayAllClicked()
+ {
+ Tizen.Log.Debug(AppConstants.LogTag, "PlaylistDetailView OnPlayAllClicked");
+ base.OnPlayAllClicked();
+ viewModel.PlayAll();
+ }
+
+ protected override void OnPlayAllWithShuffleClicked()
+ {
+ Tizen.Log.Debug(AppConstants.LogTag, "PlaylistDetailView OnPlayAllWithShuffleClicked");
+ base.OnPlayAllWithShuffleClicked();
+ viewModel.PlayAllWithShuffle();
+ }
+
+ private void OnTrackSelection(object sender, SelectionChangedEventArgs e)
+ {
+ viewModel.PlayCurrent(collectionView.SelectedItem);
+ }
+
+ private void OnDeleteClick(object sender, ClickedEventArgs e)
+ {
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Delete, ContentViewType.Track, viewModel.ListViewModel);
+ OnOperationViewAdd(operationEventArgs);
+ }
+
+ private void OnShareClick(object sender, ClickedEventArgs e)
+ {
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Share, ContentViewType.Track, viewModel.ListViewModel);
+ OnOperationViewAdd(operationEventArgs);
+ }
+
+ }
+}
--- /dev/null
+using Tizen.NUI;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using MusicPlayer.Models;
+using MusicPlayer.ViewModels;
+using MusicPlayer.Common;
+using MusicPlayer.Views.Utils;
+using System.Collections.Generic;
+
+namespace MusicPlayer.Views
+{
+ class PlaylistView : BaseContentView
+ {
+ private TextLabel playlistCountLabel;
+ private Button playlistCreateButton;
+ private PlaylistViewModel viewModel;
+
+ public PlaylistView(PlaylistViewModel viewModel)
+ {
+ Name = "PlaylistView";
+ this.viewModel = viewModel;
+ collectionView.ItemsSource = viewModel.ListViewModel;
+ collectionView.ItemTemplate = new DataTemplate(() =>
+ {
+ ListItemLayout layout = new ListItemLayout();
+ layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "PlaylistThumbnailPath");
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "PlaylistName");
+ layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "PlaylistTrackCount");
+ return layout;
+ });
+ collectionView.SelectionChanged += OnPlaylistSelectionChange;
+
+ playlistCountLabel = new TextLabel("LabelText")
+ {
+ ThemeChangeSensitive = true,
+ PixelSize = 28,
+ Text = "Playlist COUNT",
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ VerticalAlignment = VerticalAlignment.Center,
+ FontFamily = "BreezeSans",
+ FontStyle = UIFontStyles.AllNormal,
+ };
+ playlistCountLabel.BindingContext = viewModel;
+ titleView.Add(playlistCountLabel);
+ playlistCountLabel.SetBinding(TextLabel.TextProperty, "PlaylistCount");
+ RelativeLayout.SetLeftTarget(playlistCountLabel, titleView);
+ RelativeLayout.SetLeftRelativeOffset(playlistCountLabel, 0.0f);
+ RelativeLayout.SetFillHorizontal(playlistCountLabel, true);
+ RelativeLayout.SetHorizontalAlignment(playlistCountLabel, RelativeLayout.Alignment.Start);
+
+ playlistCreateButton = new Button("PlaylistAdd")
+ {
+ ThemeChangeSensitive = true,
+ Margin = new Extents(40, 0, 0, 0),
+ };
+ titleView.Add(playlistCreateButton);
+ RelativeLayout.SetLeftRelativeOffset(playlistCreateButton, 1.0f);
+ RelativeLayout.SetRightRelativeOffset(playlistCreateButton, 1.0f);
+ RelativeLayout.SetHorizontalAlignment(playlistCreateButton, RelativeLayout.Alignment.End);
+
+ RelativeLayout.SetRightTarget(playlistCountLabel, playlistCreateButton);
+ RelativeLayout.SetRightRelativeOffset(playlistCountLabel, 0.0f);
+
+ playlistCreateButton.Clicked += OnPlaylistCreate;
+ }
+
+ protected override void UpdateContentMoreButtonItems(Menu moreMenu)
+ {
+ var delete = new MenuItem { Text = "Delete" };
+ delete.Clicked += OnDeleteClick;
+ moreMenu.Items = new MenuItem[] { delete };
+ }
+
+ private void OnPlaylistCreate(object sender, ClickedEventArgs e)
+ {
+ CreatePlaylistPopup();
+ }
+
+ private void OnPlaylistSelectionChange(object sender, SelectionChangedEventArgs e)
+ {
+ PlaylistModel playlistModel = (PlaylistModel)collectionView.SelectedItem;
+ SubContentViewAddEventArgs playlistDetailViewArgs = new SubContentViewAddEventArgs(SubContentViewType.PlaylistDetails, playlistModel.PlaylistName, playlistModel.PlaylistId);
+ OnSubViewAdd(playlistDetailViewArgs);
+ }
+
+ private void CreatePlaylistPopup()
+ {
+ TextLabel titleLabel = new TextLabel("LabelText")
+ {
+ ThemeChangeSensitive = true,
+ PixelSize = 40,
+ FontFamily = "BreezeSans",
+ FontStyle = UIFontStyles.AllNormal,
+ Text = "Create playlist",
+ };
+
+ View contentArea = new View()
+ {
+ SizeHeight = 144,
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ BackgroundColor = Color.Transparent,
+ };
+
+ TextLabel contentLabel = new TextLabel("LabelText")
+ {
+ ThemeChangeSensitive = true,
+ PixelSize = 32,
+ FontFamily = "BreezeSans",
+ FontStyle = UIFontStyles.NormalLight,
+ Text = "Allow AMAN to mirror on this device",
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ PositionY = 40,
+ };
+ contentArea.Add(contentLabel);
+
+ Button cancelbutton = new Button("CancelButton")
+ {
+ ThemeChangeSensitive = true,
+ };
+ cancelbutton.TextLabel.FontStyle = UIFontStyles.AllNormal;
+ //cancelbutton.Clicked += OnCanelClicked;
+
+ Button allowButton = new Button()
+ {
+ Text = "Allow",
+ };
+ //allowButton.Clicked += OnAllowClicked;
+
+ AlertDialog alertDialog = new AlertDialog()
+ {
+ TitleContent = titleLabel,
+ Content = contentArea,
+ Actions = new List<View> { cancelbutton, allowButton },
+ };
+ Window.Instance.Add(alertDialog);
+ }
+
+ private void OnDeleteClick(object sender, ClickedEventArgs e)
+ {
+ DismissMoreMenu();
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Delete, ContentViewType.Playlist, viewModel.UserPlaylistViewModel);
+ OnOperationViewAdd(operationEventArgs);
+ }
+ }
+}
-using MusicPlayer.ViewModels;\r
-using Tizen.NUI.Components;\r
-using Tizen.NUI.BaseComponents;\r
-using Tizen.NUI;\r
+using Tizen.NUI;\r
using Tizen.NUI.Binding;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI.Components;\r
using MusicPlayer.Common;\r
+using MusicPlayer.ViewModels;\r
+using MusicPlayer.Views.Utils;\r
\r
namespace MusicPlayer.Views\r
{\r
{\r
private TrackViewModel viewModel;\r
private TextLabel trackCountLabel;\r
- private Button playAllIcon; // TODO need to implement playall feature\r
- private Button addToPlaylistIcon; // TODO need to implement playlist manager\r
- public TrackView(TrackViewModel viewModel)\r
+ private Button playAllWithShuffle;\r
+ private Button playAll;\r
+\r
+ public TrackView(TrackViewModel viewModel) : base()\r
{\r
+ Name = "TrackView";\r
this.viewModel = viewModel;\r
collectionView.ItemsSource = viewModel.ListViewModel;\r
collectionView.ItemTemplate = new DataTemplate(() =>\r
return layout;\r
});\r
collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;\r
- collectionView.WidthSpecification = LayoutParamPolicies.WrapContent;\r
+ //collectionView.WidthSpecification = LayoutParamPolicies.WrapContent;\r
collectionView.SelectionMode = ItemSelectionMode.Single;\r
collectionView.SelectionChanged += OnTrackSelection;\r
\r
ThemeChangeSensitive = true,\r
PixelSize = 28,\r
Text = "TRACK COUNT",\r
+ HorizontalAlignment = HorizontalAlignment.Begin,\r
VerticalAlignment = VerticalAlignment.Center,\r
FontFamily = "BreezeSans",\r
+ FontStyle = UIFontStyles.AllNormal,\r
};\r
trackCountLabel.BindingContext = viewModel;\r
titleView.Add(trackCountLabel);\r
trackCountLabel.SetBinding(TextLabel.TextProperty, "TrackCount");\r
RelativeLayout.SetLeftTarget(trackCountLabel, titleView);\r
- RelativeLayout.SetLeftRelativeOffset(trackCountLabel, 1.0f);\r
- RelativeLayout.SetRightRelativeOffset(trackCountLabel, 0.0f);\r
+ RelativeLayout.SetLeftRelativeOffset(trackCountLabel, 0.0f);\r
RelativeLayout.SetFillHorizontal(trackCountLabel, true);\r
\r
- playAllIcon = new Button("PlayAll")\r
+ playAll = new Button("PlayAll")\r
{\r
ThemeChangeSensitive = true,\r
};\r
- titleView.Add(playAllIcon);\r
- RelativeLayout.SetLeftRelativeOffset(playAllIcon, 1.0f);\r
- RelativeLayout.SetRightRelativeOffset(playAllIcon, 1.0f);\r
- RelativeLayout.SetHorizontalAlignment(playAllIcon, RelativeLayout.Alignment.End);\r
+ titleView.Add(playAll);\r
+ playAll.Clicked += (object sender, ClickedEventArgs e) =>\r
+ {\r
+ viewModel.PlayAll();\r
+ };\r
+ RelativeLayout.SetLeftRelativeOffset(playAll, 1.0f);\r
+ RelativeLayout.SetRightRelativeOffset(playAll, 1.0f);\r
+ RelativeLayout.SetHorizontalAlignment(playAll, RelativeLayout.Alignment.End);\r
\r
- addToPlaylistIcon = new Button("PlaylistAdd")\r
+ playAllWithShuffle = new Button("ShuffleButton")\r
{\r
ThemeChangeSensitive = true,\r
Margin = new Extents(32, 40, 0, 0),\r
};\r
- titleView.Add(addToPlaylistIcon);\r
- RelativeLayout.SetRightTarget(addToPlaylistIcon, playAllIcon);\r
- RelativeLayout.SetRightRelativeOffset(addToPlaylistIcon, 0.0f);\r
- RelativeLayout.SetHorizontalAlignment(addToPlaylistIcon, RelativeLayout.Alignment.End);\r
+ titleView.Add(playAllWithShuffle);\r
+ playAllWithShuffle.Clicked += (object sender, ClickedEventArgs e) =>\r
+ {\r
+ viewModel.PlayAllWithShuffle();\r
+ };\r
+ RelativeLayout.SetRightTarget(playAllWithShuffle, playAll);\r
+ RelativeLayout.SetRightRelativeOffset(playAllWithShuffle, 0.0f);\r
+ RelativeLayout.SetHorizontalAlignment(playAllWithShuffle, RelativeLayout.Alignment.End);\r
+\r
+ RelativeLayout.SetRightTarget(trackCountLabel, playAllWithShuffle);\r
+ RelativeLayout.SetRightRelativeOffset(trackCountLabel, 0.0f);\r
}\r
\r
- private void OnTrackSelection(object sender, SelectionChangedEventArgs e)\r
+ public override void ShowView()\r
{\r
- //TODO\r
+ trackCountLabel.Show();\r
+ playAllWithShuffle.Show();\r
+ playAll.Show();\r
+ base.ShowView();\r
}\r
\r
- protected override void OnThemeChanged(object sender, ThemeChangedEventArgs e)\r
+ public override void HideView()\r
{\r
- base.OnThemeChanged(sender, e);\r
+ trackCountLabel.Hide();\r
+ playAllWithShuffle.Hide();\r
+ playAll.Hide();\r
+ base.HideView();\r
}\r
+\r
+ protected override void UpdateContentMoreButtonItems(Menu moreMenu)\r
+ {\r
+ var addToPlaylist = new MenuItem { Text = "Add to Playlist" };\r
+ addToPlaylist.Clicked += OnAddToPlaylistClick;\r
+ var share = new MenuItem { Text = "Share" };\r
+ share.Clicked += OnShareClick;\r
+ var delete = new MenuItem { Text = "Delete" };\r
+ delete.Clicked += OnDeleteClick;\r
+\r
+ moreMenu.Items = new MenuItem[] { addToPlaylist, share, delete };\r
+ }\r
+\r
protected override void Dispose(DisposeTypes type)\r
{\r
if(Disposed)\r
trackCountLabel.Dispose();\r
trackCountLabel = null;\r
\r
- // TODO Uncomment after implementation is completed\r
- titleView.Remove(playAllIcon);\r
- playAllIcon.Dispose();\r
- playAllIcon = null;\r
+ titleView.Remove(playAllWithShuffle);\r
+ playAllWithShuffle.Dispose();\r
+ playAllWithShuffle = null;\r
\r
- //titleView.Remove(addToPlaylistIcon);\r
- addToPlaylistIcon.Dispose();\r
- addToPlaylistIcon = null;\r
+ titleView.Remove(playAll);\r
+ playAll.Dispose();\r
+ playAll = null;\r
+ moreMenu?.Dismiss();\r
+ moreMenu = null;\r
}\r
base.Dispose(type);\r
}\r
+\r
+ private void OnTrackSelection(object sender, SelectionChangedEventArgs e)\r
+ {\r
+ viewModel.OnTrackSelected(collectionView.SelectedItem);\r
+ }\r
+\r
+ private void OnDeleteClick(object sender, ClickedEventArgs e)\r
+ {\r
+ DismissMoreMenu();\r
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Delete, ContentViewType.Track, viewModel.ListViewModel);\r
+ OnOperationViewAdd(operationEventArgs);\r
+ }\r
+\r
+ private void OnShareClick(object sender, ClickedEventArgs e)\r
+ {\r
+ DismissMoreMenu();\r
+ OperationViewAddEventArgs operationEventArgs = new OperationViewAddEventArgs(OperationViewType.Share, ContentViewType.Track, viewModel.ListViewModel);\r
+ OnOperationViewAdd(operationEventArgs);\r
+ }\r
+\r
+ private void OnAddToPlaylistClick(object sender, ClickedEventArgs e)\r
+ {\r
+ DismissMoreMenu();\r
+ }\r
}\r
}\r
--- /dev/null
+using System.Diagnostics;
+using MusicPlayer.ViewModels;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Views.Utils
+{
+ public enum ContentViewType
+ {
+ Playlist = 0,
+ Track = 1,
+ Album = 2,
+ Artist = 3,
+ };
+
+ abstract class ContentViewFactory
+ {
+ public abstract BaseContentView GetContentView(ContentViewType type);
+ }
+
+ class ConcreteContentViewFactory : ContentViewFactory
+ {
+ public override BaseContentView GetContentView(ContentViewType type)
+ {
+ Tizen.Log.Debug(AppConstants.LogTag, "Getting content view of type: " + type.ToString());
+ BaseContentView contentView = null;
+ switch(type)
+ {
+ case ContentViewType.Playlist:
+ Tizen.Log.Info(AppConstants.LogTag, "Creating Artist View");
+ PlaylistViewModel viewModel = new PlaylistViewModel();
+ PlaylistView playlistView = new PlaylistView(viewModel);
+ contentView = playlistView;
+ break;
+ case ContentViewType.Track:
+ Tizen.Log.Info(AppConstants.LogTag, "Creating Track View");
+ TrackViewModel trackViewModel = new TrackViewModel();
+ TrackView trackView = new TrackView(trackViewModel);
+ contentView = trackView;
+ break;
+ case ContentViewType.Album:
+ Tizen.Log.Info(AppConstants.LogTag, "Creating album View");
+ AlbumViewModel albumViewModel = new AlbumViewModel();
+ AlbumView albumView = new AlbumView(albumViewModel);
+ contentView = albumView;
+ break;
+ case ContentViewType.Artist:
+ Tizen.Log.Error(AppConstants.LogTag, "Creating Arist View");
+ ArtistViewModel artistViewModel = new ArtistViewModel();
+ ArtistView artistView = new ArtistView(artistViewModel);
+ contentView = artistView;
+ break;
+ }
+ return contentView;
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MusicPlayer.Views.Utils
+{
+ interface IMoreButtonItems
+ {
+ void UpdateButtonMoreItems(Tizen.NUI.Components.Menu moreMenu);
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MusicPlayer.Views.Utils
+{
+ interface ISubViewStatus
+ {
+ void DeleteSubView();
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MusicPlayer.Views.Utils
+{
+ interface IViewStatus
+ {
+ void ShowView();
+ void HideView();
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MusicPlayer.Views.Utils
+{
+ class OperationViewAddEventArgs : EventArgs
+ {
+ public OperationViewAddEventArgs(OperationViewType type, ContentViewType contentType, object creationDetails)
+ {
+ OperationViewType = type;
+ ContentViewType = contentType;
+ ViewModelData = creationDetails;
+ }
+
+ public OperationViewType OperationViewType { get; private set; }
+
+ public ContentViewType ContentViewType { get; private set; }
+
+ public object ViewModelData { get; private set; }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.NUI.BaseComponents;
+using MusicPlayer.ViewModels;
+using MusicPlayer.Common;
+using MusicPlayer.Models;
+
+namespace MusicPlayer.Views.Utils
+{
+ public enum OperationViewType
+ {
+ Delete = 0,
+ Search = 1,
+ Share = 2,
+ AddToPlaylist = 3,
+ }
+
+ abstract class OperationViewFactory
+ {
+ public abstract View AddOperationView(OperationViewType type, ContentViewType viewType, object viewModelData);
+ }
+ class ConcreteOperationViewFactory : OperationViewFactory
+ {
+ public override View AddOperationView(OperationViewType type, ContentViewType viewType, object viewModelData)
+ {
+ Tizen.Log.Debug(AppConstants.LogTag, "Getting operation view of type: " + type.ToString());
+ View view = null;
+ switch (type)
+ {
+ case OperationViewType.Delete:
+ Tizen.Log.Info(AppConstants.LogTag, "Creationg Delete View");
+ view = CreateDeleteView(viewType, viewModelData);
+ break;
+ case OperationViewType.Search:
+ Tizen.Log.Info(AppConstants.LogTag, "Creationg Search View");
+ break;
+ case OperationViewType.Share:
+ Tizen.Log.Info(AppConstants.LogTag, "Creationg Share View");
+ SelectorViewModel<Track> shareViewModel = new SelectorViewModel<Track>((ListViewModel<Track>)viewModelData);
+ SelectorView<Track> seachView = new SelectorView<Track>(OperationViewType.Share, shareViewModel);
+ view = seachView;
+ break;
+ case OperationViewType.AddToPlaylist:
+ Tizen.Log.Info(AppConstants.LogTag, "Creationg AddtoPlaylist View");
+ break;
+ }
+ return view;
+ }
+
+ private View CreateDeleteView(ContentViewType type, object viewModelData)
+ {
+ View deleteView = null;
+ switch (type)
+ {
+ case ContentViewType.Playlist:
+ SelectorViewModel<PlaylistModel> viewModel = new SelectorViewModel<PlaylistModel>((ListViewModel<PlaylistModel>)viewModelData);
+ deleteView = new SelectorView<PlaylistModel>(OperationViewType.Delete, viewModel);
+ break;
+ case ContentViewType.Track:
+ SelectorViewModel<Track> trackViewModel = new SelectorViewModel<Track>((ListViewModel<Track>)viewModelData);
+ deleteView = new SelectorView<Track>(OperationViewType.Delete, trackViewModel);
+ break;
+ case ContentViewType.Album:
+ SelectorViewModel<MusicAlbum> albumViewModel = new SelectorViewModel<MusicAlbum>((ListViewModel<MusicAlbum>)viewModelData);
+ deleteView = new SelectorView<MusicAlbum>(OperationViewType.Delete, albumViewModel);
+ break;
+ case ContentViewType.Artist:
+ SelectorViewModel<PlaylistData> artistViewModel = new SelectorViewModel<PlaylistData>((ListViewModel<PlaylistData>)viewModelData);
+ deleteView = new SelectorView<PlaylistData>(OperationViewType.Delete, artistViewModel);
+ break;
+ }
+ return deleteView;
+ }
+
+ public SearchView CreateSeachView()
+ {
+ SearchViewModel viewModel = new SearchViewModel();
+ SearchView searchView = new SearchView(viewModel);
+ return searchView;
+ }
+
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using MusicPlayer.Common;
+using MusicPlayer.Models;
+using MusicPlayer.ViewModels;
+
+namespace MusicPlayer.Views.Utils
+{
+ public enum SubContentViewType
+ {
+ PlaylistDetails = 0,
+ AlbumDetails = 1,
+ ArtistDetails = 2,
+ };
+
+ abstract class SubContentViewFactory
+ {
+ public abstract BaseSubContentView GetSubContentView(SubContentViewType type, object creationDetails);
+ }
+ class ConcreteSubContentViewFactory : SubContentViewFactory
+ {
+ public override BaseSubContentView GetSubContentView(SubContentViewType type, object creationDetails)
+ {
+ Tizen.Log.Info(AppConstants.LogTag, "Getting sub content view of type: " + type.ToString());
+ BaseSubContentView subcontentView = null;
+ switch (type)
+ {
+ case SubContentViewType.PlaylistDetails:
+ Tizen.Log.Info(AppConstants.LogTag, "Creating Playlist Detail View");
+ PlaylistDetailViewModel playlistDetailViewModel = new PlaylistDetailViewModel((int)creationDetails);
+ PlaylistDetailView playlistDetailView = new PlaylistDetailView(playlistDetailViewModel);
+ subcontentView = playlistDetailView;
+ break;
+ case SubContentViewType.AlbumDetails:
+ Tizen.Log.Info(AppConstants.LogTag, "Creating album details view");
+ AlbumDetailViewModel albumDetailViewModel = new AlbumDetailViewModel((MusicAlbum)creationDetails);
+ AlbumDetailView albumDetailsView = new AlbumDetailView(albumDetailViewModel);
+ subcontentView = albumDetailsView;
+ break;
+ case SubContentViewType.ArtistDetails:
+ Tizen.Log.Info(AppConstants.LogTag, "Creating Arist details view");
+ ArtistDetailViewModel artistDetailViewModel = new ArtistDetailViewModel((Artist)creationDetails);
+ ArtistDetailView artistDetailView = new ArtistDetailView(artistDetailViewModel);
+ subcontentView = artistDetailView;
+ break;
+ }
+ return subcontentView;
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Views.Utils
+{
+ class SubContentViewAddEventArgs : EventArgs
+ {
+ public SubContentViewAddEventArgs(SubContentViewType subViewType, string titleText, object viewModelData)
+ {
+ SubViewType = subViewType;
+ TitleText = titleText;
+ ViewModelData = viewModelData;
+ }
+
+ public string TitleText { get; private set; }
+
+ public object ViewModelData { get; private set; }
+
+ public SubContentViewType SubViewType { get; private set; }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Views.Utils
+{
+ class ViewLibrary
+ {
+ private IDictionary<int, BaseContentView> contentViewDictionary;
+ private ConcreteContentViewFactory contentViewFactory;
+ private ConcreteSubContentViewFactory subContentViewFactory;
+ private ConcreteOperationViewFactory operationViewFactory;
+
+ public ViewLibrary()
+ {
+ contentViewDictionary = new Dictionary<int, BaseContentView>();
+ foreach(int i in Enum.GetValues(typeof(ContentViewType)))
+ {
+ contentViewDictionary[i] = null;
+ }
+
+ contentViewFactory = new ConcreteContentViewFactory();
+ subContentViewFactory = new ConcreteSubContentViewFactory();
+ operationViewFactory = new ConcreteOperationViewFactory();
+ }
+
+ public BaseContentView GetContentView(ContentViewType type)
+ {
+ if(contentViewDictionary[(int)type] == null)
+ {
+ contentViewDictionary[(int)type] = contentViewFactory.GetContentView(type);
+ }
+ return contentViewDictionary[(int)type];
+ }
+
+ public BaseSubContentView GetSubContentView(SubContentViewType type, object viewModelData)
+ {
+ BaseSubContentView view = subContentViewFactory.GetSubContentView(type, viewModelData);
+ return view;
+ }
+
+ public void AddOperationView(OperationViewType type, ContentViewType contentType, object viewModelData)
+ {
+ operationViewFactory.AddOperationView(type, contentType, viewModelData);
+ }
+
+ public SearchView CreateSearchView()
+ {
+ return operationViewFactory.CreateSeachView();
+ }
+
+ }
+}
--- /dev/null
+using System;
+using System.IO;
+using System.Diagnostics;
+using Tizen.NUI;
+using Tizen.NUI.Xaml;
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using MusicPlayer.Views.Utils;
+using MusicPlayer.Common;
+
+
+namespace MusicPlayer.Views
+{
+ public class ViewManager
+ {
+ private Window window;
+ private ViewLibrary viewLibrary;
+ private View rootView;
+ private BaseView baseView;
+ private static string[] TabNames = new string[]
+ {
+ "Playlists",
+ "Tracks",
+ "Albums",
+ "Artists",
+ };
+
+ public ViewManager(Window win)
+ {
+ window = win;
+ viewLibrary = new ViewLibrary();
+ UpdateTheme(ThemeManager.PlatformThemeId);
+ InitializeRootView(win);
+ InitializeBaseView(rootView);
+ ThemeManager.ThemeChanged += (object sender, ThemeChangedEventArgs e) =>
+ {
+ if (e.IsPlatformThemeChanged)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "Theme Changed: " + e.ThemeId);
+ UpdateTheme(e.PlatformThemeId);
+ }
+ };
+ }
+
+ private void SetTheme(string path)
+ {
+ try
+ {
+ Theme lightTheme = new Theme(path);
+ ThemeManager.ApplyTheme(lightTheme);
+ }
+ catch (ArgumentNullException e)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "ArgumentNullException: " + e.ParamName);
+ }
+ catch (IOException e)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "IOException: " + e.Message);
+ }
+ catch (XamlParseException e)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "XamlParseException: " + e.Message);
+ if (e.XmlInfo != null)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "XamlParseException, LineNo." + e.XmlInfo.LineNumber + " Pos: " + e.XmlInfo.LinePosition + " HasInfo: " + e.XmlInfo.HasLineInfo().ToString());
+ }
+ }
+ }
+
+ private void UpdateTheme(string platformThemeId)
+ {
+ if(platformThemeId == null)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "Platform theme id is null");
+ return;
+ }
+ if(platformThemeId.Equals(AppConstants.LightPlatformThemeId))
+ {
+ SetTheme(Resources.GetThemePath() + "light.xaml");
+ }
+ else if(platformThemeId.Equals(AppConstants.DarkPlatformThemeId))
+ {
+ SetTheme(Resources.GetThemePath() + "dark.xaml");
+ }
+ }
+
+ private void InitializeRootView(Window win)
+ {
+ rootView = new View()
+ {
+ StyleName = "AppBackground",
+ Size = new Size(win.Size),
+ ThemeChangeSensitive = true,
+ Layout = new FlexLayout()
+ {
+ Direction = FlexLayout.FlexDirection.Column,
+ ItemsAlignment = FlexLayout.AlignmentType.FlexStart,
+ Justification = FlexLayout.FlexJustification.FlexStart
+ }
+ };
+ win.Add(rootView);
+ }
+
+ private void InitializeBaseView(View rootview)
+ {
+ baseView = new BaseView()
+ {
+ Title = "Music",
+ MoreButton = true,
+ SearchButton = true,
+ };
+ rootview.Add(baseView);
+ FlexLayout.SetFlexGrow(baseView, 1);
+ FlexLayout.SetFlexShrink(baseView, 1);
+ baseView.Tabs.SelectedItemIndex = (int)ContentViewType.Playlist;
+ baseView.Tabs.ItemChangedEvent += OnTabItemSelect;
+ baseView.GetSearchButton().Clicked += OnSearchIconClicked;
+ SetTabItem(-1, (int)ContentViewType.Playlist);
+ }
+
+ private void OnSearchIconClicked(object sender, ClickedEventArgs e)
+ {
+ SearchView searchView = viewLibrary.CreateSearchView();
+ searchView.LaunchDetailView += OnSubViewAdded;
+ }
+
+ private void OnSubViewAdded(object sender, SubContentViewAddEventArgs subViewAddEventArgs)
+ {
+ BaseSubContentView baseSubContentView = viewLibrary.GetSubContentView(subViewAddEventArgs.SubViewType, subViewAddEventArgs.ViewModelData);
+ baseView.AddSubViewContent(subViewAddEventArgs.TitleText, baseSubContentView);
+ }
+
+ private void OnOpeationViewAdded(object sender, OperationViewAddEventArgs e)
+ {
+ viewLibrary.AddOperationView(e.OperationViewType, e.ContentViewType, e.ViewModelData);
+ }
+
+ private void SetTabItem(int previousIndex, int currentIndex)
+ {
+ Tizen.Log.Debug(AppConstants.LogTag, "SetTabItem item " + previousIndex + ", " + currentIndex);
+ if(previousIndex >= (int)ContentViewType.Playlist && previousIndex <= (int)ContentViewType.Artist)
+ {
+ BaseContentView previousContentView = viewLibrary.GetContentView((ContentViewType)previousIndex);
+ baseView.RemoveContent(previousContentView);
+ previousContentView?.HideView();
+ if(previousContentView != null)
+ {
+ previousContentView.SubContentViewAdded -= OnSubViewAdded;
+ previousContentView.OperationViewAdded -= OnOpeationViewAdded;
+ }
+ Tizen.Log.Error(AppConstants.LogTag, "Removing " + previousContentView.Name);
+ }
+
+ if(currentIndex >= (int)ContentViewType.Playlist && currentIndex <= (int)ContentViewType.Artist)
+ {
+ BaseContentView currentContentView = viewLibrary.GetContentView((ContentViewType)currentIndex);
+ currentContentView?.ShowView();
+ baseView.SetContent(currentContentView);
+ if (currentContentView != null)
+ {
+ currentContentView.SubContentViewAdded += OnSubViewAdded;
+ currentContentView.OperationViewAdded += OnOpeationViewAdded;
+ }
+ Tizen.Log.Error(AppConstants.LogTag, "Adding " + currentContentView.Name);
+ }
+ }
+
+ private void OnTabItemSelect(object sender, Tab.ItemChangedEventArgs e)
+ {
+ Tizen.Log.Debug(AppConstants.LogTag, "Tab Item selected: " + TabNames[e.CurrentIndex]);
+ Tizen.Log.Debug(AppConstants.LogTag, "Tab Item selected: " + "Prev Index: "+e.PreviousIndex+", Curr Index"+e.CurrentIndex);
+ if(e.PreviousIndex == e.CurrentIndex)
+ {
+ return;
+ }
+ SetTabItem(e.PreviousIndex, e.CurrentIndex);
+ }
+ }
+}
</ItemGroup>\r
\r
<ItemGroup>\r
- <PackageReference Include="Tizen.NET" Version="9.0.0.16249" />\r
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16617" />\r
<PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />\r
- <PackageReference Include="Tizen.NUI.XamlBuild" Version="1.0.11" />\r
+ <PackageReference Include="Tizen.NUI.XamlBuild" Version="1.0.31" />\r
</ItemGroup>\r
\r
</Project>\r
<c:ButtonStyle.Icon>
<ImageViewStyle>
<ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/next.png" Pressed="*Resource*/images/next_pressed.png" Disabled="*Resource*/images/next_disabled.png" />
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/shuffle_on.png" Pressed="*Resource*/images/shuffle_on_pressed.png" Disabled="*Resource*/images/shuffle_on_disabled.png" />
</ImageViewStyle.ResourceUrl>
</ImageViewStyle>
</c:ButtonStyle.Icon>
<c:ButtonStyle.Icon>
<ImageViewStyle>
<ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/addtoplaylist.png" Pressed="*Resource*/images/addtoplaylist_pressed.png" Disabled="*Resource*/images/addtoplaylist_disabled.png" />
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/playall.png" Pressed="*Resource*/images/playall_pressed.png" Disabled="*Resource*/images/playall_disabled.png" />
</ImageViewStyle.ResourceUrl>
</ImageViewStyle>
</c:ButtonStyle.Icon>
<c:ButtonStyle.Icon>
<ImageViewStyle>
<ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/shuffle_on.png" Pressed="*Resource*/images/shuffle_on_pressed.png" Disabled="*Resource*/images/shuffle_on_disabled.png" />
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/addtoplaylist.png" Pressed="*Resource*/images/addtoplaylist_pressed.png" Disabled="*Resource*/images/addtoplaylist_disabled.png" />
</ImageViewStyle.ResourceUrl>
</ImageViewStyle>
</c:ButtonStyle.Icon>
<TextLabelStyle.TextColor>
<Selector x:TypeArguments="Color" Normal="#FFFFFF" Selected="#1473E6"/>
</TextLabelStyle.TextColor>
- </TextLabelStyle>
+ </TextLabelStyle>]
+
+ <TextLabelStyle x:Key="PageLabel" TextColor="#FFFFFF"/>
+
+ <TextLabelStyle x:Key="TitleText" TextColor="#FFFFFF"/>
+
+ <c:ButtonStyle x:Key="CancelButton" Size="336, 96" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
+ <c:ButtonStyle.BackgroundImage>*Resource*/images/dark/cancel_button_bg.png</c:ButtonStyle.BackgroundImage>
+ <c:ButtonStyle.Text>
+ <TextLabelStyle TextColor="#FFFFFF" FontFamily="BreezeSans" PixelSize="32" Text="Cancel"/>
+ </c:ButtonStyle.Text>
+ </c:ButtonStyle>
+
+ <c:ButtonStyle x:Key="TextButton" Size="260, 64" IsSelectable="false" BackgroundColor="Transparent" >
+ <c:ButtonStyle.Text>
+ <TextLabelStyle TextColor="#FFFFFF" FontFamily="BreezeSans" PixelSize="28"/>
+ </c:ButtonStyle.Text>
+ </c:ButtonStyle>
+
+ <ImageViewStyle x:Key="SelectAllBg" ResourceUrl="*Resource*/images/dark/selectall_bg.png" />
</Theme>
\ No newline at end of file
<c:ButtonStyle.Icon>
<ImageViewStyle>
<ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/next.png" Pressed="*Resource*/images/next_pressed.png" Disabled="*Resource*/images/next_disabled.png" />
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/shuffle_on.png" Pressed="*Resource*/images/shuffle_on_pressed.png" Disabled="*Resource*/images/shuffle_on_disabled.png" />
</ImageViewStyle.ResourceUrl>
</ImageViewStyle>
</c:ButtonStyle.Icon>
<c:ButtonStyle.Icon>
<ImageViewStyle>
<ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/addtoplaylist.png" Pressed="*Resource*/images/addtoplaylist_pressed.png" Disabled="*Resource*/images/addtoplaylist_disabled.png" />
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/playall.png" Pressed="*Resource*/images/playall_pressed.png" Disabled="*Resource*/images/playall_disabled.png" />
</ImageViewStyle.ResourceUrl>
</ImageViewStyle>
</c:ButtonStyle.Icon>
<c:ButtonStyle.Icon>
<ImageViewStyle>
<ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/shuffle_on.png" Pressed="*Resource*/images/shuffle_on_pressed.png" Disabled="*Resource*/images/shuffle_on_disabled.png" />
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/addtoplaylist.png" Pressed="*Resource*/images/addtoplaylist_pressed.png" Disabled="*Resource*/images/addtoplaylist_disabled.png" />
</ImageViewStyle.ResourceUrl>
</ImageViewStyle>
</c:ButtonStyle.Icon>
</TextLabelStyle.TextColor>
</TextLabelStyle>
+ <TextLabelStyle x:Key="PageLabel" TextColor="#000209"/>
+
+ <TextLabelStyle x:Key="TitleText" TextColor="#000C2B"/>
+
+ <c:ButtonStyle x:Key="CancelButton" Size="336, 96" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
+ <c:ButtonStyle.BackgroundImage>*Resource*/images/light/cancel_button_bg.png</c:ButtonStyle.BackgroundImage>
+ <c:ButtonStyle.Text>
+ <TextLabelStyle TextColor="#000C2B" FontFamily="BreezeSans" PixelSize="32" Text="Cancel"/>
+ </c:ButtonStyle.Text>
+ </c:ButtonStyle>
+
+ <c:ButtonStyle x:Key="TextButton" Size="260, 64" IsSelectable="false" BackgroundColor="Transparent" >
+ <c:ButtonStyle.Text>
+ <TextLabelStyle TextColor="#000C2B" FontFamily="BreezeSans" PixelSize="28"/>
+ </c:ButtonStyle.Text>
+ </c:ButtonStyle>
+
+ <ImageViewStyle x:Key="SelectAllBg" ResourceUrl="*Resource*/images/light/selectall_bg.png" />
+
</Theme>
\ No newline at end of file
<label>MusicPlayer</label>\r
<icon>MusicPlayer.png</icon>\r
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />\r
+ <background-category value="media" />\r
<splash-screens />\r
- <background-category value="system"/>\r
</ui-application>\r
<shortcut-list />\r
+ <privileges>\r
+ <privilege>http://tizen.org/privilege/volume.set</privilege>\r
+ <privilege>http://tizen.org/privilege/mediastorage</privilege>\r
+ <privilege>http://tizen.org/privilege/externalstorage</privilege>\r
+ <privilege>http://tizen.org/privilege/externalstorage.appdata</privilege>\r
+ <privilege>http://tizen.org/privilege/notification</privilege>\r
+ <privilege>http://tizen.org/privilege/display</privilege>\r
+ <privilege>http://tizen.org/privilege/content.write</privilege>\r
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>\r
+ </privileges>\r
<dependencies />\r
<provides-appdefined-privileges />\r
</manifest>\r