diff --git a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java
index 6022525afb..40c8e50c6d 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java
@@ -103,14 +103,11 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
if(LocalProfilePlugin.LOCAL_PROFILE.equals(name)){
name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
}
- //Test if name is already containing percentage or timeshift
- if (!name.endsWith("h)") || !name.endsWith("%)")) {
- if (isCPP) {
- name += "(" + percentage + "%";
- if (timeshift != 0)
- name += "," + timeshift + "h";
- name += ")";
- }
+ if (isCPP) {
+ name += "(" + percentage + "%";
+ if (timeshift != 0)
+ name += "," + timeshift + "h";
+ name += ")";
}
return name;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java
index f81a7201c6..c2ab2bdfdb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java
@@ -109,7 +109,7 @@ public class ConfigBuilderFragment extends SubscriberFragment {
createViewsForPlugins(R.string.configbuilder_sensitivity, R.string.configbuilder_sensitivity_description, PluginType.SENSITIVITY, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginType.SENSITIVITY));
createViewsForPlugins(R.string.configbuilder_aps, R.string.configbuilder_aps_description, PluginType.APS, MainApp.getSpecificPluginsVisibleInList(PluginType.APS));
createViewsForPlugins(R.string.configbuilder_loop, R.string.configbuilder_loop_description, PluginType.LOOP, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP));
- createViewsForPlugins(R.string.configbuilder_constraints, R.string.configbuilder_constraints_description, PluginType.CONSTRAINTS, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginType.CONSTRAINTS));
+ createViewsForPlugins(R.string.constraints, R.string.configbuilder_constraints_description, PluginType.CONSTRAINTS, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginType.CONSTRAINTS));
createViewsForPlugins(R.string.configbuilder_treatments, R.string.configbuilder_treatments_description, PluginType.TREATMENT, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT));
createViewsForPlugins(R.string.configbuilder_general, R.string.configbuilder_general_description, PluginType.GENERAL, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL));
}
diff --git a/app/src/main/java/info/nightscout/utils/PercentageSplitter.java b/app/src/main/java/info/nightscout/utils/PercentageSplitter.java
index 53e50466b5..40dfdf2455 100644
--- a/app/src/main/java/info/nightscout/utils/PercentageSplitter.java
+++ b/app/src/main/java/info/nightscout/utils/PercentageSplitter.java
@@ -8,14 +8,23 @@ import java.util.regex.Pattern;
*/
public class PercentageSplitter {
+ // "Profile name (200%,2h)"
+ private static final Pattern percentagePattern = Pattern.compile("(.+)\\(\\d+%,\\d+h\\)");
+ // "Profile name (200%)"
+ private static final Pattern percentageShiftPattern = Pattern.compile("(.+)\\(\\d+%\\)");
+
+ /** Removes the suffix for percentage and timeshift from a profile name. */
public static String pureName(String name) {
- String newName = name;
- String s = "(.*)\\((\\d+)\\%\\)";
- Pattern r = Pattern.compile(s);
- Matcher m = r.matcher(name);
- if (m.find()) {
- newName = m.group(1);
+ Matcher percentageMatch = percentagePattern.matcher(name);
+ if (percentageMatch.find()) {
+ return percentageMatch.group(1).trim();
}
- return newName;
+
+ Matcher percentageShiftMatch = percentageShiftPattern.matcher(name);
+ if (percentageShiftMatch.find()) {
+ return percentageShiftMatch.group(1).trim();
+ }
+
+ return name;
}
}
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 79f99310c1..cda8cc8a59 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -88,7 +88,6 @@
Konfigurationsverktyg
APS
BG-källa
- Begränsningar
Generella inställningar
Insulin
Loop
diff --git a/app/src/test/java/info/nightscout/utils/PercentageSplitterTest.java b/app/src/test/java/info/nightscout/utils/PercentageSplitterTest.java
index d70edd3a0d..7fa7190d5a 100644
--- a/app/src/test/java/info/nightscout/utils/PercentageSplitterTest.java
+++ b/app/src/test/java/info/nightscout/utils/PercentageSplitterTest.java
@@ -14,7 +14,12 @@ public class PercentageSplitterTest {
}
@Test
- public void pureNameTest() throws Exception {
+ public void pureNameTestPercentageOnly() {
assertEquals("Fiasp", PercentageSplitter.pureName("Fiasp(101%)"));
}
+
+ @Test
+ public void pureNameTestPercentageAndShift() {
+ assertEquals("Fiasp", PercentageSplitter.pureName("Fiasp (101%,2h)"));
+ }
}