Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Added PlaylistActivity; not fully functional yet. Added play…
…list/shuffle/repeat buttons to lock screen. Added shuffle/repeat commands to PlayerCommandMessage. Added new icon for playlist. Related to issue #406.
- Loading branch information
1 parent
8038d63
commit de138ca
Showing
28 changed files
with
969 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
177 changes: 177 additions & 0 deletions
177
MPfm/MPfm.Android/Classes/Activities/PlaylistActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
// Copyright © 2011-2013 Yanick Castonguay | ||
// | ||
// This file is part of MPfm. | ||
// | ||
// MPfm is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// MPfm is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with MPfm. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.Content.PM; | ||
using Android.Views; | ||
using Android.OS; | ||
using Android.Widget; | ||
using MPfm.Android.Classes.Adapters; | ||
using MPfm.Android.Classes.Fragments; | ||
using MPfm.Android.Classes.Navigation; | ||
using MPfm.Library.Objects; | ||
using MPfm.MVP.Bootstrap; | ||
using MPfm.MVP.Navigation; | ||
using MPfm.MVP.Views; | ||
using MPfm.Player.Objects; | ||
using MPfm.Sound.AudioFiles; | ||
using MPfm.Sound.Playlists; | ||
|
||
namespace MPfm.Android | ||
{ | ||
[Activity(Label = "Playlist", ScreenOrientation = ScreenOrientation.Sensor, Theme = "@style/MyAppTheme", ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation | ConfigChanges.ScreenSize)] | ||
public class PlaylistActivity : BaseActivity, IPlaylistView | ||
{ | ||
private MobileNavigationManager _navigationManager; | ||
Button _btnNew; | ||
Button _btnShuffle; | ||
ListView _listView; | ||
PlaylistListAdapter _listAdapter; | ||
Playlist _playlist; | ||
|
||
protected override void OnCreate(Bundle bundle) | ||
{ | ||
Console.WriteLine("PlaylistActivity - OnCreate"); | ||
base.OnCreate(bundle); | ||
|
||
_navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>(); | ||
SetContentView(Resource.Layout.Playlist); | ||
ActionBar.SetDisplayHomeAsUpEnabled(true); | ||
ActionBar.SetHomeButtonEnabled(true); | ||
|
||
_btnNew = FindViewById<Button>(Resource.Id.playlist_btnNew); | ||
_btnNew.Click += BtnNewOnClick; | ||
_btnShuffle = FindViewById<Button>(Resource.Id.playlist_btnNew); | ||
_btnShuffle.Click += BtnShuffleOnClick; | ||
|
||
_listView = FindViewById<ListView>(Resource.Id.playlist_listView); | ||
_listAdapter = new PlaylistListAdapter(this, new Playlist()); | ||
_listView.SetAdapter(_listAdapter); | ||
_listView.ItemClick += ListViewOnItemClick; | ||
|
||
// Since the onViewReady action could not be added to an intent, tell the NavMgr the view is ready | ||
((AndroidNavigationManager)_navigationManager).SetPlaylistActivityInstance(this); | ||
} | ||
|
||
private void BtnNewOnClick(object sender, EventArgs eventArgs) | ||
{ | ||
OnNewPlaylist(); | ||
} | ||
|
||
private void BtnShuffleOnClick(object sender, EventArgs eventArgs) | ||
{ | ||
OnShufflePlaylist(); | ||
} | ||
|
||
private void ListViewOnItemClick(object sender, AdapterView.ItemClickEventArgs itemClickEventArgs) | ||
{ | ||
} | ||
|
||
protected override void OnStart() | ||
{ | ||
Console.WriteLine("PlaylistActivity - OnStart"); | ||
base.OnStart(); | ||
} | ||
|
||
protected override void OnRestart() | ||
{ | ||
Console.WriteLine("PlaylistActivity - OnRestart"); | ||
base.OnRestart(); | ||
} | ||
|
||
protected override void OnPause() | ||
{ | ||
Console.WriteLine("PlaylistActivity - OnPause"); | ||
base.OnPause(); | ||
} | ||
|
||
protected override void OnResume() | ||
{ | ||
Console.WriteLine("PlaylistActivity - OnResume"); | ||
base.OnResume(); | ||
} | ||
|
||
protected override void OnStop() | ||
{ | ||
Console.WriteLine("PlaylistActivity - OnStop"); | ||
base.OnStop(); | ||
} | ||
|
||
protected override void OnDestroy() | ||
{ | ||
Console.WriteLine("PlaylistActivity - OnDestroy"); | ||
base.OnDestroy(); | ||
} | ||
|
||
public override bool OnOptionsItemSelected(IMenuItem item) | ||
{ | ||
switch (item.ItemId) | ||
{ | ||
case global::Android.Resource.Id.Home: | ||
var intent = new Intent(this, typeof (MainActivity)); | ||
intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop); | ||
this.StartActivity(intent); | ||
this.Finish(); | ||
return true; | ||
break; | ||
default: | ||
return base.OnOptionsItemSelected(item); | ||
break; | ||
} | ||
} | ||
|
||
#region IPlaylistView implementation | ||
|
||
public Action<Guid, int> OnChangePlaylistItemOrder { get; set; } | ||
public Action<Guid> OnSelectPlaylistItem { get; set; } | ||
public Action<List<Guid>> OnRemovePlaylistItems { get; set; } | ||
public Action OnNewPlaylist { get; set; } | ||
public Action<string> OnLoadPlaylist { get; set; } | ||
public Action OnSavePlaylist { get; set; } | ||
public Action OnShufflePlaylist { get; set; } | ||
|
||
public void PlaylistError(Exception ex) | ||
{ | ||
RunOnUiThread(() => { | ||
AlertDialog ad = new AlertDialog.Builder(this).Create(); | ||
ad.SetCancelable(false); | ||
ad.SetMessage(string.Format("An error has occured in Playlist: {0}", ex)); | ||
ad.SetButton("OK", (sender, args) => ad.Dismiss()); | ||
ad.Show(); | ||
}); | ||
} | ||
|
||
public void RefreshPlaylist(Playlist playlist) | ||
{ | ||
RunOnUiThread(() => { | ||
_playlist = playlist; | ||
_listAdapter.SetData(_playlist); | ||
}); | ||
} | ||
|
||
public void RefreshCurrentlyPlayingSong(int index, AudioFile audioFile) | ||
{ | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright © 2011-2013 Yanick Castonguay | ||
// | ||
// This file is part of MPfm. | ||
// | ||
// MPfm is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// MPfm is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with MPfm. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System.Collections.Generic; | ||
using Android.Graphics; | ||
using Android.Views; | ||
using Android.Views.Animations; | ||
using Android.Widget; | ||
using MPfm.Library.Objects; | ||
using MPfm.Sound.AudioFiles; | ||
using MPfm.Sound.Playlists; | ||
|
||
namespace MPfm.Android.Classes.Adapters | ||
{ | ||
public class PlaylistListAdapter : BaseAdapter<AudioFile> | ||
{ | ||
readonly PlaylistActivity _context; | ||
Playlist _playlist; | ||
|
||
public PlaylistListAdapter(PlaylistActivity context, Playlist playlist) | ||
{ | ||
_context = context; | ||
_playlist = playlist; | ||
} | ||
|
||
public void SetData(Playlist playlist) | ||
{ | ||
_playlist = playlist; | ||
NotifyDataSetChanged(); | ||
} | ||
|
||
public override long GetItemId(int position) | ||
{ | ||
return position; | ||
} | ||
|
||
public override AudioFile this[int position] | ||
{ | ||
get { return _playlist.Items[position].AudioFile; } | ||
} | ||
|
||
public override int Count | ||
{ | ||
get { return _playlist.Items.Count; } | ||
} | ||
|
||
public override View GetView(int position, View convertView, ViewGroup parent) | ||
{ | ||
var item = _playlist.Items[position]; | ||
View view = convertView; | ||
if (view == null) // no view to re-use, create new | ||
view = _context.LayoutInflater.Inflate(Resource.Layout.PlaylistCell, null); | ||
|
||
if (item == null) | ||
return view; | ||
|
||
var index = view.FindViewById<TextView>(Resource.Id.playlistCell_lblIndex); | ||
var title = view.FindViewById<TextView>(Resource.Id.playlistCell_lblTitle); | ||
var subtitle = view.FindViewById<TextView>(Resource.Id.playlistCell_lblSubtitle); | ||
|
||
//index.Text = item.AudioFile.TrackNumber.ToString(); | ||
index.Text = (position+1).ToString(); | ||
title.Text = item.AudioFile.ArtistName + " / " + item.AudioFile.Title; | ||
subtitle.Text = item.AudioFile.Length; | ||
|
||
return view; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.