mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Fix version number for alpha builds (#2325)
This commit is contained in:
parent
ddc83f1f22
commit
de9611821b
11 changed files with 51 additions and 16 deletions
|
|
@ -1,5 +1,10 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
|
||||
public class ConfigUtils {
|
||||
|
|
@ -7,4 +12,16 @@ public class ConfigUtils {
|
|||
public static boolean isBetaFlavour() {
|
||||
return BuildConfig.FLAVOR.equals("beta");
|
||||
}
|
||||
|
||||
private static String getVersionName(Context context) {
|
||||
try {
|
||||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return BuildConfig.VERSION_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getVersionNameWithSha(Context context) {
|
||||
return String.format(Locale.getDefault(), "%s~%s", getVersionName(context), BuildConfig.COMMIT_SHA);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue