This commit is contained in:
Tommaso Berlose 2021-01-14 17:41:33 +01:00
parent cce86a970c
commit 57eecd630d
3 changed files with 14 additions and 1 deletions

Binary file not shown.

View File

@ -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"

View File

@ -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)