* added possibility to select another entry or create a new one from the Share-Url-Results activity

* KP2A keyboard: allows to search for the current app
* KP2A keyboard: when clicking "select (another) entry", KP2A is started an now closes automatically after selecting an entry
This commit is contained in:
Philipp Crocoll 2013-06-01 15:51:54 +02:00
parent bf139d9059
commit 40286f4f43
26 changed files with 1181 additions and 808 deletions

View File

@ -2,7 +2,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Dieser Code wurde von einem Tool generiert. // Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18033 // Laufzeitversion:4.0.30319.18046
// //
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird. // der Code erneut generiert wird.

View File

@ -4,5 +4,6 @@
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

View File

@ -11,5 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target. # Project target.
target=android-14 target=android-17
android.library=true android.library=true

View File

@ -26,6 +26,7 @@
<string name="change_entry">Select another entry</string> <string name="change_entry">Select another entry</string>
<string name="open_entry">Select entry</string> <string name="open_entry">Select entry</string>
<string name="open_entry_for_app">Search for entry with "%1$s"</string>
<!-- Labels on soft keys --> <!-- Labels on soft keys -->
<string name="label_go_key">Go</string> <string name="label_go_key">Go</string>

View File

@ -76,6 +76,8 @@ public class KP2AKeyboard extends InputMethodService implements
private String mWordSeparators; private String mWordSeparators;
private String mClientPackageName;
/** /**
* Main initialization of the input method component. Be sure to call to * Main initialization of the input method component. Be sure to call to
* super class. * super class.
@ -155,6 +157,8 @@ public class KP2AKeyboard extends InputMethodService implements
mMetaState = 0; mMetaState = 0;
} }
mClientPackageName = attribute.packageName;
mPredictionOn = false; mPredictionOn = false;
mCompletionOn = false; mCompletionOn = false;
mCompletions = null; mCompletions = null;
@ -466,7 +470,7 @@ public class KP2AKeyboard extends InputMethodService implements
if (keepass2android.kbbridge.KeyboardData.entryName == null) if (keepass2android.kbbridge.KeyboardData.entryName == null)
{ {
items.add(getString(R.string.open_entry)); items.add(getString(R.string.open_entry));
values.add(""); values.add("KP2ASPECIAL_SelectEntryTask");
} }
else else
{ {
@ -474,6 +478,13 @@ public class KP2AKeyboard extends InputMethodService implements
items.add(getString(R.string.change_entry)); items.add(getString(R.string.change_entry));
values.add(""); values.add("");
} }
if ((mClientPackageName != null) && (mClientPackageName != ""))
{
items.add(getString(R.string.open_entry_for_app,mClientPackageName));
values.add("KP2ASPECIAL_SearchUrlTask");
}
builder.setTitle(title); builder.setTitle(title);
// builder.setMessage("What do you want to type securely?"); // builder.setMessage("What do you want to type securely?");
@ -481,13 +492,21 @@ public class KP2AKeyboard extends InputMethodService implements
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) { public void onClick(DialogInterface dialog, int item) {
if (item == items.size() - 1) { if (values.get(item).startsWith("KP2ASPECIAL")) {
//change entry //change entry
Intent startKp2aIntent = getPackageManager().getLaunchIntentForPackage(getApplicationContext().getPackageName()); Intent startKp2aIntent = getPackageManager().getLaunchIntentForPackage(getApplicationContext().getPackageName());
//Intent startKp2aIntent = getPackageManager().getLaunchIntentForPackage("keepass2android.keepass2android");
if (startKp2aIntent != null) if (startKp2aIntent != null)
{ {
startKp2aIntent.addCategory(Intent.CATEGORY_LAUNCHER); startKp2aIntent.addCategory(Intent.CATEGORY_LAUNCHER);
startKp2aIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startKp2aIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
String value = values.get(item);
String taskName = value.substring("KP2ASPECIAL_".length());
startKp2aIntent.putExtra("KP2A_APPTASK", taskName);
if (taskName.equals("SearchUrlTask"))
{
startKp2aIntent.putExtra("UrlToSearch", "androidapp://"+mClientPackageName);
}
startActivity(startKp2aIntent); startActivity(startKp2aIntent);
Settings.Secure.getString( Settings.Secure.getString(
getContentResolver(), getContentResolver(),

View File

@ -4,5 +4,6 @@
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

View File

@ -10,6 +10,6 @@
# Indicates whether an apk should be generated for each density. # Indicates whether an apk should be generated for each density.
split.density=false split.density=false
# Project target. # Project target.
target=android-12 target=android-17
apk-configurations= apk-configurations=
android.library=true android.library=true

View File

@ -79,7 +79,7 @@ namespace keepass2android
protected void setupEditButtons() { protected void setupEditButtons() {
View edit = FindViewById(Resource.Id.entry_edit); View edit = FindViewById(Resource.Id.entry_edit);
edit.Click += (sender, e) => { edit.Click += (sender, e) => {
EntryEditActivity.Launch(this, mEntry); EntryEditActivity.Launch(this, mEntry,mAppTask);
}; };
} }
@ -159,6 +159,7 @@ namespace keepass2android
if (closeAfterCreate) if (closeAfterCreate)
{ {
SetResult(KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE);
Finish(); Finish();
} }
} }

View File

@ -53,20 +53,24 @@ namespace keepass2android
get { return App.entryEditActivityState; } get { return App.entryEditActivityState; }
} }
public static void Launch(Activity act, PwEntry pw) { public static void Launch(Activity act, PwEntry pw, AppTask appTask) {
Intent i = new Intent(act, typeof(EntryEditActivity)); Intent i = new Intent(act, typeof(EntryEditActivity));
i.PutExtra(KEY_ENTRY, pw.Uuid.ToHexString()); i.PutExtra(KEY_ENTRY, pw.Uuid.ToHexString());
appTask.ToIntent(i);
act.StartActivityForResult(i, 0); act.StartActivityForResult(i, 0);
} }
public static void Launch(Activity act, PwGroup pw) { public static void Launch(Activity act, PwGroup pw, AppTask appTask) {
Intent i = new Intent(act, typeof(EntryEditActivity)); Intent i = new Intent(act, typeof(EntryEditActivity));
PwGroup parent = pw; PwGroup parent = pw;
i.PutExtra(KEY_PARENT, parent.Uuid.ToHexString()); i.PutExtra(KEY_PARENT, parent.Uuid.ToHexString());
appTask.ToIntent(i);
act.StartActivityForResult(i, 0); act.StartActivityForResult(i, 0);
} }
@ -170,6 +174,7 @@ namespace keepass2android
} }
} }
}*/ }*/
mAppTask.PrepareNewEntry(State.mEntryInDatabase);
State.mIsNew = true; State.mIsNew = true;
State.mEntryModified = true; State.mEntryModified = true;
@ -383,7 +388,7 @@ namespace keepass2android
ActionOnFinish afterAddEntry = new ActionOnFinish((success, message) => ActionOnFinish afterAddEntry = new ActionOnFinish((success, message) =>
{ {
if (success) if (success)
mAppTask.AfterAddNewEntry(this); mAppTask.AfterAddNewEntry(this, newEntry);
},closeOrShowError); },closeOrShowError);
if ( State.mIsNew ) { if ( State.mIsNew ) {

View File

@ -67,6 +67,7 @@ namespace keepass2android
if ( g != null ) { if ( g != null ) {
i.PutExtra(KEY_ENTRY, g.Uuid.ToHexString()); i.PutExtra(KEY_ENTRY, g.Uuid.ToHexString());
} }
appTask.ToIntent(i);
act.StartActivityForResult(i,0); act.StartActivityForResult(i,0);
} }
@ -138,7 +139,7 @@ namespace keepass2android
// Add Entry button // Add Entry button
View addEntry = FindViewById (Resource.Id.add_entry); View addEntry = FindViewById (Resource.Id.add_entry);
addEntry.Click += (object sender, EventArgs e) => { addEntry.Click += (object sender, EventArgs e) => {
EntryEditActivity.Launch (this, mGroup); EntryEditActivity.Launch (this, mGroup, mAppTask);
}; };
} }
@ -190,6 +191,7 @@ namespace keepass2android
case Result.Canceled: case Result.Canceled:
default: default:
base.OnActivityResult(requestCode, resultCode, data);
break; break;
} }
} }

