From bb3efe760839a3454f69614c0365ced9368540ed Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 22 Nov 2019 14:34:26 +0100 Subject: [PATCH] Allow closing unused inline images hint --- .../eu/faircode/email/FragmentCompose.java | 21 +++++++++--- .../faircode/email/FragmentOptionsMisc.java | 3 +- app/src/main/res/layout/fragment_compose.xml | 32 +++++++++++++++---- 3 files changed, 45 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 b6be86be7f..ca550513a8 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -161,7 +161,7 @@ public class FragmentCompose extends FragmentBase { private ImageButton ibCcBcc; private RecyclerView rvAttachment; private TextView tvNoInternetAttachments; - private TextView tvUnusedInlineImages; + private ImageButton ibCloseUnusedImagesHint; private EditTextCompose etBody; private TextView tvNoInternet; private TextView tvSignature; @@ -178,6 +178,7 @@ public class FragmentCompose extends FragmentBase { private Group grpExtra; private Group grpAddresses; private Group grpAttachments; + private Group grpUnusedImagesHint; private Group grpBody; private Group grpSignature; private Group grpReferenceHint; @@ -259,7 +260,7 @@ public class FragmentCompose extends FragmentBase { ibCcBcc = view.findViewById(R.id.ivCcBcc); rvAttachment = view.findViewById(R.id.rvAttachment); tvNoInternetAttachments = view.findViewById(R.id.tvNoInternetAttachments); - tvUnusedInlineImages = view.findViewById(R.id.tvUnusedInlineImages); + ibCloseUnusedImagesHint = view.findViewById(R.id.ibCloseUnusedImagesHint); etBody = view.findViewById(R.id.etBody); tvNoInternet = view.findViewById(R.id.tvNoInternet); tvSignature = view.findViewById(R.id.tvSignature); @@ -278,6 +279,7 @@ public class FragmentCompose extends FragmentBase { grpAddresses = view.findViewById(R.id.grpAddresses); grpAttachments = view.findViewById(R.id.grpAttachments); grpBody = view.findViewById(R.id.grpBody); + grpUnusedImagesHint = view.findViewById(R.id.grpUnusedImagesHint); grpSignature = view.findViewById(R.id.grpSignature); grpReferenceHint = view.findViewById(R.id.grpReferenceHint); @@ -384,6 +386,15 @@ public class FragmentCompose extends FragmentBase { setZoom(); + ibCloseUnusedImagesHint.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + prefs.edit().putBoolean("inline_image_hint", false).apply(); + grpUnusedImagesHint.setVisibility(View.GONE); + } + }); + etBody.setInputContentListener(new EditTextCompose.IInputContentListener() { @Override public void onInputContent(Uri uri) { @@ -642,7 +653,7 @@ public class FragmentCompose extends FragmentBase { rvAttachment.setAdapter(adapter); tvNoInternetAttachments.setVisibility(View.GONE); - tvUnusedInlineImages.setVisibility(View.GONE); + grpUnusedImagesHint.setVisibility(View.GONE); String pkg = Helper.getOpenKeychainPackage(getContext()); Log.i("Binding to " + pkg); @@ -2705,7 +2716,9 @@ public class FragmentCompose extends FragmentBase { rvAttachment.setTag(downloading); checkInternet(); - tvUnusedInlineImages.setVisibility(inline_images ? View.VISIBLE : View.GONE); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean inline_image_hint = prefs.getBoolean("inline_image_hint", true); + grpUnusedImagesHint.setVisibility(inline_images && inline_image_hint ? View.VISIBLE : View.GONE); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 4d61b95fbe..af6b818aa4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -69,7 +69,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private final static String[] RESET_QUESTIONS = new String[]{ "welcome", "crash_reports_asked", "html_always_images", "print_html_confirmed", - "identities_asked", "compose_reference", "send_dialog" + "identities_asked", + "inline_image_hint", "compose_reference", "send_dialog" }; @Override diff --git a/app/src/main/res/layout/fragment_compose.xml b/app/src/main/res/layout/fragment_compose.xml index a4cb420b24..b8acd30a45 100644 --- a/app/src/main/res/layout/fragment_compose.xml +++ b/app/src/main/res/layout/fragment_compose.xml @@ -224,15 +224,29 @@ app:layout_constraintStart_toStartOf="@id/rvAttachment" app:layout_constraintTop_toBottomOf="@id/rvAttachment" /> - + + + app:layout_constraintTop_toBottomOf="@+id/ibCloseUnusedImagesHint" /> + +