Added support for placeholders in snippets

pull/207/head
M66B 3 years ago
parent 68d612b30c
commit 6c1e62be65

@ -4633,8 +4633,6 @@ Templates can have the following options:
* *Snippet*: template will be used as text fragment (since version 1.1857) * *Snippet*: template will be used as text fragment (since version 1.1857)
* *Hide from menus*: template will be hidden (disabled) * *Hide from menus*: template will be hidden (disabled)
Note that placeholders will not be filled in when using snippets.
<br /> <br />
<h2><a name="get-support"></a>Get support</h2> <h2><a name="get-support"></a>Get support</h2>

@ -45,6 +45,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.core.view.inputmethod.EditorInfoCompat;
@ -58,6 +59,9 @@ import org.jsoup.nodes.Document;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
public class EditTextCompose extends FixedEditText { public class EditTextCompose extends FixedEditText {
private boolean raw = false; private boolean raw = false;
private ISelection selectionListener = null; private ISelection selectionListener = null;
@ -215,9 +219,18 @@ public class EditTextCompose extends FixedEditText {
if (snippets == null) if (snippets == null)
return false; return false;
InternetAddress[] to = null;
try {
View root = getRootView();
EditText etTo = (root == null ? null : root.findViewById(R.id.etTo));
if (etTo != null)
to = MessageHelper.parseAddresses(getContext(), etTo.getText().toString());
} catch (AddressException ignored) {
}
for (EntityAnswer snippet : snippets) for (EntityAnswer snippet : snippets)
if (snippet.id.equals(id)) { if (snippet.id.equals(id)) {
String html = snippet.getHtml(null); String html = snippet.getHtml(to);
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override

Loading…
Cancel
Save