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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<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 {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "de.dennisguse.opentracks"
|
applicationId "de.dennisguse.opentracks"
|
||||||
|
//Useful for debugging.
|
||||||
|
//versionCode getVersionCode()
|
||||||
|
//versionName getVersionName()
|
||||||
|
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
|
|
||||||
@@ -29,10 +61,19 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
applicationIdSuffix ".debug"
|
||||||
|
versionNameSuffix "-debug"
|
||||||
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applicationVariants.all { variant ->
|
||||||
|
variant.resValue "string", "applicationId", variant.applicationId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -43,3 +84,4 @@ dependencies {
|
|||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
testImplementation 'androidx.test:core:1.2.0'
|
testImplementation 'androidx.test:core:1.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="de.dennisguse.opentracks"
|
package="de.dennisguse.opentracks"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
android:versionCode="100"
|
android:versionCode="2916"
|
||||||
android:versionName="3.0.0">
|
android:versionName="v3.0.0"> <!-- For FDroid. -->
|
||||||
<!-- Permission to initialize services -->
|
<!-- Permission to initialize services -->
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
@@ -186,18 +186,18 @@ limitations under the License.
|
|||||||
<!-- Providers -->
|
<!-- Providers -->
|
||||||
<provider
|
<provider
|
||||||
android:name="de.dennisguse.opentracks.content.CustomContentProvider"
|
android:name="de.dennisguse.opentracks.content.CustomContentProvider"
|
||||||
android:authorities="de.dennisguse.opentracks"
|
android:authorities="${applicationId}"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true" />
|
android:grantUriPermissions="true" />
|
||||||
<!-- Search suggestion provider -->
|
<!-- Search suggestion provider -->
|
||||||
<provider
|
<provider
|
||||||
android:name="de.dennisguse.opentracks.content.SearchEngineProvider"
|
android:name="de.dennisguse.opentracks.content.SearchEngineProvider"
|
||||||
android:authorities="de.dennisguse.opentracks.search"
|
android:authorities="${applicationId}.search"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="de.dennisguse.opentracks.fileprovider"
|
android:authorities="${applicationId}.fileprovider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|||||||
@@ -19,8 +19,11 @@ public class AboutActivity extends AbstractActivity {
|
|||||||
TextView textDescription = findViewById(R.id.about_text_description);
|
TextView textDescription = findViewById(R.id.about_text_description);
|
||||||
textDescription.setText(getString(R.string.about_description));
|
textDescription.setText(getString(R.string.about_description));
|
||||||
|
|
||||||
TextView textVersion = findViewById(R.id.about_text_version);
|
TextView textVersionName = findViewById(R.id.about_text_version_name);
|
||||||
textVersion.setText(getString(R.string.about_version, SystemUtils.getAppVersion(this)));
|
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);
|
TextView textURL = findViewById(R.id.about_app_url);
|
||||||
textURL.setText(getString(R.string.about_url, getString(R.string.app_web_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.location.LocationManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -38,7 +39,7 @@ public interface ContentProviderUtils {
|
|||||||
* The authority (the first part of the URI) for the app's content
|
* The authority (the first part of the URI) for the app's content
|
||||||
* provider.
|
* provider.
|
||||||
*/
|
*/
|
||||||
String AUTHORITY = "de.dennisguse.opentracks";
|
String AUTHORITY = BuildConfig.APPLICATION_ID;
|
||||||
/**
|
/**
|
||||||
* The default {@link LocationFactory} which creates a location each time.
|
* The default {@link LocationFactory} which creates a location each time.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import android.content.Context;
|
|||||||
import android.content.SearchRecentSuggestionsProvider;
|
import android.content.SearchRecentSuggestionsProvider;
|
||||||
import android.provider.SearchRecentSuggestions;
|
import android.provider.SearchRecentSuggestions;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content provider for search suggestions.
|
* Content provider for search suggestions.
|
||||||
*
|
*
|
||||||
@@ -26,7 +28,7 @@ import android.provider.SearchRecentSuggestions;
|
|||||||
*/
|
*/
|
||||||
public class SearchEngineProvider extends SearchRecentSuggestionsProvider {
|
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;
|
private static final int MODE = DATABASE_MODE_QUERIES;
|
||||||
|
|
||||||
public SearchEngineProvider() {
|
public SearchEngineProvider() {
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package de.dennisguse.opentracks.content;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for the track points table.
|
* Constants for the track points table.
|
||||||
*
|
*
|
||||||
@@ -27,7 +29,7 @@ import android.provider.BaseColumns;
|
|||||||
public interface TrackPointsColumns extends BaseColumns {
|
public interface TrackPointsColumns extends BaseColumns {
|
||||||
|
|
||||||
String TABLE_NAME = "trackpoints";
|
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_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.trackpoint";
|
||||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.trackpoint";
|
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.trackpoint";
|
||||||
String DEFAULT_SORT_ORDER = "_id";
|
String DEFAULT_SORT_ORDER = "_id";
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package de.dennisguse.opentracks.content;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for the tracks table.
|
* Constants for the tracks table.
|
||||||
*
|
*
|
||||||
@@ -31,7 +33,7 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
/**
|
/**
|
||||||
* Tracks provider uri.
|
* 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.
|
* Track content type.
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package de.dennisguse.opentracks.content;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for waypoints table.
|
* Constants for waypoints table.
|
||||||
*
|
*
|
||||||
@@ -27,7 +29,7 @@ import android.provider.BaseColumns;
|
|||||||
public interface WaypointsColumns extends BaseColumns {
|
public interface WaypointsColumns extends BaseColumns {
|
||||||
|
|
||||||
String TABLE_NAME = "waypoints";
|
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_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.waypoint";
|
||||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.waypoint";
|
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.waypoint";
|
||||||
String DEFAULT_SORT_ORDER = "_id";
|
String DEFAULT_SORT_ORDER = "_id";
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import android.os.Environment;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for dealing with files.
|
* Utilities for dealing with files.
|
||||||
*
|
*
|
||||||
@@ -32,7 +34,7 @@ public class FileUtils {
|
|||||||
/**
|
/**
|
||||||
* Used to transfer picture from the camera.
|
* 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.
|
* 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.os.PowerManager.WakeLock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for accessing basic Android functionality.
|
* 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.
|
* @return the version, or an empty string in case of failure.
|
||||||
*/
|
*/
|
||||||
public static String getAppVersion(Context context) {
|
public static String getAppVersionName(Context context) {
|
||||||
try {
|
try {
|
||||||
PackageInfo pi = context.getPackageManager()
|
PackageInfo pi = context.getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_META_DATA);
|
||||||
.getPackageInfo("de.dennisguse.opentracks", PackageManager.GET_META_DATA);
|
|
||||||
return pi.versionName;
|
return pi.versionName;
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Log.w(TAG, "Failed to get version info.", 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.
|
* Acquire a wake lock if not already acquired.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -33,7 +33,15 @@
|
|||||||
<View style="@style/StatsHorizontalLine" />
|
<View style="@style/StatsHorizontalLine" />
|
||||||
|
|
||||||
<TextView
|
<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"
|
style="@style/TextSmall"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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.">
|
<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>
|
Project web page: <a href="%1$s">%1$s</a>
|
||||||
</string>
|
</string>
|
||||||
<string name="about_version" translate_description="In the about activity, the version of the source code (i.e., Android's versionName).">
|
<string name="about_version_name" translate_description="In the about activity, the version of the source code (i.e., Android's versionName).">
|
||||||
Version: %1$s
|
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>
|
||||||
<string name="about_history" translatate_description="In the about activity, the relationship with MyTracks.">
|
<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).
|
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
|
<Preference
|
||||||
android:title="@string/about_preference_title">
|
android:title="@string/about_preference_title">
|
||||||
<intent
|
<intent
|
||||||
android:targetPackage="de.dennisguse.opentracks"
|
android:targetPackage="@string/applicationId"
|
||||||
android:targetClass="de.dennisguse.opentracks.AboutActivity" />
|
android:targetClass="de.dennisguse.opentracks.AboutActivity" />
|
||||||
</Preference>
|
</Preference>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
Reference in New Issue
Block a user