View File

@ -59,6 +59,19 @@ namespace keepass2android
mAppTask.ToBundle(outState); mAppTask.ToBundle(outState);
} }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (resultCode == KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE)
{
SetResult(KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE);
Finish();
}
}
private ISharedPreferences prefs; private ISharedPreferences prefs;
protected PwGroup mGroup; protected PwGroup mGroup;

View File

@ -42,14 +42,17 @@ namespace keepass2android
public const Android.App.Result EXIT_REFRESH_TITLE = Android.App.Result.FirstUser+3; public const Android.App.Result EXIT_REFRESH_TITLE = Android.App.Result.FirstUser+3;
public const Android.App.Result EXIT_FORCE_LOCK = Android.App.Result.FirstUser+4; public const Android.App.Result EXIT_FORCE_LOCK = Android.App.Result.FirstUser+4;
public const Android.App.Result EXIT_QUICK_UNLOCK = Android.App.Result.FirstUser+5; public const Android.App.Result EXIT_QUICK_UNLOCK = Android.App.Result.FirstUser+5;
public const Android.App.Result EXIT_CLOSE_AFTER_SEARCH = Android.App.Result.FirstUser+6; public const Android.App.Result EXIT_CLOSE_AFTER_TASK_COMPLETE = Android.App.Result.FirstUser+6;
public const Android.App.Result EXIT_CHANGE_DB = Android.App.Result.FirstUser+7; public const Android.App.Result EXIT_CHANGE_DB = Android.App.Result.FirstUser+7;
public const Android.App.Result EXIT_FORCE_LOCK_AND_CHANGE_DB = Android.App.Result.FirstUser+8; public const Android.App.Result EXIT_FORCE_LOCK_AND_CHANGE_DB = Android.App.Result.FirstUser+8;
public const Android.App.Result EXIT_RELOAD_DB = Android.App.Result.FirstUser+9; public const Android.App.Result EXIT_RELOAD_DB = Android.App.Result.FirstUser+9;
AppTask mAppTask;
protected override void OnCreate (Bundle bundle) protected override void OnCreate (Bundle bundle)
{ {
base.OnCreate (bundle); base.OnCreate (bundle);
mAppTask = AppTask.GetTaskInOnCreate(bundle, Intent);
Android.Util.Log.Debug("DEBUG","KeePass.OnCreate"); Android.Util.Log.Debug("DEBUG","KeePass.OnCreate");
} }
@ -161,10 +164,12 @@ namespace keepass2android
//Intent intent = new Intent(this, typeof(SearchActivity)); //Intent intent = new Intent(this, typeof(SearchActivity));
//Intent intent = new Intent(this, typeof(QuickUnlock)); //Intent intent = new Intent(this, typeof(QuickUnlock));
mAppTask.ToIntent(intent);
StartActivityForResult(intent, 0); StartActivityForResult(intent, 0);
Finish(); Finish();
} }

