Add old > new version indicator
This commit is contained in:
@@ -51,6 +51,19 @@ object PackageUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun getInstalledVersion(context: Context, packageName: String): String {
|
||||
return try {
|
||||
val packageInfo = getPackageInfo(context, packageName)
|
||||
if (packageInfo != null) {
|
||||
"${packageInfo.versionName}.${packageInfo.versionCode}"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
fun isTv(context: Context): Boolean {
|
||||
val uiMode = context.resources.configuration.uiMode
|
||||
return uiMode and Configuration.UI_MODE_TYPE_MASK == Configuration.UI_MODE_TYPE_TELEVISION
|
||||
|
||||
@@ -490,12 +490,15 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
app.versionCode.toLong()
|
||||
)
|
||||
|
||||
val installedVersion = PackageUtil.getInstalledVersion(this, app.packageName)
|
||||
|
||||
if (isUpdatable) {
|
||||
B.layoutDetailsApp.txtLine3.text =
|
||||
("$installedVersion > ${app.versionName}.${app.versionCode}")
|
||||
btn.setText(R.string.action_update)
|
||||
btn.addOnClickListener {
|
||||
startDownload()
|
||||
}
|
||||
btn.addOnClickListener { startDownload() }
|
||||
} else {
|
||||
B.layoutDetailsApp.txtLine3.text = installedVersion
|
||||
btn.setText(R.string.action_open)
|
||||
btn.addOnClickListener { openApp() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user