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 {
|
fun isTv(context: Context): Boolean {
|
||||||
val uiMode = context.resources.configuration.uiMode
|
val uiMode = context.resources.configuration.uiMode
|
||||||
return uiMode and Configuration.UI_MODE_TYPE_MASK == Configuration.UI_MODE_TYPE_TELEVISION
|
return uiMode and Configuration.UI_MODE_TYPE_MASK == Configuration.UI_MODE_TYPE_TELEVISION
|
||||||
|
|||||||
@@ -490,12 +490,15 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
app.versionCode.toLong()
|
app.versionCode.toLong()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val installedVersion = PackageUtil.getInstalledVersion(this, app.packageName)
|
||||||
|
|
||||||
if (isUpdatable) {
|
if (isUpdatable) {
|
||||||
|
B.layoutDetailsApp.txtLine3.text =
|
||||||
|
("$installedVersion > ${app.versionName}.${app.versionCode}")
|
||||||
btn.setText(R.string.action_update)
|
btn.setText(R.string.action_update)
|
||||||
btn.addOnClickListener {
|
btn.addOnClickListener { startDownload() }
|
||||||
startDownload()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
B.layoutDetailsApp.txtLine3.text = installedVersion
|
||||||
btn.setText(R.string.action_open)
|
btn.setText(R.string.action_open)
|
||||||
btn.addOnClickListener { openApp() }
|
btn.addOnClickListener { openApp() }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user