Merge branch 'kp2aforsync'

Conflicts:
	src/AndroidFileChooserBinding/AndroidFileChooserBinding.csproj
	src/AndroidFileChooserBinding/Transforms/Metadata.xml
	src/JavaFileStorageBindings/JavaFileStorageBindings.csproj
	src/KeePassLib2Android/KeePassLib2Android.csproj
	src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj
	src/java/InputStickAPI/gen/com/inputstick/api/R.java
	src/java/InputStickAPI/src/com/inputstick/api/BTConnectionManager.java
	src/java/InputStickAPI/src/com/inputstick/api/PacketManager.java
	src/java/InputStickAPI/src/com/inputstick/api/bluetooth/BTService.java
	src/java/InputStickAPI/src/com/inputstick/api/layout/KeyboardLayout.java
	src/java/InputStickAPI/src/com/inputstick/init/BasicInitManager.java
	src/java/InputStickAPI/src/com/inputstick/init/InitManager.java
	src/java/JavaFileStorage/bin/javafilestorage.jar
	src/java/KP2AKdbLibrary/bin/kp2akdblibrary.jar
	src/java/Keepass2AndroidPluginSDK/bin/keepass2androidpluginsdk.jar
	src/java/PluginInputStick/AndroidManifest.xml
	src/java/PluginInputStick/gen/com/inputstick/api/R.java
	src/java/PluginInputStick/gen/keepass2android/plugin/inputstick/R.java
	src/java/PluginInputStick/res/values/strings_activity_settings.xml
	src/java/PluginInputStick/src/keepass2android/plugin/inputstick/ActionReceiver.java
	src/keepass2android/PasswordActivity.cs
	src/keepass2android/Resources/Resource.designer.cs
	src/keepass2android/keepass2android.csproj
This commit is contained in:
Philipp Crocoll 2014-12-12 06:08:11 +01:00
commit 3963191930
7 changed files with 132 additions and 22 deletions

View File

@ -72,7 +72,7 @@
</Target> </Target>
--> -->
<ItemGroup> <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> <Link>project.zip</Link>
</LibraryProjectZip> </LibraryProjectZip>
</ItemGroup> </ItemGroup>

View File

@ -1,6 +1,7 @@
<metadata> <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.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']/class[@name='FragmentFiles']" />
<remove-node path="/api/package[@name='group.pals.android.lib.ui.filechooser.prefs']" />
<!-- <!--

View File

