Merge pull request #463 from AdrianLxM/mr-profileRhino
sum on name for LP
This commit is contained in:
commit
d1a9398451
2 changed files with 25 additions and 19 deletions
|
@ -16,7 +16,9 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
|
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfilePlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_PROFILESWITCHES)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_PROFILESWITCHES)
|
||||||
public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
|
@ -66,6 +68,9 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
|
|
||||||
public String getCustomizedName() {
|
public String getCustomizedName() {
|
||||||
String name = profileName;
|
String name = profileName;
|
||||||
|
if(LocalProfilePlugin.LOCAL_PROFILE.equals(name)){
|
||||||
|
name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
|
||||||
|
}
|
||||||
if (isCPP) {
|
if (isCPP) {
|
||||||
name += "(" + percentage + "%," + timeshift + "h)";
|
name += "(" + percentage + "%," + timeshift + "h)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.utils.SP;
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
|
public static final String LOCAL_PROFILE = "LocalProfile";
|
||||||
private static Logger log = LoggerFactory.getLogger(LocalProfilePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(LocalProfilePlugin.class);
|
||||||
|
|
||||||
private boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
@ -110,14 +111,14 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
public void storeSettings() {
|
public void storeSettings() {
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
editor.putBoolean("LocalProfile" + "mmol", mmol);
|
editor.putBoolean(LOCAL_PROFILE + "mmol", mmol);
|
||||||
editor.putBoolean("LocalProfile" + "mgdl", mgdl);
|
editor.putBoolean(LOCAL_PROFILE + "mgdl", mgdl);
|
||||||
editor.putString("LocalProfile" + "dia", dia.toString());
|
editor.putString(LOCAL_PROFILE + "dia", dia.toString());
|
||||||
editor.putString("LocalProfile" + "ic", ic.toString());
|
editor.putString(LOCAL_PROFILE + "ic", ic.toString());
|
||||||
editor.putString("LocalProfile" + "isf", isf.toString());
|
editor.putString(LOCAL_PROFILE + "isf", isf.toString());
|
||||||
editor.putString("LocalProfile" + "basal", basal.toString());
|
editor.putString(LOCAL_PROFILE + "basal", basal.toString());
|
||||||
editor.putString("LocalProfile" + "targetlow", targetLow.toString());
|
editor.putString(LOCAL_PROFILE + "targetlow", targetLow.toString());
|
||||||
editor.putString("LocalProfile" + "targethigh", targetHigh.toString());
|
editor.putString(LOCAL_PROFILE + "targethigh", targetHigh.toString());
|
||||||
|
|
||||||
editor.apply();
|
editor.apply();
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
|
@ -129,11 +130,11 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
if (Config.logPrefsChange)
|
if (Config.logPrefsChange)
|
||||||
log.debug("Loading stored settings");
|
log.debug("Loading stored settings");
|
||||||
|
|
||||||
mgdl = SP.getBoolean("LocalProfile" + "mgdl", false);
|
mgdl = SP.getBoolean(LOCAL_PROFILE + "mgdl", false);
|
||||||
mmol = SP.getBoolean("LocalProfile" + "mmol", true);
|
mmol = SP.getBoolean(LOCAL_PROFILE + "mmol", true);
|
||||||
dia = SP.getDouble("LocalProfile" + "dia", Constants.defaultDIA);
|
dia = SP.getDouble(LOCAL_PROFILE + "dia", Constants.defaultDIA);
|
||||||
try {
|
try {
|
||||||
ic = new JSONArray(SP.getString("LocalProfile" + "ic", DEFAULTARRAY));
|
ic = new JSONArray(SP.getString(LOCAL_PROFILE + "ic", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
try {
|
try {
|
||||||
ic = new JSONArray(DEFAULTARRAY);
|
ic = new JSONArray(DEFAULTARRAY);
|
||||||
|
@ -141,7 +142,7 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
isf = new JSONArray(SP.getString("LocalProfile" + "isf", DEFAULTARRAY));
|
isf = new JSONArray(SP.getString(LOCAL_PROFILE + "isf", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
try {
|
try {
|
||||||
isf = new JSONArray(DEFAULTARRAY);
|
isf = new JSONArray(DEFAULTARRAY);
|
||||||
|
@ -149,7 +150,7 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
basal = new JSONArray(SP.getString("LocalProfile" + "basal", DEFAULTARRAY));
|
basal = new JSONArray(SP.getString(LOCAL_PROFILE + "basal", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
try {
|
try {
|
||||||
basal = new JSONArray(DEFAULTARRAY);
|
basal = new JSONArray(DEFAULTARRAY);
|
||||||
|
@ -157,7 +158,7 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
targetLow = new JSONArray(SP.getString("LocalProfile" + "targetlow", DEFAULTARRAY));
|
targetLow = new JSONArray(SP.getString(LOCAL_PROFILE + "targetlow", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
try {
|
try {
|
||||||
targetLow = new JSONArray(DEFAULTARRAY);
|
targetLow = new JSONArray(DEFAULTARRAY);
|
||||||
|
@ -165,7 +166,7 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
targetHigh = new JSONArray(SP.getString("LocalProfile" + "targethigh", DEFAULTARRAY));
|
targetHigh = new JSONArray(SP.getString(LOCAL_PROFILE + "targethigh", DEFAULTARRAY));
|
||||||
} catch (JSONException e1) {
|
} catch (JSONException e1) {
|
||||||
try {
|
try {
|
||||||
targetHigh = new JSONArray(DEFAULTARRAY);
|
targetHigh = new JSONArray(DEFAULTARRAY);
|
||||||
|
@ -219,7 +220,7 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
JSONObject profile = new JSONObject();
|
JSONObject profile = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json.put("defaultProfile", "LocalProfile");
|
json.put("defaultProfile", LOCAL_PROFILE);
|
||||||
json.put("store", store);
|
json.put("store", store);
|
||||||
profile.put("dia", dia);
|
profile.put("dia", dia);
|
||||||
profile.put("carbratio", ic);
|
profile.put("carbratio", ic);
|
||||||
|
@ -228,12 +229,12 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
profile.put("target_low", targetLow);
|
profile.put("target_low", targetLow);
|
||||||
profile.put("target_high", targetHigh);
|
profile.put("target_high", targetHigh);
|
||||||
profile.put("units", mgdl ? Constants.MGDL : Constants.MMOL);
|
profile.put("units", mgdl ? Constants.MGDL : Constants.MMOL);
|
||||||
store.put("LocalProfile", profile);
|
store.put(LOCAL_PROFILE, profile);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
convertedProfile = new ProfileStore(json);
|
convertedProfile = new ProfileStore(json);
|
||||||
convertedProfileName = "LocalProfile";
|
convertedProfileName = LOCAL_PROFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue