From f7dd9a3dcfc8cf951d0f0ed01a3664b769d4ed83 Mon Sep 17 00:00:00 2001 From: ycastonguay Date: Mon, 11 Feb 2013 23:47:29 -0500 Subject: [PATCH] Added MobileOptionsMenu presenter/view. --- .../Classes/Activities/MainActivity.cs | 355 ++++++----- .../Classes/Activities/PreferencesActivity.cs | 253 ++++---- MPfm/MPfm.Android/Classes/Application.cs | 175 +++--- .../AndroidNavigationManager.cs | 168 ++--- MPfm/MPfm.Android/MPfm.Android.csproj | 332 +++++----- .../Resources/Resource.Designer.cs | 575 +++++++++--------- .../Bootstrapper.cs | 159 ++--- MPfm/MPfm.MVP/MPfm.MVP.Android.csproj | 423 ++++++------- .../Navigation/MobileNavigationManager.cs | 402 ++++++------ MPfm/MPfm.MVP/Navigation/NavigationManager.cs | 261 ++++---- .../Interfaces/IMobileOptionsMenuPresenter.cs | 29 + .../Presenters/MobileOptionsMenuPresenter.cs | 64 ++ MPfm/MPfm.MVP/Views/IMobileOptionsMenuView.cs | 31 + 13 files changed, 1683 insertions(+), 1544 deletions(-) rename MPfm/MPfm.Android/Classes/{ => Navigation}/AndroidNavigationManager.cs (94%) rename MPfm/MPfm.MVP/{Bootstrapper => Bootstrap}/Bootstrapper.cs (96%) create mode 100644 MPfm/MPfm.MVP/Presenters/Interfaces/IMobileOptionsMenuPresenter.cs create mode 100644 MPfm/MPfm.MVP/Presenters/MobileOptionsMenuPresenter.cs create mode 100644 MPfm/MPfm.MVP/Views/IMobileOptionsMenuView.cs diff --git a/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs b/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs index 3a4ae8fe..f54a652f 100644 --- a/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs +++ b/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs @@ -1,180 +1,175 @@ -// 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 . - -using System; -using System.Collections.Generic; -using Android.App; -using Android.Content; -using Android.Content.PM; -using Android.Support.V4.View; -using Android.Views; -using Android.OS; -using Android.Widget; -using MPfm.Android.Classes; -using MPfm.Android.Classes.Adapters; -using MPfm.Android.Classes.Fragments; -using MPfm.Android.Classes.Objects; -using MPfm.Library.UpdateLibrary; -using MPfm.MVP.Models; -using MPfm.MVP.Views; -using Environment = Android.OS.Environment; - -namespace MPfm.Android -{ - [Activity(MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait, Theme = "@style/MyAppTheme")] - public class MainActivity : BaseActivity - { - private ViewPager _viewPager; - private TabPagerAdapter _tabPagerAdapter; - private List _fragments; - private SplashFragment _splashFragment; - private UpdateLibraryFragment _updateLibraryFragment; - - protected override void OnCreate(Bundle bundle) - { - Console.WriteLine("MainActivity - OnCreate"); - base.OnCreate(bundle); - - // Get application state - ApplicationState state = (ApplicationState)LastNonConfigurationInstance; - if (state != null) - { - // Restore state here - } - - // Request features - RequestWindowFeature(WindowFeatures.ActionBar); - SetContentView(Resource.Layout.Main); - ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; - - // Get controls - _viewPager = FindViewById(Resource.Id.main_pager); - - // Create view pager adapter - _fragments = new List(); - _tabPagerAdapter = new TabPagerAdapter(FragmentManager, _fragments, _viewPager, ActionBar); - _viewPager.Adapter = _tabPagerAdapter; - _viewPager.SetOnPageChangeListener(_tabPagerAdapter); - - // Bind this activity to splash and update library views - AndroidNavigationManager.Instance.MainActivity = this; - AndroidNavigationManager.Instance.Start(); - } - - public void AddTab(string title, Fragment fragment) - { - _fragments.Add(fragment); - var tab = ActionBar.NewTab(); - tab.SetTabListener(_tabPagerAdapter); - tab.SetText(title); - ActionBar.AddTab(tab); - } - - protected override void OnStart() - { - Console.WriteLine("MainActivity - OnStart"); - base.OnStart(); - } - - protected override void OnRestart() - { - Console.WriteLine("MainActivity - OnRestart"); - base.OnRestart(); - } - - protected override void OnPause() - { - Console.WriteLine("MainActivity - OnPause"); - base.OnPause(); - } - - protected override void OnResume() - { - Console.WriteLine("MainActivity - OnResume"); - base.OnResume(); - } - - protected override void OnStop() - { - Console.WriteLine("MainActivity - OnStop"); - base.OnStop(); - } - - protected override void OnDestroy() - { - Console.WriteLine("MainActivity - OnDestroy"); - base.OnDestroy(); - } - - public override Java.Lang.Object OnRetainNonConfigurationInstance() - { - // Save stuff here - ApplicationState state = new ApplicationState(); - return state; - } - - public override bool OnCreateOptionsMenu(IMenu menu) - { - MenuInflater.Inflate(Resource.Menu.main_menu, menu); - return true; - } - - public override bool OnOptionsItemSelected(IMenuItem menuItem) - { - // TODO: Determine if the menu should call the NavMgr directly, or the presenter... something like a MainMenuPresenter? - string text = menuItem.TitleFormatted.ToString(); - if (text.ToUpper() == "EFFECTS") - { - - } - else if (text.ToUpper() == "UPDATE LIBRARY") - { - ShowUpdateLibrary((UpdateLibraryFragment)AndroidNavigationManager.Instance.CreateUpdateLibraryView()); - } - else if (text.ToUpper() == "PREFERENCES") - { - Intent intent = new Intent(this, typeof(PreferencesActivity)); - StartActivity(intent); - } - else if (text.ToUpper() == "ABOUT MPFM") - { - //ShowSplashScreen(); - //var dialog = new DialogTest(); - //dialog.Show(FragmentManager, "tagnumber"); - } - return base.OnOptionsItemSelected(menuItem); - } - - public void ShowSplashScreen(SplashFragment fragment) - { - // Display fragment in a dialog - _splashFragment = fragment; - _splashFragment.Show(FragmentManager, ""); - } - - public void RemoveSplashScreen() - { - _splashFragment.Dialog.Dismiss(); - } - - private void ShowUpdateLibrary(UpdateLibraryFragment fragment) - { - _updateLibraryFragment = fragment; - _updateLibraryFragment.Show(FragmentManager, ""); - } - } -} +// 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 . + +using System; +using System.Collections.Generic; +using Android.App; +using Android.Content; +using Android.Content.PM; +using Android.Support.V4.View; +using Android.Views; +using Android.OS; +using MPfm.Android.Classes.Adapters; +using MPfm.Android.Classes.Fragments; +using MPfm.Android.Classes.Navigation; +using MPfm.Android.Classes.Objects; + +namespace MPfm.Android +{ + [Activity(MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait, Theme = "@style/MyAppTheme")] + public class MainActivity : BaseActivity + { + private ViewPager _viewPager; + private TabPagerAdapter _tabPagerAdapter; + private List _fragments; + private SplashFragment _splashFragment; + private UpdateLibraryFragment _updateLibraryFragment; + + protected override void OnCreate(Bundle bundle) + { + Console.WriteLine("MainActivity - OnCreate"); + base.OnCreate(bundle); + + // Get application state + ApplicationState state = (ApplicationState)LastNonConfigurationInstance; + if (state != null) + { + // Restore state here + } + + // Request features + RequestWindowFeature(WindowFeatures.ActionBar); + SetContentView(Resource.Layout.Main); + ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; + + // Get controls + _viewPager = FindViewById(Resource.Id.main_pager); + + // Create view pager adapter + _fragments = new List(); + _tabPagerAdapter = new TabPagerAdapter(FragmentManager, _fragments, _viewPager, ActionBar); + _viewPager.Adapter = _tabPagerAdapter; + _viewPager.SetOnPageChangeListener(_tabPagerAdapter); + + // Bind this activity to splash and update library views + AndroidNavigationManager.Instance.MainActivity = this; + AndroidNavigationManager.Instance.Start(); + } + + public void AddTab(string title, Fragment fragment) + { + _fragments.Add(fragment); + var tab = ActionBar.NewTab(); + tab.SetTabListener(_tabPagerAdapter); + tab.SetText(title); + ActionBar.AddTab(tab); + } + + protected override void OnStart() + { + Console.WriteLine("MainActivity - OnStart"); + base.OnStart(); + } + + protected override void OnRestart() + { + Console.WriteLine("MainActivity - OnRestart"); + base.OnRestart(); + } + + protected override void OnPause() + { + Console.WriteLine("MainActivity - OnPause"); + base.OnPause(); + } + + protected override void OnResume() + { + Console.WriteLine("MainActivity - OnResume"); + base.OnResume(); + } + + protected override void OnStop() + { + Console.WriteLine("MainActivity - OnStop"); + base.OnStop(); + } + + protected override void OnDestroy() + { + Console.WriteLine("MainActivity - OnDestroy"); + base.OnDestroy(); + } + + public override Java.Lang.Object OnRetainNonConfigurationInstance() + { + // Save stuff here + ApplicationState state = new ApplicationState(); + return state; + } + + public override bool OnCreateOptionsMenu(IMenu menu) + { + MenuInflater.Inflate(Resource.Menu.main_menu, menu); + return true; + } + + public override bool OnOptionsItemSelected(IMenuItem menuItem) + { + // TODO: Determine if the menu should call the NavMgr directly, or the presenter... something like a MainMenuPresenter? + string text = menuItem.TitleFormatted.ToString(); + if (text.ToUpper() == "EFFECTS") + { + + } + else if (text.ToUpper() == "UPDATE LIBRARY") + { + ShowUpdateLibrary((UpdateLibraryFragment)AndroidNavigationManager.Instance.CreateUpdateLibraryView()); + } + else if (text.ToUpper() == "PREFERENCES") + { + Intent intent = new Intent(this, typeof(PreferencesActivity)); + StartActivity(intent); + } + else if (text.ToUpper() == "ABOUT MPFM") + { + //ShowSplashScreen(); + //var dialog = new DialogTest(); + //dialog.Show(FragmentManager, "tagnumber"); + } + return base.OnOptionsItemSelected(menuItem); + } + + public void ShowSplashScreen(SplashFragment fragment) + { + // Display fragment in a dialog + _splashFragment = fragment; + _splashFragment.Show(FragmentManager, ""); + } + + public void RemoveSplashScreen() + { + _splashFragment.Dialog.Dismiss(); + } + + private void ShowUpdateLibrary(UpdateLibraryFragment fragment) + { + _updateLibraryFragment = fragment; + _updateLibraryFragment.Show(FragmentManager, ""); + } + } +} diff --git a/MPfm/MPfm.Android/Classes/Activities/PreferencesActivity.cs b/MPfm/MPfm.Android/Classes/Activities/PreferencesActivity.cs index 3b4702bd..16ff9535 100644 --- a/MPfm/MPfm.Android/Classes/Activities/PreferencesActivity.cs +++ b/MPfm/MPfm.Android/Classes/Activities/PreferencesActivity.cs @@ -1,126 +1,127 @@ -// 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 . - -using System; -using System.Collections.Generic; -using Android.App; -using Android.Content.PM; -using Android.Support.V4.View; -using Android.Views; -using Android.OS; -using MPfm.Android.Classes; -using MPfm.Android.Classes.Adapters; -using MPfm.Android.Classes.Fragments; -using MPfm.Android.Classes.Objects; -using TagLib.Riff; - -namespace MPfm.Android -{ - [Activity(Label = "MPfm: Preferences")] - public class PreferencesActivity : BaseActivity, View.IOnClickListener - { - private ViewPager _viewPager; - private TabPagerAdapter _tabPagerAdapter; - private List _fragments; - - protected override void OnCreate(Bundle bundle) - { - Console.WriteLine("PreferencesActivity - OnCreate"); - base.OnCreate(bundle); - - // Load navigation manager and other important stuff before showing splash screen - RequestWindowFeature(WindowFeatures.ActionBar); - SetContentView(Resource.Layout.Settings); - ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; - - // Bind view to presenter - //AndroidNavigationManager.Instance.BindPreferencesView(this); - } - - protected override void OnStart() - { - Console.WriteLine("PreferencesActivity - OnStart"); - base.OnStart(); - - // Create fragments - _fragments = new List(); - _fragments.Add((Fragment)AndroidNavigationManager.Instance.CreateGeneralPreferencesView()); - _fragments.Add((Fragment)AndroidNavigationManager.Instance.CreateAudioPreferencesView()); - _fragments.Add((Fragment)AndroidNavigationManager.Instance.CreateLibraryPreferencesView()); - - // Create view pager (for lateral navigation) - _viewPager = FindViewById(Resource.Id.settings_pager); - _tabPagerAdapter = new TabPagerAdapter(FragmentManager, _fragments, _viewPager, ActionBar); - _viewPager.Adapter = _tabPagerAdapter; - _viewPager.SetOnPageChangeListener(_tabPagerAdapter); - - // Create tabs - var generalTab = ActionBar.NewTab(); - generalTab.SetTabListener(_tabPagerAdapter); - generalTab.SetText("General"); - ActionBar.AddTab(generalTab); - var audioTab = ActionBar.NewTab(); - audioTab.SetTabListener(_tabPagerAdapter); - audioTab.SetText("Audio"); - ActionBar.AddTab(audioTab); - var libraryTab = ActionBar.NewTab(); - libraryTab.SetTabListener(_tabPagerAdapter); - libraryTab.SetText("Library"); - ActionBar.AddTab(libraryTab); - } - - protected override void OnRestart() - { - Console.WriteLine("PreferencesActivity - OnRestart"); - base.OnRestart(); - } - - protected override void OnPause() - { - Console.WriteLine("PreferencesActivity - OnPause"); - base.OnPause(); - } - - protected override void OnResume() - { - Console.WriteLine("PreferencesActivity - OnResume"); - base.OnResume(); - } - - protected override void OnStop() - { - Console.WriteLine("PreferencesActivity - OnStop"); - base.OnStop(); - } - - protected override void OnDestroy() - { - Console.WriteLine("PreferencesActivity - OnDestroy"); - base.OnDestroy(); - } - - public void OnClick(View v) - { - } - - //public override void OnBackPressed() - //{ - // // Close activity - // Finish(); - //} - } -} +// 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 . + +using System; +using System.Collections.Generic; +using Android.App; +using Android.Content.PM; +using Android.Support.V4.View; +using Android.Views; +using Android.OS; +using MPfm.Android.Classes; +using MPfm.Android.Classes.Adapters; +using MPfm.Android.Classes.Fragments; +using MPfm.Android.Classes.Navigation; +using MPfm.Android.Classes.Objects; +using TagLib.Riff; + +namespace MPfm.Android +{ + [Activity(Label = "MPfm: Preferences")] + public class PreferencesActivity : BaseActivity, View.IOnClickListener + { + private ViewPager _viewPager; + private TabPagerAdapter _tabPagerAdapter; + private List _fragments; + + protected override void OnCreate(Bundle bundle) + { + Console.WriteLine("PreferencesActivity - OnCreate"); + base.OnCreate(bundle); + + // Load navigation manager and other important stuff before showing splash screen + RequestWindowFeature(WindowFeatures.ActionBar); + SetContentView(Resource.Layout.Settings); + ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; + + // Bind view to presenter + //AndroidNavigationManager.Instance.BindPreferencesView(this); + } + + protected override void OnStart() + { + Console.WriteLine("PreferencesActivity - OnStart"); + base.OnStart(); + + // Create fragments + _fragments = new List(); + _fragments.Add((Fragment)AndroidNavigationManager.Instance.CreateGeneralPreferencesView()); + _fragments.Add((Fragment)AndroidNavigationManager.Instance.CreateAudioPreferencesView()); + _fragments.Add((Fragment)AndroidNavigationManager.Instance.CreateLibraryPreferencesView()); + + // Create view pager (for lateral navigation) + _viewPager = FindViewById(Resource.Id.settings_pager); + _tabPagerAdapter = new TabPagerAdapter(FragmentManager, _fragments, _viewPager, ActionBar); + _viewPager.Adapter = _tabPagerAdapter; + _viewPager.SetOnPageChangeListener(_tabPagerAdapter); + + // Create tabs + var generalTab = ActionBar.NewTab(); + generalTab.SetTabListener(_tabPagerAdapter); + generalTab.SetText("General"); + ActionBar.AddTab(generalTab); + var audioTab = ActionBar.NewTab(); + audioTab.SetTabListener(_tabPagerAdapter); + audioTab.SetText("Audio"); + ActionBar.AddTab(audioTab); + var libraryTab = ActionBar.NewTab(); + libraryTab.SetTabListener(_tabPagerAdapter); + libraryTab.SetText("Library"); + ActionBar.AddTab(libraryTab); + } + + protected override void OnRestart() + { + Console.WriteLine("PreferencesActivity - OnRestart"); + base.OnRestart(); + } + + protected override void OnPause() + { + Console.WriteLine("PreferencesActivity - OnPause"); + base.OnPause(); + } + + protected override void OnResume() + { + Console.WriteLine("PreferencesActivity - OnResume"); + base.OnResume(); + } + + protected override void OnStop() + { + Console.WriteLine("PreferencesActivity - OnStop"); + base.OnStop(); + } + + protected override void OnDestroy() + { + Console.WriteLine("PreferencesActivity - OnDestroy"); + base.OnDestroy(); + } + + public void OnClick(View v) + { + } + + //public override void OnBackPressed() + //{ + // // Close activity + // Finish(); + //} + } +} diff --git a/MPfm/MPfm.Android/Classes/Application.cs b/MPfm/MPfm.Android/Classes/Application.cs index 31bcfced..4d9c5103 100644 --- a/MPfm/MPfm.Android/Classes/Application.cs +++ b/MPfm/MPfm.Android/Classes/Application.cs @@ -1,87 +1,88 @@ -// 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 . - -using System; -using Android.App; -using Android.Content.PM; -using Android.Runtime; -using MPfm.Android.Classes.Fragments; -using MPfm.MVP; -using MPfm.MVP.Bootstrapper; -using MPfm.MVP.Navigation; -using MPfm.MVP.Views; -using MPfm.Player; -using MPfm.Sound.Bass.Net; - -namespace MPfm.Android.Classes -{ - [Application (Name="my.App", Debuggable=true, Label="MPfm: Music Player for Musicians")] - public class MPfmApplication : Application - { - private IPlayer _player; - - public MPfmApplication(IntPtr javaReference, JniHandleOwnership transfer) - : base(javaReference, transfer) - { - } - - public override void OnCreate() - { - base.OnCreate(); - - // Complete IoC configuration - TinyIoC.TinyIoCContainer container = Bootstrapper.GetContainer(); - container.Register().AsSingleton(); - container.Register().AsMultiInstance(); - container.Register().AsMultiInstance(); - container.Register().AsMultiInstance(); - container.Register().AsMultiInstance(); - container.Register().AsMultiInstance(); - container.Register().AsMultiInstance(); - - // Set player plugin directory path - ApplicationInfo appInfo = PackageManager.GetApplicationInfo(PackageName, 0); - string nativeDir = appInfo.NativeLibraryDir; - Player.Player.PluginDirectoryPath = appInfo.NativeLibraryDir; - - // Initialize player - Device device = new Device() - { - DriverType = DriverType.DirectSound, - Id = -1 - }; - _player = new MPfm.Player.Player(device, 44100, 5000, 100, true); - } - - public override void OnLowMemory() - { - base.OnLowMemory(); - } - - public override void OnTerminate() - { - base.OnTerminate(); - - // Clean up player - if (MPfm.Player.Player.CurrentPlayer.IsPlaying) - { - MPfm.Player.Player.CurrentPlayer.Stop(); - } - MPfm.Player.Player.CurrentPlayer.Dispose(); - } - } -} +// 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 . + +using System; +using Android.App; +using Android.Content.PM; +using Android.Runtime; +using MPfm.Android.Classes.Fragments; +using MPfm.Android.Classes.Navigation; +using MPfm.MVP; +using MPfm.MVP.Bootstrap; +using MPfm.MVP.Navigation; +using MPfm.MVP.Views; +using MPfm.Player; +using MPfm.Sound.Bass.Net; + +namespace MPfm.Android.Classes +{ + [Application (Name="my.App", Debuggable=true, Label="MPfm: Music Player for Musicians")] + public class MPfmApplication : Application + { + private IPlayer _player; + + public MPfmApplication(IntPtr javaReference, JniHandleOwnership transfer) + : base(javaReference, transfer) + { + } + + public override void OnCreate() + { + base.OnCreate(); + + // Complete IoC configuration + TinyIoC.TinyIoCContainer container = Bootstrapper.GetContainer(); + container.Register().AsSingleton(); + container.Register().AsMultiInstance(); + container.Register().AsMultiInstance(); + container.Register().AsMultiInstance(); + container.Register().AsMultiInstance(); + container.Register().AsMultiInstance(); + container.Register().AsMultiInstance(); + + // Set player plugin directory path + ApplicationInfo appInfo = PackageManager.GetApplicationInfo(PackageName, 0); + string nativeDir = appInfo.NativeLibraryDir; + Player.Player.PluginDirectoryPath = appInfo.NativeLibraryDir; + + // Initialize player + Device device = new Device() + { + DriverType = DriverType.DirectSound, + Id = -1 + }; + _player = new MPfm.Player.Player(device, 44100, 5000, 100, true); + } + + public override void OnLowMemory() + { + base.OnLowMemory(); + } + + public override void OnTerminate() + { + base.OnTerminate(); + + // Clean up player + if (MPfm.Player.Player.CurrentPlayer.IsPlaying) + { + MPfm.Player.Player.CurrentPlayer.Stop(); + } + MPfm.Player.Player.CurrentPlayer.Dispose(); + } + } +} diff --git a/MPfm/MPfm.Android/Classes/AndroidNavigationManager.cs b/MPfm/MPfm.Android/Classes/Navigation/AndroidNavigationManager.cs similarity index 94% rename from MPfm/MPfm.Android/Classes/AndroidNavigationManager.cs rename to MPfm/MPfm.Android/Classes/Navigation/AndroidNavigationManager.cs index 18fb51e3..3bad0cae 100644 --- a/MPfm/MPfm.Android/Classes/AndroidNavigationManager.cs +++ b/MPfm/MPfm.Android/Classes/Navigation/AndroidNavigationManager.cs @@ -1,84 +1,84 @@ -// 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 . - -using MPfm.Android.Classes.Fragments; -using MPfm.MVP.Navigation; -using MPfm.MVP.Views; - -namespace MPfm.Android.Classes -{ - public sealed class AndroidNavigationManager : MobileNavigationManager - { - private static readonly AndroidNavigationManager _instance = new AndroidNavigationManager(); - public static AndroidNavigationManager Instance - { - get { return _instance; } - } - - public MainActivity MainActivity { get; set; } - - public override void ShowSplash(ISplashView view) - { - MainActivity.ShowSplashScreen((SplashFragment)view); - } - - public override void HideSplash() - { - MainActivity.RemoveSplashScreen(); - } - - public override void AddTab(string title, IBaseView view) - { - MobileLibraryBrowserFragment fragment = (MobileLibraryBrowserFragment)view; - MainActivity.AddTab(title, fragment); - // iOS: AppDelegate.AddTabItem(newView); - } - - public override void PushView(IBaseView context, IBaseView newView) - { - // If there's no context, this means this is a top-level view - if (context == null) - { - if (newView is IMobileLibraryBrowserView) - { - } - else if (newView is IAudioPreferencesView) - { - - } - - - // Here would be the top views. - // Mobile = 4x Mobile Library Browser - // Desktop = 1x Main Window - - // Need to have Activity ref here. - // The MainActivity is created before initializing the NavigationManager. - //MainActivity.PushView(context); // inside main activity, add - } - - if (context is IMobileLibraryBrowserView) - { - MobileLibraryBrowserFragment fragment = (MobileLibraryBrowserFragment)context; - //fragment.PushView(newView); - } - - - - } - } -} +// 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 . + +using MPfm.Android.Classes.Fragments; +using MPfm.MVP.Navigation; +using MPfm.MVP.Views; + +namespace MPfm.Android.Classes.Navigation +{ + public sealed class AndroidNavigationManager : MobileNavigationManager + { + private static readonly AndroidNavigationManager _instance = new AndroidNavigationManager(); + public static AndroidNavigationManager Instance + { + get { return _instance; } + } + + public MainActivity MainActivity { get; set; } + + public override void ShowSplash(ISplashView view) + { + MainActivity.ShowSplashScreen((SplashFragment)view); + } + + public override void HideSplash() + { + MainActivity.RemoveSplashScreen(); + } + + public override void AddTab(string title, IBaseView view) + { + MobileLibraryBrowserFragment fragment = (MobileLibraryBrowserFragment)view; + MainActivity.AddTab(title, fragment); + // iOS: AppDelegate.AddTabItem(newView); + } + + public override void PushView(IBaseView context, IBaseView newView) + { + // If there's no context, this means this is a top-level view + if (context == null) + { + if (newView is IMobileLibraryBrowserView) + { + } + else if (newView is IAudioPreferencesView) + { + + } + + + // Here would be the top views. + // Mobile = 4x Mobile Library Browser + // Desktop = 1x Main Window + + // Need to have Activity ref here. + // The MainActivity is created before initializing the NavigationManager. + //MainActivity.PushView(context); // inside main activity, add + } + + if (context is IMobileLibraryBrowserView) + { + MobileLibraryBrowserFragment fragment = (MobileLibraryBrowserFragment)context; + //fragment.PushView(newView); + } + + + + } + } +} diff --git a/MPfm/MPfm.Android/MPfm.Android.csproj b/MPfm/MPfm.Android/MPfm.Android.csproj index e7b662c0..27a1ad7a 100644 --- a/MPfm/MPfm.Android/MPfm.Android.csproj +++ b/MPfm/MPfm.Android/MPfm.Android.csproj @@ -1,173 +1,173 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {3B7ACEA3-D637-4BE4-A09E-8FF9A878600E} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Properties - MPfm.Android - MPfm.Android - 512 - true - Resources\Resource.Designer.cs - Off - v4.1 - armeabi%3barmeabi-v7a%3bx86 - - - Properties\AndroidManifest.xml - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - True - None - - True - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - False - SdkOnly - - - - - - - - - - - False - ..\MPfm.Sound\Lib\Android\taglib-sharp.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Designer - - - Designer - - - Designer - - - Designer - - - Designer - - - Designer - - - Designer - - - Designer - - - - - Designer - - - - - - - - {d536fde5-989e-4979-9b39-63621ae4a205} - MPfm.Core.Android - - - {2a62d229-d7fc-41da-b676-bb1371659bfb} - MPfm.Library.Android - - - {b6b0613c-ff39-479d-9ef0-31daf9684a06} - MPfm.MVP.Android - - - {feb7497c-784c-4380-874f-46fd93c82ba1} - MPfm.Player.Android - - - {d92f718e-9a24-4b8b-9e40-77f93cf89eae} - MPfm.Sound.Android - - - - - - - - - - - - - - - - + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {3B7ACEA3-D637-4BE4-A09E-8FF9A878600E} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + MPfm.Android + MPfm.Android + 512 + true + Resources\Resource.Designer.cs + Off + v4.1 + armeabi%3barmeabi-v7a%3bx86 + + + Properties\AndroidManifest.xml + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + True + None + + True + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + False + SdkOnly + + + + + + + + + + + False + ..\MPfm.Sound\Lib\Android\taglib-sharp.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + + + Designer + + + + + + + + {d536fde5-989e-4979-9b39-63621ae4a205} + MPfm.Core.Android + + + {2a62d229-d7fc-41da-b676-bb1371659bfb} + MPfm.Library.Android + + + {b6b0613c-ff39-479d-9ef0-31daf9684a06} + MPfm.MVP.Android + + + {feb7497c-784c-4380-874f-46fd93c82ba1} + MPfm.Player.Android + + + {d92f718e-9a24-4b8b-9e40-77f93cf89eae} + MPfm.Sound.Android + + + + + + + + + + + + + + + + + --> \ No newline at end of file diff --git a/MPfm/MPfm.Android/Resources/Resource.Designer.cs b/MPfm/MPfm.Android/Resources/Resource.Designer.cs index 60b8e91f..8c9e91df 100644 --- a/MPfm/MPfm.Android/Resources/Resource.Designer.cs +++ b/MPfm/MPfm.Android/Resources/Resource.Designer.cs @@ -1,296 +1,279 @@ -// 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 . - -#pragma warning disable 1591 -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18034 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[assembly: Android.Runtime.ResourceDesignerAttribute("MPfm.Android.Resource", IsApplication=true)] - -namespace MPfm.Android -{ - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("Novell.MonoDroid.Build.Tasks", "1.0.0.0")] - public partial class Resource - { - - public static void UpdateIdValues() - { - } - - public partial class Animation - { - - // aapt resource value: 0x7f040000 - public const int fade_in = 2130968576; - - // aapt resource value: 0x7f040001 - public const int fade_out = 2130968577; - - private Animation() - { - } - } - - public partial class Attribute - { - - private Attribute() - { - } - } - - public partial class Color - { - - // aapt resource value: 0x7f050000 - public const int color_black = 2131034112; - - private Color() - { - } - } - - public partial class Drawable - { - - // aapt resource value: 0x7f020000 - public const int Icon = 2130837504; - - // aapt resource value: 0x7f020001 - public const int Splash = 2130837505; - - private Drawable() - { - } - } - - public partial class Id - { - - // aapt resource value: 0x7f090001 - public const int fragment_audioSettings_lblTitle = 2131296257; - - // aapt resource value: 0x7f090000 - public const int fragment_audioSettings_mainLayout = 2131296256; - - // aapt resource value: 0x7f090003 - public const int fragment_generalSettings_lblTitle = 2131296259; - - // aapt resource value: 0x7f090002 - public const int fragment_generalSettings_mainLayout = 2131296258; - - // aapt resource value: 0x7f090005 - public const int fragment_librarySettings_lblTitle = 2131296261; - - // aapt resource value: 0x7f090004 - public const int fragment_librarySettings_mainLayout = 2131296260; - - // aapt resource value: 0x7f090013 - public const int fragment_player_btnNext = 2131296275; - - // aapt resource value: 0x7f090012 - public const int fragment_player_btnPlayPause = 2131296274; - - // aapt resource value: 0x7f090011 - public const int fragment_player_btnPrevious = 2131296273; - - // aapt resource value: 0x7f090007 - public const int fragment_player_frameLayout = 2131296263; - - // aapt resource value: 0x7f090008 - public const int fragment_player_imageViewAlbumArt = 2131296264; - - // aapt resource value: 0x7f09000b - public const int fragment_player_lblAlbumTitle = 2131296267; - - // aapt resource value: 0x7f09000a - public const int fragment_player_lblArtistName = 2131296266; - - // aapt resource value: 0x7f09000e - public const int fragment_player_lblLength = 2131296270; - - // aapt resource value: 0x7f09000d - public const int fragment_player_lblPosition = 2131296269; - - // aapt resource value: 0x7f09000c - public const int fragment_player_lblSongTitle = 2131296268; - - // aapt resource value: 0x7f090009 - public const int fragment_player_linearLayout = 2131296265; - - // aapt resource value: 0x7f090010 - public const int fragment_player_linearLayoutButtons = 2131296272; - - // aapt resource value: 0x7f090006 - public const int fragment_player_mainLayout = 2131296262; - - // aapt resource value: 0x7f09000f - public const int fragment_player_seekBar = 2131296271; - - // aapt resource value: 0x7f090019 - public const int fragment_updateLibrary_button = 2131296281; - - // aapt resource value: 0x7f090018 - public const int fragment_updateLibrary_lblSubtitle = 2131296280; - - // aapt resource value: 0x7f090017 - public const int fragment_updateLibrary_lblTitle = 2131296279; - - // aapt resource value: 0x7f090014 - public const int fragment_updateLibrary_mainLayout = 2131296276; - - // aapt resource value: 0x7f090016 - public const int fragment_updateLibrary_progressBar = 2131296278; - - // aapt resource value: 0x7f090015 - public const int fragment_updateLibrary_relativeLayout = 2131296277; - - // aapt resource value: 0x7f09001a - public const int genericcell_image = 2131296282; - - // aapt resource value: 0x7f09001b - public const int genericcell_title = 2131296283; - - // aapt resource value: 0x7f09001c - public const int main_layout = 2131296284; - - // aapt resource value: 0x7f09001d - public const int main_pager = 2131296285; - - // aapt resource value: 0x7f090025 - public const int menu_item_about = 2131296293; - - // aapt resource value: 0x7f090022 - public const int menu_item_effects = 2131296290; - - // aapt resource value: 0x7f090024 - public const int menu_item_preferences = 2131296292; - - // aapt resource value: 0x7f090023 - public const int menu_item_updateLibrary = 2131296291; - - // aapt resource value: 0x7f09001e - public const int settings_layout = 2131296286; - - // aapt resource value: 0x7f09001f - public const int settings_pager = 2131296287; - - // aapt resource value: 0x7f090020 - public const int splash_layout = 2131296288; - - // aapt resource value: 0x7f090021 - public const int splash_text = 2131296289; - - private Id() - { - } - } - - public partial class Layout - { - - // aapt resource value: 0x7f030000 - public const int Fragment_AudioPreferences = 2130903040; - - // aapt resource value: 0x7f030001 - public const int Fragment_GeneralPreferences = 2130903041; - - // aapt resource value: 0x7f030002 - public const int Fragment_LibraryPreferences = 2130903042; - - // aapt resource value: 0x7f030003 - public const int Fragment_Player = 2130903043; - - // aapt resource value: 0x7f030004 - public const int Fragment_UpdateLibrary = 2130903044; - - // aapt resource value: 0x7f030005 - public const int GenericCell = 2130903045; - - // aapt resource value: 0x7f030006 - public const int Main = 2130903046; - - // aapt resource value: 0x7f030007 - public const int Settings = 2130903047; - - // aapt resource value: 0x7f030008 - public const int Splash = 2130903048; - - private Layout() - { - } - } - - public partial class Menu - { - - // aapt resource value: 0x7f080000 - public const int main_menu = 2131230720; - - private Menu() - { - } - } - - public partial class String - { - - // aapt resource value: 0x7f060001 - public const int ApplicationName = 2131099649; - - // aapt resource value: 0x7f060000 - public const int Hello = 2131099648; - - private String() - { - } - } - - public partial class Style - { - - // aapt resource value: 0x7f070004 - public const int DialogAnimation = 2131165188; - - // aapt resource value: 0x7f070001 - public const int MyActionBar = 2131165185; - - // aapt resource value: 0x7f070000 - public const int MyAppTheme = 2131165184; - - // aapt resource value: 0x7f070002 - public const int SplashTheme = 2131165186; - - // aapt resource value: 0x7f070003 - public const int UpdateLibraryTheme = 2131165187; - - private Style() - { - } - } - } -} -#pragma warning restore 1591 +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18034 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +[assembly: Android.Runtime.ResourceDesignerAttribute("MPfm.Android.Resource", IsApplication=true)] + +namespace MPfm.Android +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Novell.MonoDroid.Build.Tasks", "1.0.0.0")] + public partial class Resource + { + + public static void UpdateIdValues() + { + } + + public partial class Animation + { + + // aapt resource value: 0x7f040000 + public const int fade_in = 2130968576; + + // aapt resource value: 0x7f040001 + public const int fade_out = 2130968577; + + private Animation() + { + } + } + + public partial class Attribute + { + + private Attribute() + { + } + } + + public partial class Color + { + + // aapt resource value: 0x7f050000 + public const int color_black = 2131034112; + + private Color() + { + } + } + + public partial class Drawable + { + + // aapt resource value: 0x7f020000 + public const int Icon = 2130837504; + + // aapt resource value: 0x7f020001 + public const int Splash = 2130837505; + + private Drawable() + { + } + } + + public partial class Id + { + + // aapt resource value: 0x7f090001 + public const int fragment_audioSettings_lblTitle = 2131296257; + + // aapt resource value: 0x7f090000 + public const int fragment_audioSettings_mainLayout = 2131296256; + + // aapt resource value: 0x7f090003 + public const int fragment_generalSettings_lblTitle = 2131296259; + + // aapt resource value: 0x7f090002 + public const int fragment_generalSettings_mainLayout = 2131296258; + + // aapt resource value: 0x7f090005 + public const int fragment_librarySettings_lblTitle = 2131296261; + + // aapt resource value: 0x7f090004 + public const int fragment_librarySettings_mainLayout = 2131296260; + + // aapt resource value: 0x7f090013 + public const int fragment_player_btnNext = 2131296275; + + // aapt resource value: 0x7f090012 + public const int fragment_player_btnPlayPause = 2131296274; + + // aapt resource value: 0x7f090011 + public const int fragment_player_btnPrevious = 2131296273; + + // aapt resource value: 0x7f090007 + public const int fragment_player_frameLayout = 2131296263; + + // aapt resource value: 0x7f090008 + public const int fragment_player_imageViewAlbumArt = 2131296264; + + // aapt resource value: 0x7f09000b + public const int fragment_player_lblAlbumTitle = 2131296267; + + // aapt resource value: 0x7f09000a + public const int fragment_player_lblArtistName = 2131296266; + + // aapt resource value: 0x7f09000e + public const int fragment_player_lblLength = 2131296270; + + // aapt resource value: 0x7f09000d + public const int fragment_player_lblPosition = 2131296269; + + // aapt resource value: 0x7f09000c + public const int fragment_player_lblSongTitle = 2131296268; + + // aapt resource value: 0x7f090009 + public const int fragment_player_linearLayout = 2131296265; + + // aapt resource value: 0x7f090010 + public const int fragment_player_linearLayoutButtons = 2131296272; + + // aapt resource value: 0x7f090006 + public const int fragment_player_mainLayout = 2131296262; + + // aapt resource value: 0x7f09000f + public const int fragment_player_seekBar = 2131296271; + + // aapt resource value: 0x7f090019 + public const int fragment_updateLibrary_button = 2131296281; + + // aapt resource value: 0x7f090018 + public const int fragment_updateLibrary_lblSubtitle = 2131296280; + + // aapt resource value: 0x7f090017 + public const int fragment_updateLibrary_lblTitle = 2131296279; + + // aapt resource value: 0x7f090014 + public const int fragment_updateLibrary_mainLayout = 2131296276; + + // aapt resource value: 0x7f090016 + public const int fragment_updateLibrary_progressBar = 2131296278; + + // aapt resource value: 0x7f090015 + public const int fragment_updateLibrary_relativeLayout = 2131296277; + + // aapt resource value: 0x7f09001a + public const int genericcell_image = 2131296282; + + // aapt resource value: 0x7f09001b + public const int genericcell_title = 2131296283; + + // aapt resource value: 0x7f09001c + public const int main_layout = 2131296284; + + // aapt resource value: 0x7f09001d + public const int main_pager = 2131296285; + + // aapt resource value: 0x7f090025 + public const int menu_item_about = 2131296293; + + // aapt resource value: 0x7f090022 + public const int menu_item_effects = 2131296290; + + // aapt resource value: 0x7f090024 + public const int menu_item_preferences = 2131296292; + + // aapt resource value: 0x7f090023 + public const int menu_item_updateLibrary = 2131296291; + + // aapt resource value: 0x7f09001e + public const int settings_layout = 2131296286; + + // aapt resource value: 0x7f09001f + public const int settings_pager = 2131296287; + + // aapt resource value: 0x7f090020 + public const int splash_layout = 2131296288; + + // aapt resource value: 0x7f090021 + public const int splash_text = 2131296289; + + private Id() + { + } + } + + public partial class Layout + { + + // aapt resource value: 0x7f030000 + public const int Fragment_AudioPreferences = 2130903040; + + // aapt resource value: 0x7f030001 + public const int Fragment_GeneralPreferences = 2130903041; + + // aapt resource value: 0x7f030002 + public const int Fragment_LibraryPreferences = 2130903042; + + // aapt resource value: 0x7f030003 + public const int Fragment_Player = 2130903043; + + // aapt resource value: 0x7f030004 + public const int Fragment_UpdateLibrary = 2130903044; + + // aapt resource value: 0x7f030005 + public const int GenericCell = 2130903045; + + // aapt resource value: 0x7f030006 + public const int Main = 2130903046; + + // aapt resource value: 0x7f030007 + public const int Settings = 2130903047; + + // aapt resource value: 0x7f030008 + public const int Splash = 2130903048; + + private Layout() + { + } + } + + public partial class Menu + { + + // aapt resource value: 0x7f080000 + public const int main_menu = 2131230720; + + private Menu() + { + } + } + + public partial class String + { + + // aapt resource value: 0x7f060001 + public const int ApplicationName = 2131099649; + + // aapt resource value: 0x7f060000 + public const int Hello = 2131099648; + + private String() + { + } + } + + public partial class Style + { + + // aapt resource value: 0x7f070004 + public const int DialogAnimation = 2131165188; + + // aapt resource value: 0x7f070001 + public const int MyActionBar = 2131165185; + + // aapt resource value: 0x7f070000 + public const int MyAppTheme = 2131165184; + + // aapt resource value: 0x7f070002 + public const int SplashTheme = 2131165186; + + // aapt resource value: 0x7f070003 + public const int UpdateLibraryTheme = 2131165187; + + private Style() + { + } + } + } +} +#pragma warning restore 1591 diff --git a/MPfm/MPfm.MVP/Bootstrapper/Bootstrapper.cs b/MPfm/MPfm.MVP/Bootstrap/Bootstrapper.cs similarity index 96% rename from MPfm/MPfm.MVP/Bootstrapper/Bootstrapper.cs rename to MPfm/MPfm.MVP/Bootstrap/Bootstrapper.cs index 5c8e8c66..add78afa 100644 --- a/MPfm/MPfm.MVP/Bootstrapper/Bootstrapper.cs +++ b/MPfm/MPfm.MVP/Bootstrap/Bootstrapper.cs @@ -1,79 +1,80 @@ -// 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 . - -using MPfm.Library.Database; -using MPfm.Library.Database.Interfaces; -using MPfm.MVP.Services; -using MPfm.MVP.Presenters.Interfaces; -using MPfm.MVP.Presenters; -using MPfm.MVP.Helpers; -using MPfm.MVP.Services.Interfaces; - -namespace MPfm.MVP.Bootstrapper -{ - /// - /// Singleton static class for bootstrapping the application. - /// Configures AutoMapper and Ninject. - /// - public static class Bootstrapper - { - /// - /// Constructor for the Bootstrapper static class. - /// - static Bootstrapper() - { - // Get IoC container - var container = TinyIoC.TinyIoCContainer.Current; - - // Register services - //container.Register().UsingConstructor(() => new DatabaseFacade(ConfigurationHelper.DatabaseFilePath)); - container.Register(new DatabaseFacade(ConfigurationHelper.DatabaseFilePath)); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - - // Register presenters - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - container.Register().AsSingleton(); - - // Configure Automapper - //Mapper.CreateMap(); - } - - /// - /// Returns the IoC container. - /// - /// IoC container - public static TinyIoC.TinyIoCContainer GetContainer() - { - return TinyIoC.TinyIoCContainer.Current; - } - } -} - +// 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 . + +using MPfm.Library.Database; +using MPfm.Library.Database.Interfaces; +using MPfm.MVP.Services; +using MPfm.MVP.Presenters.Interfaces; +using MPfm.MVP.Presenters; +using MPfm.MVP.Helpers; +using MPfm.MVP.Services.Interfaces; + +namespace MPfm.MVP.Bootstrap +{ + /// + /// Singleton static class for bootstrapping the application. + /// Configures AutoMapper and Ninject. + /// + public static class Bootstrapper + { + /// + /// Constructor for the Bootstrapper static class. + /// + static Bootstrapper() + { + // Get IoC container + var container = TinyIoC.TinyIoCContainer.Current; + + // Register services + //container.Register().UsingConstructor(() => new DatabaseFacade(ConfigurationHelper.DatabaseFilePath)); + container.Register(new DatabaseFacade(ConfigurationHelper.DatabaseFilePath)); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + + // Register presenters + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + container.Register().AsSingleton(); + + // Configure Automapper + //Mapper.CreateMap(); + } + + /// + /// Returns the IoC container. + /// + /// IoC container + public static TinyIoC.TinyIoCContainer GetContainer() + { + return TinyIoC.TinyIoCContainer.Current; + } + } +} + diff --git a/MPfm/MPfm.MVP/MPfm.MVP.Android.csproj b/MPfm/MPfm.MVP/MPfm.MVP.Android.csproj index 34eb55a8..f2a20a2a 100644 --- a/MPfm/MPfm.MVP/MPfm.MVP.Android.csproj +++ b/MPfm/MPfm.MVP/MPfm.MVP.Android.csproj @@ -1,211 +1,214 @@ - - - - Debug - AnyCPU - 10.0.0 - 2.0 - {B6B0613C-FF39-479D-9EF0-31DAF9684A06} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - MPfm.MVP - MPfm.MVP - - - True - full - False - ..\Output\Debug - DEBUG;ANDROID - prompt - 4 - False - None - - - none - False - bin\Release - prompt - 4 - False - SdkOnly - False - - - True - full - False - ..\Output\Debug_Linux\ - DEBUG;TRACE;LINUX - prompt - 4 - None - - - True - full - False - ..\Output\Debug_Mac\ - DEBUG;TRACE;MACOSX - 4 - None - - - True - full - False - ..\Output\Debug_Mac\ - DEBUG;TRACE;MACOSX - 4 - SdkOnly - False - - - True - full - False - ..\Output\Debug_Linux\ - DEBUG;TRACE;LINUX - prompt - 4 - SdkOnly - False - - - - - Lib\AutoMapper.dll - - - - - ..\MPfm.Library\Lib\System.Data.SQLite.dll - - - - - False - ..\MPfm.Sound\Lib\Android\taglib-sharp.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {D536FDE5-989E-4979-9B39-63621AE4A205} - MPfm.Core.Android - - - {2A62D229-D7FC-41DA-B676-BB1371659BFB} - MPfm.Library.Android - - - {FEB7497C-784C-4380-874F-46FD93C82BA1} - MPfm.Player.Android - - - {D92F718E-9A24-4B8B-9E40-77F93CF89EAE} - MPfm.Sound.Android - - + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {B6B0613C-FF39-479D-9EF0-31DAF9684A06} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + MPfm.MVP + MPfm.MVP + + + True + full + False + ..\Output\Debug + DEBUG;ANDROID + prompt + 4 + False + None + + + none + False + bin\Release + prompt + 4 + False + SdkOnly + False + + + True + full + False + ..\Output\Debug_Linux\ + DEBUG;TRACE;LINUX + prompt + 4 + None + + + True + full + False + ..\Output\Debug_Mac\ + DEBUG;TRACE;MACOSX + 4 + None + + + True + full + False + ..\Output\Debug_Mac\ + DEBUG;TRACE;MACOSX + 4 + SdkOnly + False + + + True + full + False + ..\Output\Debug_Linux\ + DEBUG;TRACE;LINUX + prompt + 4 + SdkOnly + False + + + + + Lib\AutoMapper.dll + + + + + ..\MPfm.Library\Lib\System.Data.SQLite.dll + + + + + False + ..\MPfm.Sound\Lib\Android\taglib-sharp.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {D536FDE5-989E-4979-9B39-63621AE4A205} + MPfm.Core.Android + + + {2A62D229-D7FC-41DA-B676-BB1371659BFB} + MPfm.Library.Android + + + {FEB7497C-784C-4380-874F-46FD93C82BA1} + MPfm.Player.Android + + + {D92F718E-9A24-4B8B-9E40-77F93CF89EAE} + MPfm.Sound.Android + + \ No newline at end of file diff --git a/MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs b/MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs index 167d95b1..84f3ace2 100644 --- a/MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs +++ b/MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs @@ -1,186 +1,216 @@ -// 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 . - -using System; -using System.Collections.Generic; -using TinyIoC; -using MPfm.MVP.Views; -using MPfm.MVP.Presenters.Interfaces; - -namespace MPfm.MVP.Navigation -{ - /// - /// Manager class for managing view and presenter instances. - /// - public abstract class MobileNavigationManager - { - private ISplashView _splashView; - private ISplashPresenter _splashPresenter; - - private IPreferencesView _preferencesView; - private IAudioPreferencesView _audioPreferencesView; - private IGeneralPreferencesView _generalPreferencesView; - private ILibraryPreferencesView _libraryPreferencesView; - private IAudioPreferencesPresenter _audioPreferencesPresenter; - private IGeneralPreferencesPresenter _generalPreferencesPresenter; - private ILibraryPreferencesPresenter _libraryPreferencesPresenter; - - private IUpdateLibraryView _updateLibraryView; - private IUpdateLibraryPresenter _updateLibraryPresenter; - - private Dictionary _mobileLibraryBrowserList = new Dictionary(); - - public abstract void ShowSplash(ISplashView view); - public abstract void HideSplash(); - public abstract void AddTab(string title, IBaseView view); - public abstract void PushView(IBaseView context, IBaseView newView); - - public virtual void Start() - { - Action onInitDone = () => - { - // Create 4 main tabs - var playlistsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Playlists); - var artistsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Artists); - var albumsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Albums); - var songsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Songs); - AddTab("Playlists", playlistsView); - AddTab("Artists", artistsView); - AddTab("Alumbs", albumsView); - AddTab("Songs", songsView); - - // Finally hide the splash screen, our UI is ready - HideSplash(); - }; - ShowSplash(CreateSplashView(onInitDone)); - } - - public virtual ISplashView CreateSplashView(Action onInitDone) - { - Action onViewReady = (view) => { - _splashPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _splashPresenter.BindView((ISplashView)view); - _splashPresenter.Initialize(onInitDone); - }; - _splashView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _splashView.OnViewDestroy = (view) => { - _splashView = null; - _splashPresenter = null; - }; - return _splashView; - } - - public virtual IUpdateLibraryView CreateUpdateLibraryView() - { - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onViewReady = (view) => - { - _updateLibraryPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _updateLibraryPresenter.BindView((IUpdateLibraryView)view); - }; - - // Create view and manage view destruction - _updateLibraryView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _updateLibraryView.OnViewDestroy = (view) => - { - _updateLibraryView = null; - _updateLibraryPresenter = null; - }; - return _updateLibraryView; - } - - public virtual IAudioPreferencesView CreateAudioPreferencesView() - { - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onViewReady = (view) => - { - _audioPreferencesPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _audioPreferencesPresenter.BindView((IAudioPreferencesView)view); - }; - - // Create view and manage view destruction - _audioPreferencesView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _audioPreferencesView.OnViewDestroy = (view) => - { - _audioPreferencesView = null; - _audioPreferencesPresenter = null; - }; - return _audioPreferencesView; - } - - public virtual IGeneralPreferencesView CreateGeneralPreferencesView() - { - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onViewReady = (view) => - { - _generalPreferencesPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _generalPreferencesPresenter.BindView((IGeneralPreferencesView)view); - }; - - // Create view and manage view destruction - _generalPreferencesView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _generalPreferencesView.OnViewDestroy = (view) => - { - _generalPreferencesView = null; - _generalPreferencesPresenter = null; - }; - return _generalPreferencesView; - } - - public virtual ILibraryPreferencesView CreateLibraryPreferencesView() - { - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onViewReady = (view) => - { - _libraryPreferencesPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _libraryPreferencesPresenter.BindView((ILibraryPreferencesView)view); - }; - - // Create view and manage view destruction - _libraryPreferencesView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _libraryPreferencesView.OnViewDestroy = (view) => - { - _libraryPreferencesView = null; - _libraryPreferencesPresenter = null; - }; - return _libraryPreferencesView; - } - - public virtual IMobileLibraryBrowserView CreateMobileLibraryBrowserView(MobileLibraryBrowserType browserType) - { - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onViewReady = (view) => - { - var presenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - presenter.BindView((IMobileLibraryBrowserView)view); - _mobileLibraryBrowserList.Add((IMobileLibraryBrowserView)view, presenter); - }; - - // Create view and manage view destruction - IMobileLibraryBrowserView newView = null; - newView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - newView.BrowserType = browserType; // TODO: Shouldn't this be in the presenter instead...? browserType + filter (can be artist or album) - newView.OnViewDestroy = (view) => - { - if (_mobileLibraryBrowserList.ContainsKey((IMobileLibraryBrowserView)view)) - _mobileLibraryBrowserList.Remove((IMobileLibraryBrowserView)view); - }; - return newView; - } - - } -} +// 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 . + +using System; +using System.Collections.Generic; +using MPfm.MVP.Bootstrap; +using TinyIoC; +using MPfm.MVP.Views; +using MPfm.MVP.Presenters.Interfaces; + +namespace MPfm.MVP.Navigation +{ + /// + /// Manager class for managing view and presenter instances. + /// + public abstract class MobileNavigationManager + { + private IMobileOptionsMenuView _optionsMenuView; + private IMobileOptionsMenuPresenter _optionsMenuPresenter; + + private ISplashView _splashView; + private ISplashPresenter _splashPresenter; + + private IAudioPreferencesView _audioPreferencesView; + private IGeneralPreferencesView _generalPreferencesView; + private ILibraryPreferencesView _libraryPreferencesView; + private IAudioPreferencesPresenter _audioPreferencesPresenter; + private IGeneralPreferencesPresenter _generalPreferencesPresenter; + private ILibraryPreferencesPresenter _libraryPreferencesPresenter; + + private IUpdateLibraryView _updateLibraryView; + private IUpdateLibraryPresenter _updateLibraryPresenter; + + private Dictionary _mobileLibraryBrowserList = new Dictionary(); + + public abstract void ShowSplash(ISplashView view); + public abstract void HideSplash(); + public abstract void AddTab(string title, IBaseView view); + public abstract void PushView(IBaseView context, IBaseView newView); + + public virtual void Start() + { + Action onInitDone = () => + { + // Create 4 main tabs + var playlistsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Playlists); + var artistsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Artists); + var albumsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Albums); + var songsView = CreateMobileLibraryBrowserView(MobileLibraryBrowserType.Songs); + AddTab("Playlists", playlistsView); + AddTab("Artists", artistsView); + AddTab("Alumbs", albumsView); + AddTab("Songs", songsView); + + // iOS has one more tab, the More tab (Options Menu equivalent on Android). +#if IOS + var moreView = CreateOptionsMenuView(); + AddTab("More", moreView); +#endif + + // Finally hide the splash screen, our UI is ready + HideSplash(); + }; + ShowSplash(CreateSplashView(onInitDone)); + } + + private IMobileOptionsMenuView CreateOptionsMenuView() + { + // This is used only on iOS, where the Options menu is actually a tab named "More" + Action onViewReady = (view) => BindOptionsMenuView((IMobileOptionsMenuView)view); + _optionsMenuView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + return _optionsMenuView; + } + + public virtual void BindOptionsMenuView(IMobileOptionsMenuView view) + { + // This is used only on Android, where the Options menu is bound to the activity. + _optionsMenuView = view; + _optionsMenuPresenter = Bootstrapper.GetContainer().Resolve(); + _optionsMenuPresenter.BindView(view); + _optionsMenuView.OnViewDestroy = (theView) => + { + _optionsMenuView = null; + _optionsMenuPresenter = null; + }; + } + + public virtual ISplashView CreateSplashView(Action onInitDone) + { + Action onViewReady = (view) => { + _splashPresenter = Bootstrapper.GetContainer().Resolve(); + _splashPresenter.BindView((ISplashView)view); + _splashPresenter.Initialize(onInitDone); + }; + _splashView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _splashView.OnViewDestroy = (view) => { + _splashView = null; + _splashPresenter = null; + }; + return _splashView; + } + + public virtual IUpdateLibraryView CreateUpdateLibraryView() + { + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onViewReady = (view) => + { + _updateLibraryPresenter = Bootstrapper.GetContainer().Resolve(); + _updateLibraryPresenter.BindView((IUpdateLibraryView)view); + }; + + // Create view and manage view destruction + _updateLibraryView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _updateLibraryView.OnViewDestroy = (view) => + { + _updateLibraryView = null; + _updateLibraryPresenter = null; + }; + return _updateLibraryView; + } + + public virtual IAudioPreferencesView CreateAudioPreferencesView() + { + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onViewReady = (view) => + { + _audioPreferencesPresenter = Bootstrapper.GetContainer().Resolve(); + _audioPreferencesPresenter.BindView((IAudioPreferencesView)view); + }; + + // Create view and manage view destruction + _audioPreferencesView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _audioPreferencesView.OnViewDestroy = (view) => + { + _audioPreferencesView = null; + _audioPreferencesPresenter = null; + }; + return _audioPreferencesView; + } + + public virtual IGeneralPreferencesView CreateGeneralPreferencesView() + { + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onViewReady = (view) => + { + _generalPreferencesPresenter = Bootstrapper.GetContainer().Resolve(); + _generalPreferencesPresenter.BindView((IGeneralPreferencesView)view); + }; + + // Create view and manage view destruction + _generalPreferencesView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _generalPreferencesView.OnViewDestroy = (view) => + { + _generalPreferencesView = null; + _generalPreferencesPresenter = null; + }; + return _generalPreferencesView; + } + + public virtual ILibraryPreferencesView CreateLibraryPreferencesView() + { + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onViewReady = (view) => + { + _libraryPreferencesPresenter = Bootstrapper.GetContainer().Resolve(); + _libraryPreferencesPresenter.BindView((ILibraryPreferencesView)view); + }; + + // Create view and manage view destruction + _libraryPreferencesView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _libraryPreferencesView.OnViewDestroy = (view) => + { + _libraryPreferencesView = null; + _libraryPreferencesPresenter = null; + }; + return _libraryPreferencesView; + } + + public virtual IMobileLibraryBrowserView CreateMobileLibraryBrowserView(MobileLibraryBrowserType browserType) + { + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onViewReady = (view) => + { + var presenter = Bootstrapper.GetContainer().Resolve(); + presenter.BindView((IMobileLibraryBrowserView)view); + _mobileLibraryBrowserList.Add((IMobileLibraryBrowserView)view, presenter); + }; + + // Create view and manage view destruction + IMobileLibraryBrowserView newView = null; + newView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + newView.BrowserType = browserType; // TODO: Shouldn't this be in the presenter instead...? browserType + filter (can be artist or album) + newView.OnViewDestroy = (view) => + { + if (_mobileLibraryBrowserList.ContainsKey((IMobileLibraryBrowserView)view)) + _mobileLibraryBrowserList.Remove((IMobileLibraryBrowserView)view); + }; + return newView; + } + + } +} diff --git a/MPfm/MPfm.MVP/Navigation/NavigationManager.cs b/MPfm/MPfm.MVP/Navigation/NavigationManager.cs index e4f2e665..c1202be2 100644 --- a/MPfm/MPfm.MVP/Navigation/NavigationManager.cs +++ b/MPfm/MPfm.MVP/Navigation/NavigationManager.cs @@ -1,130 +1,131 @@ -// 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 . - -using System; -using System.Collections.Generic; -using TinyIoC; -using MPfm.MVP.Views; -using MPfm.MVP.Presenters.Interfaces; - -namespace MPfm.MVP.Navigation -{ - /// - /// Manager class for managing view and presenter instances. - /// - public abstract class NavigationManager - { - private ISplashView _splashView; - private ISplashPresenter _splashPresenter; - - private IMainView _mainView; - private IMainPresenter _mainPresenter; - private IPlayerPresenter _playerPresenter; - private ILibraryBrowserPresenter _libraryBrowserPresenter; - private ISongBrowserPresenter _songBrowserPresenter; - - private IPreferencesView _preferencesView; - private IAudioPreferencesView _audioPreferencesView; - private IGeneralPreferencesView _generalPreferencesView; - private ILibraryPreferencesView _libraryPreferencesView; - private IAudioPreferencesPresenter _audioPreferencesPresenter; - private IGeneralPreferencesPresenter _generalPreferencesPresenter; - private ILibraryPreferencesPresenter _libraryPreferencesPresenter; - - private IUpdateLibraryView _updateLibraryView; - private IUpdateLibraryPresenter _updateLibraryPresenter; - - public virtual ISplashView CreateSplashView() - { - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onInitDone = () => - { - Console.WriteLine("SplashInitDone"); - CreateMainView(); - }; - Action onViewReady = (view) => - { - _splashPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _splashPresenter.BindView((ISplashView)view); - _splashPresenter.Initialize(onInitDone); // TODO: Should the presenter call NavMgr instead of using an action? - }; - _splashView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _splashView.OnViewDestroy = (view) => - { - _splashView = null; - _splashPresenter = null; - }; - return _splashView; - } - - public virtual IMainView CreateMainView() - { - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onViewReady = (view) => { - _mainPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _mainPresenter.BindView((IMainView)view); - _playerPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _playerPresenter.BindView((IPlayerView)view); - _libraryBrowserPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _libraryBrowserPresenter.BindView((ILibraryBrowserView)view); - _songBrowserPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _songBrowserPresenter.BindView((ISongBrowserView)view); - }; - _mainView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _mainView.OnViewDestroy = (view) => { - _mainView = null; - _mainPresenter = null; - _playerPresenter.Dispose(); // Dispose unmanaged stuff (i.e. BASS) - _playerPresenter = null; - _libraryBrowserPresenter = null; - _songBrowserPresenter = null; - }; - return _mainView; - } - - public virtual IPreferencesView CreatePreferencesView() - { - // If the view is still visible, just make it the top level window - if(_preferencesView != null) - { - _preferencesView.ShowView(true); - return _preferencesView; - } - - // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. - Action onViewReady = (view) => - { - _audioPreferencesPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _audioPreferencesPresenter.BindView((IAudioPreferencesView)view); - _generalPreferencesPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _generalPreferencesPresenter.BindView((IGeneralPreferencesView)view); - _libraryPreferencesPresenter = Bootstrapper.Bootstrapper.GetContainer().Resolve(); - _libraryPreferencesPresenter.BindView((ILibraryPreferencesView)view); - }; - - // Create view and manage view destruction - _preferencesView = Bootstrapper.Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); - _preferencesView.OnViewDestroy = (view) => { - _preferencesView = null; - _audioPreferencesPresenter = null; - _generalPreferencesPresenter = null; - _libraryPreferencesPresenter = null; - }; - return _preferencesView; - } - } -} +// 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 . + +using System; +using System.Collections.Generic; +using MPfm.MVP.Bootstrap; +using TinyIoC; +using MPfm.MVP.Views; +using MPfm.MVP.Presenters.Interfaces; + +namespace MPfm.MVP.Navigation +{ + /// + /// Manager class for managing view and presenter instances. + /// + public abstract class NavigationManager + { + private ISplashView _splashView; + private ISplashPresenter _splashPresenter; + + private IMainView _mainView; + private IMainPresenter _mainPresenter; + private IPlayerPresenter _playerPresenter; + private ILibraryBrowserPresenter _libraryBrowserPresenter; + private ISongBrowserPresenter _songBrowserPresenter; + + private IPreferencesView _preferencesView; + private IAudioPreferencesView _audioPreferencesView; + private IGeneralPreferencesView _generalPreferencesView; + private ILibraryPreferencesView _libraryPreferencesView; + private IAudioPreferencesPresenter _audioPreferencesPresenter; + private IGeneralPreferencesPresenter _generalPreferencesPresenter; + private ILibraryPreferencesPresenter _libraryPreferencesPresenter; + + private IUpdateLibraryView _updateLibraryView; + private IUpdateLibraryPresenter _updateLibraryPresenter; + + public virtual ISplashView CreateSplashView() + { + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onInitDone = () => + { + Console.WriteLine("SplashInitDone"); + CreateMainView(); + }; + Action onViewReady = (view) => + { + _splashPresenter = Bootstrapper.GetContainer().Resolve(); + _splashPresenter.BindView((ISplashView)view); + _splashPresenter.Initialize(onInitDone); // TODO: Should the presenter call NavMgr instead of using an action? + }; + _splashView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _splashView.OnViewDestroy = (view) => + { + _splashView = null; + _splashPresenter = null; + }; + return _splashView; + } + + public virtual IMainView CreateMainView() + { + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onViewReady = (view) => { + _mainPresenter = Bootstrapper.GetContainer().Resolve(); + _mainPresenter.BindView((IMainView)view); + _playerPresenter = Bootstrapper.GetContainer().Resolve(); + _playerPresenter.BindView((IPlayerView)view); + _libraryBrowserPresenter = Bootstrapper.GetContainer().Resolve(); + _libraryBrowserPresenter.BindView((ILibraryBrowserView)view); + _songBrowserPresenter = Bootstrapper.GetContainer().Resolve(); + _songBrowserPresenter.BindView((ISongBrowserView)view); + }; + _mainView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _mainView.OnViewDestroy = (view) => { + _mainView = null; + _mainPresenter = null; + _playerPresenter.Dispose(); // Dispose unmanaged stuff (i.e. BASS) + _playerPresenter = null; + _libraryBrowserPresenter = null; + _songBrowserPresenter = null; + }; + return _mainView; + } + + public virtual IPreferencesView CreatePreferencesView() + { + // If the view is still visible, just make it the top level window + if(_preferencesView != null) + { + _preferencesView.ShowView(true); + return _preferencesView; + } + + // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. + Action onViewReady = (view) => + { + _audioPreferencesPresenter = Bootstrapper.GetContainer().Resolve(); + _audioPreferencesPresenter.BindView((IAudioPreferencesView)view); + _generalPreferencesPresenter = Bootstrapper.GetContainer().Resolve(); + _generalPreferencesPresenter.BindView((IGeneralPreferencesView)view); + _libraryPreferencesPresenter = Bootstrapper.GetContainer().Resolve(); + _libraryPreferencesPresenter.BindView((ILibraryPreferencesView)view); + }; + + // Create view and manage view destruction + _preferencesView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); + _preferencesView.OnViewDestroy = (view) => { + _preferencesView = null; + _audioPreferencesPresenter = null; + _generalPreferencesPresenter = null; + _libraryPreferencesPresenter = null; + }; + return _preferencesView; + } + } +} diff --git a/MPfm/MPfm.MVP/Presenters/Interfaces/IMobileOptionsMenuPresenter.cs b/MPfm/MPfm.MVP/Presenters/Interfaces/IMobileOptionsMenuPresenter.cs new file mode 100644 index 00000000..a11ec4fa --- /dev/null +++ b/MPfm/MPfm.MVP/Presenters/Interfaces/IMobileOptionsMenuPresenter.cs @@ -0,0 +1,29 @@ +// 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 . + +using MPfm.MVP.Views; + +namespace MPfm.MVP.Presenters.Interfaces +{ + /// + /// Main window presenter interface. + /// + public interface IMobileOptionsMenuPresenter : IBasePresenter + { + } +} + diff --git a/MPfm/MPfm.MVP/Presenters/MobileOptionsMenuPresenter.cs b/MPfm/MPfm.MVP/Presenters/MobileOptionsMenuPresenter.cs new file mode 100644 index 00000000..8cb32822 --- /dev/null +++ b/MPfm/MPfm.MVP/Presenters/MobileOptionsMenuPresenter.cs @@ -0,0 +1,64 @@ +// 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 . + +using System; +using MPfm.MVP.Navigation; +using MPfm.MVP.Presenters.Interfaces; +using MPfm.MVP.Views; + +namespace MPfm.MVP.Presenters +{ + /// + /// Main window presenter. + /// + public class MobileOptionsMenuPresenter : BasePresenter, IMobileOptionsMenuPresenter + { + readonly MobileNavigationManager _navigationManager; + + #region Constructor and Dispose + + public MobileOptionsMenuPresenter(MobileNavigationManager navigationManager) + { + this._navigationManager = navigationManager; + } + + #endregion + + public override void BindView(IMobileOptionsMenuView view) + { + // Subscribe to view actions + view.OnClickAbout = OnClickAbout; + view.OnClickEffects = OnClickEffects; + view.OnClickPreferences = OnClickPreferences; + + base.BindView(view); + } + + private void OnClickPreferences() + { + } + + private void OnClickEffects() + { + } + + private void OnClickAbout() + { + } + } +} + diff --git a/MPfm/MPfm.MVP/Views/IMobileOptionsMenuView.cs b/MPfm/MPfm.MVP/Views/IMobileOptionsMenuView.cs new file mode 100644 index 00000000..a9b0c58d --- /dev/null +++ b/MPfm/MPfm.MVP/Views/IMobileOptionsMenuView.cs @@ -0,0 +1,31 @@ +// 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 . + +using System; + +namespace MPfm.MVP.Views +{ + /// + /// Options menu view interface for mobile devices. + /// + public interface IMobileOptionsMenuView : IBaseView + { + Action OnClickPreferences { get; set; } + Action OnClickEffects { get; set; } + Action OnClickAbout { get; set; } + } +}