+ 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

Binary file not shown.

View File

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

View File

@@ -43,6 +43,15 @@
android:layout_marginLeft="17dp"
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>

View File

@@ -149,10 +149,12 @@ import keepass2android.javafilestorage.JavaFileStorage;
import keepass2android.javafilestorage.JavaFileStorage.FileEntry;
import keepass2android.javafilestorage.SftpStorage;
import keepass2android.javafilestorage.SkyDriveFileStorage;
import keepass2android.javafilestorage.UserInteractionRequiredException;
import keepass2android.kp2afilechooser.StorageFileProvider;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.app.AlertDialog;
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) {
storageToTest = new SftpStorage();
//storageToTest = new SkyDriveFileStorage("000000004010C234", appContext);
//storageToTest = new SftpStorage();
storageToTest = new SkyDriveFileStorage("000000004010C234", appContext);
//storageToTest = new GoogleDriveFileStorage();
//storageToTest = new DropboxFileStorage(ctx,"4ybka4p4a1027n6", "1z5lv528un9nre8", true);
//storageToTest = new DropboxAppFolderFileStorage(ctx,"ax0268uydp1ya57", "3s86datjhkihwyc", true);
@@ -494,6 +557,9 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
ArrayList<Uri> uris = data
.getParcelableArrayListExtra(FileChooserActivity.EXTRA_RESULTS);
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:
createStorageToTest(this, getApplicationContext()).prepareFileUsage(this, path, 2123, false);

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="keepass2android.plugin.inputstick"
android:versionCode="1"
android:versionName="1.0" >
android:versionCode="2"
android:versionName="1.1" >
<uses-sdk
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_type_enter=0x7f060007;
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;
/** 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_shortdesc=0x7f060003;
public static final int kp2aplugin_title=0x7f060002;
public static final int layout_title=0x7f06000a;
public static final int title_activity_settings=0x7f060008;
public static final int layout_title=0x7f06000b;
public static final int title_activity_settings=0x7f060009;
}
public static final class style {
/**

View File

@@ -12,5 +12,6 @@
<string name="action_input_stick">Type 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_user_tab_pass_enter">Type username/password with InputStick</string>
</resources>

View File

@@ -1,5 +1,6 @@
package keepass2android.plugin.inputstick;
import keepass2android.pluginsdk.KeepassDefs;
import keepass2android.pluginsdk.PluginAccessException;
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),
R.drawable.ic_launcher, null);
}
Bundle b1 = new Bundle();
b1.putString(EXTRA_TEXT, "\t");
oe.addEntryAction(oe.getContext().getString(R.string.action_type_tab), R.drawable.ic_launcher, b1);
Bundle b2 = new Bundle();
b2.putString(EXTRA_TEXT, "\n");
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) {
e.printStackTrace();
}
@@ -45,7 +50,20 @@ public class ActionReceiver extends keepass2android.pluginsdk.PluginActionBroadc
protected void actionSelected(ActionSelectedAction actionSelected) {
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
{