|
|
|
@ -63,9 +63,10 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
final long account = getArguments().getLong("account", -1);
|
|
|
|
|
final long folder = getArguments().getLong("folder", -1);
|
|
|
|
|
|
|
|
|
|
boolean pro = ActivityBilling.isPro(getContext());
|
|
|
|
|
final Context context = getContext();
|
|
|
|
|
boolean pro = ActivityBilling.isPro(context);
|
|
|
|
|
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
boolean fts = prefs.getBoolean("fts", false);
|
|
|
|
|
boolean last_search_senders = prefs.getBoolean("last_search_senders", true);
|
|
|
|
|
boolean last_search_recipients = prefs.getBoolean("last_search_recipients", true);
|
|
|
|
@ -75,7 +76,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
boolean last_search_notes = prefs.getBoolean("last_search_notes", true);
|
|
|
|
|
String last_search = prefs.getString("last_search", null);
|
|
|
|
|
|
|
|
|
|
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_search, null);
|
|
|
|
|
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_search, null);
|
|
|
|
|
|
|
|
|
|
final AutoCompleteTextView etQuery = dview.findViewById(R.id.etQuery);
|
|
|
|
|
final ImageButton ibAttachment = dview.findViewById(R.id.ibAttachment);
|
|
|
|
@ -104,7 +105,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
final TextView tvAfter = dview.findViewById(R.id.tvAfter);
|
|
|
|
|
final Group grpMore = dview.findViewById(R.id.grpMore);
|
|
|
|
|
|
|
|
|
|
final InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
|
|
|
|
|
ibInfo.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
@ -115,7 +116,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
|
|
|
|
|
getContext(),
|
|
|
|
|
context,
|
|
|
|
|
R.layout.search_suggestion,
|
|
|
|
|
null,
|
|
|
|
|
new String[]{"suggestion"},
|
|
|
|
@ -131,7 +132,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
return cursor;
|
|
|
|
|
|
|
|
|
|
String query = "%" + typed + "%";
|
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
return db.message().getSuggestions(
|
|
|
|
|
account < 0 ? null : account,
|
|
|
|
|
folder < 0 ? null : folder,
|
|
|
|
@ -280,7 +281,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
etQuery.requestFocus();
|
|
|
|
|
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
|
|
|
|
|
|
|
|
|
final AlertDialog dialog = new AlertDialog.Builder(getContext())
|
|
|
|
|
final AlertDialog dialog = new AlertDialog.Builder(context)
|
|
|
|
|
.setView(dview)
|
|
|
|
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
@ -354,7 +355,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, EntityFolder archive) {
|
|
|
|
|
FragmentMessages.search(
|
|
|
|
|
getContext(), getViewLifecycleOwner(), getParentFragmentManager(),
|
|
|
|
|
context, getViewLifecycleOwner(), getParentFragmentManager(),
|
|
|
|
|
account,
|
|
|
|
|
archive == null ? folder : archive.id,
|
|
|
|
|
archive != null,
|
|
|
|
@ -365,10 +366,10 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(getContext(), getViewLifecycleOwner(), getArguments(), "search:raw");
|
|
|
|
|
}.execute(context, getViewLifecycleOwner(), getArguments(), "search:raw");
|
|
|
|
|
else
|
|
|
|
|
FragmentMessages.search(
|
|
|
|
|
getContext(), getViewLifecycleOwner(), getParentFragmentManager(),
|
|
|
|
|
context, getViewLifecycleOwner(), getParentFragmentManager(),
|
|
|
|
|
account, folder, false, criteria);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -399,7 +400,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FragmentMessages.search(
|
|
|
|
|
getContext(), getViewLifecycleOwner(), getParentFragmentManager(),
|
|
|
|
|
context, getViewLifecycleOwner(), getParentFragmentManager(),
|
|
|
|
|
account, folder, false, criteria);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|