Merge pull request #150 from cryptobanana/version_from_git_tag_instead_of_hardcoded
Define the versionName shown in settings from git
This commit is contained in:
commit
aff515efa0
|
@ -1,5 +1,15 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
def getVersionName = { ->
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'describe', '--tags'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
return stdout.toString().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 22
|
||||||
buildToolsVersion "22.0.1"
|
buildToolsVersion "22.0.1"
|
||||||
|
@ -9,7 +19,7 @@ android {
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 12
|
versionCode 12
|
||||||
versionName "1.5.0"
|
versionName = getVersionName()
|
||||||
}
|
}
|
||||||
|
|
||||||
File keystoreFile = file('keystore.properties')
|
File keystoreFile = file('keystore.properties')
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class AboutDialogFragment
|
||||||
versionName = null;
|
versionName = null;
|
||||||
}
|
}
|
||||||
TextView version = (TextView) mainView.findViewById(R.id.app_version);
|
TextView version = (TextView) mainView.findViewById(R.id.app_version);
|
||||||
version.setText("v" + versionName);
|
version.setText(versionName);
|
||||||
|
|
||||||
TextView about = (TextView)mainView.findViewById(R.id.about_desc);
|
TextView about = (TextView)mainView.findViewById(R.id.about_desc);
|
||||||
about.setText(Html.fromHtml(getString(R.string.about_desc)));
|
about.setText(Html.fromHtml(getString(R.string.about_desc)));
|
||||||
|
@ -60,4 +60,4 @@ public class AboutDialogFragment
|
||||||
return builder.create();
|
return builder.create();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class SettingsFragment extends PreferenceFragment
|
||||||
// About preference
|
// About preference
|
||||||
String nameAndVersion = getActivity().getString(R.string.app_name);
|
String nameAndVersion = getActivity().getString(R.string.app_name);
|
||||||
try {
|
try {
|
||||||
nameAndVersion += " v" +
|
nameAndVersion += " " +
|
||||||
getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
|
getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
|
||||||
} catch (PackageManager.NameNotFoundException exc) {
|
} catch (PackageManager.NameNotFoundException exc) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue