mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-12-23 07:28:48 -05:00
Merge branch 'master' of https://git01.codeplex.com/keepass2android
This commit is contained in:
commit
fa8b53793a
@ -72,7 +72,7 @@
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<LibraryProjectZip Include="..\..\..\..\Users\Philipp\Documents\keepass2android\repo\keepass2android19\src\java\android-filechooser\code\project.zip">
|
||||
<LibraryProjectZip Include="..\java\android-filechooser\code\project.zip">
|
||||
<Link>project.zip</Link>
|
||||
</LibraryProjectZip>
|
||||
</ItemGroup>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<metadata>
|
||||
<remove-node path="/api/package[@name='group.pals.android.lib.ui.filechooser.providers.localfile']/class[@name='FileObserverEx']" />
|
||||
<remove-node path="/api/package[@name='group.pals.android.lib.ui.filechooser']/class[@name='FragmentFiles']" />
|
||||
<remove-node path="/api/package[@name='group.pals.android.lib.ui.filechooser.prefs']" />
|
||||
|
||||
|
||||
<!--
|
||||
|
@ -93,13 +93,31 @@ namespace keepass2android.Io
|
||||
}
|
||||
|
||||
|
||||
private Exception LogAndConvertJavaException(Java.Lang.Exception e)
|
||||
private Exception LogAndConvertJavaException(Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.Message);
|
||||
var ex = new Exception(e.LocalizedMessage ??
|
||||
e.Message ??
|
||||
_app.GetResourceString(UiStringKey.ErrorOcurred)+e.GetType().Name, e);
|
||||
return ex;
|
||||
|
||||
if (e is UserInteractionRequiredException)
|
||||
return e;
|
||||
//seems like UserInteractionRequiredException is not propagated correctly into the C# world, we can't catch it
|
||||
// -> rethrow correctly here
|
||||
// Note: the Contains-check looks a bit broad, but it should be safe
|
||||
if (e.ToString().Contains("keepass2android.javafilestorage.UserInteractionRequiredException"))
|
||||
{
|
||||
throw new UserInteractionRequiredException();
|
||||
}
|
||||
|
||||
Java.Lang.Exception exception = e as Java.Lang.Exception;
|
||||
if (exception != null)
|
||||
{
|
||||
var ex = new Exception(exception.LocalizedMessage ??
|
||||
e.Message ??
|
||||
_app.GetResourceString(UiStringKey.ErrorOcurred) + exception.GetType().Name, e);
|
||||
return ex;
|
||||
}
|
||||
|
||||
return e;
|
||||
|
||||
}
|
||||
|
||||
public IWriteTransaction OpenWriteTransaction(IOConnectionInfo ioc, bool useFileTransaction)
|
||||
@ -241,12 +259,38 @@ namespace keepass2android.Io
|
||||
|
||||
public void PrepareFileUsage(IFileStorageSetupInitiatorActivity activity, IOConnectionInfo ioc, int requestCode, Boolean alwaysReturnSuccess)
|
||||
{
|
||||
_jfs.PrepareFileUsage((IJavaFileStorageFileStorageSetupInitiatorActivity)activity, IocToPath(ioc), requestCode, alwaysReturnSuccess);
|
||||
try
|
||||
{
|
||||
_jfs.PrepareFileUsage((IJavaFileStorageFileStorageSetupInitiatorActivity) activity, IocToPath(ioc), requestCode,
|
||||
alwaysReturnSuccess);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw LogAndConvertJavaException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void PrepareFileUsage(Context ctx, IOConnectionInfo ioc)
|
||||
{
|
||||
_jfs.PrepareFileUsage(ctx, IocToPath(ioc));
|
||||
try
|
||||
{
|
||||
_jfs.PrepareFileUsage(ctx, IocToPath(ioc));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw LogAndConvertJavaException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsPermanentLocation(IOConnectionInfo ioc)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsReadOnly(IOConnectionInfo ioc)
|
||||
{
|
||||
return false; //TODO implement. note, however, that we MAY return false even if it's read-only
|
||||
}
|
||||
|
||||
public bool IsPermanentLocation(IOConnectionInfo ioc)
|
||||
|
@ -153,6 +153,49 @@ public class GermanLayout extends KeyboardLayout {
|
||||
|
||||
};
|
||||
|
||||
public static final int DEADKEYS[] = {
|
||||
0x0060, 0x00b4, 0x005e
|
||||
};
|
||||
|
||||
public static final int DEADKEY_LUT[][] = {
|
||||
{ 0x00b4 , 0x0079 , 0x00fd } ,
|
||||
{ 0x00b4 , 0x0061 , 0x00e1 } ,
|
||||
{ 0x00b4 , 0x0065 , 0x00e9 } ,
|
||||
{ 0x00b4 , 0x0075 , 0x00fa } ,
|
||||
{ 0x00b4 , 0x0069 , 0x00ed } ,
|
||||
{ 0x00b4 , 0x006f , 0x00f3 } ,
|
||||
{ 0x00b4 , 0x0059 , 0x00dd } ,
|
||||
{ 0x00b4 , 0x0041 , 0x00c1 } ,
|
||||
{ 0x00b4 , 0x0045 , 0x00c9 } ,
|
||||
{ 0x00b4 , 0x0055 , 0x00da } ,
|
||||
{ 0x00b4 , 0x0049 , 0x00cd } ,
|
||||
{ 0x00b4 , 0x004f , 0x00d3 } ,
|
||||
{ 0x00b4 , 0x0020 , 0x00b4 } ,
|
||||
{ 0x0060 , 0x0061 , 0x00e0 } ,
|
||||
{ 0x0060 , 0x0065 , 0x00e8 } ,
|
||||
{ 0x0060 , 0x0075 , 0x00f9 } ,
|
||||
{ 0x0060 , 0x0069 , 0x00ec } ,
|
||||
{ 0x0060 , 0x006f , 0x00f2 } ,
|
||||
{ 0x0060 , 0x0041 , 0x00c0 } ,
|
||||
{ 0x0060 , 0x0045 , 0x00c8 } ,
|
||||
{ 0x0060 , 0x0055 , 0x00d9 } ,
|
||||
{ 0x0060 , 0x0049 , 0x00cc } ,
|
||||
{ 0x0060 , 0x004f , 0x00d2 } ,
|
||||
{ 0x0060 , 0x0020 , 0x0060 } ,
|
||||
{ 0x005e , 0x0061 , 0x00e2 } ,
|
||||
{ 0x005e , 0x0065 , 0x00ea } ,
|
||||
{ 0x005e , 0x0075 , 0x00fb } ,
|
||||
{ 0x005e , 0x0069 , 0x00ee } ,
|
||||
{ 0x005e , 0x006f , 0x00f4 } ,
|
||||
{ 0x005e , 0x0041 , 0x00c2 } ,
|
||||
{ 0x005e , 0x0045 , 0x00ca } ,
|
||||
{ 0x005e , 0x0055 , 0x00db } ,
|
||||
{ 0x005e , 0x0049 , 0x00ce } ,
|
||||
{ 0x005e , 0x004f , 0x00d4 } ,
|
||||
{ 0x005e , 0x0020 , 0x005e } ,
|
||||
|
||||
};
|
||||
|
||||
private static GermanLayout instance = new GermanLayout();
|
||||
|
||||
private GermanLayout() {
|
||||
|
@ -175,7 +175,7 @@ public class DropboxFileStorage extends JavaFileStorageBase {
|
||||
Log.d(TAG, "LoggedIn=false (due to unlink exception)");
|
||||
setLoggedIn(false);
|
||||
clearKeys();
|
||||
return new Exception("Unlinked from Dropbox!", e);
|
||||
return new UserInteractionRequiredException("Unlinked from Dropbox! User must re-link.", e);
|
||||
|
||||
}
|
||||
|
||||
|
@ -281,13 +281,16 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
@Override
|
||||
public InputStream openFileForRead(String path) throws Exception {
|
||||
|
||||
logDebug("openFileForRead...");
|
||||
GDrivePath gdrivePath = new GDrivePath(path);
|
||||
Drive driveService = getDriveService(gdrivePath.getAccount());
|
||||
|
||||
try
|
||||
{
|
||||
File file = getFileForPath(gdrivePath, driveService);
|
||||
return getFileContent(file, driveService);
|
||||
InputStream res = getFileContent(file, driveService);
|
||||
logDebug("openFileForRead ok.");
|
||||
return res;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -340,15 +343,17 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
@Override
|
||||
public void uploadFile(String path, byte[] data, boolean writeTransactional)
|
||||
throws Exception {
|
||||
|
||||
ByteArrayContent content = new ByteArrayContent(null, data);
|
||||
GDrivePath gdrivePath = new GDrivePath(path);
|
||||
Drive driveService = getDriveService(gdrivePath.getAccount());
|
||||
logDebug("upload file...");
|
||||
try
|
||||
{
|
||||
ByteArrayContent content = new ByteArrayContent(null, data);
|
||||
GDrivePath gdrivePath = new GDrivePath(path);
|
||||
Drive driveService = getDriveService(gdrivePath.getAccount());
|
||||
|
||||
File driveFile = getFileForPath(gdrivePath, driveService);
|
||||
getDriveService(gdrivePath.getAccount()).files()
|
||||
.update(driveFile.getId(), driveFile, content).execute();
|
||||
logDebug("upload file ok.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -451,8 +456,11 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
}
|
||||
|
||||
private Exception convertException(Exception e) {
|
||||
logDebug("Exception: " + e.toString());
|
||||
e.printStackTrace();
|
||||
if (UserRecoverableAuthIOException.class.isAssignableFrom(e.getClass()))
|
||||
{
|
||||
logDebug("clearing account data.");
|
||||
//this is not really nice because it removes data from the cache which might still be valid but we don't have the account name here...
|
||||
mAccountData.clear();
|
||||
}
|
||||
@ -682,29 +690,37 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
|
||||
private void initializeAccount(final Context appContext,
|
||||
final String accountName) throws IOException {
|
||||
logDebug("Init account for " + accountName);
|
||||
if (!mAccountData.containsKey(accountName))
|
||||
{
|
||||
AccountData newAccountData = new AccountData();
|
||||
newAccountData.drive = createDriveService(accountName, appContext);
|
||||
mAccountData.put(accountName, newAccountData);
|
||||
logDebug("Added account data for " + accountName);
|
||||
//try to finish the initialization. If this fails, we throw.
|
||||
//in case of "Always return true" (inside CachingFileStorage) this means
|
||||
//we have a partially uninitialized AccountData object.
|
||||
//We'll try to initialize later in verify() if (e.g.) network is available again.
|
||||
finishInitialization(newAccountData, accountName);
|
||||
}
|
||||
AccountData accountData = mAccountData.get(accountName);
|
||||
//try to finish the initialization. If this fails, we throw.
|
||||
//in case of "Always return true" (inside CachingFileStorage) this means
|
||||
//we have a partially uninitialized AccountData object.
|
||||
//We'll try to initialize later in verify() if (e.g.) network is available again.
|
||||
finishInitialization(accountData, accountName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void finishInitialization(AccountData newAccountData, String accountName) throws IOException
|
||||
{
|
||||
|
||||
if (TextUtils.isEmpty(newAccountData.mRootFolderId))
|
||||
{
|
||||
logDebug("Finish init account for " + accountName);
|
||||
About about = newAccountData.drive.about().get().execute();
|
||||
newAccountData.mRootFolderId = about.getRootFolderId();
|
||||
}
|
||||
else
|
||||
{
|
||||
logDebug("Account for " + accountName + " already fully initialized.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -726,6 +742,7 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
{
|
||||
try
|
||||
{
|
||||
logDebug("prepareFileUsage " + path + "...");
|
||||
String accountName;
|
||||
GDrivePath gdrivePath = null;
|
||||
if (path.startsWith(getProtocolPrefix()))
|
||||
@ -740,9 +757,11 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
accountName = path;
|
||||
|
||||
initializeAccount(appContext, accountName);
|
||||
logDebug("prepareFileUsage ok");
|
||||
}
|
||||
catch (UserRecoverableAuthIOException e)
|
||||
{
|
||||
logDebug("prepareFileUsage: UserInteractionRequiredException");
|
||||
throw new UserInteractionRequiredException(e);
|
||||
}
|
||||
|
||||
@ -764,6 +783,7 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
@Override
|
||||
public void onStart(final JavaFileStorage.FileStorageSetupActivity setupAct) {
|
||||
|
||||
logDebug("onStart");
|
||||
Activity activity = (Activity)setupAct;
|
||||
|
||||
if (PROCESS_NAME_SELECTFILE.equals(setupAct.getProcessName()))
|
||||
|
@ -1,10 +1,8 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
|
||||
|
||||
public class UserInteractionRequiredException extends Exception {
|
||||
|
||||
public UserInteractionRequiredException(UserRecoverableAuthIOException e) {
|
||||
public UserInteractionRequiredException(Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
@ -12,6 +10,10 @@ public class UserInteractionRequiredException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
public UserInteractionRequiredException(String string, Throwable e) {
|
||||
super(string, e);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user