Skip to content

Commit

Permalink
iOS: Added new Playlist button in NavigationController of PlayerViewC…
Browse files Browse the repository at this point in the history
…ontroller. Moved MPVolumeView from PlayerViewController to EqualizerPresetsViewController. Added left swipe back gesture (iOS 7 standard) for several view controllers.

Related to issue #405.
  • Loading branch information
ycastonguay committed Oct 10, 2013
1 parent 110605c commit d4e18a7
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 88 deletions.
3 changes: 3 additions & 0 deletions MPfm/MPfm.iOS/Classes/Controllers/AboutViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public AboutViewController(Action<IBaseView> onViewReady)

public override void ViewDidLoad()
{
NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public AudioPreferencesViewController(Action<IBaseView> onViewReady)

public override void ViewDidLoad()
{
NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ public override void ViewDidLoad()

for(int a = 0; a < 18; a++)
AddFaderToScrollView(a.ToString() + ".0 kHz");


NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand Down
41 changes: 29 additions & 12 deletions MPfm/MPfm.iOS/Classes/Controllers/EqualizerPresetsViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@
using System.Linq;
using MPfm.MVP.Navigation;
using MPfm.MVP.Views;
using MPfm.Player.Objects;
using MonoTouch.CoreAnimation;
using MonoTouch.CoreGraphics;
using MonoTouch.Foundation;
using MonoTouch.MediaPlayer;
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.iOS.Classes.Controls;
using MPfm.iOS.Classes.Objects;
using MPfm.Player.Objects;
using MPfm.iOS.Helpers;

namespace MPfm.iOS
{
public partial class EqualizerPresetsViewController : BaseViewController, IEqualizerPresetsView
{
MPVolumeView _volumeView;
UIBarButtonItem _btnDone;
UIBarButtonItem _btnAdd;
string _cellIdentifier = "EqualizerPresetCell";
Expand All @@ -47,6 +50,8 @@ public EqualizerPresetsViewController(Action<IBaseView> onViewReady)

public override void ViewDidLoad()
{
var screenSize = UIKitHelper.GetDeviceSize();

tableView.WeakDataSource = this;
tableView.WeakDelegate = this;

Expand All @@ -60,10 +65,10 @@ public override void ViewDidLoad()
switchBypass.On = false;
switchBypass.ValueChanged += HandleSwitchBypassValueChanged;

sliderMasterVolume.SetThumbImage(UIImage.FromBundle("Images/Sliders/thumb"), UIControlState.Normal);
sliderMasterVolume.SetMinTrackImage(UIImage.FromBundle("Images/Sliders/slider2").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
sliderMasterVolume.SetMaxTrackImage(UIImage.FromBundle("Images/Sliders/slider").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
sliderMasterVolume.ValueChanged += HandleSliderMasterVolumeValueChanged;
//sliderMasterVolume.SetThumbImage(UIImage.FromBundle("Images/Sliders/thumb"), UIControlState.Normal);
//sliderMasterVolume.SetMinTrackImage(UIImage.FromBundle("Images/Sliders/slider2").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
//sliderMasterVolume.SetMaxTrackImage(UIImage.FromBundle("Images/Sliders/slider").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
//sliderMasterVolume.ValueChanged += HandleSliderMasterVolumeValueChanged;

var btnDone = new MPfmFlatButton();
btnDone.Label.Text = "Done";
Expand Down Expand Up @@ -98,14 +103,26 @@ public override void ViewDidLoad()
var navCtrl = (MPfmNavigationController)NavigationController;
navCtrl.SetBackButtonVisible(false);

// Create MPVolumeView (only visible on physical iOS device)
RectangleF rectVolume;
if (UserInterfaceIdiomIsPhone)
rectVolume = new RectangleF(74, 25, 236, 46);
else
rectVolume = new RectangleF(74, 25, 236, 46);
_volumeView = new MPVolumeView(rectVolume);
_volumeView.SetMinimumVolumeSliderImage(UIImage.FromBundle("Images/Sliders/slider2").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
_volumeView.SetMaximumVolumeSliderImage(UIImage.FromBundle("Images/Sliders/slider").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
_volumeView.SetVolumeThumbImage(UIImage.FromBundle("Images/Sliders/thumbbig"), UIControlState.Normal);
this.View.AddSubview(_volumeView);

base.ViewDidLoad();
}

private void HandleSliderMasterVolumeValueChanged(object sender, EventArgs e)
{
lblMasterVolumeValue.Text = sliderMasterVolume.Value.ToString("0") + " %";
OnSetVolume(sliderMasterVolume.Value / 100);
}
// private void HandleSliderMasterVolumeValueChanged(object sender, EventArgs e)
// {
// lblMasterVolumeValue.Text = sliderMasterVolume.Value.ToString("0") + " %";
// OnSetVolume(sliderMasterVolume.Value / 100);
// }

private void HandleButtonAddTouchUpInside()
{
Expand Down Expand Up @@ -258,8 +275,8 @@ public void RefreshOutputMeter(float[] dataLeft, float[] dataRight)
public void RefreshVolume(float volume)
{
InvokeOnMainThread(() => {
sliderMasterVolume.Value = volume * 100;
lblMasterVolumeValue.Text = (volume * 100).ToString("0") + " %";
//sliderMasterVolume.Value = volume * 100;
//lblMasterVolumeValue.Text = (volume * 100).ToString("0") + " %";
});
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public GeneralPreferencesViewController(Action<IBaseView> onViewReady)

public override void ViewDidLoad()
{
NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public LibraryPreferencesViewController(Action<IBaseView> onViewReady)

public override void ViewDidLoad()
{
NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override void ViewDidLoad()
this.NavigationItem.HidesBackButton = true;

UISwipeGestureRecognizer swipe = new UISwipeGestureRecognizer(HandleSwipe);
swipe.Direction = UISwipeGestureRecognizerDirection.Right;
swipe.Direction = UISwipeGestureRecognizerDirection.Left;
tableView.AddGestureRecognizer(swipe);

UILongPressGestureRecognizer longPressTableView = new UILongPressGestureRecognizer(HandleLongPressTableCellRow);
Expand All @@ -106,6 +106,9 @@ public override void ViewDidLoad()
longPressCollectionView.WeakDelegate = this;
collectionView.AddGestureRecognizer(longPressCollectionView);

NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand All @@ -132,12 +135,13 @@ public override void ViewDidDisappear(bool animated)

private void HandleSwipe(UISwipeGestureRecognizer gestureRecognizer)
{
var point = gestureRecognizer.LocationInView(tableView);
var indexPath = tableView.IndexPathForRowAtPoint(point);
//Console.WriteLine("MLBVC - HandleSwipe");
//var point = gestureRecognizer.LocationInView(tableView);
//var indexPath = tableView.IndexPathForRowAtPoint(point);

// IndexPath is null when swiping an empty cell
if (indexPath == null)
return;
//if (indexPath == null)
// return;
}

private void HandleLongPressCollectionCellRow(UILongPressGestureRecognizer gestureRecognizer)
Expand Down Expand Up @@ -549,25 +553,33 @@ public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
[Export ("tableView:didSelectRowAtIndexPath:")]
public void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
if (indexPath.Row == _editingTableCellRowPosition)
Console.WriteLine("MLBVC - RowSelected - row: {0}", indexPath.Row);
//if (indexPath.Row == _editingTableCellRowPosition)
if(_editingTableCellRowPosition != -1)
{
Console.WriteLine("MLBVC - RowSelected - Deselecting row... - row: {0}", indexPath.Row);
tableView.DeselectRow(indexPath, true);
ResetEditingTableCellRow();
return;
}

Console.WriteLine("MLBVC - RowSelected - OnItemClick - row: {0}", indexPath.Row);
OnItemClick(indexPath.Row);
}

[Export ("tableView:didHighlightRowAtIndexPath:")]
public void DidHighlightRowAtIndexPath(UITableView tableView, NSIndexPath indexPath)
{
Console.WriteLine("MLBVC - DidHighlightRowAtIndexPath - row: {0}", indexPath.Row);
var cell = (MPfmTableViewCell)tableView.CellAt(indexPath);
if (cell == null)
return;

if(indexPath.Row != _editingTableCellRowPosition)
ResetEditingTableCellRow();
// if (indexPath.Row != _editingTableCellRowPosition)
// {
// Console.WriteLine("MLBVC - DidHighlightRowAtIndexPath - Removing secondary menu... - row: {0}", indexPath.Row);
// ResetEditingTableCellRow();
// }
cell.ImageChevron.Image = UIImage.FromBundle("Images/Tables/chevron_white");
cell.RightImage.Image = UIImage.FromBundle("Images/Icons/icon_speaker_white");
}
Expand Down
38 changes: 6 additions & 32 deletions MPfm/MPfm.iOS/Classes/Controllers/PlayerViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public partial class PlayerViewController : BaseViewController, IPlayerView
bool _isPositionChanging = false;
string _currentAlbumArtKey = string.Empty;
string _currentNavigationSubtitle = string.Empty;
MPVolumeView _volumeView;
UIBarButtonItem _btnBack;
PlayerMetadataViewController _playerMetadataViewController;
float _lastSliderPositionValue = 0;

Expand All @@ -72,8 +70,6 @@ public override void DidReceiveMemoryWarning()

public override void ViewDidLoad()
{
var screenSize = UIKitHelper.GetDeviceSize();

btnPrevious.BackgroundColor = GlobalTheme.BackgroundColor;
btnPlayPause.BackgroundColor = GlobalTheme.BackgroundColor;
btnNext.BackgroundColor = GlobalTheme.BackgroundColor;
Expand Down Expand Up @@ -139,7 +135,6 @@ public override void ViewDidLoad()
scrollViewWaveForm.Frame = new RectangleF(scrollViewWaveForm.Frame.X, scrollViewWaveForm.Frame.Y + offset, scrollViewWaveForm.Frame.Width, scrollViewWaveForm.Frame.Height * 2);
scrollViewWaveForm.WaveFormView.Frame = new RectangleF(scrollViewWaveForm.WaveFormView.Frame.X, scrollViewWaveForm.WaveFormView.Frame.Y, scrollViewWaveForm.WaveFormView.Frame.Width, (scrollViewWaveForm.WaveFormView.Frame.Height * 2) + 22);
viewMain.Frame = new RectangleF(viewMain.Frame.X, viewPosition.Frame.Height + scrollViewWaveForm.Frame.Height, viewMain.Frame.Width, viewMain.Frame.Height);
_volumeView.Frame = new RectangleF(_volumeView.Frame.X, viewPosition.Frame.Height + scrollViewWaveForm.Frame.Height + viewMain.Frame.Height - 32, _volumeView.Frame.Width, _volumeView.Frame.Height);
lblSlideMessage.Alpha = 1;
lblScrubbingType.Alpha = 1;
scrollViewWaveForm.ShowSecondaryPosition(true);
Expand All @@ -159,7 +154,6 @@ public override void ViewDidLoad()
scrollViewWaveForm.Frame = new RectangleF(scrollViewWaveForm.Frame.X, scrollViewWaveForm.Frame.Y - offset, scrollViewWaveForm.Frame.Width, scrollViewWaveForm.Frame.Height / 2);
scrollViewWaveForm.WaveFormView.Frame = new RectangleF(scrollViewWaveForm.WaveFormView.Frame.X, scrollViewWaveForm.WaveFormView.Frame.Y, scrollViewWaveForm.WaveFormView.Frame.Width, (scrollViewWaveForm.WaveFormView.Frame.Height - 22) / 2);
viewMain.Frame = new RectangleF(viewMain.Frame.X, viewPosition.Frame.Height + scrollViewWaveForm.Frame.Height, viewMain.Frame.Width, viewMain.Frame.Height);
_volumeView.Frame = new RectangleF(_volumeView.Frame.X, viewPosition.Frame.Height + scrollViewWaveForm.Frame.Height + viewMain.Frame.Height - 32, _volumeView.Frame.Width, _volumeView.Frame.Height);
lblSlideMessage.Alpha = 0;
lblScrubbingType.Alpha = 0;
});
Expand All @@ -171,19 +165,6 @@ public override void ViewDidLoad()
_isPositionChanging = false;
};

// Create MPVolumeView (only visible on physical iOS device)

RectangleF rectVolume;
if (UserInterfaceIdiomIsPhone)
rectVolume = new RectangleF(8, screenSize.Height - 44 - 52, screenSize.Width - 16, 46);
else
rectVolume = new RectangleF(8 + 320, screenSize.Height - 44 - 50, screenSize.Width - 16 - 320, 46);
_volumeView = new MPVolumeView(rectVolume);
_volumeView.SetMinimumVolumeSliderImage(UIImage.FromBundle("Images/Sliders/slider2").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
_volumeView.SetMaximumVolumeSliderImage(UIImage.FromBundle("Images/Sliders/slider").CreateResizableImage(new UIEdgeInsets(0, 8, 0, 8), UIImageResizingMode.Tile), UIControlState.Normal);
_volumeView.SetVolumeThumbImage(UIImage.FromBundle("Images/Sliders/thumbbig"), UIControlState.Normal);
this.View.AddSubview(_volumeView);

// Only display wave form on iPhone 5+ and iPad
if (DarwinHardwareHelper.Version == DarwinHardwareHelper.HardwareVersion.iPhone3GS ||
DarwinHardwareHelper.Version == DarwinHardwareHelper.HardwareVersion.iPhone4 ||
Expand Down Expand Up @@ -215,23 +196,16 @@ public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);

MPfmNavigationController navCtrl = (MPfmNavigationController)this.NavigationController;
navCtrl.SetTitle("Now Playing", _currentNavigationSubtitle);
//MPfmNavigationController navCtrl = (MPfmNavigationController)this.NavigationController;
//navCtrl.SetTitle("Now Playing", _currentNavigationSubtitle);
}

public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();

var screenSize = UIKitHelper.GetDeviceSize();
if (UserInterfaceIdiomIsPhone)
if (!UserInterfaceIdiomIsPhone)
{
//_volumeView.Frame = new RectangleF(8, screenSize.Height - 44 - 52, screenSize.Width - 16, 46);
}
else
{
_volumeView.Frame = new RectangleF(8 + 320, screenSize.Height - 44 - 50, screenSize.Width - 16 - 320, 46);

// Resize scrollview subviews.
for (int a = 0; a < scrollView.Subviews.Count(); a++)
{
Expand Down Expand Up @@ -519,9 +493,9 @@ public async void RefreshSongInformation(AudioFile audioFile, long lengthBytes,
InvokeOnMainThread(() => {
try
{
_currentNavigationSubtitle = (playlistIndex+1).ToString() + " of " + playlistCount.ToString();
MPfmNavigationController navCtrl = (MPfmNavigationController)this.NavigationController;
navCtrl.SetTitle("Now Playing", _currentNavigationSubtitle);
//_currentNavigationSubtitle = (playlistIndex+1).ToString() + " of " + playlistCount.ToString();
//MPfmNavigationController navCtrl = (MPfmNavigationController)this.NavigationController;
//navCtrl.SetTitle("Now Playing", _currentNavigationSubtitle);
ShowPlayerMetadata(true, false);
lblLength.Text = audioFile.Length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public override void ViewDidLoad()
tableView.WeakDataSource = this;
tableView.WeakDelegate = this;

NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand Down
3 changes: 3 additions & 0 deletions MPfm/MPfm.iOS/Classes/Controllers/SyncMenuViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public override void ViewDidLoad()
viewSync.Hidden = true;
tableView.Hidden = true;

NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();
}

Expand Down
Loading

0 comments on commit d4e18a7

Please sign in to comment.