Glimpse: Switch to NavigationRail for large screen devices
Change-Id: I84dbb03ee100fb018ab6c19d20108570dbdd6068
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
diff --git a/app/src/main/java/org/lineageos/glimpse/fragments/MainFragment.kt b/app/src/main/java/org/lineageos/glimpse/fragments/MainFragment.kt
index f962451..3ac603e 100644
--- a/app/src/main/java/org/lineageos/glimpse/fragments/MainFragment.kt
+++ b/app/src/main/java/org/lineageos/glimpse/fragments/MainFragment.kt
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2023 The LineageOS Project
+ * SPDX-FileCopyrightText: 2023-2024 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,7 +16,7 @@
class MainFragment : Fragment(R.layout.fragment_main) {
// Views
- private val bottomNavigationView by getViewProperty<NavigationBarView>(R.id.bottomNavigationView)
+ private val navigationBarView by getViewProperty<NavigationBarView>(R.id.navigationBarView)
// Fragments
private val childNavHostFragment by lazy { childFragmentManager.findFragmentById(R.id.childNavHostFragment) as NavHostFragment }
@@ -26,6 +26,6 @@
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- bottomNavigationView.setupWithNavController(childNavController)
+ navigationBarView.setupWithNavController(childNavController)
}
}
diff --git a/app/src/main/res/layout-sw600dp/fragment_main.xml b/app/src/main/res/layout-sw600dp/fragment_main.xml
new file mode 100644
index 0000000..65ac8bf
--- /dev/null
+++ b/app/src/main/res/layout-sw600dp/fragment_main.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2024 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity">
+
+ <androidx.fragment.app.FragmentContainerView
+ android:id="@+id/childNavHostFragment"
+ android:name="androidx.navigation.fragment.NavHostFragment"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:defaultNavHost="true"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/navigationBarView"
+ app:layout_constraintTop_toTopOf="parent"
+ app:navGraph="@navigation/main_fragment_navigation" />
+
+ <com.google.android.material.navigationrail.NavigationRailView
+ android:id="@+id/navigationBarView"
+ style="@style/Widget.Material3.BottomAppBar"
+ android:layout_width="wrap_content"
+ android:layout_height="0dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:menu="@menu/fragment_main_bottom_app_bar"
+ app:menuGravity="center" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml
index e16013e..eac0420 100644
--- a/app/src/main/res/layout/fragment_main.xml
+++ b/app/src/main/res/layout/fragment_main.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- SPDX-FileCopyrightText: 2023 The LineageOS Project
+ SPDX-FileCopyrightText: 2023-2024 The LineageOS Project
SPDX-License-Identifier: Apache-2.0
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -16,14 +16,14 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
- app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
+ app:layout_constraintBottom_toTopOf="@+id/navigationBarView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/main_fragment_navigation" />
<com.google.android.material.bottomnavigation.BottomNavigationView
- android:id="@+id/bottomNavigationView"
+ android:id="@+id/navigationBarView"
style="@style/Widget.Material3.BottomAppBar"
android:layout_width="0dp"
android:layout_height="wrap_content"