mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-12-23 07:28:48 -05:00
Search when pressing "Enter" button
This commit is contained in:
parent
f5f6eb055b
commit
1106f618eb
@ -17,10 +17,12 @@
|
||||
<EditText
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
android:hint="@string/search_hint"
|
||||
android:layout_toLeftOf="@id/search_button"
|
||||
android:singleLine="true"
|
||||
android:layout_below="@id/search_label"
|
||||
android:imeOptions="actionSearch"
|
||||
android:id="@+id/searchEditText" />
|
||||
<ScrollView
|
||||
android:minWidth="25px"
|
||||
|
@ -67,35 +67,43 @@ namespace keepass2android
|
||||
|
||||
btnSearch.Click += (object sender, EventArgs e) =>
|
||||
{
|
||||
String searchString = ((EditText)FindViewById(Resource.Id.searchEditText)).Text;
|
||||
if (String.IsNullOrWhiteSpace(searchString))
|
||||
return;
|
||||
|
||||
SearchParameters spNew = new SearchParameters();
|
||||
|
||||
Intent searchIntent = new Intent(this, typeof(SearchResults));
|
||||
searchIntent.PutExtra("SearchInTitles", GetCheckBoxValue(Resource.Id.cbSearchInTitle));
|
||||
searchIntent.PutExtra("SearchInUrls", GetCheckBoxValue(Resource.Id.cbSearchInUrl));
|
||||
searchIntent.PutExtra("SearchInPasswords", GetCheckBoxValue(Resource.Id.cbSearchInPassword));
|
||||
searchIntent.PutExtra("SearchInUserNames", GetCheckBoxValue(Resource.Id.cbSearchInUsername));
|
||||
searchIntent.PutExtra("SearchInNotes", GetCheckBoxValue(Resource.Id.cbSearchInNotes));
|
||||
searchIntent.PutExtra("SearchInGroupNames", GetCheckBoxValue(Resource.Id.cbSearchInGroupName));
|
||||
searchIntent.PutExtra("SearchInOther", GetCheckBoxValue(Resource.Id.cbSearchInOtherStrings));
|
||||
searchIntent.PutExtra("SearchInTags", GetCheckBoxValue(Resource.Id.cbSearchInTags));
|
||||
searchIntent.PutExtra("RegularExpression", GetCheckBoxValue(Resource.Id.cbRegEx));
|
||||
searchIntent.PutExtra("CaseSensitive", GetCheckBoxValue(Resource.Id.cbCaseSensitive));
|
||||
searchIntent.PutExtra("ExcludeExpired", GetCheckBoxValue(Resource.Id.cbExcludeExpiredEntries));
|
||||
searchIntent.PutExtra(SearchManager.Query, searchString);
|
||||
|
||||
StartActivityForResult(searchIntent,0);
|
||||
Finish();
|
||||
PerformSearch();
|
||||
};
|
||||
|
||||
FindViewById<EditText>(Resource.Id.searchEditText).EditorAction += (object sender, TextView.EditorActionEventArgs e) =>
|
||||
{
|
||||
if (e.ActionId == Android.Views.InputMethods.ImeAction.Search) {
|
||||
PerformSearch();
|
||||
}
|
||||
};
|
||||
}
|
||||
void populateCheckBox(int resId, bool value)
|
||||
{
|
||||
((CheckBox) FindViewById(resId)).Checked = value;
|
||||
}
|
||||
|
||||
void PerformSearch()
|
||||
{
|
||||
String searchString = ((EditText)FindViewById(Resource.Id.searchEditText)).Text;
|
||||
if (String.IsNullOrWhiteSpace(searchString))
|
||||
return;
|
||||
SearchParameters spNew = new SearchParameters();
|
||||
Intent searchIntent = new Intent(this, typeof(SearchResults));
|
||||
searchIntent.PutExtra("SearchInTitles", GetCheckBoxValue(Resource.Id.cbSearchInTitle));
|
||||
searchIntent.PutExtra("SearchInUrls", GetCheckBoxValue(Resource.Id.cbSearchInUrl));
|
||||
searchIntent.PutExtra("SearchInPasswords", GetCheckBoxValue(Resource.Id.cbSearchInPassword));
|
||||
searchIntent.PutExtra("SearchInUserNames", GetCheckBoxValue(Resource.Id.cbSearchInUsername));
|
||||
searchIntent.PutExtra("SearchInNotes", GetCheckBoxValue(Resource.Id.cbSearchInNotes));
|
||||
searchIntent.PutExtra("SearchInGroupNames", GetCheckBoxValue(Resource.Id.cbSearchInGroupName));
|
||||
searchIntent.PutExtra("SearchInOther", GetCheckBoxValue(Resource.Id.cbSearchInOtherStrings));
|
||||
searchIntent.PutExtra("SearchInTags", GetCheckBoxValue(Resource.Id.cbSearchInTags));
|
||||
searchIntent.PutExtra("RegularExpression", GetCheckBoxValue(Resource.Id.cbRegEx));
|
||||
searchIntent.PutExtra("CaseSensitive", GetCheckBoxValue(Resource.Id.cbCaseSensitive));
|
||||
searchIntent.PutExtra("ExcludeExpired", GetCheckBoxValue(Resource.Id.cbExcludeExpiredEntries));
|
||||
searchIntent.PutExtra(SearchManager.Query, searchString);
|
||||
StartActivityForResult(searchIntent, 0);
|
||||
Finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user