View File

@ -195,7 +195,7 @@ namespace keepass2android
startedWithActivityResult = true; startedWithActivityResult = true;
Android.Util.Log.Debug("DEBUG","PasswordActivity.OnActivityResult "+resultCode+"/"+requestCode); Android.Util.Log.Debug("DEBUG","PasswordActivity.OnActivityResult "+resultCode+"/"+requestCode);
if (resultCode != KeePass.EXIT_CLOSE_AFTER_SEARCH) if (resultCode != KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE)
{ {
//Stop service when app activity is left //Stop service when app activity is left
StopService(new Intent(this, typeof(CopyToClipboardService))); StopService(new Intent(this, typeof(CopyToClipboardService)));
@ -229,8 +229,8 @@ namespace keepass2android
case KeePass.EXIT_CHANGE_DB: case KeePass.EXIT_CHANGE_DB:
lockAndClose(); lockAndClose();
break; break;
case KeePass.EXIT_CLOSE_AFTER_SEARCH: case KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE:
SetResult(KeePass.EXIT_CLOSE_AFTER_SEARCH); SetResult(KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE);
Finish(); Finish();
break; break;
case KeePass.EXIT_QUICK_UNLOCK: case KeePass.EXIT_QUICK_UNLOCK:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:attr/dividerVertical"
android:showDividers="middle"
android:layout_alignParentBottom="true"
android:dividerPadding="12dp"
android:baselineAligned="false">
<FrameLayout
android:id="@+id/select_other_entry"
style="@style/BottomBarActionButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/select_other_entry" />
</FrameLayout>
<FrameLayout
android:id="@+id/add_url_entry"
style="@style/BottomBarActionButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/add_url_entry" />
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_above="@id/bottom_bar"
android:background="#b8b8b8" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/divider2"
android:layout_below="@id/top"
android:paddingRight="8dp"
android:paddingLeft="8dp" />
</RelativeLayout>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:attr/dividerVertical"
android:showDividers="middle"
android:layout_alignParentBottom="true"
android:dividerPadding="12dp"
android:baselineAligned="false">
<FrameLayout
android:id="@+id/select_other_entry"
style="@style/BottomBarActionButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/select_other_entry" />
</FrameLayout>
<FrameLayout
android:id="@+id/add_url_entry"
style="@style/BottomBarActionButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:text="@string/add_url_entry" />
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_above="@id/bottom_bar"
android:background="#b8b8b8" />
<TextView
android:id="@+id/no_results"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/top"
android:text="@string/no_results" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/divider2"
android:layout_below="@id/no_results"
android:paddingRight="8dp"
android:paddingLeft="8dp" />
</RelativeLayout>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<keepass2android.view.GroupHeaderView
android:id="@+id/group_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
style="@style/GroupAndEntryHeader">
<Button
android:id="@+id/select_other_entry"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="@string/select_other_entry"
/>
<Button
android:id="@+id/add_url_entry"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/select_other_entry"
android:layout_alignParentBottom="true"
android:text="@string/add_url_entry"
/>
</LinearLayout>
<ImageView
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottom_bar"
android:scaleType="fitXY"
android:tint="@color/blue_highlight"
android:src="@android:drawable/divider_horizontal_dark" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/divider2"
android:layout_below="@id/group_header" />
</RelativeLayout>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<keepass2android.view.GroupHeaderView
android:id="@+id/group_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
style="@style/GroupAndEntryHeader">
<Button
android:id="@+id/select_other_entry"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="@string/select_other_entry" />
<Button
android:id="@+id/add_url_entry"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/select_other_entry"
android:layout_alignParentBottom="true"
android:text="@string/add_url_entry" />
</LinearLayout>
<ImageView
android:id="@+id/divider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottom_bar"
android:scaleType="fitXY"
android:tint="@color/blue_highlight"
android:src="@android:drawable/divider_horizontal_dark" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/divider2"
android:layout_below="@id/group_header" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@android:id/list"
android:text="@string/no_results" />
</RelativeLayout>

View File

@ -7,6 +7,7 @@
<string name="CreditsText">The User Interface is based on a port of KeepassDroid developed by Brian Pellin. Code for database operations is based on KeePass by Dominik Reichl. The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.</string> <string name="CreditsText">The User Interface is based on a port of KeepassDroid developed by Brian Pellin. Code for database operations is based on KeePass by Dominik Reichl. The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.</string>
<string name="accept">Accept</string> <string name="accept">Accept</string>
<string name="add_entry">Add entry</string> <string name="add_entry">Add entry</string>
<string name="add_url_entry">Create entry for URL</string>
<string name="add_group">Add group</string> <string name="add_group">Add group</string>
<string name="add_group_title">Add Group</string> <string name="add_group_title">Add Group</string>
<string name="algorithm">Algorithm</string> <string name="algorithm">Algorithm</string>
@ -163,6 +164,8 @@
<string name="search_hint">Find what</string> <string name="search_hint">Find what</string>
<string name="search_results">Search results</string> <string name="search_results">Search results</string>
<string name="search_in">Search in</string> <string name="search_in">Search in</string>
<string name="select_other_entry">Select another entry</string>
<string name="select_group_then_add">Open the desired group, then press "%1$s"!</string>
<string name="twofish">Twofish</string> <string name="twofish">Twofish</string>
<string name="underline">Underline</string> <string name="underline">Underline</string>
<string name="unsupported_db_version">Unsupported database version.</string> <string name="unsupported_db_version">Unsupported database version.</string>

View File

@ -61,7 +61,7 @@ namespace keepass2android
{ {
base.OnCreate(savedInstanceState); base.OnCreate(savedInstanceState);
SetResult(KeePass.EXIT_CLOSE_AFTER_SEARCH); SetResult(KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE);
mDb = App.getDB(); mDb = App.getDB();
@ -137,25 +137,41 @@ namespace keepass2android
return; return;
} }
} }
//if there is exactly one match: open the entry
if (mGroup.Entries.Count() == 1)
{
LaunchActivityForEntry(mGroup.Entries.Single(),0);
return;
}
//show results: //show results:
if (mGroup == null || (mGroup.Entries.Count() < 1)) if (mGroup == null || (mGroup.Entries.Count() < 1))
{ {
SetContentView(new GroupEmptyView(this)); //SetContentView(new GroupEmptyView(this));
SetContentView(Resource.Layout.searchurlresults_empty);
} else } else
{ {
SetContentView(new GroupViewOnlyView(this)); SetContentView(Resource.Layout.searchurlresults);
//SetContentView(new GroupViewOnlyView(this));
} }
setGroupTitle(); setGroupTitle();
ListAdapter = new PwGroupListAdapter(this, mGroup); ListAdapter = new PwGroupListAdapter(this, mGroup);
//if there is exactly one match: open the entry View selectOtherEntry = FindViewById (Resource.Id.select_other_entry);
if (mGroup.Entries.Count() == 1) selectOtherEntry.Click += (object sender, EventArgs e) => {
{ GroupActivity.Launch (this, new SelectEntryTask());
LaunchActivityForEntry(mGroup.Entries.Single(),0); };
}
View createUrlEntry = FindViewById (Resource.Id.add_url_entry);
createUrlEntry.Click += (object sender, EventArgs e) => {
GroupActivity.Launch (this, new CreateEntryThenCloseTask() { Url = url } );
Toast.MakeText(this, GetString(Resource.String.select_group_then_add, new Java.Lang.Object[]{GetString(Resource.String.add_entry)}), ToastLength.Long ).Show();
};
} }
private String getSearchUrl(Intent queryIntent) { private String getSearchUrl(Intent queryIntent) {

View File

@ -44,10 +44,25 @@ namespace keepass2android
public static void gotoUrl(Context context, String url) { public static void gotoUrl(Context context, String url) {
if ( url != null && url.Length > 0 ) { if ( url != null && url.Length > 0 ) {
if (url.StartsWith("androidapp://"))
{
string packageName = url.Substring("androidapp://".Length);
Intent startKp2aIntent = context.PackageManager.GetLaunchIntentForPackage(packageName);
if (startKp2aIntent != null)
{
startKp2aIntent.AddCategory(Intent.CategoryLauncher);
startKp2aIntent.AddFlags(ActivityFlags.NewTask);
context.StartActivity(startKp2aIntent);
}
}
else
{
Android.Net.Uri uri = Android.Net.Uri.Parse(url); Android.Net.Uri uri = Android.Net.Uri.Parse(url);
context.StartActivity(new Intent(Intent.ActionView, uri)); context.StartActivity(new Intent(Intent.ActionView, uri));
} }
} }
}
public static void gotoUrl(Context context, int resId) { public static void gotoUrl(Context context, int resId) {
gotoUrl(context, context.GetString(resId)); gotoUrl(context, context.GetString(resId));

View File

@ -19,6 +19,8 @@ using Android.App;
using Android.Content; using Android.Content;
using Android.OS; using Android.OS;
using System.Collections.Generic; using System.Collections.Generic;
using KeePassLib;
using KeePassLib.Security;
namespace keepass2android namespace keepass2android
{ {
@ -88,7 +90,7 @@ namespace keepass2android
GroupActivity.Launch(act, this); GroupActivity.Launch(act, this);
} }
public virtual void AfterAddNewEntry(EntryEditActivity entryEditActivity) public virtual void AfterAddNewEntry(EntryEditActivity entryEditActivity, PwEntry newEntry)
{ {
} }
@ -97,6 +99,12 @@ namespace keepass2android
get { return false;} get { return false;}
} }
public virtual void PrepareNewEntry(PwEntry newEntry)
{
}
public const String AppTask_key = "KP2A_APPTASK"; public const String AppTask_key = "KP2A_APPTASK";
/// <summary> /// <summary>
@ -105,14 +113,17 @@ namespace keepass2android
/// </summary> /// </summary>
public static AppTask GetTaskInOnCreate(Bundle savedInstanceState, Intent intent) public static AppTask GetTaskInOnCreate(Bundle savedInstanceState, Intent intent)
{ {
AppTask task;
if (savedInstanceState != null) if (savedInstanceState != null)
{ {
return AppTask.CreateFromBundle(savedInstanceState); task = AppTask.CreateFromBundle(savedInstanceState);
} }
else else
{ {
return AppTask.CreateFromIntent(intent); task = AppTask.CreateFromIntent(intent);
} }
Android.Util.Log.Debug("DEBUG", "Loaded task " + task.ToString());
return task;
} }
public static AppTask CreateFromIntent(Intent i) public static AppTask CreateFromIntent(Intent i)
@ -125,24 +136,23 @@ namespace keepass2android
if (b == null) if (b == null)
return new NullTask(); return new NullTask();
string taskType = b.GetString("KP2A_APP_TASK_TYPE"); string taskType = b.GetString(AppTask_key);
if (string.IsNullOrEmpty(taskType)) if (string.IsNullOrEmpty(taskType))
return new NullTask(); return new NullTask();
Type[] types = {typeof(SearchUrlTask), typeof(NullTask)}; try
foreach (Type type in types)
{ {
if (taskType == type.Name) AppTask task = (AppTask)Activator.CreateInstance(Type.GetType("keepass2android."+taskType));
{
AppTask task = (AppTask)Activator.CreateInstance(type);
task.Setup(b); task.Setup(b);
return task; return task;
} }
catch (Exception e)
{
Android.Util.Log.Debug("DEBUG", "Cannot convert " + taskType + " in task: " + e.ToString());
return new NullTask();
} }
return new NullTask();
} }
/// <summary> /// <summary>
@ -177,7 +187,7 @@ namespace keepass2android
/// </summary> /// </summary>
static IExtra GetTypeExtra(Type type) static IExtra GetTypeExtra(Type type)
{ {
return new StringExtra() { Key="KP2A_APP_TASK_TYPE", Value=type.Name}; return new StringExtra() { Key=AppTask_key, Value=type.Name};
} }
} }
@ -264,6 +274,21 @@ namespace keepass2android
yield break; yield break;
} }
} }
public override void PrepareNewEntry(PwEntry newEntry)
{
newEntry.Strings.Set(PwDefs.UrlField, new ProtectedString(false, Url));
}
public override void AfterAddNewEntry(EntryEditActivity entryEditActivity, PwEntry newEntry)
{
EntryActivity.Launch(entryEditActivity, newEntry, -1, new SelectEntryTask());
entryEditActivity.SetResult(KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE);
//no need to call Finish here, that's done in EntryEditActivity ("closeOrShowError")
}
public override bool CloseEntryActivityAfterCreate public override bool CloseEntryActivityAfterCreate
{ {
//if the user selects an entry before creating the new one, we're not closing the app //if the user selects an entry before creating the new one, we're not closing the app

View File

@ -204,7 +204,7 @@ namespace keepass2android
base.OnCreate(savedInstanceState); base.OnCreate(savedInstanceState);
Android.Util.Log.Debug("DEBUG", "FileSelect.OnCreate"); Android.Util.Log.Debug("DEBUG", "FileSelect.OnCreate");
Android.Util.Log.Debug("DEBUG", "FileSelect:apptask="+Intent.GetStringExtra("KP2A_APP_TASK_TYPE")); Android.Util.Log.Debug("DEBUG", "FileSelect:apptask="+Intent.GetStringExtra("KP2A_APPTASK"));
if (Intent.Action == Intent.ActionSend) if (Intent.Action == Intent.ActionSend)
{ {
@ -427,7 +427,7 @@ namespace keepass2android
createdWithActivityResult = true; createdWithActivityResult = true;
if (resultCode == KeePass.EXIT_CLOSE_AFTER_SEARCH) if (resultCode == KeePass.EXIT_CLOSE_AFTER_TASK_COMPLETE)
{ {
Finish(); Finish();
return; return;

View File

@ -34,6 +34,7 @@
<Command type="BeforeBuild" command="UseManifestNet.bat" /> <Command type="BeforeBuild" command="UseManifestNet.bat" />
</CustomCommands> </CustomCommands>
</CustomCommands> </CustomCommands>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>none</DebugType>
@ -644,6 +645,10 @@
<AndroidResource Include="Resources\anim\anim_leave.xml" /> <AndroidResource Include="Resources\anim\anim_leave.xml" />
<AndroidResource Include="Resources\anim\anim_enter_back.xml" /> <AndroidResource Include="Resources\anim\anim_enter_back.xml" />
<AndroidResource Include="Resources\anim\anim_leave_back.xml" /> <AndroidResource Include="Resources\anim\anim_leave_back.xml" />
<AndroidResource Include="Resources\layout\searchurlresults.xml" />
<AndroidResource Include="Resources\layout\searchurlresults_empty.xml" />
<AndroidResource Include="Resources\layout-v14\searchurlresults.xml" />
<AndroidResource Include="Resources\layout-v14\searchurlresults_empty.xml" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup> <ItemGroup>

View File

@ -37,7 +37,6 @@ namespace keepass2android.search
{ {
private Database mDb; private Database mDb;
protected override void OnCreate (Bundle bundle) protected override void OnCreate (Bundle bundle)
{ {
base.OnCreate (bundle); base.OnCreate (bundle);