+ binary JavaFileStorage

This commit is contained in:
Philipp Crocoll 2014-07-30 06:25:37 +02:00
parent 7fa3dd191f
commit 97bcf753a4
16 changed files with 214 additions and 79 deletions

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Cryptography;
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using Android.Content.PM; using Android.Content.PM;
@ -7,22 +9,27 @@ using Android.Runtime;
using Android.Views; using Android.Views;
using Android.Widget; using Android.Widget;
using Android.OS; using Android.OS;
using KeeChallenge;
using KeePassLib.Serialization; //using KeePassLib.Serialization;
using keepass2android; using MasterPassword;
using keepass2android.Io; //using keepass2android;
//using keepass2android.Io;
namespace ArtTestApp namespace ArtTestApp
{ {
[Activity(Label = "ArtTestApp", MainLauncher = true, Icon = "@drawable/icon")] [Activity(Label = "ArtTestApp", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity public class Activity1 : Activity
{ {
private ChallengeInfo _chalInfo; //private IOConnectionInfo _ioConnectionInfo;
private byte[] _challengeSecret; //private IOConnectionInfo _ioConnectionInfoOut;
private IOConnectionInfo _ioConnectionInfo;
private IOConnectionInfo _ioConnectionInfoOut;
private const int RequestCodeChallengeYubikey = 98; private const int RequestCodeChallengeYubikey = 98;
private static byte[] HashHMAC(byte[] key, byte[] message)
{
var hash = new HMACSHA256(key);
return hash.ComputeHash(message);
}
protected override void OnCreate(Bundle bundle) protected override void OnCreate(Bundle bundle)
{ {
base.OnCreate(bundle); base.OnCreate(bundle);
@ -30,20 +37,31 @@ namespace ArtTestApp
// Set our view from the "main" layout resource // Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main); SetContentView(Resource.Layout.Main);
_ioConnectionInfo = new IOConnectionInfo() { Path = "/mnt/sdcard/keepass/keechallenge.xml" }; /*_ioConnectionInfo = new IOConnectionInfo() { Path = "/mnt/sdcard/keepass/keechallenge.xml" };
_ioConnectionInfoOut = new IOConnectionInfo() { Path = "/mnt/sdcard/keepass/keechallengeOut.xml" }; _ioConnectionInfoOut = new IOConnectionInfo() { Path = "/mnt/sdcard/keepass/keechallengeOut.xml" };
*/
FindViewById<Button>(Resource.Id.MyButton1).Text = "";
Stopwatch sw = new Stopwatch();
sw.Start();
var key = new MpAlgorithm().GetKeyForPassword("u", "test");
sw.Stop();
string password = MpAlgorithm.GenerateContent("Long Password", "strn", key, 1, HashHMAC);
FindViewById<Button>(Resource.Id.MyButton1).Text = password;
FindViewById<Button>(Resource.Id.MyButton2).Text = sw.ElapsedMilliseconds.ToString();
// Get our button from the layout resource, // Get our button from the layout resource,
// and attach an event to it // and attach an event to it
FindViewById<Button>(Resource.Id.MyButton1).Click += (sender, args) => FindViewById<Button>(Resource.Id.MyButton1).Click += (sender, args) =>
{ {
Decrypt(_ioConnectionInfo); // Decrypt(_ioConnectionInfo);
}; };
FindViewById<Button>(Resource.Id.MyButton2).Click += (sender, args) => FindViewById<Button>(Resource.Id.MyButton2).Click += (sender, args) =>
{ {
Decrypt(_ioConnectionInfoOut); //Decrypt(_ioConnectionInfoOut);
}; };
@ -51,7 +69,7 @@ namespace ArtTestApp
} }
private void Decrypt(IOConnectionInfo ioConnectionInfo) /*private void Decrypt(IOConnectionInfo ioConnectionInfo)
{ {
try try
{ {
@ -73,44 +91,8 @@ namespace ArtTestApp
{ {
Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show(); Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
} }
} }*/
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == RequestCodeChallengeYubikey && resultCode == Result.Ok)
{
try
{
byte[] challengeResponse = data.GetByteArrayExtra("response");
_challengeSecret = KeeChallengeProv.GetSecret(_chalInfo, challengeResponse);
Array.Clear(challengeResponse, 0, challengeResponse.Length);
}
catch (Exception e)
{
Kp2aLog.Log(e.ToString());
Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show();
return;
}
if (_challengeSecret != null)
{
Toast.MakeText(this, "OK!", ToastLength.Long).Show();
ChallengeInfo temp = KeeChallengeProv.Encrypt(_challengeSecret, _chalInfo.IV);
if (!temp.Save(_ioConnectionInfoOut))
{
Toast.MakeText(this, "error writing file", ToastLength.Long).Show();
return;
}
}
else
{
Toast.MakeText(this, "Not good :-(", ToastLength.Long).Show();
return;
}
}
}
} }
} }

