diff --git a/MPfm/MPfm.iOS/Classes/Controllers/MoreViewController.cs b/MPfm/MPfm.iOS/Classes/Controllers/MoreViewController.cs
index f7bd8ec1..d97f1d3f 100644
--- a/MPfm/MPfm.iOS/Classes/Controllers/MoreViewController.cs
+++ b/MPfm/MPfm.iOS/Classes/Controllers/MoreViewController.cs
@@ -34,6 +34,7 @@
using MPfm.iOS.Classes.Controls;
using MPfm.iOS.Classes.Objects;
using MPfm.iOS.Helpers;
+using DropBoxSync.iOS;
namespace MPfm.iOS
{
@@ -124,6 +125,12 @@ public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
[Export ("tableView:didSelectRowAtIndexPath:")]
public void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
+ if (_items[indexPath.Row].Key == MobileOptionsMenuType.SyncLibraryCloud)
+ {
+ DBAccountManager.SharedManager.LinkFromController(this);
+ return;
+ }
+
OnItemClick(_items[indexPath.Row].Key);
}
diff --git a/MPfm/MPfm.iOS/Classes/Delegates/AppDelegate.cs b/MPfm/MPfm.iOS/Classes/Delegates/AppDelegate.cs
index 43b568e5..643bc503 100644
--- a/MPfm/MPfm.iOS/Classes/Delegates/AppDelegate.cs
+++ b/MPfm/MPfm.iOS/Classes/Delegates/AppDelegate.cs
@@ -33,6 +33,7 @@
using MPfm.iOS.Classes.Objects;
using MPfm.iOS.Classes.Providers;
using MPfm.iOS.Helpers;
+using DropBoxSync.iOS;
namespace MPfm.iOS.Classes.Delegates
{
@@ -41,7 +42,10 @@ namespace MPfm.iOS.Classes.Delegates
// application events from iOS.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
- {
+ {
+ private string _dropboxAppKey = "6tc6565743i743n";
+ private string _dropboxAppSecret = "fbkt3neevjjl0l2";
+
MPfmWindow _window;
MPfmTabBarController _tabBarController;
SplashViewController _splashViewController;
@@ -70,6 +74,8 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
UITabBar.Appearance.TintColor = UIColor.White;
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
+ RegisterDropbox();
+
_window = new MPfmWindow(UIScreen.MainScreen.Bounds);
_window.TintColor = GlobalTheme.SecondaryColor;
@@ -249,5 +255,32 @@ public void PushDialogSubview(MobileDialogPresentationType presentationType, str
navCtrl.PushViewController(viewController, true);
});
}
+
+ public void RegisterDropbox()
+ {
+ // The account manager stores all the account info. Create this when your app launches
+ var manager = new DBAccountManager (_dropboxAppKey, _dropboxAppSecret);
+ DBAccountManager.SharedManager = manager;
+
+ var account = manager.LinkedAccount;
+ if (account != null) {
+ var filesystem = new DBFilesystem (account);
+ DBFilesystem.SharedFilesystem = filesystem;
+ }
+ }
+
+ public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
+ {
+ var account = DBAccountManager.SharedManager.HandleOpenURL (url);
+ if (account != null) {
+ var filesystem = new DBFilesystem (account);
+ DBFilesystem.SharedFilesystem = filesystem;
+ Console.WriteLine ("App linked successfully!");
+ return true;
+ } else {
+ Console.WriteLine ("App is not linked");
+ return false;
+ }
+ }
}
}
diff --git a/MPfm/MPfm.iOS/Classes/Providers/iOSAppConfigProvider.cs b/MPfm/MPfm.iOS/Classes/Providers/iOSAppConfigProvider.cs
index 67b62564..3f0ced4c 100644
--- a/MPfm/MPfm.iOS/Classes/Providers/iOSAppConfigProvider.cs
+++ b/MPfm/MPfm.iOS/Classes/Providers/iOSAppConfigProvider.cs
@@ -17,6 +17,9 @@
using MPfm.MVP.Config;
using MPfm.MVP.Config.Providers;
+using System.Reflection;
+using System.Diagnostics;
+using MonoTouch.Foundation;
namespace MPfm.iOS.Classes.Providers
{
@@ -24,11 +27,95 @@ public class iOSAppConfigProvider : IAppConfigProvider
{
public RootAppConfig Load(string filePath)
{
- return new RootAppConfig();
+ var config = new RootAppConfig();
+ config.IsFirstRun = false;
+ SaveRecursive(config, "Root.");
+ config.IsFirstRun = true;
+ LoadRecursive(config, "Root.");
+ return config;
}
public void Save(string filePath, RootAppConfig config)
{
+ SaveRecursive(config, "Root.");
+ }
+
+ private void LoadRecursive(IAppConfig config, string keyPreset)
+ {
+ // Create map by scanning properties
+ var keyStore = NSUbiquitousKeyValueStore.DefaultStore;
+ var propertyInfos = config.GetType().GetTypeInfo().DeclaredProperties;
+ foreach (PropertyInfo propertyInfo in propertyInfos)
+ {
+ var propertyType = propertyInfo.PropertyType;
+ string fullName = keyPreset + propertyInfo.Name;
+ bool isAssignable = typeof(IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo());
+ //Debug.WriteLine("{0} - {1} - isAssignable: {2}", fullName, propertyInfo.PropertyType.Name, isAssignable);
+
+ if (propertyType == typeof(int))
+ {
+ propertyInfo.SetValue(config, (int)keyStore.GetLong(fullName));
+ }
+ else if (propertyType == typeof(bool))
+ {
+ propertyInfo.SetValue(config, keyStore.GetBool(fullName));
+ }
+ else if (propertyType == typeof(double))
+ {
+ propertyInfo.SetValue(config, keyStore.GetDouble(fullName));
+ }
+ else if (propertyType == typeof(float))
+ {
+ propertyInfo.SetValue(config, (float)keyStore.GetDouble(fullName));
+ }
+ else if (propertyType == typeof(string))
+ {
+ propertyInfo.SetValue(config, keyStore.GetString(fullName));
+ }
+ else if (typeof(IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo()))
+ {
+ var subConfig = (IAppConfig)propertyInfo.GetValue(config);
+ LoadRecursive(subConfig, keyPreset + propertyType.Name + ".");
+ }
+ }
+ }
+
+ private void SaveRecursive(IAppConfig config, string keyPreset)
+ {
+ // Create map by scanning properties
+ var keyStore = NSUbiquitousKeyValueStore.DefaultStore;
+ var propertyInfos = config.GetType().GetTypeInfo().DeclaredProperties;
+ foreach (PropertyInfo propertyInfo in propertyInfos)
+ {
+ var propertyType = propertyInfo.PropertyType;
+ string fullName = keyPreset + propertyInfo.Name;
+ object value = propertyInfo.GetValue(config);
+ bool isAssignable = typeof (IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo());
+ //Debug.WriteLine("{0} - {1} - isAssignable: {2}", fullName, propertyInfo.PropertyType.Name, isAssignable);
+
+ if (propertyType == typeof(int))
+ {
+ keyStore.SetLong(fullName, (long)(int)value);
+ }
+ else if (propertyType == typeof(bool))
+ {
+ keyStore.SetBool(fullName, (bool)value);
+ }
+ else if (propertyType == typeof(double) || (propertyType == typeof(float)))
+ {
+ keyStore.SetDouble(fullName, System.Convert.ToDouble(value));
+ }
+ else if (propertyType == typeof(string))
+ {
+ string stringValue = value == null ? string.Empty : (string)value;
+ keyStore.SetString(fullName, stringValue);
+ }
+ else if (typeof (IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo()))
+ {
+ var subConfig = (IAppConfig)propertyInfo.GetValue(config);
+ SaveRecursive(subConfig, keyPreset + propertyType.Name + ".");
+ }
+ }
}
}
}
diff --git a/MPfm/MPfm.iOS/Info.plist b/MPfm/MPfm.iOS/Info.plist
index 3704fd69..f3497f3e 100644
--- a/MPfm/MPfm.iOS/Info.plist
+++ b/MPfm/MPfm.iOS/Info.plist
@@ -69,5 +69,14 @@
UIViewControllerBasedStatusBarAppearance
+ CFBundleURLTypes
+
+
+ CFBundleURLSchemes
+
+ db-6tc6565743i743n
+
+
+
diff --git a/MPfm/MPfm.iOS/MPfm.iOS.csproj b/MPfm/MPfm.iOS/MPfm.iOS.csproj
index 821219da..a8de32f7 100644
--- a/MPfm/MPfm.iOS/MPfm.iOS.csproj
+++ b/MPfm/MPfm.iOS/MPfm.iOS.csproj
@@ -56,7 +56,6 @@
ARMv7
-v -v -v --compiler=clang -gcc_flags "-L${ProjectDir}/Lib/ -framework Accelerate -framework AudioToolbox -ObjC -lstdc++ -lbass -lbassmix -lbass_fx -lbass_ape -lbass_mpc -lbassflac -lbasswv -all_load"
- 5C51C790-BB21-4F44-BECA-051A853109C6
none
@@ -110,6 +109,9 @@
..\MPfm.Core\Lib\iOS\TinyIoC.dll
+
+ ..\Components\dropboxsync-1.9.1\lib\ios\DropBoxSync.iOS.dll
+
@@ -521,4 +523,11 @@
+
+
+ True
+ 1.9.1
+ False
+
+