diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java
index 2cb22a29fd..3e9026331b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java
@@ -65,12 +65,12 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.circadianpercentageprofile_fragment, container, false);
- diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
- mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
- mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
- carView = (EditText) layout.findViewById(R.id.simpleprofile_car);
- targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
- targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
+ diaView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_dia);
+ mgdlView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mgdl);
+ mmolView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mmol);
+ carView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_car);
+ targetlowView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_targetlow);
+ targethighView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_targethigh);
percentageView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_percentage);
timeshiftView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
profileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_profileview);
@@ -133,7 +133,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
@Override
public void onFocusChange(View view, boolean b) {
if(b)
- ToastUtils.showToastInUiThread(getContext(), "Time in hours by which the profile will be shifted round robin.");
+ ToastUtils.showToastInUiThread(getContext(), getString(R.string.timeshift_hint));
}
});
@@ -142,7 +142,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
@Override
public void onFocusChange(View view, boolean b) {
if(b)
- ToastUtils.showToastInUiThread(getContext(), "Percentage factor by which the base profile will be multiplied.");
+ ToastUtils.showToastInUiThread(getContext(), getString(R.string.percentagefactor_hint));
}
});
@@ -169,24 +169,24 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
basaleditIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- BasalEditDialog basalEditDialog = new BasalEditDialog(getPlugin().basebasal, "Edit Base-Basal:");
- basalEditDialog.show(getFragmentManager(), "Edit Basal");
+ BasalEditDialog basalEditDialog = new BasalEditDialog(getPlugin().basebasal, getString(R.string.edit_base_basal));
+ basalEditDialog.show(getFragmentManager(), getString(R.string.edit_base_basal));
}
});
isfeditIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- BasalEditDialog basalEditDialog = new BasalEditDialog(getPlugin().baseisf, "Edit Base-ISF:");
- basalEditDialog.show(getFragmentManager(), "Edit ISF");
+ BasalEditDialog basalEditDialog = new BasalEditDialog(getPlugin().baseisf, getString(R.string.edit_base_isf));
+ basalEditDialog.show(getFragmentManager(), getString(R.string.edit_base_isf));
}
});
iceditIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- BasalEditDialog basalEditDialog = new BasalEditDialog(getPlugin().baseic, "Edit Base-IC:");
- basalEditDialog.show(getFragmentManager(), "Edit IC");
+ BasalEditDialog basalEditDialog = new BasalEditDialog(getPlugin().baseic, getString(R.string.edit_base_ic));
+ basalEditDialog.show(getFragmentManager(), getString(R.string.edit_base_ic));
}
});
@@ -234,16 +234,23 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
private void updateProfileInfo() {
StringBuilder sb = new StringBuilder();
sb.append("
");
- sb.append("Active Profile:");
+ sb.append(getString(R.string.nsprofileview_activeprofile_label));
sb.append("
");
- sb.append("Basal:
" + circadianPercentageProfilePlugin.basalString());
- sb.append("IC:
" + circadianPercentageProfilePlugin.icString());
- sb.append("ISF:
" + circadianPercentageProfilePlugin.isfString());
+ sb.append("");
+ sb.append(getString(R.string.nsprofileview_basal_label));
+ sb.append("
" + circadianPercentageProfilePlugin.basalString());
+ sb.append("");
+ sb.append(getString(R.string.nsprofileview_ic_label));
+ sb.append("
" + circadianPercentageProfilePlugin.icString());
+ sb.append("");
+ sb.append(getString(R.string.nsprofileview_isf_label));
+ sb.append("
" + circadianPercentageProfilePlugin.isfString());
profileView.setText(Html.fromHtml(sb.toString()));
- baseprofileBasal.setText(Html.fromHtml("Base Profile:
Basal:
" + circadianPercentageProfilePlugin.baseBasalString()));
- baseprofileIC.setText(Html.fromHtml("IC:
" + circadianPercentageProfilePlugin.baseIcString()));
- baseprofileISF.setText(Html.fromHtml("ISF:
" + circadianPercentageProfilePlugin.baseIsfString()));
+ baseprofileBasal.setText(Html.fromHtml("" + getString(R.string.base_profile_label) + "
" +
+ "" + getString(R.string.nsprofileview_basal_label) + "
" + circadianPercentageProfilePlugin.baseBasalString()));
+ baseprofileIC.setText(Html.fromHtml("" + getString(R.string.nsprofileview_ic_label) + "
" + circadianPercentageProfilePlugin.baseIcString()));
+ baseprofileISF.setText(Html.fromHtml("" + getString(R.string.nsprofileview_isf_label) + "
" + circadianPercentageProfilePlugin.baseIsfString()));
}
private class BasalEditDialog extends DialogFragment{
@@ -307,7 +314,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
}
});
-
return view;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java
index 671d35c3a9..a3dcc73940 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java
@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.client.data.NSProfile;
@@ -59,9 +60,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
@Override
public String getName() {
- // TODO Adrian: stringify! (omitted to prevent merge conflicts)
- return "CPP";
- //return MainApp.instance().getString(R.string.simpleprofile);
+ return MainApp.instance().getString(R.string.circadian_percentage_profile);
}
@Override
@@ -89,7 +88,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
this.fragmentVisible = fragmentVisible;
}
- public void storeSettings() {
+ void storeSettings() {
if (Config.logPrefsChange)
log.debug("Storing settings");
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
@@ -100,11 +99,11 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
editor.putString(SETTINGS_PREFIX + "car", car.toString());
editor.putString(SETTINGS_PREFIX + "targetlow", targetLow.toString());
editor.putString(SETTINGS_PREFIX + "targethigh", targetHigh.toString());
- editor.putString(SETTINGS_PREFIX + "timeshift", timeshift+"");
- editor.putString(SETTINGS_PREFIX + "percentage", percentage+"");
+ editor.putString(SETTINGS_PREFIX + "timeshift", timeshift + "");
+ editor.putString(SETTINGS_PREFIX + "percentage", percentage + "");
- for (int i = 0; i<24; i++) {
+ for (int i = 0; i < 24; i++) {
editor.putString(SETTINGS_PREFIX + "basebasal" + i, DecimalFormatter.to2Decimal(basebasal[i]));
editor.putString(SETTINGS_PREFIX + "baseisf" + i, DecimalFormatter.to2Decimal(baseisf[i]));
editor.putString(SETTINGS_PREFIX + "baseic" + i, DecimalFormatter.to2Decimal(baseic[i]));
@@ -113,12 +112,12 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
createConvertedProfile();
}
- private void loadSettings() {
+ void loadSettings() {
if (Config.logPrefsChange)
log.debug("Loading stored settings");
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
- if (settings.contains(SETTINGS_PREFIX+ "mgdl"))
+ if (settings.contains(SETTINGS_PREFIX + "mgdl"))
try {
mgdl = settings.getBoolean(SETTINGS_PREFIX + "mgdl", true);
} catch (Exception e) {
@@ -176,7 +175,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
}
else timeshift = 0;
- for (int i = 0; i<24; i++){
+ for (int i = 0; i < 24; i++) {
try {
basebasal[i] = SafeParse.stringToDouble(settings.getString(SETTINGS_PREFIX + "basebasal" + i, DecimalFormatter.to2Decimal(basebasal[i])));
} catch (Exception e) {
@@ -197,7 +196,8 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
createConvertedProfile();
}
- void createConvertedProfile() {
+
+ private void createConvertedProfile() {
JSONObject json = new JSONObject();
JSONObject store = new JSONObject();
JSONObject profile = new JSONObject();
@@ -220,25 +220,25 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
json.put("store", store);
profile.put("dia", dia);
- int offset = -(timeshift%24) + 24;
+ int offset = -(timeshift % 24) + 24;
JSONArray icArray = new JSONArray();
- for (int i = 0; i<24; i++){
- icArray.put(new JSONObject().put("timeAsSeconds", i*60*60).put("value", baseic[(offset+i)%24]*100d/percentage));
+ for (int i = 0; i < 24; i++) {
+ icArray.put(new JSONObject().put("timeAsSeconds", i * 60 * 60).put("value", baseic[(offset + i) % 24] * 100d / percentage));
}
profile.put("carbratio", icArray);
profile.put("carbs_hr", car);
JSONArray isfArray = new JSONArray();
- for (int i = 0; i<24; i++){
- isfArray.put(new JSONObject().put("timeAsSeconds", i*60*60).put("value", baseisf[(offset+i)%24]*100d/percentage));
+ for (int i = 0; i < 24; i++) {
+ isfArray.put(new JSONObject().put("timeAsSeconds", i * 60 * 60).put("value", baseisf[(offset + i) % 24] * 100d / percentage));
}
profile.put("sens", isfArray);
JSONArray basalArray = new JSONArray();
- for (int i = 0; i<24; i++){
- basalArray.put(new JSONObject().put("timeAsSeconds", i*60*60).put("value", basebasal[(offset+i)%24]*percentage/100d));
+ for (int i = 0; i < 24; i++) {
+ basalArray.put(new JSONObject().put("timeAsSeconds", i * 60 * 60).put("value", basebasal[(offset + i) % 24] * percentage / 100d));
}
profile.put("basal", basalArray);
@@ -258,41 +258,47 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
return convertedProfile;
}
- public String basalString() {
+ String basalString() {
return profileString(basebasal, timeshift, percentage, true);
}
- public String icString() {
+ String icString() {
return profileString(baseic, timeshift, percentage, false);
}
- public String isfString() {
+ String isfString() {
return profileString(baseisf, timeshift, percentage, false);
}
- public String baseIcString() {
+ String baseIcString() {
return profileString(baseic, 0, 100, false);
}
- public String baseIsfString() {
+ String baseIsfString() {
return profileString(baseisf, 0, 100, false);
}
- public String baseBasalString() {
- return profileString(basebasal, 0, 100, true);
- }
+ String baseBasalString() {return profileString(basebasal, 0, 100, true);}
- private static String profileString(double[] values, int timeshift, int percentage, boolean inc){
- timeshift = -(timeshift%24) + 24;
+
+ private static String profileString(double[] values, int timeshift, int percentage, boolean inc) {
+ timeshift = -(timeshift % 24) + 24;
StringBuilder sb = new StringBuilder();
- sb.append(""); sb.append(0); sb.append("h: "); sb.append("");
- sb.append(DecimalFormatter.to2Decimal(values[(timeshift+0)%24]*(inc?percentage/100d:100d/percentage)));
- double prevVal = values[(timeshift+0)%24];
+ sb.append("");
+ sb.append(0);
+ sb.append("h: ");
+ sb.append("");
+ sb.append(DecimalFormatter.to2Decimal(values[(timeshift + 0) % 24] * (inc ? percentage / 100d : 100d / percentage)));
+ double prevVal = values[(timeshift + 0) % 24];
for (int i = 1; i < 24; i++) {
- if(prevVal != values[(timeshift+i)%24]){
- sb.append(", ");sb.append(""); sb.append(i); sb.append("h: ");sb.append("");
- sb.append(DecimalFormatter.to2Decimal(values[(timeshift+i)%24]*(inc?percentage/100d:100d/percentage)));
- prevVal = values[(timeshift+i)%24];
+ if (prevVal != values[(timeshift + i) % 24]) {
+ sb.append(", ");
+ sb.append("");
+ sb.append(i);
+ sb.append("h: ");
+ sb.append("");
+ sb.append(DecimalFormatter.to2Decimal(values[(timeshift + i) % 24] * (inc ? percentage / 100d : 100d / percentage)));
+ prevVal = values[(timeshift + i) % 24];
}
}
return sb.toString();
diff --git a/app/src/main/res/layout/circadianpercentageprofile_editbasal_dialog.xml b/app/src/main/res/layout/circadianpercentageprofile_editbasal_dialog.xml
index 90e2000aa8..ac703d6536 100644
--- a/app/src/main/res/layout/circadianpercentageprofile_editbasal_dialog.xml
+++ b/app/src/main/res/layout/circadianpercentageprofile_editbasal_dialog.xml
@@ -6,7 +6,6 @@
android:orientation="vertical"
android:padding="10dp">
-
-
-
+ android:orientation="horizontal"
+ android:padding="10dp">
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml
index 9254b6571b..da2a23b4cd 100644
--- a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml
+++ b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml
@@ -19,39 +19,37 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
- android:padding="6dp"
android:background="@color/cardColorBackground"
- android:text="Profile View"
+ android:padding="6dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
+ android:layout_gravity="center_horizontal"
+ android:orientation="horizontal">
+ android:src="@mipmap/ic_percentage"
+ android:textAppearance="?android:attr/textAppearanceMedium"/>
+ android:hint="@string/percentagefactor_hint"
+ android:inputType="number"/>
@@ -59,25 +57,24 @@
+ android:src="@mipmap/ic_time"
+ android:textAppearance="?android:attr/textAppearanceMedium"/>
+ android:hint="@string/timeshift_hint"
+ android:inputType="number"/>
@@ -87,101 +84,101 @@
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
- android:text="SEND TO PUMP"
- android:layout_gravity="center_horizontal"
+ android:text="@string/send_to_pump"
android:textColor="@color/colorProfileSwitchButton" />
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="@color/cardColorBackground"
+ android:textAppearance="?android:attr/textAppearanceSmall"/>
+ android:src="@mipmap/ic_edit"/>
+ android:orientation="horizontal"
+ android:paddingTop="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall">
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="@color/cardColorBackground"
+ android:textAppearance="?android:attr/textAppearanceSmall"/>
+ android:src="@mipmap/ic_edit"/>
+ android:orientation="horizontal"
+ android:paddingTop="5dp"
+ android:textAppearance="?android:attr/textAppearanceSmall">
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="@color/cardColorBackground"
+ android:textAppearance="?android:attr/textAppearanceSmall"/>
+ android:src="@mipmap/ic_edit"/>
@@ -203,23 +200,23 @@
+ android:text="@string/mgdl" />
+ android:text="@string/mmol" />
@@ -230,11 +227,11 @@
-
-
diff --git a/app/src/main/res/layout/circadianpercentageprofile_listelement.xml b/app/src/main/res/layout/circadianpercentageprofile_listelement.xml
index 7d013e4977..28d72b2a09 100644
--- a/app/src/main/res/layout/circadianpercentageprofile_listelement.xml
+++ b/app/src/main/res/layout/circadianpercentageprofile_listelement.xml
@@ -2,10 +2,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cardColorBackground"
+ android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:gravity="center_horizontal">
+ android:textAppearance="?android:attr/textAppearanceSmall">
+ android:layout_marginLeft="15dp"
+ android:inputType="numberDecimal"/>
+ android:layout_marginLeft="15dp"
+ android:src="@mipmap/ic_copyprev"/>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index db668d23d2..0b7b4db0f7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -347,4 +347,18 @@
Button 1
Button 2
Button 3
+ Percentage factor by which the base profile will be multiplied.
+ Time in hours by which the profile will be shifted round robin.
+ SEND TO PUMP
+ Units:
+ mg/dl
+ mmol/l
+ DIA:
+ Absorption rate:
+ Target range:
+ Edit Base-Basal:
+ Edit Base-ISF:
+ Edit Base-IC:
+ Base Profile:
+ CircadianPercentageProfile