From 6d4f858d01be77628057aed62eea23154ca57036 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 12 Jan 2020 09:12:20 +0100 Subject: [PATCH] Added legend to compose --- .../eu/faircode/email/FragmentCompose.java | 21 +++++++++++++++++++ .../eu/faircode/email/FragmentLegend.java | 10 +++++++++ app/src/main/res/menu/menu_compose.xml | 5 +++++ 3 files changed, 36 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index bbb639b3e8..08d520a909 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -90,6 +90,9 @@ import androidx.constraintlayout.widget.Group; import androidx.core.content.FileProvider; import androidx.cursoradapter.widget.SimpleCursorAdapter; import androidx.documentfile.provider.DocumentFile; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Observer; import androidx.preference.PreferenceManager; @@ -1027,6 +1030,9 @@ public class FragmentCompose extends FragmentBase { case R.id.menu_clear: StyleHelper.apply(R.id.menu_clear, etBody); return true; + case R.id.menu_legend: + onMenuLegend(); + return true; case R.id.menu_contact_group: onMenuContactGroup(); return true; @@ -1141,6 +1147,21 @@ public class FragmentCompose extends FragmentBase { bottom_navigation.setLayoutParams(params); } + private void onMenuLegend() { + if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + getParentFragmentManager().popBackStack("legend", FragmentManager.POP_BACK_STACK_INCLUSIVE); + + Bundle args = new Bundle(); + args.putString("tab", "compose"); + + Fragment fragment = new FragmentLegend(); + fragment.setArguments(args); + + FragmentTransaction fragmentTransaction = getParentFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("legend"); + fragmentTransaction.commit(); + } + private void onMenuContactGroup() { Bundle args = new Bundle(); args.putLong("working", working); diff --git a/app/src/main/java/eu/faircode/email/FragmentLegend.java b/app/src/main/java/eu/faircode/email/FragmentLegend.java index 12d567456c..f5dd37c829 100644 --- a/app/src/main/java/eu/faircode/email/FragmentLegend.java +++ b/app/src/main/java/eu/faircode/email/FragmentLegend.java @@ -72,6 +72,16 @@ public class FragmentLegend extends FragmentBase { if (layout < 0) { TabLayout tabLayout = view.findViewById(R.id.tab_layout); tabLayout.setupWithViewPager(pager); + + Bundle args = getArguments(); + if (args != null) { + String tab = args.getString("tab"); + if ("compose".equals(tab)) + pager.setCurrentItem(3); + + args.remove("tab"); + setArguments(args); + } } } diff --git a/app/src/main/res/menu/menu_compose.xml b/app/src/main/res/menu/menu_compose.xml index 8927f79a82..d8132560c3 100644 --- a/app/src/main/res/menu/menu_compose.xml +++ b/app/src/main/res/menu/menu_compose.xml @@ -25,6 +25,11 @@ android:title="@string/title_compact" app:showAsAction="never" /> + +