@ -93,13 +93,31 @@ namespace keepass2android.Io
} }
private Exception LogAndConvertJavaException(Java.Lang.Exception e) private Exception LogAndConvertJavaException(Exception e)
{ {
Kp2aLog.Log(e.Message); Kp2aLog.Log(e.Message);
var ex = new Exception(e.LocalizedMessage ??
e.Message ?? if (e is UserInteractionRequiredException)
_app.GetResourceString(UiStringKey.ErrorOcurred)+e.GetType().Name, e); return e;
return ex; //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) 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) 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) 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) public bool IsPermanentLocation(IOConnectionInfo ioc)

View File

@ -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 static GermanLayout instance = new GermanLayout();
private GermanLayout() { private GermanLayout() {

View File

@ -175,7 +175,7 @@ public class DropboxFileStorage extends JavaFileStorageBase {
Log.d(TAG, "LoggedIn=false (due to unlink exception)"); Log.d(TAG, "LoggedIn=false (due to unlink exception)");
setLoggedIn(false); setLoggedIn(false);
clearKeys(); clearKeys();
return new Exception("Unlinked from Dropbox!", e); return new UserInteractionRequiredException("Unlinked from Dropbox! User must re-link.", e);
} }

View File

@ -281,13 +281,16 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
@Override @Override
public InputStream openFileForRead(String path) throws Exception { public InputStream openFileForRead(String path) throws Exception {
logDebug("openFileForRead...");
GDrivePath gdrivePath = new GDrivePath(path); GDrivePath gdrivePath = new GDrivePath(path);
Drive driveService = getDriveService(gdrivePath.getAccount()); Drive driveService = getDriveService(gdrivePath.getAccount());
try try
{ {
File file = getFileForPath(gdrivePath, driveService); File file = getFileForPath(gdrivePath, driveService);
return getFileContent(file, driveService); InputStream res = getFileContent(file, driveService);
logDebug("openFileForRead ok.");
return res;
} }
catch (Exception e) catch (Exception e)
{ {
@ -340,15 +343,17 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
@Override @Override
public void uploadFile(String path, byte[] data, boolean writeTransactional) public void uploadFile(String path, byte[] data, boolean writeTransactional)
throws Exception { throws Exception {
logDebug("upload file...");
ByteArrayContent content = new ByteArrayContent(null, data);
GDrivePath gdrivePath = new GDrivePath(path);
Drive driveService = getDriveService(gdrivePath.getAccount());
try try
{ {
ByteArrayContent content = new ByteArrayContent(null, data);
GDrivePath gdrivePath = new GDrivePath(path);
Drive driveService = getDriveService(gdrivePath.getAccount());
File driveFile = getFileForPath(gdrivePath, driveService); File driveFile = getFileForPath(gdrivePath, driveService);
getDriveService(gdrivePath.getAccount()).files() getDriveService(gdrivePath.getAccount()).files()
.update(driveFile.getId(), driveFile, content).execute(); .update(driveFile.getId(), driveFile, content).execute();
logDebug("upload file ok.");
} }
catch (Exception e) catch (Exception e)
{ {
@ -451,8 +456,11 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
} }
private Exception convertException(Exception e) { private Exception convertException(Exception e) {
logDebug("Exception: " + e.toString());
e.printStackTrace();
if (UserRecoverableAuthIOException.class.isAssignableFrom(e.getClass())) 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... //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(); mAccountData.clear();
} }
@ -682,29 +690,37 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
private void initializeAccount(final Context appContext, private void initializeAccount(final Context appContext,
final String accountName) throws IOException { final String accountName) throws IOException {
logDebug("Init account for " + accountName);
if (!mAccountData.containsKey(accountName)) if (!mAccountData.containsKey(accountName))
{ {
AccountData newAccountData = new AccountData(); AccountData newAccountData = new AccountData();
newAccountData.drive = createDriveService(accountName, appContext); newAccountData.drive = createDriveService(accountName, appContext);
mAccountData.put(accountName, newAccountData); mAccountData.put(accountName, newAccountData);
logDebug("Added account data for " + accountName); 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 private void finishInitialization(AccountData newAccountData, String accountName) throws IOException
{ {
if (TextUtils.isEmpty(newAccountData.mRootFolderId)) if (TextUtils.isEmpty(newAccountData.mRootFolderId))
{ {
logDebug("Finish init account for " + accountName);
About about = newAccountData.drive.about().get().execute(); About about = newAccountData.drive.about().get().execute();
newAccountData.mRootFolderId = about.getRootFolderId(); newAccountData.mRootFolderId = about.getRootFolderId();
} }
else
{
logDebug("Account for " + accountName + " already fully initialized.");
}
} }
@Override @Override
@ -726,6 +742,7 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
{ {
try try
{ {
logDebug("prepareFileUsage " + path + "...");
String accountName; String accountName;
GDrivePath gdrivePath = null; GDrivePath gdrivePath = null;
if (path.startsWith(getProtocolPrefix())) if (path.startsWith(getProtocolPrefix()))
@ -740,9 +757,11 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
accountName = path; accountName = path;
initializeAccount(appContext, accountName); initializeAccount(appContext, accountName);
logDebug("prepareFileUsage ok");
} }
catch (UserRecoverableAuthIOException e) catch (UserRecoverableAuthIOException e)
{ {
logDebug("prepareFileUsage: UserInteractionRequiredException");
throw new UserInteractionRequiredException(e); throw new UserInteractionRequiredException(e);
} }
@ -764,6 +783,7 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
@Override @Override
public void onStart(final JavaFileStorage.FileStorageSetupActivity setupAct) { public void onStart(final JavaFileStorage.FileStorageSetupActivity setupAct) {
logDebug("onStart");
Activity activity = (Activity)setupAct; Activity activity = (Activity)setupAct;
if (PROCESS_NAME_SELECTFILE.equals(setupAct.getProcessName())) if (PROCESS_NAME_SELECTFILE.equals(setupAct.getProcessName()))

View File

@ -1,10 +1,8 @@
package keepass2android.javafilestorage; package keepass2android.javafilestorage;
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
public class UserInteractionRequiredException extends Exception { public class UserInteractionRequiredException extends Exception {
public UserInteractionRequiredException(UserRecoverableAuthIOException e) { public UserInteractionRequiredException(Throwable e) {
super(e); super(e);
} }
@ -12,6 +10,10 @@ public class UserInteractionRequiredException extends Exception {
} }
public UserInteractionRequiredException(String string, Throwable e) {
super(string, e);
}
/** /**
* *
*/ */