Hightlight partial search results

pull/215/head
M66B 6 months ago
parent 0d2ebeb133
commit a0fa0b487c

@ -2567,6 +2567,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
args.putBoolean("filter_archive", intent.getBooleanExtra("filter_archive", true)); args.putBoolean("filter_archive", intent.getBooleanExtra("filter_archive", true));
args.putBoolean("found", found); args.putBoolean("found", found);
args.putString("searched", intent.getStringExtra("searched")); args.putString("searched", intent.getStringExtra("searched"));
args.putBoolean("searchedPartial", intent.getBooleanExtra("searchedPartial", false));
args.putBoolean("pinned", intent.getBooleanExtra("pinned", false)); args.putBoolean("pinned", intent.getBooleanExtra("pinned", false));
args.putString("msgid", intent.getStringExtra("msgid")); args.putString("msgid", intent.getStringExtra("msgid"));

@ -210,6 +210,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private String type; private String type;
private boolean found; private boolean found;
private String searched; private String searched;
private boolean searchedPartial;
private ViewType viewType; private ViewType viewType;
private boolean compact; private boolean compact;
private int zoom; private int zoom;
@ -3328,7 +3329,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
HtmlHelper.autoLink(document); HtmlHelper.autoLink(document);
if (message.ui_found && found && !TextUtils.isEmpty(searched)) if (message.ui_found && found && !TextUtils.isEmpty(searched))
HtmlHelper.highlightSearched(context, document, searched); HtmlHelper.highlightSearched(context, document, searched, searchedPartial);
boolean overview_mode = prefs.getBoolean("overview_mode", false); boolean overview_mode = prefs.getBoolean("overview_mode", false);
HtmlHelper.setViewport(document, overview_mode); HtmlHelper.setViewport(document, overview_mode);
@ -3357,7 +3358,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
HtmlHelper.autoLink(document); HtmlHelper.autoLink(document);
if (message.ui_found && found && !TextUtils.isEmpty(searched)) if (message.ui_found && found && !TextUtils.isEmpty(searched))
HtmlHelper.highlightSearched(context, document, searched); HtmlHelper.highlightSearched(context, document, searched, searchedPartial);
// Cleanup message // Cleanup message
document = HtmlHelper.sanitizeView(context, document, show_images); document = HtmlHelper.sanitizeView(context, document, show_images);
@ -4686,7 +4687,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.putExtra("lpos", getAdapterPosition()) .putExtra("lpos", getAdapterPosition())
.putExtra("filter_archive", filter_archive) .putExtra("filter_archive", filter_archive)
.putExtra("found", viewType == ViewType.SEARCH) .putExtra("found", viewType == ViewType.SEARCH)
.putExtra("searched", searched); .putExtra("searched", searched)
.putExtra("searchedPartial", searchedPartial);
boolean doubletap = prefs.getBoolean("doubletap", false); boolean doubletap = prefs.getBoolean("doubletap", false);
@ -8176,7 +8178,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
AdapterMessage(Fragment parentFragment, AdapterMessage(Fragment parentFragment,
String type, boolean found, String searched, ViewType viewType, String type, boolean found, String searched, boolean searchedPartial, ViewType viewType,
boolean compact, int zoom, boolean large_buttons, String sort, boolean ascending, boolean compact, int zoom, boolean large_buttons, String sort, boolean ascending,
boolean filter_duplicates, boolean filter_trash, boolean filter_duplicates, boolean filter_trash,
final IProperties properties) { final IProperties properties) {
@ -8184,6 +8186,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.type = type; this.type = type;
this.found = found; this.found = found;
this.searched = searched; this.searched = searched;
this.searchedPartial = searchedPartial;
this.viewType = viewType; this.viewType = viewType;
this.compact = compact; this.compact = compact;
this.zoom = zoom; this.zoom = zoom;

@ -1283,6 +1283,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
return term; return term;
} }
boolean isPartial() {
return !this.fts;
}
String getTitle(Context context) { String getTitle(Context context) {
List<String> flags = new ArrayList<>(); List<String> flags = new ArrayList<>();
if (with_unseen) if (with_unseen)

@ -327,6 +327,7 @@ public class FragmentMessages extends FragmentBase
private boolean filter_archive; private boolean filter_archive;
private boolean found; private boolean found;
private String searched; private String searched;
private boolean searchedPartial;
private boolean pinned; private boolean pinned;
private String msgid; private String msgid;
private BoundaryCallbackMessages.SearchCriteria criteria = null; private BoundaryCallbackMessages.SearchCriteria criteria = null;
@ -471,11 +472,14 @@ public class FragmentMessages extends FragmentBase
filter_archive = args.getBoolean("filter_archive", true); filter_archive = args.getBoolean("filter_archive", true);
found = args.getBoolean("found", false); found = args.getBoolean("found", false);
searched = args.getString("searched"); searched = args.getString("searched");
searchedPartial = args.getBoolean("searchedPartial");
pinned = args.getBoolean("pinned", false); pinned = args.getBoolean("pinned", false);
msgid = args.getString("msgid"); msgid = args.getString("msgid");
criteria = (BoundaryCallbackMessages.SearchCriteria) args.getSerializable("criteria"); criteria = (BoundaryCallbackMessages.SearchCriteria) args.getSerializable("criteria");
if (criteria != null) if (criteria != null) {
searched = criteria.query; searched = criteria.query;
searchedPartial = criteria.isPartial();
}
pane = args.getBoolean("pane", false); pane = args.getBoolean("pane", false);
primary = args.getLong("primary", -1); primary = args.getLong("primary", -1);
connected = args.getBoolean("connected", false); connected = args.getBoolean("connected", false);
@ -1260,7 +1264,7 @@ public class FragmentMessages extends FragmentBase
filter_trash = false; filter_trash = false;
adapter = new AdapterMessage( adapter = new AdapterMessage(
this, type, found, searched, viewType, this, type, found, searched, searchedPartial, viewType,
compact, zoom, large_buttons, sort, ascending, compact, zoom, large_buttons, sort, ascending,
filter_duplicates, filter_trash, filter_duplicates, filter_trash,
iProperties); iProperties);
@ -8082,6 +8086,7 @@ public class FragmentMessages extends FragmentBase
nargs.putInt("lpos", forward ^ reversed ? lpos + 1 : lpos - 1); nargs.putInt("lpos", forward ^ reversed ? lpos + 1 : lpos - 1);
nargs.putBoolean("found", found); nargs.putBoolean("found", found);
nargs.putString("searched", searched); nargs.putString("searched", searched);
nargs.putBoolean("searchedPartial", searchedPartial);
nargs.putBoolean("pane", pane); nargs.putBoolean("pane", pane);
nargs.putLong("primary", primary); nargs.putLong("primary", primary);
nargs.putBoolean("connected", connected); nargs.putBoolean("connected", connected);

@ -3199,7 +3199,7 @@ public class HtmlHelper {
return ssb; return ssb;
} }
static void highlightSearched(Context context, Document document, String query) { static void highlightSearched(Context context, Document document, String query, boolean partial) {
try { try {
int color = Helper.resolveColor(context, R.attr.colorHighlight); int color = Helper.resolveColor(context, R.attr.colorHighlight);
@ -3213,8 +3213,13 @@ public class HtmlHelper {
sb.append(Pattern.quote(w)); sb.append(Pattern.quote(w));
} }
} }
if (partial) {
sb.insert(0, ".*?(");
sb.append(").*?");
} else {
sb.insert(0, ".*?\\b("); sb.insert(0, ".*?\\b(");
sb.append(")\\b.*?"); sb.append(")\\b.*?");
}
// TODO: match für for fur // TODO: match für for fur
Pattern p = Pattern.compile(sb.toString(), Pattern.DOTALL | Pattern.CASE_INSENSITIVE); Pattern p = Pattern.compile(sb.toString(), Pattern.DOTALL | Pattern.CASE_INSENSITIVE);

Loading…
Cancel
Save