Skip to content

Commit

Permalink
shift to nav menu
Browse files Browse the repository at this point in the history
  • Loading branch information
anandwana001 committed Nov 2, 2024
1 parent 4b19860 commit 11d8c3e
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class HomeScreenFragment :

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.versionText.text = String.format(getString(R.string.build), BuildConfig.VERSION_NAME)
// Ensure nav drawer cannot be swiped out, which would conflict with map pan gestures.
binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
homeScreenViewModel.showOfflineAreaMenuItem.observe(viewLifecycleOwner) {
Expand Down Expand Up @@ -121,6 +120,10 @@ class HomeScreenFragment :
.show()
}
}

val navigationView = view.findViewById<NavigationView>(R.id.nav_view)
val menuItem = navigationView.menu.findItem(R.id.nav_log_version)
menuItem.title = String.format(getString(R.string.build), BuildConfig.VERSION_NAME)
}

private fun updateNavHeader() =
Expand Down
22 changes: 2 additions & 20 deletions ground/src/main/res/layout/home_screen_frag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
~ limitations under the License.
-->
<layout 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">
xmlns:app="http://schemas.android.com/apk/res-auto">

<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_layout"
Expand Down Expand Up @@ -64,24 +63,7 @@
app:itemBackground="@android:color/transparent"
app:itemIconTint="@color/nav_drawer_item"
app:itemTextColor="@color/nav_drawer_item"
app:menu="@menu/nav_drawer_menu">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<TextView
android:id="@+id/version_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="32dp"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="Build number" />
</androidx.constraintlayout.widget.ConstraintLayout>

</com.google.android.material.navigation.NavigationView>
app:menu="@menu/nav_drawer_menu"/>

</androidx.drawerlayout.widget.DrawerLayout>
</layout>
33 changes: 33 additions & 0 deletions ground/src/main/res/layout/nav_drawer_footer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright 2018 Google LLC
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">

<TextView
android:id="@+id/version_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tools:text="Build number" />
</LinearLayout>
</layout>
52 changes: 31 additions & 21 deletions ground/src/main/res/menu/nav_drawer_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,35 @@
~ limitations under the License.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/sync_status"
android:icon="@drawable/ic_history"
android:title="@string/sync_status" />
<item
android:id="@+id/nav_offline_areas"
android:icon="@drawable/cloud_off"
android:title="@string/offline_map_imagery" />
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_settings"
android:title="@string/settings" />
<item
android:id="@+id/about"
android:icon="@drawable/info_outline"
android:title="@string/about" />
<item
android:id="@+id/terms_of_service"
android:icon="@drawable/feed"
android:title="@string/terms_of_service" />
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group>
<item
android:id="@+id/sync_status"
android:icon="@drawable/ic_history"
android:title="@string/sync_status" />
<item
android:id="@+id/nav_offline_areas"
android:icon="@drawable/cloud_off"
android:title="@string/offline_map_imagery" />
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_settings"
android:title="@string/settings" />
<item
android:id="@+id/about"
android:icon="@drawable/info_outline"
android:title="@string/about" />
<item
android:id="@+id/terms_of_service"
android:icon="@drawable/feed"
android:title="@string/terms_of_service" />
</group>
<group
android:id="@+id/nav_footer">
<item
android:id="@+id/nav_log_version"
android:title=""
app:actionLayout="@layout/nav_drawer_footer" />
</group>
</menu>

0 comments on commit 11d8c3e

Please sign in to comment.