Simplified editing signatures inline

master
M66B 2 weeks ago
parent de7c5068cc
commit 0838a10ef3

@ -824,6 +824,7 @@ public class FragmentCompose extends FragmentBase {
Object tag = cbSignature.getTag(); Object tag = cbSignature.getTag();
if (tag == null || !tag.equals(checked)) { if (tag == null || !tag.equals(checked)) {
cbSignature.setTag(checked); cbSignature.setTag(checked);
ibSignature.setEnabled(checked);
tvSignature.setAlpha(checked ? 1.0f : Helper.LOW_LIGHT); tvSignature.setAlpha(checked ? 1.0f : Helper.LOW_LIGHT);
if (tag != null) { if (tag != null) {
Bundle extras = new Bundle(); Bundle extras = new Bundle();
@ -841,18 +842,27 @@ public class FragmentCompose extends FragmentBase {
if (identity == null || TextUtils.isEmpty(identity.signature)) if (identity == null || TextUtils.isEmpty(identity.signature))
return; return;
ClipboardManager clipboard = Helper.getSystemService(v.getContext(), ClipboardManager.class); Document d = HtmlHelper.sanitizeCompose(v.getContext(), identity.signature, true);
if (clipboard == null) SpannableStringBuilder spanned = HtmlHelper.fromDocument(v.getContext(), d, new HtmlHelper.ImageGetterEx() {
return; @Override
public Drawable getDrawable(Element element) {
return ImageHelper.decodeImage(v.getContext(),
working, element, true, zoom, 1.0f, etBody);
}
}, null);
if (spanned.length() > 0 && spanned.charAt(spanned.length() - 1) != '\n')
spanned.append('\n');
ClipData clip = ClipData.newHtmlText( Editable edit = etBody.getText();
v.getContext().getString(R.string.title_edit_signature_text), if (edit.length() > 0 && edit.charAt(edit.length() - 1) != '\n')
HtmlHelper.getText(v.getContext(), identity.signature), edit.append('\n');
identity.signature);
clipboard.setPrimaryClip(clip);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) int start = edit.length();
ToastEx.makeText(v.getContext(), R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); edit.append(spanned);
etBody.setSelection(start);
cbSignature.setChecked(false);
ibSignature.setEnabled(false);
} }
}); });
@ -7960,6 +7970,7 @@ public class FragmentCompose extends FragmentBase {
ivMarkdown.setVisibility(markdown ? View.VISIBLE : View.GONE); ivMarkdown.setVisibility(markdown ? View.VISIBLE : View.GONE);
cbSignature.setChecked(draft.signature); cbSignature.setChecked(draft.signature);
ibSignature.setEnabled(draft.signature);
tvSignature.setAlpha(draft.signature ? 1.0f : Helper.LOW_LIGHT); tvSignature.setAlpha(draft.signature ? 1.0f : Helper.LOW_LIGHT);
boolean ref_has_images = args.getBoolean("ref_has_images"); boolean ref_has_images = args.getBoolean("ref_has_images");

@ -413,12 +413,12 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_clipboard_copy" android:contentDescription="@string/title_edit_signature"
android:padding="3dp" android:padding="3dp"
android:tooltipText="@string/title_clipboard_copy" android:tooltipText="@string/title_edit_signature"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cbSignature" app:layout_constraintTop_toBottomOf="@+id/cbSignature"
app:srcCompat="@drawable/twotone_file_copy_24" /> app:srcCompat="@drawable/twotone_edit_24" />
<View <View
android:id="@+id/vSeparatorSignature" android:id="@+id/vSeparatorSignature"

Loading…
Cancel
Save