Reply with styled selected text

This commit is contained in:
M66B 2022-01-13 17:55:31 +01:00
parent c9459097fb
commit ceb75b93f7
3 changed files with 19 additions and 15 deletions

View File

@ -5964,7 +5964,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return getKeyAtPosition(getAdapterPosition());
}
String getSelectedText() {
CharSequence getSelectedText() {
if (tvBody == null)
return null;
@ -5984,7 +5984,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
end = tmp;
}
return tvBody.getText().subSequence(start, end).toString();
return tvBody.getText().subSequence(start, end);
}
private View.AccessibilityDelegate accessibilityDelegateHeader = new View.AccessibilityDelegate() {
@ -7199,7 +7199,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
void move(long id, String type);
void reply(TupleMessageEx message, String selected, View anchor);
void reply(TupleMessageEx message, CharSequence selected, View anchor);
void startSearch(TextView view);

View File

@ -1392,7 +1392,7 @@ public class FragmentCompose extends FragmentBase {
args.putString("subject", a.getString("subject"));
args.putString("body", a.getString("body"));
args.putString("text", a.getString("text"));
args.putString("selected", a.getString("selected"));
args.putCharSequence("selected", a.getCharSequence("selected"));
if (a.containsKey("attachments")) {
args.putParcelableArrayList("attachments", a.getParcelableArrayList("attachments"));
@ -4243,7 +4243,7 @@ public class FragmentCompose extends FragmentBase {
String external_subject = args.getString("subject", "");
String external_body = args.getString("body", "");
String external_text = args.getString("text");
String selected_text = args.getString("selected");
CharSequence selected_text = args.getCharSequence("selected");
ArrayList<Uri> uris = args.getParcelableArrayList("attachments");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -4787,12 +4787,16 @@ public class FragmentCompose extends FragmentBase {
d = Document.createShell("");
Element div = d.createElement("div");
for (String line : selected_text.split("\\r?\\n")) {
Element span = document.createElement("span");
span.text(line);
div.appendChild(span);
div.appendElement("br");
}
if (selected_text instanceof Spanned)
div.html(HtmlHelper.toHtml((Spanned) selected_text, context));
else
for (String line : selected_text.toString().split("\\r?\\n")) {
Element span = document.createElement("span");
span.text(line);
div.appendChild(span);
div.appendElement("br");
}
d.body().appendChild(div);
}

View File

@ -2123,7 +2123,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
@Override
public void reply(TupleMessageEx message, String selected, View anchor) {
public void reply(TupleMessageEx message, CharSequence selected, View anchor) {
onReply(message, selected, anchor);
}
@ -2792,7 +2792,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
TupleMessageEx message = adapter.getItemAtPosition(pos);
AdapterMessage.ViewHolder holder =
(AdapterMessage.ViewHolder) rvMessage.findViewHolderForAdapterPosition(pos);
String selected = (holder == null ? null : holder.getSelectedText());
CharSequence selected = (holder == null ? null : holder.getSelectedText());
if (message == null)
return;
@ -2805,7 +2805,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
}
private void onReply(final TupleMessageEx message, final String selected, final View anchor) {
private void onReply(final TupleMessageEx message, final CharSequence selected, final View anchor) {
Bundle args = new Bundle();
args.putLong("id", message.id);
@ -2979,7 +2979,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
onMenuReply(message, action, null);
}
private void onMenuReply(TupleMessageEx message, String action, String selected) {
private void onMenuReply(TupleMessageEx message, String action, CharSequence selected) {
Intent reply = new Intent(getContext(), ActivityCompose.class)
.putExtra("action", action)
.putExtra("reference", message.id)