Sort apps that failed to install by name
This commit is contained in:
parent
56d8d64261
commit
1667d44967
2 changed files with 10 additions and 5 deletions
|
@ -66,6 +66,7 @@ internal class ApkRestore(
|
||||||
packageName = packageName,
|
packageName = packageName,
|
||||||
progress = progress,
|
progress = progress,
|
||||||
state = if (isAllowedToInstallApks) QUEUED else FAILED,
|
state = if (isAllowedToInstallApks) QUEUED else FAILED,
|
||||||
|
name = metadata.name?.toString(),
|
||||||
installerPackageName = metadata.installer
|
installerPackageName = metadata.installer
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -153,7 +154,7 @@ internal class ApkRestore(
|
||||||
publicSourceDir = cachedApk.absolutePath
|
publicSourceDir = cachedApk.absolutePath
|
||||||
}
|
}
|
||||||
val icon = appInfo?.loadIcon(pm)
|
val icon = appInfo?.loadIcon(pm)
|
||||||
val name = appInfo?.let { pm.getApplicationLabel(it) }
|
val name = appInfo?.let { pm.getApplicationLabel(it).toString() }
|
||||||
|
|
||||||
installResult.update(packageName) { result ->
|
installResult.update(packageName) { result ->
|
||||||
result.copy(state = IN_PROGRESS, name = name, icon = icon)
|
result.copy(state = IN_PROGRESS, name = name, icon = icon)
|
||||||
|
|
|
@ -118,10 +118,10 @@ internal class MutableInstallResult(override val total: Int) : InstallResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ApkInstallResult(
|
data class ApkInstallResult(
|
||||||
val packageName: CharSequence,
|
val packageName: String,
|
||||||
val progress: Int,
|
val progress: Int,
|
||||||
val state: ApkInstallState,
|
val state: ApkInstallState,
|
||||||
val name: CharSequence? = null,
|
val name: String? = null,
|
||||||
val icon: Drawable? = null,
|
val icon: Drawable? = null,
|
||||||
val installerPackageName: CharSequence? = null,
|
val installerPackageName: CharSequence? = null,
|
||||||
) : Comparable<ApkInstallResult> {
|
) : Comparable<ApkInstallResult> {
|
||||||
|
@ -132,9 +132,13 @@ data class ApkInstallResult(
|
||||||
|
|
||||||
internal class FailedFirstComparator : Comparator<ApkInstallResult> {
|
internal class FailedFirstComparator : Comparator<ApkInstallResult> {
|
||||||
override fun compare(a1: ApkInstallResult, a2: ApkInstallResult): Int {
|
override fun compare(a1: ApkInstallResult, a2: ApkInstallResult): Int {
|
||||||
return (if (a1.state == FAILED && a2.state != FAILED) -1
|
return if (a1.state == FAILED && a2.state != FAILED) -1
|
||||||
else if (a2.state == FAILED && a1.state != FAILED) 1
|
else if (a2.state == FAILED && a1.state != FAILED) 1
|
||||||
else a1.compareTo(a2))
|
else {
|
||||||
|
val str = a1.name ?: a1.packageName
|
||||||
|
val otherStr = a2.name ?: a2.packageName
|
||||||
|
str.compareTo(otherStr, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue