diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java b/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java index c22e674cd6..0e2e7dbe7d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java @@ -17,6 +17,7 @@ import android.widget.AutoCompleteTextView; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.FilterQueryProvider; +import android.widget.ImageButton; import android.widget.TextView; import androidx.annotation.NonNull; @@ -32,6 +33,7 @@ public class FragmentDialogSearch extends FragmentDialogBase { View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_search, null); final AutoCompleteTextView etQuery = dview.findViewById(R.id.etQuery); + final ImageButton ibInfo = dview.findViewById(R.id.ibInfo); final CheckBox cbSearchIndex = dview.findViewById(R.id.cbSearchIndex); final CheckBox cbSenders = dview.findViewById(R.id.cbSenders); final CheckBox cbRecipients = dview.findViewById(R.id.cbRecipients); @@ -52,15 +54,7 @@ public class FragmentDialogSearch extends FragmentDialogBase { boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false); String last_search = prefs.getString("last_search", null); - if (!TextUtils.isEmpty(last_search)) { - etQuery.setText(last_search); - etQuery.setSelection(0, last_search.length()); - } - - etQuery.requestFocus(); - - InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + final InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); SimpleCursorAdapter adapter = new SimpleCursorAdapter( getContext(), @@ -87,6 +81,14 @@ public class FragmentDialogSearch extends FragmentDialogBase { etQuery.setAdapter(adapter); + ibInfo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + imm.hideSoftInputFromWindow(etQuery.getWindowToken(), 0); + Helper.viewFAQ(getContext(), 13); + } + }); + cbSearchIndex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -108,6 +110,14 @@ public class FragmentDialogSearch extends FragmentDialogBase { cbUnseen.setChecked(filter_seen); cbFlagged.setChecked(filter_unflagged); + if (!TextUtils.isEmpty(last_search)) { + etQuery.setText(last_search); + etQuery.setSelection(0, last_search.length()); + } + + etQuery.requestFocus(); + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + final AlertDialog dialog = new AlertDialog.Builder(getContext()) .setView(dview) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @@ -137,6 +147,8 @@ public class FragmentDialogSearch extends FragmentDialogBase { criteria.with_attachments = cbAttachments.isChecked(); } + imm.hideSoftInputFromWindow(etQuery.getWindowToken(), 0); + FragmentMessages.search( getContext(), getViewLifecycleOwner(), getParentFragmentManager(), account, folder, false, criteria); @@ -148,10 +160,10 @@ public class FragmentDialogSearch extends FragmentDialogBase { // Do nothing } }) - .setNeutralButton(R.string.title_info, new DialogInterface.OnClickListener() { + .setOnDismissListener(new DialogInterface.OnDismissListener() { @Override - public void onClick(DialogInterface dialog, int which) { - Helper.viewFAQ(getContext(), 13); + public void onDismiss(DialogInterface dialog) { + imm.hideSoftInputFromWindow(etQuery.getWindowToken(), 0); } }) .create(); diff --git a/app/src/main/res/layout/dialog_search.xml b/app/src/main/res/layout/dialog_search.xml index a006cd0f70..fbd08b5b5a 100644 --- a/app/src/main/res/layout/dialog_search.xml +++ b/app/src/main/res/layout/dialog_search.xml @@ -11,18 +11,33 @@ + + + app:layout_constraintTop_toBottomOf="@id/ibInfo" /> - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d231464858..f0e12fb513 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -908,7 +908,7 @@ In senders (from) In recipients (to, cc) In subject - In keyword (if supported) + In keywords (if supported) In message text And Unread @@ -922,11 +922,6 @@ encrypted attachments - - Searching will initially look at messages stored on your device. - To search the server too, tap on the "search again" button. - - Search on device Search on server Search in