From 05c4aa1bd5bbb22d634e16d4bb9251cbd9d17d3f Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 4 Mar 2020 16:30:06 +0100 Subject: [PATCH] Removed hiding of action bar This needs to be replaced by AppBarLayout --- .../java/eu/faircode/email/FragmentBase.java | 24 ---------------- .../eu/faircode/email/FragmentFolders.java | 28 +------------------ .../eu/faircode/email/FragmentMessages.java | 26 ----------------- .../res/layout/fragment_options_behavior.xml | 1 + 4 files changed, 2 insertions(+), 77 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentBase.java b/app/src/main/java/eu/faircode/email/FragmentBase.java index 5858884f02..89c05e100b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentBase.java +++ b/app/src/main/java/eu/faircode/email/FragmentBase.java @@ -66,7 +66,6 @@ import static android.app.Activity.RESULT_OK; public class FragmentBase extends Fragment { private String title = null; private String subtitle = " "; - private boolean action = true; private boolean finish = false; private long message = -1; @@ -97,28 +96,6 @@ public class FragmentBase extends Fragment { updateSubtitle(); } - protected void setActionBar(boolean show) { - Log.i("Set action bar=" + show); - - AppCompatActivity activity = (AppCompatActivity) getActivity(); - if (activity == null) - return; - - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); - boolean hide_actionbar = prefs.getBoolean("hide_actionbar", false); - - ActionBar actionBar = activity.getSupportActionBar(); - if (actionBar == null) - return; - - if (show || !hide_actionbar) - actionBar.show(); - else - actionBar.hide(); - - this.action = show; - } - @Override public void startActivity(Intent intent) { try { @@ -201,7 +178,6 @@ public class FragmentBase extends Fragment { Log.d("Resume " + this); super.onResume(); updateSubtitle(); - setActionBar(action); if (finish) { getParentFragmentManager().popBackStack(); finish = false; diff --git a/app/src/main/java/eu/faircode/email/FragmentFolders.java b/app/src/main/java/eu/faircode/email/FragmentFolders.java index d57ed38b8c..433dcc7461 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolders.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolders.java @@ -155,35 +155,9 @@ public class FragmentFolders extends FragmentBase { }); rvFolder.setHasFixedSize(false); - LinearLayoutManager llm = new LinearLayoutManager(getContext()) { - @Override - public void onScrollStateChanged(int state) { - super.onScrollStateChanged(state); - - try { - int y = rvFolder.computeVerticalScrollOffset(); - Log.i("Scroll state=" + state + " y=" + y); - setActionBar(y == 0); - } catch (Throwable ex) { - Log.w(ex); - } - } - }; + LinearLayoutManager llm = new LinearLayoutManager(getContext()); rvFolder.setLayoutManager(llm); - rvFolder.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - try { - int y = rvFolder.computeVerticalScrollOffset(); - Log.i("Layout completed y=" + y); - setActionBar(y == 0); - } catch (Throwable ex) { - Log.w(ex); - } - } - }); - if (!cards) { DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) { @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index c237a352ef..a2ec66d0d1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -557,35 +557,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Log.w(ex); } } - - @Override - public void onScrollStateChanged(int state) { - super.onScrollStateChanged(state); - - try { - int y = rvMessage.computeVerticalScrollOffset(); - Log.i("Scroll state=" + state + " y=" + y); - setActionBar(y == 0); - } catch (Throwable ex) { - Log.w(ex); - } - } }; rvMessage.setLayoutManager(llm); - rvMessage.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - try { - int y = rvMessage.computeVerticalScrollOffset(); - Log.i("Layout completed y=" + y); - setActionBar(y == 0); - } catch (Throwable ex) { - Log.w(ex); - } - } - }); - if (!cards) { DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) { @Override diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index 0dacf3807c..2900432917 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -46,6 +46,7 @@ android:layout_height="wrap_content" android:layout_marginTop="12dp" android:text="@string/title_advanced_hide_actionbar" + android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swPull"