From 8957fe27928ac63da997f771301cdbdcf304488f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:37:45 -0500 Subject: [PATCH 1/3] all: bump `org.jetbrains.kotlinx:kotlinx-serialization-json` to 1.8.0 (fixes #4961) (#4951) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dogi --- app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b53d4f3dd6..e8899d0937 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2170 - versionName "0.21.70" + versionCode 2171 + versionName "0.21.71" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true @@ -191,7 +191,7 @@ dependencies { implementation 'org.osmdroid:osmdroid-android:6.1.20' implementation 'org.jetbrains:annotations:26.0.1' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0" implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.29' implementation 'com.mikepenz:google-material-typeface:3.0.1.1.original@aar' From ebe67f8e27a93167a782814e61d06bea193ea62b Mon Sep 17 00:00:00 2001 From: Deep Vora <70479785+deeppp15@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:41:04 -0500 Subject: [PATCH 2/3] teams: smoother list (fixes #4949) (#4950) Co-authored-by: dogi --- app/build.gradle | 4 ++-- .../ole/planet/myplanet/ui/team/TeamFragment.kt | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e8899d0937..3d86aa432b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2171 - versionName "0.21.71" + versionCode 2172 + versionName "0.21.72" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt index afaed2d3a2..31838b4df9 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt @@ -203,8 +203,9 @@ class TeamFragment : Fragment(), AdapterTeamList.OnClickTeamItem { .notEqualTo("status", "archived") .contains("name", charSequence.toString(), Case.INSENSITIVE) val (list, conditionApplied) = getList(query) + val sortedList = sortTeams(list) val adapterTeamList = AdapterTeamList( - activity as Context, list, mRealm, childFragmentManager + activity as Context, sortedList, mRealm, childFragmentManager ) adapterTeamList.setTeamListener(this@TeamFragment) fragmentTeamBinding.rvTeamList.adapter = adapterTeamList @@ -253,6 +254,17 @@ class TeamFragment : Fragment(), AdapterTeamList.OnClickTeamItem { } } + private fun sortTeams(list: List): List { + val user = user?.id + return list.sortedWith(compareByDescending { team -> + when { + RealmMyTeam.isTeamLeader(team.teamId, user, mRealm) -> 3 + team.isMyTeam(user, mRealm) -> 2 + else -> 1 + } + }) + } + override fun onEditTeam(team: RealmMyTeam?) { createTeamAlert(team!!) } @@ -261,7 +273,8 @@ class TeamFragment : Fragment(), AdapterTeamList.OnClickTeamItem { activity?.runOnUiThread { val query = mRealm.where(RealmMyTeam::class.java).isEmpty("teamId").notEqualTo("status", "archived") val (filteredList, conditionApplied) = getList(query) - val adapterTeamList = AdapterTeamList(activity as Context, filteredList, mRealm, childFragmentManager).apply { + val sortedList = sortTeams(filteredList) + val adapterTeamList = AdapterTeamList(activity as Context, sortedList, mRealm, childFragmentManager).apply { setType(type) setTeamListener(this@TeamFragment) } From 48badc8137cf2b1563bb3ea8d4a29d5d6a4c5b0b Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Tue, 7 Jan 2025 22:48:17 +0300 Subject: [PATCH 3/3] resources: smoother download dialog (fixes #4958) (#4959) Co-authored-by: dogi --- app/build.gradle | 4 +- .../myplanet/base/BaseResourceFragment.kt | 58 ++++++++++--------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3d86aa432b..45d872e585 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2172 - versionName "0.21.72" + versionCode 2173 + versionName "0.21.73" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt index 239bd33ca7..0d7995c2ab 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt @@ -98,19 +98,26 @@ abstract class BaseResourceFragment : Fragment() { } protected fun showDownloadDialog(dbMyLibrary: List) { - if (isAdded) { - Service(MainApplication.context).isPlanetAvailable(object : PlanetAvailableListener { - override fun isAvailable() { - if (dbMyLibrary.isNotEmpty()) { - if (!isAdded) { - return - } - val inflater = activity?.layoutInflater - val rootView = requireActivity().findViewById(android.R.id.content) - convertView = inflater?.inflate(R.layout.my_library_alertdialog, rootView, false) - val alertDialogBuilder = AlertDialog.Builder(requireContext(), R.style.AlertDialogTheme) - alertDialogBuilder.setView(convertView).setTitle(R.string.download_suggestion) - alertDialogBuilder.setPositiveButton(R.string.download_selected) { _: DialogInterface?, _: Int -> + if (!isAdded) return + Service(MainApplication.context).isPlanetAvailable(object : PlanetAvailableListener { + override fun isAvailable() { + if (!isAdded) return + if (dbMyLibrary.isEmpty()) { + activity?.let { + Utilities.toast(it, getString(R.string.no_resources_to_download)) + } + return + } + + activity?.let { fragmentActivity -> + val inflater = fragmentActivity.layoutInflater + val rootView = fragmentActivity.findViewById(android.R.id.content) + convertView = inflater.inflate(R.layout.my_library_alertdialog, rootView, false) + + val alertDialogBuilder = AlertDialog.Builder(fragmentActivity, R.style.AlertDialogTheme) + alertDialogBuilder.setView(convertView) + .setTitle(R.string.download_suggestion) + .setPositiveButton(R.string.download_selected) { _: DialogInterface?, _: Int -> lv?.selectedItemsList?.let { addToLibrary(dbMyLibrary, it) downloadFiles(dbMyLibrary, it) @@ -121,23 +128,20 @@ abstract class BaseResourceFragment : Fragment() { } startDownload(downloadAllFiles(dbMyLibrary)) }.setNegativeButton(R.string.txt_cancel, null) - val alertDialog = alertDialogBuilder.create() - createListView(dbMyLibrary, alertDialog) - alertDialog.show() - alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = (lv?.selectedItemsList?.size ?: 0) > 0 - } else { - Utilities.toast(requireContext(), getString(R.string.no_resources_to_download)) - } + val alertDialog = alertDialogBuilder.create() + createListView(dbMyLibrary, alertDialog) + alertDialog.show() + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = (lv?.selectedItemsList?.size ?: 0) > 0 } + } - override fun notAvailable() { - if (!isAdded) { - return - } - Utilities.toast(requireContext(), getString(R.string.planet_not_available)) + override fun notAvailable() { + if (!isAdded) return + activity?.let { + Utilities.toast(it, getString(R.string.planet_not_available)) } - }) - } + } + }) } fun showPendingSurveyDialog() {