forked from upstream-mirrors/OpenTracks
Automatic versioning (versionName and versionCode) using GIT.
This commit is contained in:
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -17,11 +17,43 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
def getVersionCode = { ->
|
||||
try {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'rev-list', 'HEAD', '--count'
|
||||
standardOutput = stdout
|
||||
}
|
||||
return Integer.parseInt(stdout.toString().trim())
|
||||
}
|
||||
catch (ignored) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
def getVersionName = { ->
|
||||
try {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'describe', '--tags', '--dirty'
|
||||
standardOutput = stdout
|
||||
}
|
||||
return stdout.toString().trim()
|
||||
}
|
||||
catch (ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
|
||||
defaultConfig {
|
||||
applicationId "de.dennisguse.opentracks"
|
||||
//Useful for debugging.
|
||||
//versionCode getVersionCode()
|
||||
//versionName getVersionName()
|
||||
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
|
||||
@@ -29,10 +61,19 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
versionNameSuffix "-debug"
|
||||
}
|
||||
|
||||
release {
|
||||
minifyEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
applicationVariants.all { variant ->
|
||||
variant.resValue "string", "applicationId", variant.applicationId
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -43,3 +84,4 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
testImplementation 'androidx.test:core:1.2.0'
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="de.dennisguse.opentracks"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="100"
|
||||
android:versionName="3.0.0">
|
||||
android:versionCode="2916"
|
||||
android:versionName="v3.0.0"> <!-- For FDroid. -->
|
||||
<!-- Permission to initialize services -->
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
@@ -186,18 +186,18 @@ limitations under the License.
|
||||
<!-- Providers -->
|
||||
<provider
|
||||
android:name="de.dennisguse.opentracks.content.CustomContentProvider"
|
||||
android:authorities="de.dennisguse.opentracks"
|
||||
android:authorities="${applicationId}"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true" />
|
||||
<!-- Search suggestion provider -->
|
||||
<provider
|
||||
android:name="de.dennisguse.opentracks.content.SearchEngineProvider"
|
||||
android:authorities="de.dennisguse.opentracks.search"
|
||||
android:authorities="${applicationId}.search"
|
||||
android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="de.dennisguse.opentracks.fileprovider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
|
||||
@@ -19,8 +19,11 @@ public class AboutActivity extends AbstractActivity {
|
||||
TextView textDescription = findViewById(R.id.about_text_description);
|
||||
textDescription.setText(getString(R.string.about_description));
|
||||
|
||||
TextView textVersion = findViewById(R.id.about_text_version);
|
||||
textVersion.setText(getString(R.string.about_version, SystemUtils.getAppVersion(this)));
|
||||
TextView textVersionName = findViewById(R.id.about_text_version_name);
|
||||
textVersionName.setText(getString(R.string.about_version_name, SystemUtils.getAppVersionName(this)));
|
||||
|
||||
TextView textVersionCode = findViewById(R.id.about_text_version_code);
|
||||
textVersionCode.setText(getString(R.string.about_version_code, SystemUtils.getAppVersionCode(this)));
|
||||
|
||||
TextView textURL = findViewById(R.id.about_app_url);
|
||||
textURL.setText(getString(R.string.about_url, getString(R.string.app_web_url)));
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
|
||||
import java.util.Iterator;
|
||||
@@ -38,7 +39,7 @@ public interface ContentProviderUtils {
|
||||
* The authority (the first part of the URI) for the app's content
|
||||
* provider.
|
||||
*/
|
||||
String AUTHORITY = "de.dennisguse.opentracks";
|
||||
String AUTHORITY = BuildConfig.APPLICATION_ID;
|
||||
/**
|
||||
* The default {@link LocationFactory} which creates a location each time.
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,8 @@ import android.content.Context;
|
||||
import android.content.SearchRecentSuggestionsProvider;
|
||||
import android.provider.SearchRecentSuggestions;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
|
||||
/**
|
||||
* Content provider for search suggestions.
|
||||
*
|
||||
@@ -26,7 +28,7 @@ import android.provider.SearchRecentSuggestions;
|
||||
*/
|
||||
public class SearchEngineProvider extends SearchRecentSuggestionsProvider {
|
||||
|
||||
private static final String AUTHORITY = "de.dennisguse.opentracks.search";
|
||||
private static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".search";
|
||||
private static final int MODE = DATABASE_MODE_QUERIES;
|
||||
|
||||
public SearchEngineProvider() {
|
||||
|
||||
@@ -19,6 +19,8 @@ package de.dennisguse.opentracks.content;
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
|
||||
/**
|
||||
* Constants for the track points table.
|
||||
*
|
||||
@@ -27,7 +29,7 @@ import android.provider.BaseColumns;
|
||||
public interface TrackPointsColumns extends BaseColumns {
|
||||
|
||||
String TABLE_NAME = "trackpoints";
|
||||
Uri CONTENT_URI = Uri.parse("content://de.dennisguse.opentracks/trackpoints");
|
||||
Uri CONTENT_URI = Uri.parse("content://" + BuildConfig.APPLICATION_ID + "/trackpoints");
|
||||
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.trackpoint";
|
||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.trackpoint";
|
||||
String DEFAULT_SORT_ORDER = "_id";
|
||||
|
||||
@@ -19,6 +19,8 @@ package de.dennisguse.opentracks.content;
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
|
||||
/**
|
||||
* Constants for the tracks table.
|
||||
*
|
||||
@@ -31,7 +33,7 @@ public interface TracksColumns extends BaseColumns {
|
||||
/**
|
||||
* Tracks provider uri.
|
||||
*/
|
||||
Uri CONTENT_URI = Uri.parse("content://de.dennisguse.opentracks/tracks");
|
||||
Uri CONTENT_URI = Uri.parse("content://" + BuildConfig.APPLICATION_ID + "/tracks");
|
||||
|
||||
/**
|
||||
* Track content type.
|
||||
|
||||
@@ -19,6 +19,8 @@ package de.dennisguse.opentracks.content;
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
|
||||
/**
|
||||
* Constants for waypoints table.
|
||||
*
|
||||
@@ -27,7 +29,7 @@ import android.provider.BaseColumns;
|
||||
public interface WaypointsColumns extends BaseColumns {
|
||||
|
||||
String TABLE_NAME = "waypoints";
|
||||
Uri CONTENT_URI = Uri.parse("content://de.dennisguse.opentracks/waypoints");
|
||||
Uri CONTENT_URI = Uri.parse("content://" + BuildConfig.APPLICATION_ID + "/waypoints");
|
||||
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.waypoint";
|
||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.waypoint";
|
||||
String DEFAULT_SORT_ORDER = "_id";
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -33,7 +33,15 @@
|
||||
<View style="@style/StatsHorizontalLine" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_text_version"
|
||||
android:id="@+id/about_text_version_name"
|
||||
style="@style/TextSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="6dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_text_version_code"
|
||||
style="@style/TextSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -24,8 +24,11 @@ limitations under the License.
|
||||
<string name="about_url" translate_description="In the about activity, the URL to the source code repository.">
|
||||
Project web page: <a href="%1$s">%1$s</a>
|
||||
</string>
|
||||
<string name="about_version" translate_description="In the about activity, the version of the source code (i.e., Android's versionName).">
|
||||
Version: %1$s
|
||||
<string name="about_version_name" translate_description="In the about activity, the version of the source code (i.e., Android's versionName).">
|
||||
Version name: %1$s
|
||||
</string>
|
||||
<string name="about_version_code" translate_description="In the about activity, the version of the source code (i.e., Android's versionName).">
|
||||
Version code: %1$d
|
||||
</string>
|
||||
<string name="about_history" translatate_description="In the about activity, the relationship with MyTracks.">
|
||||
OpenTracks is a fork of <a href="https://code.google.com/archive/p/mytracks/"><i>Google\'s MyTracks</i></a> (discontinued in 2016).
|
||||
|
||||
@@ -38,7 +38,7 @@ limitations under the License.
|
||||
<Preference
|
||||
android:title="@string/about_preference_title">
|
||||
<intent
|
||||
android:targetPackage="de.dennisguse.opentracks"
|
||||
android:targetPackage="@string/applicationId"
|
||||
android:targetClass="de.dennisguse.opentracks.AboutActivity" />
|
||||
</Preference>
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user