mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-12-24 07:48:49 -05:00
integrated SkyDrive support
This commit is contained in:
parent
684312b412
commit
be9f18d996
@ -141,6 +141,9 @@
|
|||||||
<Link>Jars\jsr305-1.3.9.jar</Link>
|
<Link>Jars\jsr305-1.3.9.jar</Link>
|
||||||
</EmbeddedReferenceJar>
|
</EmbeddedReferenceJar>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedReferenceJar Include="Jars\livesdk.jar" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Android.App;
|
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using KeePassLib.Serialization;
|
using KeePassLib.Serialization;
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
<Compile Include="Io\IFileStorage.cs" />
|
<Compile Include="Io\IFileStorage.cs" />
|
||||||
<Compile Include="Io\IoUtil.cs" />
|
<Compile Include="Io\IoUtil.cs" />
|
||||||
<Compile Include="Io\JavaFileStorage.cs" />
|
<Compile Include="Io\JavaFileStorage.cs" />
|
||||||
|
<Compile Include="Io\SkyDriveFileStorage.cs" />
|
||||||
<Compile Include="IProgressDialog.cs" />
|
<Compile Include="IProgressDialog.cs" />
|
||||||
<Compile Include="PreferenceKey.cs" />
|
<Compile Include="PreferenceKey.cs" />
|
||||||
<Compile Include="UiStringKey.cs" />
|
<Compile Include="UiStringKey.cs" />
|
||||||
|
2
src/Kp2aUnitTests/Resources/Resource.Designer.cs
generated
2
src/Kp2aUnitTests/Resources/Resource.Designer.cs
generated
@ -26,7 +26,7 @@ namespace Kp2aUnitTests
|
|||||||
|
|
||||||
public static void UpdateIdValues()
|
public static void UpdateIdValues()
|
||||||
{
|
{
|
||||||
KeePassLib2Android.Resource.String.library_name = Kp2aUnitTests.Resource.String.library_name;
|
global::KeePassLib2Android.Resource.String.library_name = global::Kp2aUnitTests.Resource.String.library_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class Attribute
|
public partial class Attribute
|
||||||
|
@ -132,6 +132,10 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
|||||||
String[] parts = mAccountLocalPath.split("/");
|
String[] parts = mAccountLocalPath.split("/");
|
||||||
|
|
||||||
AccountData accountData = mAccountData.get(mAccount);
|
AccountData accountData = mAccountData.get(mAccount);
|
||||||
|
if (accountData == null)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("Looks like account "+mAccount+" was not properly initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
String parentId = accountData.mRootFolderId;
|
String parentId = accountData.mRootFolderId;
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import keepass2android.javafilestorage.JavaFileStorageBase.InvalidPathException;
|
|
||||||
import keepass2android.javafilestorage.skydrive.SkyDriveException;
|
import keepass2android.javafilestorage.skydrive.SkyDriveException;
|
||||||
import keepass2android.javafilestorage.skydrive.SkyDriveFile;
|
import keepass2android.javafilestorage.skydrive.SkyDriveFile;
|
||||||
import keepass2android.javafilestorage.skydrive.SkyDriveFolder;
|
import keepass2android.javafilestorage.skydrive.SkyDriveFolder;
|
||||||
@ -44,8 +43,6 @@ public class SkyDriveFileStorage extends JavaFileStorageBase {
|
|||||||
|
|
||||||
private LiveAuthClient mAuthClient;
|
private LiveAuthClient mAuthClient;
|
||||||
|
|
||||||
private LiveConnectSession mSession;
|
|
||||||
|
|
||||||
private LiveConnectClient mConnectClient;
|
private LiveConnectClient mConnectClient;
|
||||||
|
|
||||||
private String mRootFolderId;
|
private String mRootFolderId;
|
||||||
@ -57,6 +54,10 @@ public class SkyDriveFileStorage extends JavaFileStorageBase {
|
|||||||
// see http://stackoverflow.com/questions/17997688/howto-to-parse-skydrive-api-date-in-java
|
// see http://stackoverflow.com/questions/17997688/howto-to-parse-skydrive-api-date-in-java
|
||||||
SimpleDateFormat SKYDRIVE_DATEFORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH);
|
SimpleDateFormat SKYDRIVE_DATEFORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH);
|
||||||
|
|
||||||
|
private Context mAppContext;
|
||||||
|
|
||||||
|
private String mClientId;
|
||||||
|
|
||||||
public final class JsonKeys {
|
public final class JsonKeys {
|
||||||
public static final String CODE = "code";
|
public static final String CODE = "code";
|
||||||
public static final String DATA = "data";
|
public static final String DATA = "data";
|
||||||
@ -283,6 +284,8 @@ public class SkyDriveFileStorage extends JavaFileStorageBase {
|
|||||||
|
|
||||||
public SkyDriveFileStorage(String clientId, Context appContext) {
|
public SkyDriveFileStorage(String clientId, Context appContext) {
|
||||||
mAuthClient = new LiveAuthClient(appContext, clientId);
|
mAuthClient = new LiveAuthClient(appContext, clientId);
|
||||||
|
mAppContext = appContext;
|
||||||
|
mClientId = clientId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +315,6 @@ public class SkyDriveFileStorage extends JavaFileStorageBase {
|
|||||||
private void initialize(final FileStorageSetupActivity setupAct,
|
private void initialize(final FileStorageSetupActivity setupAct,
|
||||||
LiveConnectSession session) {
|
LiveConnectSession session) {
|
||||||
|
|
||||||
mSession = session;
|
|
||||||
mConnectClient = new LiveConnectClient(session);
|
mConnectClient = new LiveConnectClient(session);
|
||||||
|
|
||||||
final Activity activity = (Activity)setupAct;
|
final Activity activity = (Activity)setupAct;
|
||||||
@ -458,13 +460,18 @@ public class SkyDriveFileStorage extends JavaFileStorageBase {
|
|||||||
@Override
|
@Override
|
||||||
public String getDisplayName(String path) {
|
public String getDisplayName(String path) {
|
||||||
|
|
||||||
return "";
|
SkyDrivePath skydrivePath = new SkyDrivePath();
|
||||||
/*
|
try {
|
||||||
* SkyDrivePath skydrivePath = new SkyDrivePath(); try {
|
skydrivePath.setPathWithoutVerify(path);
|
||||||
* skydrivePath.setPathWithoutVerify(path); } catch (Exception e) {
|
}
|
||||||
* e.printStackTrace(); return path; } return
|
catch (Exception e)
|
||||||
* skydrivePath.getDisplayName();
|
{
|
||||||
*/
|
e.printStackTrace();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return skydrivePath.getDisplayName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -752,6 +759,17 @@ public class SkyDriveFileStorage extends JavaFileStorageBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(final FileStorageSetupActivity activity) {
|
public void onStart(final FileStorageSetupActivity activity) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
initialize(activity);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
finishWithError((Activity)activity, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(final FileStorageSetupActivity activity) {
|
||||||
mAuthClient.initialize(Arrays.asList(SCOPES), new LiveAuthListener() {
|
mAuthClient.initialize(Arrays.asList(SCOPES), new LiveAuthListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAuthError(LiveAuthException exception,
|
public void onAuthError(LiveAuthException exception,
|
||||||
@ -764,14 +782,34 @@ public class SkyDriveFileStorage extends JavaFileStorageBase {
|
|||||||
LiveConnectSession session, Object userState) {
|
LiveConnectSession session, Object userState) {
|
||||||
|
|
||||||
if (status == LiveStatus.CONNECTED) {
|
if (status == LiveStatus.CONNECTED) {
|
||||||
|
Log.d(TAG, "connected!");
|
||||||
initialize(activity, session);
|
initialize(activity, session);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (status == LiveStatus.NOT_CONNECTED)
|
||||||
|
Log.d(TAG, "not connected");
|
||||||
|
else if (status == LiveStatus.UNKNOWN)
|
||||||
|
Log.d(TAG, "unknown");
|
||||||
|
else
|
||||||
|
Log.d(TAG, "unexpected status " + status);
|
||||||
|
try
|
||||||
|
{
|
||||||
login(activity);
|
login(activity);
|
||||||
}
|
}
|
||||||
|
catch (IllegalStateException e)
|
||||||
|
{
|
||||||
|
//this may happen if an un-cancelled login progress is already in progress.
|
||||||
|
//however, the activity might have been destroyed, so try again with another auth client next time
|
||||||
|
mAuthClient = new LiveAuthClient(mAppContext, mClientId);
|
||||||
|
finishWithError((Activity)activity, e);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
finishWithError((Activity)activity, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,7 +5,7 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
public class SkyDriveFile extends SkyDriveObject {
|
public class SkyDriveFile extends SkyDriveObject {
|
||||||
|
|
||||||
public static final String TYPE = "file";
|
public static final String TYPENAME = "file";
|
||||||
|
|
||||||
public SkyDriveFile(JSONObject file) {
|
public SkyDriveFile(JSONObject file) {
|
||||||
super(file);
|
super(file);
|
||||||
|
@ -3,7 +3,7 @@ package keepass2android.javafilestorage.skydrive;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class SkyDriveFolder extends SkyDriveObject {
|
public class SkyDriveFolder extends SkyDriveObject {
|
||||||
public static final String TYPE = "folder";
|
public static final String TYPENAME = "folder";
|
||||||
|
|
||||||
public SkyDriveFolder(JSONObject object) {
|
public SkyDriveFolder(JSONObject object) {
|
||||||
super(object);
|
super(object);
|
||||||
|
@ -48,9 +48,9 @@ public abstract class SkyDriveObject {
|
|||||||
public static SkyDriveObject create(JSONObject skyDriveObject) {
|
public static SkyDriveObject create(JSONObject skyDriveObject) {
|
||||||
String type = skyDriveObject.optString("type");
|
String type = skyDriveObject.optString("type");
|
||||||
|
|
||||||
if (type.equals(SkyDriveFolder.TYPE)) {
|
if (type.equals(SkyDriveFolder.TYPENAME)) {
|
||||||
return new SkyDriveFolder(skyDriveObject);
|
return new SkyDriveFolder(skyDriveObject);
|
||||||
} else if (type.equals(SkyDriveFile.TYPE)) {
|
} else if (type.equals(SkyDriveFile.TYPENAME)) {
|
||||||
return new SkyDriveFile(skyDriveObject);
|
return new SkyDriveFile(skyDriveObject);
|
||||||
} else return null;
|
} else return null;
|
||||||
}
|
}
|
||||||
|
31
src/keepass2android/Resources/Resource.designer.cs
generated
31
src/keepass2android/Resources/Resource.designer.cs
generated
@ -1854,46 +1854,49 @@ namespace keepass2android
|
|||||||
public const int ic_storage_https = 2130837815;
|
public const int ic_storage_https = 2130837815;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020138
|
// aapt resource value: 0x7f020138
|
||||||
public const int ic_unlocked_gray = 2130837816;
|
public const int ic_storage_skydrive = 2130837816;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020139
|
// aapt resource value: 0x7f020139
|
||||||
public const int location_web_site = 2130837817;
|
public const int ic_unlocked_gray = 2130837817;
|
||||||
|
|
||||||
// aapt resource value: 0x7f02013a
|
// aapt resource value: 0x7f02013a
|
||||||
public const int navigation_accept = 2130837818;
|
public const int location_web_site = 2130837818;
|
||||||
|
|
||||||
// aapt resource value: 0x7f02013b
|
// aapt resource value: 0x7f02013b
|
||||||
public const int navigation_accept_dark = 2130837819;
|
public const int navigation_accept = 2130837819;
|
||||||
|
|
||||||
// aapt resource value: 0x7f02013c
|
// aapt resource value: 0x7f02013c
|
||||||
public const int navigation_cancel = 2130837820;
|
public const int navigation_accept_dark = 2130837820;
|
||||||
|
|
||||||
// aapt resource value: 0x7f02013d
|
// aapt resource value: 0x7f02013d
|
||||||
public const int navigation_previous_item = 2130837821;
|
public const int navigation_cancel = 2130837821;
|
||||||
|
|
||||||
// aapt resource value: 0x7f02013e
|
// aapt resource value: 0x7f02013e
|
||||||
public const int navigation_previous_item_dark = 2130837822;
|
public const int navigation_previous_item = 2130837822;
|
||||||
|
|
||||||
// aapt resource value: 0x7f02013f
|
// aapt resource value: 0x7f02013f
|
||||||
public const int notify = 2130837823;
|
public const int navigation_previous_item_dark = 2130837823;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020140
|
// aapt resource value: 0x7f020140
|
||||||
public const int notify_keyboard = 2130837824;
|
public const int notify = 2130837824;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020141
|
// aapt resource value: 0x7f020141
|
||||||
public const int oktoberfest = 2130837825;
|
public const int notify_keyboard = 2130837825;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020142
|
// aapt resource value: 0x7f020142
|
||||||
public const int RedButton = 2130837826;
|
public const int oktoberfest = 2130837826;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020143
|
// aapt resource value: 0x7f020143
|
||||||
public const int section_header = 2130837827;
|
public const int RedButton = 2130837827;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020144
|
// aapt resource value: 0x7f020144
|
||||||
public const int transparent = 2130837828;
|
public const int section_header = 2130837828;
|
||||||
|
|
||||||
// aapt resource value: 0x7f020145
|
// aapt resource value: 0x7f020145
|
||||||
public const int YellowButton = 2130837829;
|
public const int transparent = 2130837829;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f020146
|
||||||
|
public const int YellowButton = 2130837830;
|
||||||
|
|
||||||
static Drawable()
|
static Drawable()
|
||||||
{
|
{
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
src/keepass2android/Resources/drawable/ic_storage_skydrive.png
Normal file
BIN
src/keepass2android/Resources/drawable/ic_storage_skydrive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -393,6 +393,7 @@ namespace keepass2android
|
|||||||
#if !EXCLUDE_JAVAFILESTORAGE
|
#if !EXCLUDE_JAVAFILESTORAGE
|
||||||
new DropboxFileStorage(Application.Context, this),
|
new DropboxFileStorage(Application.Context, this),
|
||||||
new GoogleDriveFileStorage(Application.Context, this),
|
new GoogleDriveFileStorage(Application.Context, this),
|
||||||
|
new SkyDriveFileStorage(Application.Context, this),
|
||||||
#endif
|
#endif
|
||||||
new BuiltInFileStorage()
|
new BuiltInFileStorage()
|
||||||
};
|
};
|
||||||
|
@ -374,6 +374,10 @@ namespace keepass2android
|
|||||||
StartFileChooser(ioc.Path);
|
StartFileChooser(ioc.Path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if ((resultCode == Result.Canceled) && (data != null) && (data.HasExtra("EXTRA_ERROR_MESSAGE")))
|
||||||
|
{
|
||||||
|
Toast.MakeText(this, data.GetStringExtra("EXTRA_ERROR_MESSAGE"), ToastLength.Long).Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if !EXCLUDE_FILECHOOSER
|
#if !EXCLUDE_FILECHOOSER
|
||||||
private void StartFileChooser(string defaultPath)
|
private void StartFileChooser(string defaultPath)
|
||||||
|
@ -5,6 +5,7 @@ using System.Text;
|
|||||||
|
|
||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
|
using Android.Content.PM;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Android.Runtime;
|
using Android.Runtime;
|
||||||
using Android.Views;
|
using Android.Views;
|
||||||
@ -14,13 +15,14 @@ using keepass2android.Io;
|
|||||||
|
|
||||||
namespace keepass2android.fileselect
|
namespace keepass2android.fileselect
|
||||||
{
|
{
|
||||||
[Activity(Label = "@string/filestorage_setup_title",Theme="@style/Base")]
|
[Activity(Label = "@string/filestorage_setup_title",Theme="@style/Base", ConfigurationChanges=ConfigChanges.Orientation|
|
||||||
|
ConfigChanges.KeyboardHidden)]
|
||||||
public class FileStorageSetupActivity : Activity, IFileStorageSetupActivity
|
public class FileStorageSetupActivity : Activity, IFileStorageSetupActivity
|
||||||
#if !EXCLUDE_JAVAFILESTORAGE
|
#if !EXCLUDE_JAVAFILESTORAGE
|
||||||
,Keepass2android.Javafilestorage.IJavaFileStorageFileStorageSetupActivity
|
,Keepass2android.Javafilestorage.IJavaFileStorageFileStorageSetupActivity
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
private bool isRecreated = false;
|
private bool _isRecreated = false;
|
||||||
|
|
||||||
protected override void OnCreate(Bundle bundle)
|
protected override void OnCreate(Bundle bundle)
|
||||||
{
|
{
|
||||||
@ -40,10 +42,10 @@ namespace keepass2android.fileselect
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
State = (Bundle) bundle.Clone();
|
State = (Bundle) bundle.Clone();
|
||||||
isRecreated = true;
|
_isRecreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isRecreated)
|
if (!_isRecreated)
|
||||||
App.Kp2a.GetFileStorage(Ioc).OnCreate(this, bundle);
|
App.Kp2a.GetFileStorage(Ioc).OnCreate(this, bundle);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -51,7 +53,7 @@ namespace keepass2android.fileselect
|
|||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
{
|
{
|
||||||
base.OnStart();
|
base.OnStart();
|
||||||
if (!isRecreated)
|
if (!_isRecreated)
|
||||||
App.Kp2a.GetFileStorage(Ioc).OnStart(this);
|
App.Kp2a.GetFileStorage(Ioc).OnStart(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,4 +872,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\layout-v14\text_with_help.xml" />
|
<AndroidResource Include="Resources\layout-v14\text_with_help.xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable\ic_storage_skydrive.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable-hdpi\ic_storage_skydrive.png" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user