Skip to content

Commit 22c2068

Browse files
Converted Config Utils to Kotlin (commons-app#3674)
* Converted Config Utils to Kotlin * Changes made as per suggestion * Omitted this
1 parent 6e60bbf commit 22c2068

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

app/src/main/java/fr/free/nrw/commons/utils/ConfigUtils.java

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package fr.free.nrw.commons.utils
2+
3+
import android.content.Context
4+
import android.content.pm.PackageManager
5+
import fr.free.nrw.commons.BuildConfig
6+
7+
object ConfigUtils {
8+
@JvmStatic
9+
val isBetaFlavour: Boolean = BuildConfig.FLAVOR == "beta"
10+
11+
@JvmStatic
12+
private fun Context.getVersionName(): String {
13+
return try {
14+
packageManager.getPackageInfo(packageName, 0).versionName
15+
} catch (e: PackageManager.NameNotFoundException) {
16+
BuildConfig.VERSION_NAME
17+
}
18+
}
19+
20+
@JvmStatic
21+
fun Context.getVersionNameWithSha(): String {
22+
return "${getVersionName()}~${BuildConfig.COMMIT_SHA}"
23+
}
24+
}

0 commit comments

Comments
 (0)