Skip to content

Commit

Permalink
Long type for version code
Browse files Browse the repository at this point in the history
  • Loading branch information
massivemadness committed Nov 19, 2023
1 parent 252637e commit 8c93ecc
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,27 @@ package com.blacksquircle.ui.feature.settings.data.utils

import android.content.Context
import android.content.pm.PackageManager
import androidx.core.content.PackageManagerCompat
import androidx.core.content.pm.PackageInfoCompat

val Context.applicationName: String
get() = try {
applicationInfo.loadLabel(packageManager).toString()
} catch (e: PackageManager.NameNotFoundException) {
""
"null"
}

val Context.versionName: String
get() = try {
packageManager.getPackageInfo(packageName, 0).versionName
} catch (e: PackageManager.NameNotFoundException) {
""
"null"
}

val Context.versionCode: Int
val Context.versionCode: Long
get() = try {
packageManager.getPackageInfo(packageName, 0).versionCode
val packageInfo = packageManager.getPackageInfo(packageName, 0)
PackageInfoCompat.getLongVersionCode(packageInfo)
} catch (e: PackageManager.NameNotFoundException) {
-1
-1L
}

0 comments on commit 8c93ecc

Please sign in to comment.