Allow pasting signature

This commit is contained in:
M66B 2020-05-21 19:10:58 +02:00
parent 3b1e1b5ccd
commit 1a967ae03e
2 changed files with 35 additions and 4 deletions

View File

@ -219,6 +219,7 @@ public class FragmentCompose extends FragmentBase {
private TextView tvNoInternet; private TextView tvNoInternet;
private TextView tvSignature; private TextView tvSignature;
private CheckBox cbSignature; private CheckBox cbSignature;
private ImageButton ibSignature;
private TextView tvReference; private TextView tvReference;
private ImageButton ibCloseRefHint; private ImageButton ibCloseRefHint;
private ImageButton ibReferenceEdit; private ImageButton ibReferenceEdit;
@ -318,6 +319,7 @@ public class FragmentCompose extends FragmentBase {
tvNoInternet = view.findViewById(R.id.tvNoInternet); tvNoInternet = view.findViewById(R.id.tvNoInternet);
tvSignature = view.findViewById(R.id.tvSignature); tvSignature = view.findViewById(R.id.tvSignature);
cbSignature = view.findViewById(R.id.cbSignature); cbSignature = view.findViewById(R.id.cbSignature);
ibSignature = view.findViewById(R.id.ibSignature);
tvReference = view.findViewById(R.id.tvReference); tvReference = view.findViewById(R.id.tvReference);
ibCloseRefHint = view.findViewById(R.id.ibCloseRefHint); ibCloseRefHint = view.findViewById(R.id.ibCloseRefHint);
ibReferenceEdit = view.findViewById(R.id.ibReferenceEdit); ibReferenceEdit = view.findViewById(R.id.ibReferenceEdit);
@ -567,6 +569,24 @@ public class FragmentCompose extends FragmentBase {
} }
}); });
ibSignature.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
if (identity == null && TextUtils.isEmpty(identity.signature))
return;
Spanned sig = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
return ImageHelper.decodeImage(getContext(), working, source, true, zoom, etBody);
}
}, null);
etBody.getText().insert(etBody.getSelectionStart(), sig);
}
});
ibCloseRefHint.setOnClickListener(new View.OnClickListener() { ibCloseRefHint.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {

View File

@ -318,11 +318,11 @@
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:fontFamily="monospace" android:fontFamily="monospace"
android:minHeight="24dp" android:minHeight="72dp"
android:text="Signature" android:text="Signature"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textIsSelectable="true" android:textIsSelectable="true"
app:layout_constraintEnd_toStartOf="@+id/cbSignature" app:layout_constraintEnd_toStartOf="@+id/ibSignature"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" /> app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />
@ -330,10 +330,21 @@
android:id="@+id/cbSignature" android:id="@+id/cbSignature"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@id/ibSignature"
app:layout_constraintStart_toStartOf="@id/ibSignature"
app:layout_constraintTop_toTopOf="@+id/tvSignature" />
<ImageButton
android:id="@+id/ibSignature"
android:layout_width="36dp"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_show_images"
android:padding="3dp"
app:layout_constraintBottom_toBottomOf="@+id/tvSignature" app:layout_constraintBottom_toBottomOf="@+id/tvSignature"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvSignature" /> app:srcCompat="@drawable/baseline_assignment_24" />
<View <View
android:id="@+id/vSeparatorSignature" android:id="@+id/vSeparatorSignature"
@ -458,7 +469,7 @@
android:id="@+id/grpSignature" android:id="@+id/grpSignature"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorSignature,tvSignature,cbSignature" /> app:constraint_referenced_ids="vSeparatorSignature,tvSignature,cbSignature,ibSignature" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpReferenceHint" android:id="@+id/grpReferenceHint"