#2186 all main destinations now hide toolbars on scroll and fixed snackbar

This commit is contained in:
HissPirat 2020-07-14 12:28:58 +02:00
parent a29c9d6231
commit 068277e55f
7 changed files with 110 additions and 59 deletions

View File

@ -24,6 +24,7 @@ import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.Menu import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toFile import androidx.core.net.toFile
import androidx.core.net.toUri import androidx.core.net.toUri
@ -73,6 +74,15 @@ class ReaderFragment : CoreReaderFragment() {
} }
} }
override fun onPause() {
super.onPause()
// ScrollingViewWithBottomNavigationBehavior changes the margin to the size of the nav bar,
// this resets the margin to zero, before fragment navigation.
val params = parentFragment?.view?.layoutParams as ViewGroup.MarginLayoutParams?
params?.bottomMargin = 0
parentFragment?.view?.requestLayout()
}
override fun onCreateOptionsMenu(menu: Menu, menuInflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, menuInflater: MenuInflater) {
super.onCreateOptionsMenu(menu, menuInflater) super.onCreateOptionsMenu(menu, menuInflater)
menu.findItem(R.id.menu_new_navigation)?.isVisible = false menu.findItem(R.id.menu_new_navigation)?.isVisible = false

View File

@ -33,10 +33,8 @@
android:name="org.kiwix.kiwixmobile.main.NavigationHostFragment" android:name="org.kiwix.kiwixmobile.main.NavigationHostFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="bottom"
app:defaultNavHost="true" app:defaultNavHost="true"
app:layout_behavior=".nav.helper.ScrollingViewWithBottomNavigationBehavior" app:layout_behavior=".nav.helper.ScrollingViewWithBottomNavigationBehavior"
app:layout_dodgeInsetEdges="bottom"
app:navGraph="@navigation/kiwix_nav_graph" app:navGraph="@navigation/kiwix_nav_graph"
tools:ignore="FragmentTagUsage" /> tools:ignore="FragmentTagUsage" />
@ -46,6 +44,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior" app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
app:layout_scrollFlags="scroll|enterAlways"
app:menu="@menu/menu_bottom_nav" /> app:menu="@menu/menu_bottom_nav" />
</org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout> </org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout>

View File

@ -16,18 +16,42 @@
~ ~
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/layout_toolbar" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/layout_scrolling_toolbar" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/librarySwipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/libraryList"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout>
<TextView <TextView
android:id="@+id/libraryErrorText" android:id="@+id/libraryErrorText"
style="@style/no_list_content_text" style="@style/no_list_content_text"
@ -36,20 +60,5 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/librarySwipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/libraryList"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@ -16,18 +16,42 @@
~ ~
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/layout_toolbar" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/layout_scrolling_toolbar" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/zim_swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/zimfilelist"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout>
<TextView <TextView
android:id="@+id/file_management_no_files" android:id="@+id/file_management_no_files"
@ -48,20 +72,5 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/file_management_no_files" /> app:layout_constraintTop_toBottomOf="@+id/file_management_no_files" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/zim_swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/zimfilelist"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@ -871,7 +871,7 @@ public abstract class CoreReaderFragment extends BaseFragment
} }
tabsAdapter.notifyItemRemoved(index); tabsAdapter.notifyItemRemoved(index);
tabsAdapter.notifyDataSetChanged(); tabsAdapter.notifyDataSetChanged();
Snackbar.make(tabSwitcherRoot, R.string.tab_closed, Snackbar.LENGTH_LONG) Snackbar.make(snackbarRoot, R.string.tab_closed, Snackbar.LENGTH_LONG)
.setAction(R.string.undo, v -> { .setAction(R.string.undo, v -> {
webViewList.add(index, tempForUndo); webViewList.add(index, tempForUndo);
tabsAdapter.notifyItemInserted(index); tabsAdapter.notifyItemInserted(index);

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Kiwix Android
~ Copyright (c) 2020 Kiwix <android.kiwix.org>
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
~
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/KiwixTheme"
app:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" />
</merge>

View File

@ -34,13 +34,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar <include layout="@layout/layout_scrolling_toolbar" />
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/KiwixTheme"
app:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" />
<androidx.core.widget.ContentLoadingProgressBar <androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/main_fragment_progress_view" android:id="@+id/main_fragment_progress_view"
@ -135,8 +129,9 @@
android:id="@+id/snackbar_root" android:id="@+id/snackbar_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/activity_main_button_pause_tts" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<include <include
android:id="@+id/activity_main_tab_switcher" android:id="@+id/activity_main_tab_switcher"