Define the versionName shown in settings from git

Remove extra prepended "v" from version string
This commit is contained in:
Daniel Levin 2015-12-12 20:18:13 +01:00
parent 4d7acd80d0
commit ca5023bae7
3 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,15 @@
apply plugin: 'com.android.application'
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
@ -9,7 +19,7 @@ android {
minSdkVersion 15
targetSdkVersion 22
versionCode 12
versionName "1.5.0"
versionName = getVersionName()
}
File keystoreFile = file('keystore.properties')

View File

@ -40,7 +40,7 @@ public class AboutDialogFragment
versionName = null;
}
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);
about.setText(Html.fromHtml(getString(R.string.about_desc)));
@ -60,4 +60,4 @@ public class AboutDialogFragment
return builder.create();
}
}
}

View File

@ -118,7 +118,7 @@ public class SettingsFragment extends PreferenceFragment
// About preference
String nameAndVersion = getActivity().getString(R.string.app_name);
try {
nameAndVersion += " v" +
nameAndVersion += " " +
getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException exc) {
}