diff --git a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java index f4cf561ebe..66e94de1b6 100644 --- a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java +++ b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java @@ -108,6 +108,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback 0) + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean fts_fallback = prefs.getBoolean("fts_fallback", true); + + if (!fts_fallback || state.ids.size() > 0 || state.matches != null) return found; + else + ApplicationEx.getMainHandler().post(new Runnable() { + @Override + public void run() { + if (intf != null) + intf.onScan(); + } + }); } while (found < pageSize && !state.destroyed) { diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 8b1f199b30..956788f7ea 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -365,6 +365,7 @@ public class FragmentMessages extends FragmentBase private boolean reset = false; private boolean initialized = false; private boolean loading = false; + private boolean scan = false; private boolean swiping = false; private boolean scrolling = false; private boolean navigating = false; @@ -6862,6 +6863,7 @@ public class FragmentMessages extends FragmentBase initialized = false; loading = false; + scan = false; vmodel.setCallback(getViewLifecycleOwner(), callback); vmodel.setObserver(getViewLifecycleOwner(), observer); } @@ -6870,9 +6872,15 @@ public class FragmentMessages extends FragmentBase @Override public void onLoading() { loading = true; + scan = false; updateListState("Loading", SimpleTask.getCount(), adapter == null ? 0 : adapter.getItemCount()); } + public void onScan() { + scan = true; + updateListState("Scan", SimpleTask.getCount(), adapter == null ? 0 : adapter.getItemCount()); + } + @Override public void onLoaded(int found) { loading = false; @@ -6988,12 +6996,18 @@ public class FragmentMessages extends FragmentBase (language_detection && !TextUtils.isEmpty(filter_language) && !outbox)); boolean none = (items == 0 && initialized); + boolean partial = (viewType == AdapterMessage.ViewType.SEARCH && !server && loading && scan && items == 0); boolean searching = (viewType == AdapterMessage.ViewType.SEARCH && server && (!initialized || loading) && items == 0); boolean filtered = (filter_active && viewType != AdapterMessage.ViewType.SEARCH); pbWait.setVisibility(loading || tasks > 0 ? View.VISIBLE : View.GONE); - tvNoEmail.setText(searching ? R.string.title_search_server_wait : R.string.title_no_messages); - tvNoEmail.setVisibility(none || searching ? View.VISIBLE : View.GONE); + if (partial) + tvNoEmail.setText(R.string.title_search_device_scan); + else if (searching) + tvNoEmail.setText(R.string.title_search_server_wait); + else + tvNoEmail.setText(R.string.title_no_messages); + tvNoEmail.setVisibility(none || scan || searching ? View.VISIBLE : View.GONE); tvNoEmailHint.setVisibility(none && filtered ? View.VISIBLE : View.GONE); if (BuildConfig.DEBUG) @@ -7001,8 +7015,11 @@ public class FragmentMessages extends FragmentBase Log.i("List state who=" + Helper.getWho(this) + "" + " reason=" + reason + - " tasks=" + tasks + " loading=" + loading + - " items=" + items + " initialized=" + initialized + + " tasks=" + tasks + + " initialized=" + initialized + + " loading=" + loading + + " scan=" + scan + + " items=" + items + " wait=" + (pbWait.getVisibility() == View.VISIBLE) + " no=" + (tvNoEmail.getVisibility() == View.VISIBLE)); } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index ca53b9cc88..e18161a00e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -115,6 +115,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swExternalAnswer; private SwitchCompat swShortcuts; private SwitchCompat swFts; + private SwitchCompat swFtsFallback; private SwitchCompat swClassification; private TextView tvClassMinProbability; private SeekBar sbClassMinProbability; @@ -279,7 +280,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private static final long MIN_FILE_SIZE = 1024 * 1024L; private final static String[] RESET_OPTIONS = new String[]{ - "sort_answers", "shortcuts", "fts", + "sort_answers", "shortcuts", "fts", "fts_fallback", "classification", "class_min_probability", "class_min_difference", "show_filtered", "language", @@ -368,6 +369,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swExternalAnswer = view.findViewById(R.id.swExternalAnswer); swShortcuts = view.findViewById(R.id.swShortcuts); swFts = view.findViewById(R.id.swFts); + swFtsFallback = view.findViewById(R.id.swFtsFallback); swClassification = view.findViewById(R.id.swClassification); ibClassification = view.findViewById(R.id.ibClassification); tvClassMinProbability = view.findViewById(R.id.tvClassMinProbability); @@ -586,6 +588,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("fts", checked).apply(); + swFtsFallback.setEnabled(checked); WorkerFts.init(getContext(), true); @@ -619,6 +622,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swFtsFallback.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("fts_fallback", checked).apply(); + } + }); + Helper.linkPro(tvFtsPro); swClassification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @@ -2472,6 +2482,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swExternalAnswer.setChecked(Helper.isComponentEnabled(getContext(), ActivityAnswer.class)); swShortcuts.setChecked(prefs.getBoolean("shortcuts", true)); swFts.setChecked(prefs.getBoolean("fts", false)); + swFtsFallback.setChecked(prefs.getBoolean("fts_fallback", true)); + swFtsFallback.setEnabled(swFts.isChecked()); swClassification.setChecked(prefs.getBoolean("classification", false)); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 8f8d6171ed..a34c7c9cf0 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -179,18 +179,30 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swFts" /> + + + app:layout_constraintTop_toBottomOf="@id/swFtsFallback" /> Provide reply templates to other apps Show frequently used contacts in Android share menu Build search index + Continue with partial word search %1$d / %2$d messages indexed (%3$s) Classify messages Minimum class probability: %1$s %% @@ -1804,6 +1805,7 @@ size > %1$s Search on device + Searching with partial words Search on server Waiting for server Search in