From f9a41cfce5e63c014fb6bebdd18e8b00ba278ea5 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 5 Mar 2019 13:16:36 +0000 Subject: [PATCH] Simplify compose zoom --- .../eu/faircode/email/FragmentCompose.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index a7287eb3c8..36cb0d2a18 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -309,6 +309,8 @@ public class FragmentCompose extends FragmentBase { ivCcAdd.setOnClickListener(onPick); ivBccAdd.setOnClickListener(onPick); + setZoom(); + ibReferenceEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -915,8 +917,22 @@ public class FragmentCompose extends FragmentBase { int zoom = prefs.getInt("zoom", compact ? 0 : 1); zoom = ++zoom % 3; prefs.edit().putInt("zoom", zoom).apply(); - onAction(R.id.action_save); - showDraft(working); + setZoom(); + } + + private void setZoom() { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean compact = prefs.getBoolean("compact", false); + int zoom = prefs.getInt("zoom", compact ? 0 : 1); + setZoom(zoom); + } + + private void setZoom(int zoom) { + float textSize = Helper.getTextSize(getContext(), zoom); + if (textSize != 0) { + etBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); + tvReference.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); + } } private void onMenuImage() { @@ -2341,15 +2357,6 @@ public class FragmentCompose extends FragmentBase { @Override protected void onExecuted(Bundle args, Spanned[] text) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - boolean compact = prefs.getBoolean("compact", false); - int zoom = prefs.getInt("zoom", compact ? 0 : 1); - float textSize = Helper.getTextSize(getContext(), zoom); - if (textSize != 0) { - etBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); - tvReference.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); - } - etBody.setText(text[0]); etBody.setSelection(0); grpBody.setVisibility(View.VISIBLE);