Added inline switching of write above/below

This commit is contained in:
M66B 2021-08-22 09:11:44 +02:00
parent c8a181790b
commit abaa194b61
4 changed files with 54 additions and 0 deletions

View File

@ -252,6 +252,7 @@ public class FragmentCompose extends FragmentBase {
private ImageButton ibSignature;
private TextView tvReference;
private ImageButton ibCloseRefHint;
private ImageButton ibWriteAboveBelow;
private ImageButton ibReferenceEdit;
private ImageButton ibReferenceImages;
private View vwAnchor;
@ -370,6 +371,7 @@ public class FragmentCompose extends FragmentBase {
ibSignature = view.findViewById(R.id.ibSignature);
tvReference = view.findViewById(R.id.tvReference);
ibCloseRefHint = view.findViewById(R.id.ibCloseRefHint);
ibWriteAboveBelow = view.findViewById(R.id.ibWriteAboveBelow);
ibReferenceEdit = view.findViewById(R.id.ibReferenceEdit);
ibReferenceImages = view.findViewById(R.id.ibReferenceImages);
vwAnchor = view.findViewById(R.id.vwAnchor);
@ -767,6 +769,21 @@ public class FragmentCompose extends FragmentBase {
}
});
ibWriteAboveBelow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(v.getContext());
boolean write_below = !prefs.getBoolean("write_below", false);
prefs.edit().putBoolean("write_below", write_below).apply();
ibWriteAboveBelow.setImageLevel(write_below ? 1 : 0);
ToastEx.makeText(v.getContext(),
write_below
? R.string.title_advanced_write_below
: R.string.title_advanced_write_above,
Toast.LENGTH_LONG).show();
}
});
ibReferenceEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -904,6 +921,7 @@ public class FragmentCompose extends FragmentBase {
grpBody.setVisibility(View.GONE);
grpSignature.setVisibility(View.GONE);
grpReferenceHint.setVisibility(View.GONE);
ibWriteAboveBelow.setVisibility(View.GONE);
ibReferenceEdit.setVisibility(View.GONE);
ibReferenceImages.setVisibility(View.GONE);
tvReference.setVisibility(View.GONE);
@ -5235,6 +5253,8 @@ public class FragmentCompose extends FragmentBase {
}
Document doc = JsoupEx.parse(draft.getFile(context));
Element first = (doc.body().childrenSize() == 0 ? null : doc.body().child(0));
boolean below = (first != null && first.attr("fairemail").equals("reference"));
doc.select("div[fairemail=signature]").remove();
Elements ref = doc.select("div[fairemail=reference]");
ref.remove();
@ -5242,6 +5262,11 @@ public class FragmentCompose extends FragmentBase {
if (extras != null && extras.containsKey("html"))
dirty = true;
if (below != write_below &&
doc.body().childrenSize() > 0 &&
draft.wasforwardedfrom == null)
dirty = true;
if (!dirty)
if (loaded == null) {
Document b = JsoupEx.parse(body); // Is-dirty
@ -6022,10 +6047,15 @@ public class FragmentCompose extends FragmentBase {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean ref_hint = prefs.getBoolean("compose_reference", true);
boolean write_below = prefs.getBoolean("write_below", false);
tvReference.setText(text[1]);
tvReference.setVisibility(text[1] == null ? View.GONE : View.VISIBLE);
grpReferenceHint.setVisibility(text[1] == null || !ref_hint ? View.GONE : View.VISIBLE);
ibWriteAboveBelow.setImageLevel(write_below ? 1 : 0);
ibWriteAboveBelow.setVisibility(text[1] == null ||
draft.wasforwardedfrom != null || BuildConfig.PLAY_STORE_RELEASE
? View.GONE : View.VISIBLE);
ibReferenceEdit.setVisibility(text[1] == null ? View.GONE : View.VISIBLE);
ibReferenceImages.setVisibility(ref_has_images && !show_images ? View.VISIBLE : View.GONE);

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/twotone_vertical_align_top_24"
android:maxLevel="0" />
<item
android:drawable="@drawable/twotone_vertical_align_bottom_24"
android:maxLevel="1" />
</level-list>

View File

@ -406,6 +406,20 @@
app:layout_constraintStart_toEndOf="@id/ibCloseRefHint"
app:layout_constraintTop_toBottomOf="@id/vSeparatorSignature" />
<ImageButton
android:id="@+id/ibWriteAboveBelow"
android:layout_width="36dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_advanced_write_below"
android:padding="3dp"
android:tooltipText="@string/title_advanced_write_below"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvReferenceHint"
app:srcCompat="@drawable/abovebelow" />
<ImageButton
android:id="@+id/ibReferenceEdit"
android:layout_width="36dp"

View File

@ -357,6 +357,7 @@
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_separate_reply">Insert a horizontal line before a reply/forward header</string>
<string name="title_advanced_extended_reply">Use extended reply/forward header</string>
<string name="title_advanced_write_above">Write above the sender\'s text</string>
<string name="title_advanced_write_below">Write below the sender\'s text</string>
<string name="title_advanced_quote_reply">Quote replied text</string>
<string name="title_advanced_limit_reply">Limit the number of nested quotes</string>