From 57eecd630d4c1b958bb9367a23a3e022f6486729 Mon Sep 17 00:00:00 2001 From: Tommaso Berlose Date: Thu, 14 Jan 2021 17:41:33 +0100 Subject: [PATCH] Fix #275 --- .idea/caches/build_file_checksums.ser | Bin 537 -> 537 bytes app/build.gradle | 2 +- .../tabs/ChooseApplicationActivity.kt | 13 +++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index aeae49bb3c663baf0277b450d3c975d27c21a5d8..e62f5854480135ac144912e34b357b4f3d193491 100644 GIT binary patch delta 34 scmV+-0NwwY1epYomj!nLen1+roNNIR?Xb6Ce*W6tCX5*XrP0T|c=A*arvLx| delta 34 qcmbQqGLvP(bk?%(eAW{;&dFgEoO4dqo$>6fimpG^Oc#U`wJHGe^$r*S diff --git a/app/build.gradle b/app/build.gradle index eada9a2..ad1ed4b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,7 +22,7 @@ android { applicationId "com.tommasoberlose.anotherwidget" minSdkVersion 23 targetSdkVersion 30 - versionCode 127 + versionCode 128 versionName "2.2.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt index 6652a33..db82d49 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/tabs/ChooseApplicationActivity.kt @@ -19,6 +19,7 @@ import com.google.android.material.card.MaterialCardView import com.tommasoberlose.anotherwidget.databinding.ActivityChooseApplicationBinding import com.tommasoberlose.anotherwidget.global.Constants import com.tommasoberlose.anotherwidget.helpers.IntentHelper +import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper import com.tommasoberlose.anotherwidget.ui.viewmodels.tabs.ChooseApplicationViewModel import kotlinx.coroutines.* import net.idik.lib.slimadapter.SlimAdapter @@ -171,6 +172,18 @@ class ChooseApplicationActivity : AppCompatActivity() { list.filter { it.loadLabel(viewModel.pm).contains(search, true) } + }.sortedWith { app1, app2 -> + when (selectedPackage) { + app1.activityInfo.packageName -> { + -1 + } + app2.activityInfo.packageName -> { + 1 + } + else -> { + app1.loadLabel(viewModel.pm).toString().compareTo(app2.loadLabel(viewModel.pm).toString(), ignoreCase = true) + } + } } withContext(Dispatchers.Main) { adapter.updateData(listOf(IntentHelper.DO_NOTHING_OPTION, IntentHelper.DEFAULT_OPTION, IntentHelper.REFRESH_WIDGET_OPTION) + filteredList)