Search when pressing "Enter" button
This commit is contained in:
@@ -17,10 +17,12 @@
|
|||||||
<EditText
|
<EditText
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text"
|
||||||
android:hint="@string/search_hint"
|
android:hint="@string/search_hint"
|
||||||
android:layout_toLeftOf="@id/search_button"
|
android:layout_toLeftOf="@id/search_button"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:layout_below="@id/search_label"
|
android:layout_below="@id/search_label"
|
||||||
|
android:imeOptions="actionSearch"
|
||||||
android:id="@+id/searchEditText" />
|
android:id="@+id/searchEditText" />
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:minWidth="25px"
|
android:minWidth="25px"
|
||||||
|
|||||||
@@ -67,35 +67,43 @@ namespace keepass2android
|
|||||||
|
|
||||||
btnSearch.Click += (object sender, EventArgs e) =>
|
btnSearch.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
String searchString = ((EditText)FindViewById(Resource.Id.searchEditText)).Text;
|
PerformSearch();
|
||||||
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();
|
|
||||||
|
|
||||||
|
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)
|
void populateCheckBox(int resId, bool value)
|
||||||
{
|
{
|
||||||
((CheckBox) FindViewById(resId)).Checked = 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user