mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-31 20:25:38 +00:00
Added WebView text search
This commit is contained in:
parent
d88a47708b
commit
a07731e876
2 changed files with 58 additions and 11 deletions
|
@ -2277,7 +2277,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibPin.setVisibility(tools && !outbox && button_pin && pin ? View.VISIBLE : View.GONE);
|
||||
ibShare.setVisibility(tools && !outbox && button_share && message.content ? View.VISIBLE : View.GONE);
|
||||
ibEvent.setVisibility(tools && !outbox && button_event && message.content ? View.VISIBLE : View.GONE);
|
||||
ibSearchText.setVisibility(tools && !outbox && button_search_text && message.content && !full ? View.VISIBLE : View.GONE);
|
||||
ibSearchText.setVisibility(tools && !outbox && button_search_text && message.content ? View.VISIBLE : View.GONE);
|
||||
ibSearch.setVisibility(tools && !outbox && button_search && (froms > 0 || tos > 0) ? View.VISIBLE : View.GONE);
|
||||
ibTranslate.setVisibility(tools && !outbox && button_translate && DeepL.isAvailable(context) && message.content ? View.VISIBLE : View.GONE);
|
||||
ibFullScreen.setVisibility(tools && full && button_full_screen && message.content ? View.VISIBLE : View.GONE);
|
||||
|
@ -3296,6 +3296,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.setCount(false).execute(context, owner, args, "message:body");
|
||||
}
|
||||
|
||||
public void searchWebView(String text) {
|
||||
if (wvBody instanceof WebView)
|
||||
((WebView) wvBody).findAllAsync(text);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.Q)
|
||||
private void bindConversationActions(TupleMessageEx message, ConversationActions cactions) {
|
||||
boolean has = false;
|
||||
|
|
|
@ -7636,6 +7636,32 @@ public class FragmentMessages extends FragmentBase
|
|||
if (searchView == null)
|
||||
return;
|
||||
|
||||
View itemView = rvMessage.findContainingItemView(searchView);
|
||||
if (itemView == null) {
|
||||
Log.w("Search: itemView not found");
|
||||
return;
|
||||
}
|
||||
|
||||
int p = rvMessage.getChildAdapterPosition(itemView);
|
||||
if (p == NO_POSITION) {
|
||||
Log.w("Search: position not found");
|
||||
return;
|
||||
}
|
||||
|
||||
long id = adapter.getKeyAtPosition(p);
|
||||
if (id == NO_POSITION) {
|
||||
Log.w("Search: id not found");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean show_full = iProperties.getValue("full", id);
|
||||
if (show_full) {
|
||||
AdapterMessage.ViewHolder holder = (AdapterMessage.ViewHolder) rvMessage.getChildViewHolder(itemView);
|
||||
String query = etSearch.getText().toString().toLowerCase();
|
||||
holder.searchWebView(query);
|
||||
return;
|
||||
}
|
||||
|
||||
searchIndex = (next ? searchIndex + 1 : 1);
|
||||
String query = etSearch.getText().toString().toLowerCase();
|
||||
String text = searchView.getText().toString().toLowerCase();
|
||||
|
@ -7667,16 +7693,13 @@ public class FragmentMessages extends FragmentBase
|
|||
int y = layout.getLineTop(line);
|
||||
int dy = context.getResources().getDimensionPixelSize(R.dimen.search_in_text_margin);
|
||||
|
||||
View itemView = rvMessage.findContainingItemView(searchView);
|
||||
if (itemView != null) {
|
||||
Rect rect = new Rect();
|
||||
searchView.getDrawingRect(rect);
|
||||
Rect rect = new Rect();
|
||||
searchView.getDrawingRect(rect);
|
||||
|
||||
RecyclerView.ViewHolder holder = rvMessage.getChildViewHolder(itemView);
|
||||
((ViewGroup) itemView).offsetDescendantRectToMyCoords(searchView, rect);
|
||||
RecyclerView.ViewHolder holder = rvMessage.getChildViewHolder(itemView);
|
||||
((ViewGroup) itemView).offsetDescendantRectToMyCoords(searchView, rect);
|
||||
|
||||
iProperties.scrollTo(holder.getAdapterPosition(), rect.top + y - dy);
|
||||
}
|
||||
iProperties.scrollTo(holder.getAdapterPosition(), rect.top + y - dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7691,8 +7714,27 @@ public class FragmentMessages extends FragmentBase
|
|||
}
|
||||
|
||||
private void clearSearch() {
|
||||
if (searchView != null)
|
||||
searchView.clearComposingText();
|
||||
if (searchView == null)
|
||||
return;
|
||||
searchView.clearComposingText();
|
||||
|
||||
View itemView = rvMessage.findContainingItemView(searchView);
|
||||
if (itemView == null)
|
||||
return;
|
||||
|
||||
int p = rvMessage.getChildAdapterPosition(itemView);
|
||||
if (p == NO_POSITION)
|
||||
return;
|
||||
|
||||
long id = adapter.getKeyAtPosition(p);
|
||||
if (id == NO_POSITION)
|
||||
return;
|
||||
|
||||
boolean show_full = iProperties.getValue("full", id);
|
||||
if (show_full) {
|
||||
AdapterMessage.ViewHolder holder = (AdapterMessage.ViewHolder) rvMessage.getChildViewHolder(itemView);
|
||||
holder.searchWebView("");
|
||||
}
|
||||
}
|
||||
|
||||
private ActivityBase.IKeyPressedListener keyPressedListener = new ActivityBase.IKeyPressedListener() {
|
||||
|
|
Loading…
Reference in a new issue