View File

@ -50,9 +50,6 @@
<ItemGroup> <ItemGroup>
<Compile Include="Activity1.cs" /> <Compile Include="Activity1.cs" />
<Compile Include="Activity2.cs" /> <Compile Include="Activity2.cs" />
<Compile Include="App.cs" />
<Compile Include="ChallengeInfo.cs" />
<Compile Include="KeeChallenge.cs" />
<Compile Include="PrefActivity.cs" /> <Compile Include="PrefActivity.cs" />
<Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
@ -76,16 +73,6 @@
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\Xml\pref.xml" /> <AndroidResource Include="Resources\Xml\pref.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\KeePassLib2Android\KeePassLib2Android.csproj">
<Project>{545b4a6b-8bba-4fbe-92fc-4ac060122a54}</Project>
<Name>KeePassLib2Android</Name>
</ProjectReference>
<ProjectReference Include="..\Kp2aBusinessLogic\Kp2aBusinessLogic.csproj">
<Project>{53a9cb7f-6553-4bc0-b56b-9410bb2e59aa}</Project>
<Name>Kp2aBusinessLogic</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.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.

View File

@ -35,6 +35,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MasterPassword", "MasterPas
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MPTest", "MPTest\MPTest.csproj", "{96A3EA5A-7024-479F-A5B1-06654D0867A3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MPTest", "MPTest\MPTest.csproj", "{96A3EA5A-7024-479F-A5B1-06654D0867A3}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MasterKee", "MasterKee", "{CAC7DBC4-E21F-41E1-B33A-E3A04585F6A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MasterKeeWinPlugin", "MasterKeeWinPlugin\MasterKeeWinPlugin.csproj", "{BBF77830-BC7D-4F28-A255-A348B5C6A925}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamplePlugin", "SamplePlugin\SamplePlugin.csproj", "{4C1BB6F8-D2CD-49C2-9053-21705681356C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoTypeNeo", "..\..\..\..\..\Dropbox\programmieren\KeepassPlugins\AutoTypeNeo\AutoTypeNeo.csproj", "{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -402,10 +410,72 @@ Global
{96A3EA5A-7024-479F-A5B1-06654D0867A3}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU {96A3EA5A-7024-479F-A5B1-06654D0867A3}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
{96A3EA5A-7024-479F-A5B1-06654D0867A3}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU {96A3EA5A-7024-479F-A5B1-06654D0867A3}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{96A3EA5A-7024-479F-A5B1-06654D0867A3}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU {96A3EA5A-7024-479F-A5B1-06654D0867A3}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Debug|Win32.ActiveCfg = Debug|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Debug|x64.ActiveCfg = Debug|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Release|Any CPU.Build.0 = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Release|Win32.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.Release|x64.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{BBF77830-BC7D-4F28-A255-A348B5C6A925}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Debug|Win32.ActiveCfg = Debug|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Debug|x64.ActiveCfg = Debug|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Release|Any CPU.Build.0 = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Release|Win32.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.Release|x64.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{4C1BB6F8-D2CD-49C2-9053-21705681356C}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Debug|Win32.ActiveCfg = Debug|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Debug|x64.ActiveCfg = Debug|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Release|Any CPU.Build.0 = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Release|Win32.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.Release|x64.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2F7CB5B4-AC2A-4790-B0F3-42E6C9A060D5} = {CAC7DBC4-E21F-41E1-B33A-E3A04585F6A3}
{96A3EA5A-7024-479F-A5B1-06654D0867A3} = {CAC7DBC4-E21F-41E1-B33A-E3A04585F6A3}
{9A4C5BAA-1A8A-49B4-BBC3-60D4871FB36C} = {CAC7DBC4-E21F-41E1-B33A-E3A04585F6A3}
{BBF77830-BC7D-4F28-A255-A348B5C6A925} = {CAC7DBC4-E21F-41E1-B33A-E3A04585F6A3}
{4C1BB6F8-D2CD-49C2-9053-21705681356C} = {CAC7DBC4-E21F-41E1-B33A-E3A04585F6A3}
{4E5181A6-5FC4-4963-87B3-BAD15E7A765B} = {CAC7DBC4-E21F-41E1-B33A-E3A04585F6A3}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = keepass2android\keepass2android.csproj StartupItem = keepass2android\keepass2android.csproj
Policies = $0 Policies = $0

View File

@ -74,7 +74,9 @@
<AndroidResource Include="Resources\layout\Main.axml" /> <AndroidResource Include="Resources\layout\Main.axml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\values\Strings.xml" /> <AndroidResource Include="Resources\values\Strings.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\drawable\Icon.png" /> <AndroidResource Include="Resources\drawable\Icon.png" />

View File

@ -9,7 +9,7 @@
<string name="button_ok">OK</string> <string name="button_ok">OK</string>
<string name="error_pass_match">Passwords do not match.</string> <string name="error_pass_match">Passwords do not match.</string>
<string name="deriving_key">Calculating derived key... This might take a few seconds.</string> <string name="deriving_key">Calculating derived key... This might take a few seconds.</string>
<string name="AddMkEntry">Add MasterKee entry</string> <string name="AddMkEntry">Add entry for new site</string>
<string name="kp2aplugin_title">MasterKee Plugin</string> <string name="kp2aplugin_title">MasterKee Plugin</string>
<string name="kp2aplugin_shortdesc">Plugin to generate passwords compatible with the MasterPassword approach by Maarten Billemont giving you the ability to restore passwords even if your database is lost.</string> <string name="kp2aplugin_shortdesc">Plugin to generate passwords compatible with the MasterPassword approach by Maarten Billemont giving you the ability to restore passwords even if your database is lost.</string>

Binary file not shown.

View File

@ -12,6 +12,5 @@
# Project target. # Project target.
target=android-17 target=android-17
android.library.reference.1=../JavaFileStorage android.library.reference.1=..\\JavaFileStorage
android.library.reference.2=../../../../LiveSDK-for-Android/src android.library.reference.2=..\\android-filechooser\\code
android.library.reference.3=../android-filechooser/code

View File

@ -43,6 +43,15 @@
android:layout_marginLeft="17dp" android:layout_marginLeft="17dp"
android:text="Test File Chooser Save As" /> android:text="Test File Chooser Save As" />
<Button
android:id="@+id/button_test_preparefileusage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/button_test_filechooser_saveas"
android:layout_marginLeft="17dp"
android:text="Test Prepare File Usage" />
</RelativeLayout> </RelativeLayout>

View File

@ -149,10 +149,12 @@ import keepass2android.javafilestorage.JavaFileStorage;
import keepass2android.javafilestorage.JavaFileStorage.FileEntry; import keepass2android.javafilestorage.JavaFileStorage.FileEntry;
import keepass2android.javafilestorage.SftpStorage; import keepass2android.javafilestorage.SftpStorage;
import keepass2android.javafilestorage.SkyDriveFileStorage; import keepass2android.javafilestorage.SkyDriveFileStorage;
import keepass2android.javafilestorage.UserInteractionRequiredException;
import keepass2android.kp2afilechooser.StorageFileProvider; import keepass2android.kp2afilechooser.StorageFileProvider;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Application; import android.app.Application;
@ -450,11 +452,72 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
}); });
findViewById(R.id.button_test_preparefileusage).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final String path = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("selectedPath", "");
if (path.equals(""))
{
Toast.makeText(MainActivity.this, "select path with file chooser first", Toast.LENGTH_LONG).show();
return;
}
new AsyncTask<Object, Object, Object>() {
@Override
protected Object doInBackground(Object... params) {
try
{
createStorageToTest(MainActivity.this, MainActivity.this.getApplicationContext()).prepareFileUsage(MainActivity.this, path);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "prepare ok", Toast.LENGTH_LONG).show();
}
});
}
catch (UserInteractionRequiredException e)
{
final UserInteractionRequiredException e2 = e;
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "this requires user interaction! "+e2.getClass().getName()+ " "+e2.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
catch (Throwable t)
{
final Throwable t2 = t;
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, t2.getClass().getName()+": "+ t2.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
return null;
}
}.execute();
}
});
} }
static JavaFileStorage createStorageToTest(Context ctx, Context appContext) { static JavaFileStorage createStorageToTest(Context ctx, Context appContext) {
storageToTest = new SftpStorage(); //storageToTest = new SftpStorage();
//storageToTest = new SkyDriveFileStorage("000000004010C234", appContext); storageToTest = new SkyDriveFileStorage("000000004010C234", appContext);
//storageToTest = new GoogleDriveFileStorage(); //storageToTest = new GoogleDriveFileStorage();
//storageToTest = new DropboxFileStorage(ctx,"4ybka4p4a1027n6", "1z5lv528un9nre8", true); //storageToTest = new DropboxFileStorage(ctx,"4ybka4p4a1027n6", "1z5lv528un9nre8", true);
//storageToTest = new DropboxAppFolderFileStorage(ctx,"ax0268uydp1ya57", "3s86datjhkihwyc", true); //storageToTest = new DropboxAppFolderFileStorage(ctx,"ax0268uydp1ya57", "3s86datjhkihwyc", true);
@ -494,6 +557,9 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
ArrayList<Uri> uris = data ArrayList<Uri> uris = data
.getParcelableArrayListExtra(FileChooserActivity.EXTRA_RESULTS); .getParcelableArrayListExtra(FileChooserActivity.EXTRA_RESULTS);
String path = BaseFileProviderUtils.getRealUri(this, uris.get(0)).toString(); String path = BaseFileProviderUtils.getRealUri(this, uris.get(0)).toString();
PreferenceManager.getDefaultSharedPreferences(this).edit()
.putString("selectedPath", path).commit();
//create a new storage to simulate the case that the file name was saved and is used again after restarting the app: //create a new storage to simulate the case that the file name was saved and is used again after restarting the app:
createStorageToTest(this, getApplicationContext()).prepareFileUsage(this, path, 2123, false); createStorageToTest(this, getApplicationContext()).prepareFileUsage(this, path, 2123, false);

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="keepass2android.plugin.inputstick" package="keepass2android.plugin.inputstick"
android:versionCode="1" android:versionCode="2"
android:versionName="1.0" > android:versionName="1.1" >
<uses-sdk <uses-sdk
android:minSdkVersion="14" android:minSdkVersion="14"

View File

@ -53,15 +53,16 @@ public final class R {
public static final int action_settings=0x7f060001; public static final int action_settings=0x7f060001;
public static final int action_type_enter=0x7f060007; public static final int action_type_enter=0x7f060007;
public static final int action_type_tab=0x7f060006; public static final int action_type_tab=0x7f060006;
public static final int action_type_user_tab_pass_enter=0x7f060008;
public static final int app_name=0x7f060000; public static final int app_name=0x7f060000;
/** Strings related to Settings /** Strings related to Settings
*/ */
public static final int configure_plugin=0x7f060009; public static final int configure_plugin=0x7f06000a;
public static final int kp2aplugin_author=0x7f060004; public static final int kp2aplugin_author=0x7f060004;
public static final int kp2aplugin_shortdesc=0x7f060003; public static final int kp2aplugin_shortdesc=0x7f060003;
public static final int kp2aplugin_title=0x7f060002; public static final int kp2aplugin_title=0x7f060002;
public static final int layout_title=0x7f06000a; public static final int layout_title=0x7f06000b;
public static final int title_activity_settings=0x7f060008; public static final int title_activity_settings=0x7f060009;
} }
public static final class style { public static final class style {
/** /**

View File

@ -12,5 +12,6 @@
<string name="action_input_stick">Type with InputStick</string> <string name="action_input_stick">Type with InputStick</string>
<string name="action_type_tab">Type Tab with InputStick</string> <string name="action_type_tab">Type Tab with InputStick</string>
<string name="action_type_enter">Type Enter with InputStick</string> <string name="action_type_enter">Type Enter with InputStick</string>
<string name="action_type_user_tab_pass_enter">Type username/password with InputStick</string>
</resources> </resources>

View File

@ -1,5 +1,6 @@
package keepass2android.plugin.inputstick; package keepass2android.plugin.inputstick;
import keepass2android.pluginsdk.KeepassDefs;
import keepass2android.pluginsdk.PluginAccessException; import keepass2android.pluginsdk.PluginAccessException;
import keepass2android.pluginsdk.Strings; import keepass2android.pluginsdk.Strings;
@ -20,12 +21,16 @@ public class ActionReceiver extends keepass2android.pluginsdk.PluginActionBroadc
oe.addEntryFieldAction("keepass2android.plugin.inputstick.type", Strings.PREFIX_STRING+field, oe.getContext().getString(R.string.action_input_stick), oe.addEntryFieldAction("keepass2android.plugin.inputstick.type", Strings.PREFIX_STRING+field, oe.getContext().getString(R.string.action_input_stick),
R.drawable.ic_launcher, null); R.drawable.ic_launcher, null);
} }
Bundle b1 = new Bundle(); Bundle b1 = new Bundle();
b1.putString(EXTRA_TEXT, "\t"); b1.putString(EXTRA_TEXT, "\t");
oe.addEntryAction(oe.getContext().getString(R.string.action_type_tab), R.drawable.ic_launcher, b1); oe.addEntryAction(oe.getContext().getString(R.string.action_type_tab), R.drawable.ic_launcher, b1);
Bundle b2 = new Bundle(); Bundle b2 = new Bundle();
b2.putString(EXTRA_TEXT, "\n"); b2.putString(EXTRA_TEXT, "\n");
oe.addEntryAction(oe.getContext().getString(R.string.action_type_enter), R.drawable.ic_launcher, b2); oe.addEntryAction(oe.getContext().getString(R.string.action_type_enter), R.drawable.ic_launcher, b2);
Bundle b3 = new Bundle();
b3.putString(EXTRA_TEXT, "user_pass");
oe.addEntryAction(oe.getContext().getString(R.string.action_type_user_tab_pass_enter), R.drawable.ic_launcher, b3);
} catch (PluginAccessException e) { } catch (PluginAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -45,7 +50,20 @@ public class ActionReceiver extends keepass2android.pluginsdk.PluginActionBroadc
protected void actionSelected(ActionSelectedAction actionSelected) { protected void actionSelected(ActionSelectedAction actionSelected) {
if (actionSelected.isEntryAction()) if (actionSelected.isEntryAction())
{ {
typeText(actionSelected.getContext(), actionSelected.getActionData().getString(EXTRA_TEXT)); String text = actionSelected.getActionData().getString(EXTRA_TEXT);
if ("user_pass".equals(text))
{
typeText(actionSelected.getContext(),
actionSelected.getEntryFields().get(KeepassDefs.UserNameField));
typeText(actionSelected.getContext(), "\t");
typeText(actionSelected.getContext(), actionSelected.getEntryFields().get(KeepassDefs.PasswordField));
typeText(actionSelected.getContext(), "\n");
}
else
{
typeText(actionSelected.getContext(), text);
}
} }
else else
{ {

View File

@ -32,7 +32,7 @@ namespace keepass2android
}); });
b.SetNegativeButton(Resource.String.cancel, delegate { }); b.SetNegativeButton(Resource.String.cancel, delegate { });
b.SetTitle(AppNames.AppName); b.SetTitle(GetString(AppNames.AppNameResource));
b.SetOnDismissListener(this); b.SetOnDismissListener(this);
var dialog = b.Create(); var dialog = b.Create();
dialog.Show(); dialog.Show();

View File

@ -30,7 +30,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM</DefineConstants> <DefineConstants>DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;INCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>