From 54c65d0ba994f47603b1bff3ac2d42dbe8ecbfd0 Mon Sep 17 00:00:00 2001 From: Pavneet Singh Cheema <90737218+pavi38@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:00:17 -0600 Subject: [PATCH] all: smoother navigation links (fixes #5046) (#5053) Co-authored-by: Gideon Okuro Co-authored-by: dogi --- app/build.gradle | 4 ++-- .../ole/planet/myplanet/ui/dashboard/DashboardActivity.kt | 4 +++- .../planet/myplanet/ui/dashboard/DashboardActivity.kt.lite | 4 +++- .../ole/planet/myplanet/ui/sync/DashboardElementActivity.kt | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 03dfb69973..5ff7484566 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2220 - versionName "0.22.20" + versionCode 2221 + versionName "0.22.21" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt index aa18c97340..6df1c66749 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt @@ -800,7 +800,9 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N val b = Bundle() b.putBoolean("isMyCourseLib", true) f.arguments = b - openCallFragment(f, "shelf") + val fragmentName = f::class.java.simpleName + val tag = "My$fragmentName" + openCallFragment(f, tag) } override fun onDestroy() { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite index 37abe945af..8dca97ce96 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite @@ -800,7 +800,9 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N val b = Bundle() b.putBoolean("isMyCourseLib", true) f.arguments = b - openCallFragment(f, "shelf") + val fragmentName = f::class.java.simpleName + val tag = "My$fragmentName" + openCallFragment(f, tag) } override fun onDestroy() { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt index 8a09f3ba91..924e4441cc 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt @@ -54,6 +54,7 @@ abstract class DashboardElementActivity : SyncActivity(), FragmentManager.OnBack profileDbHandler = UserProfileDbHandler(this) settings = applicationContext.getSharedPreferences(PREFS_NAME, MODE_PRIVATE) prefData = SharedPrefManager(this) + supportFragmentManager.addOnBackStackChangedListener(this) } fun onClickTabItems(position: Int) { @@ -246,13 +247,13 @@ abstract class DashboardElementActivity : SyncActivity(), FragmentManager.OnBack val f = supportFragmentManager.findFragmentById(R.id.fragment_container) val fragmentTag = f?.tag if (f is CoursesFragment) { - if ("shelf" == fragmentTag) { + if ("MyCoursesFragment" == fragmentTag) { navigationView.menu.findItem(R.id.menu_mycourses).isChecked = true } else { navigationView.menu.findItem(R.id.menu_courses).isChecked = true } } else if (f is ResourcesFragment) { - if ("shelf" == fragmentTag) { + if ("MyResourcesFragment" == fragmentTag) { navigationView.menu.findItem(R.id.menu_mylibrary).isChecked = true } else { navigationView.menu.findItem(R.id.menu_library).isChecked = true