Version-Number in settings

This commit is contained in:
AdrianLxM 2017-08-08 02:06:46 +02:00
parent 3bfecd6da8
commit 7bc0a18f6e
3 changed files with 59 additions and 0 deletions

View file

@ -1,5 +1,25 @@
apply plugin: 'com.android.application'
def generateGitBuild = { ->
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append('"')
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
stringBuilder.append('NoGitSystemAvailable')
}
stringBuilder.append('-')
stringBuilder.append((new Date()).format('yyyy.MM.dd'))
stringBuilder.append('"')
return stringBuilder.toString()
}
android {
compileSdkVersion 23
@ -11,6 +31,7 @@ android {
targetSdkVersion 23
versionCode 1
versionName "1.0.2"
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
buildTypes {
release {

View file

@ -0,0 +1,31 @@
package info.nightscout.androidaps.interaction.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.Toast;
import info.nightscout.androidaps.BuildConfig;
import preference.WearListPreference;
/**
* Created by adrian on 07/08/17.
*/
public class VersionPreference extends WearListPreference {
public VersionPreference(Context context, AttributeSet attrs) {
super(context, attrs);
entries = new CharSequence[]{BuildConfig.BUILDVERSION};
entryValues = new CharSequence[]{BuildConfig.BUILDVERSION};
}
@Override public CharSequence getSummary(@NonNull final Context context) {
return BuildConfig.BUILDVERSION;
}
@Override
public void onPreferenceClick(@NonNull Context context) {
Toast.makeText(context, "Build version:" + BuildConfig.BUILDVERSION, Toast.LENGTH_LONG).show();
}
}

View file

@ -149,4 +149,11 @@
android:title="Wizard Percentage"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
<info.nightscout.androidaps.interaction.utils.VersionPreference
android:defaultValue="1"
android:entries="@array/input_design"
android:entryValues="@array/input_design_values"
android:key="version_number"
android:summary="Input Design"
android:title="Version:" />
</PreferenceScreen>