forked from upstream-mirrors/OpenTracks
Automatic versioning (versionName and versionCode) using GIT.
This commit is contained in:
@@ -22,6 +22,8 @@ import android.os.Environment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
|
||||
/**
|
||||
* Utilities for dealing with files.
|
||||
*
|
||||
@@ -32,7 +34,7 @@ public class FileUtils {
|
||||
/**
|
||||
* Used to transfer picture from the camera.
|
||||
*/
|
||||
public static final String FILEPROVIDER = "de.dennisguse.opentracks.fileprovider";
|
||||
public static final String FILEPROVIDER = BuildConfig.APPLICATION_ID + ".fileprovider";
|
||||
/**
|
||||
* The play tracks directory in the app's cache directory.
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,8 @@ import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.util.Log;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
|
||||
/**
|
||||
* Utility class for accessing basic Android functionality.
|
||||
*
|
||||
@@ -42,10 +44,9 @@ public class SystemUtils {
|
||||
*
|
||||
* @return the version, or an empty string in case of failure.
|
||||
*/
|
||||
public static String getAppVersion(Context context) {
|
||||
public static String getAppVersionName(Context context) {
|
||||
try {
|
||||
PackageInfo pi = context.getPackageManager()
|
||||
.getPackageInfo("de.dennisguse.opentracks", PackageManager.GET_META_DATA);
|
||||
PackageInfo pi = context.getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_META_DATA);
|
||||
return pi.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.w(TAG, "Failed to get version info.", e);
|
||||
@@ -53,6 +54,16 @@ public class SystemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Long getAppVersionCode(Context context) {
|
||||
try {
|
||||
PackageInfo pi = context.getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_META_DATA);
|
||||
return pi.getLongVersionCode();
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.w(TAG, "Failed to get version info.", e);
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquire a wake lock if not already acquired.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user