Prepared for PR

This commit is contained in:
Andy Rozman 2019-07-12 19:29:36 +01:00
parent 264bbdee20
commit a5a36332f3
4 changed files with 28 additions and 96 deletions

View file

@ -111,14 +111,11 @@ android {
targetSdkVersion 28
multiDexEnabled true
versionCode 1500
version "medtronic-0.12.0-SNAPSHOT"
version "2.4-dev"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
buildConfigField "String", "DEV_VERSION", '"2.4-dev"'
buildConfigField "String", "DEV_DATE", '"4.7.2019"'
buildConfigField "String", "DEV_CHECKIN", '"0693a599d50843999ff4e3b1312d1f3ed5d1369b"'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// if you change minSdkVersion to less than 11, you need to change executeTask for wear

View file

@ -1,49 +0,0 @@
package info.nightscout.androidaps.plugins.general.overview;
import info.nightscout.androidaps.R;
/**
* Created by andy on 3/2/19.
*/
public enum OverviewColorScheme {
TempTargetNotSet(R.color.ribbonDefault, R.color.ribbonTextDefault, R.color.tempTargetDisabledBackground, R.color.white),
TempTargetSet(R.color.ribbonWarning, R.color.ribbonTextWarning, R.color.tempTargetBackground, R.color.black),
APS_Loop_Enabled(R.color.ribbonDefault, R.color.ribbonTextDefault, R.color.loopenabled, R.color.black),
APS_SuperBolus(R.color.ribbonWarning, R.color.ribbonTextWarning, R.color.looppumpsuspended, R.color.white),
APS_Loop_Disconnected(R.color.ribbonCritical, R.color.ribbonTextCritical, R.color.looppumpsuspended, R.color.white),
APS_Loop_Suspended(R.color.ribbonWarning, R.color.ribbonTextWarning, R.color.looppumpsuspended, R.color.white),
APS_Pump_Suspended(R.color.ribbonWarning, R.color.ribbonTextWarning, R.color.loopenabled, R.color.white),
APS_Loop_Disabled(R.color.ribbonCritical, R.color.ribbonTextCritical, R.color.loopdisabled, R.color.white),
ProfileNormal(R.color.ribbonDefault, R.color.ribbonTextDefault, R.color.gray, R.color.white),
ProfileChanged(R.color.ribbonWarning, R.color.ribbonTextWarning, R.color.gray, R.color.white),
;
int newBackground;
int newTextColor;
int oldBackground;
int oldTextColor;
OverviewColorScheme(int newBackground, int newTextColor, int oldBackground, int oldTextColor) {
this.newBackground = newBackground;
this.newTextColor = newTextColor;
this.oldBackground = oldBackground;
this.oldTextColor = oldTextColor;
}
public int getBackground(boolean isNew) {
return isNew ? this.newBackground : this.oldBackground;
}
public int getTextColor(boolean isNew) {
return isNew ? this.newTextColor : this.oldTextColor;
}
}

View file

@ -1026,28 +1026,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (Config.APS && pump.getPumpDescription().isTempBasalCapable) {
apsModeView.setVisibility(View.VISIBLE);
apsModeView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.APS_Loop_Enabled));
apsModeView.setTextColor(getTextColor(OverviewColorScheme.APS_Loop_Enabled));
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuperBolus()) {
apsModeView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.APS_SuperBolus));
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor),
loopPlugin.minutesToEndOfSuspend()));
apsModeView.setTextColor(getTextColor(OverviewColorScheme.APS_SuperBolus));
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend()));
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
} else if (loopPlugin.isDisconnected()) {
apsModeView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.APS_Loop_Disconnected));
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor),
loopPlugin.minutesToEndOfSuspend()));
apsModeView.setTextColor(getTextColor(OverviewColorScheme.APS_Loop_Disconnected));
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonCritical));
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend()));
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical));
} else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended()) {
apsModeView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.APS_Loop_Suspended));
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor),
loopPlugin.minutesToEndOfSuspend()));
apsModeView.setTextColor(getTextColor(OverviewColorScheme.APS_Loop_Suspended));
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend()));
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
} else if (pump.isSuspended()) {
apsModeView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.APS_Pump_Suspended));
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
apsModeView.setText(MainApp.gs(R.string.pumpsuspended));
apsModeView.setTextColor(getTextColor(OverviewColorScheme.APS_Pump_Suspended));
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
if (closedLoopEnabled.value()) {
apsModeView.setText(MainApp.gs(R.string.closedloop));
@ -1055,9 +1052,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
apsModeView.setText(MainApp.gs(R.string.openloop));
}
} else {
apsModeView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.APS_Loop_Disabled));
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonCritical));
apsModeView.setText(MainApp.gs(R.string.disabledloop));
apsModeView.setTextColor(getTextColor(OverviewColorScheme.APS_Loop_Disabled));
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical));
}
} else {
apsModeView.setVisibility(View.GONE);
@ -1066,16 +1063,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// temp target
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
if (tempTarget != null) {
tempTargetView.setTextColor(getTextColor(OverviewColorScheme.TempTargetSet));
tempTargetView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.TempTargetSet));
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
tempTargetView.setVisibility(View.VISIBLE);
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units)
+ " " + DateUtil.untilString(tempTarget.end()));
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end()));
} else {
tempTargetView.setTextColor(getTextColor(OverviewColorScheme.TempTargetNotSet));
tempTargetView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.TempTargetNotSet));
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units,
units));
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units));
tempTargetView.setVisibility(View.VISIBLE);
}
@ -1174,11 +1169,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
activeProfileView.setText(ProfileFunctions.getInstance().getProfileName());
if (profile.getPercentage() != 100 || profile.getTimeshift() != 0) {
activeProfileView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.ProfileChanged));
activeProfileView.setTextColor(getTextColor(OverviewColorScheme.ProfileChanged));
activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonWarning));
activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
} else {
activeProfileView.setBackgroundColor(getBackgroundColor(OverviewColorScheme.ProfileNormal));
activeProfileView.setTextColor(getTextColor(OverviewColorScheme.ProfileNormal));
activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
}
// QuickWizard button
@ -1509,17 +1504,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
Profiler.log(log, from, updateGUIStart);
}
boolean useNewRibbonColors = true;
public int getBackgroundColor(OverviewColorScheme scheme) {
return MainApp.gc(scheme.getBackground(useNewRibbonColors));
}
public int getTextColor(OverviewColorScheme scheme) {
return MainApp.gc(scheme.getTextColor(useNewRibbonColors));
}
public static void applyStatuslight(TextView view, String text, double value, double warnThreshold, double urgentThreshold, double invalid, boolean checkAscending) {
Function<Double, Boolean> check = checkAscending ? (Double threshold) -> value >= threshold : (Double threshold) -> value <= threshold;
if (value != invalid) {
@ -1537,4 +1521,4 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
}
}
}

View file

@ -46,7 +46,7 @@ private fun checkVersion() = if (isConnected()) {
Thread {
try {
val version: String? = findVersion(URL("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle").readText())
compareWithCurrentVersion(version, BuildConfig.DEV_VERSION)
compareWithCurrentVersion(version, BuildConfig.VERSION)
} catch (e: IOException) {
log.debug("Github master version check error: $e")
}