fix merge conflict

This commit is contained in:
Milos Kozak 2017-06-30 09:35:20 +02:00
commit 39c6ae5eae
45 changed files with 1700 additions and 1255 deletions

View file

@ -44,7 +44,7 @@ android {
minSdkVersion 21
targetSdkVersion 23
versionCode 1500
version "1.5"
version "1.5a"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}

View file

@ -69,7 +69,9 @@ public class BgReading implements DataPointWithLabelInterface {
public String directionToSymbol() {
String symbol = "";
if (direction.compareTo("DoubleDown") == 0) {
if (direction == null) {
symbol = "??";
} else if (direction.compareTo("DoubleDown") == 0) {
symbol = "\u21ca";
} else if (direction.compareTo("SingleDown") == 0) {
symbol = "\u2193";

View file

@ -10,6 +10,7 @@ import java.util.Date;
import java.util.Objects;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile;
@ -18,6 +19,7 @@ import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SP;
/**
* Created by mike on 21.05.2017.
@ -271,6 +273,15 @@ public class TemporaryBasal implements Interval {
public String toStringShort() {
if (isAbsolute) {
if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){
Profile profile = MainApp.getConfigBuilder().getProfile();
if(profile != null) {
double basal = profile.getBasal(System.currentTimeMillis());
if(basal != 0){
return Math.round(absoluteRate*100d/basal) + "% ";
}
}
}
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h ";
} else { // percent
return percentRate + "% ";

View file

@ -169,14 +169,14 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch);
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(manager, "NewNSTreatmentDialog");
break;
case R.id.actions_temptarget:
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
final OptionsToShow temptarget = CareportalFragment.temptarget;
temptarget.executeTempTarget = true;
newTTDialog.setOptions(temptarget);
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
newTTDialog.show(manager, "NewNSTreatmentDialog");
break;
case R.id.actions_extendedbolus:

View file

@ -100,66 +100,66 @@ public class CareportalFragment extends Fragment implements View.OnClickListener
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
switch (id) {
case R.id.careportal_bgcheck:
newDialog.setOptions(bgcheck);
newDialog.setOptions(bgcheck, R.string.careportal_bgcheck);
break;
case R.id.careportal_announcement:
newDialog.setOptions(announcement);
newDialog.setOptions(announcement, R.string.careportal_announcement);
break;
case R.id.careportal_cgmsensorinsert:
newDialog.setOptions(sensorchange);
newDialog.setOptions(sensorchange, R.string.careportal_cgmsensorinsert);
break;
case R.id.careportal_cgmsensorstart:
newDialog.setOptions(sensorstart);
newDialog.setOptions(sensorstart, R.string.careportal_cgmsensorstart);
break;
case R.id.careportal_combobolus:
newDialog.setOptions(combobolus);
newDialog.setOptions(combobolus, R.string.careportal_combobolus);
break;
case R.id.careportal_correctionbolus:
newDialog.setOptions(correctionbolus);
newDialog.setOptions(correctionbolus, R.string.careportal_correctionbolus);
break;
case R.id.careportal_carbscorrection:
newDialog.setOptions(carbcorrection);
newDialog.setOptions(carbcorrection, R.string.careportal_carbscorrection);
break;
case R.id.careportal_exercise:
newDialog.setOptions(exercise);
newDialog.setOptions(exercise, R.string.careportal_exercise);
break;
case R.id.careportal_insulincartridgechange:
newDialog.setOptions(insulinchange);
newDialog.setOptions(insulinchange, R.string.careportal_insulincartridgechange);
break;
case R.id.careportal_pumpbatterychange:
newDialog.setOptions(pumpbatterychange);
newDialog.setOptions(pumpbatterychange, R.string.careportal_pumpbatterychange);
break;
case R.id.careportal_mealbolus:
newDialog.setOptions(mealbolus);
newDialog.setOptions(mealbolus, R.string.careportal_mealbolus);
break;
case R.id.careportal_note:
newDialog.setOptions(note);
newDialog.setOptions(note, R.string.careportal_note);
break;
case R.id.careportal_profileswitch:
profileswitch.executeProfileSwitch = false;
newDialog.setOptions(profileswitch);
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
break;
case R.id.careportal_pumpsitechange:
newDialog.setOptions(sitechange);
newDialog.setOptions(sitechange, R.string.careportal_pumpsitechange);
break;
case R.id.careportal_question:
newDialog.setOptions(question);
newDialog.setOptions(question, R.string.careportal_question);
break;
case R.id.careportal_snackbolus:
newDialog.setOptions(snackbolus);
newDialog.setOptions(snackbolus, R.string.careportal_snackbolus);
break;
case R.id.careportal_tempbasalstart:
newDialog.setOptions(tempbasalstart);
newDialog.setOptions(tempbasalstart, R.string.careportal_tempbasalstart);
break;
case R.id.careportal_tempbasalend:
newDialog.setOptions(tempbasalend);
newDialog.setOptions(tempbasalend, R.string.careportal_tempbasalend);
break;
case R.id.careportal_openapsoffline:
newDialog.setOptions(openapsoffline);
newDialog.setOptions(openapsoffline, R.string.careportal_openapsoffline);
break;
case R.id.careportal_temporarytarget:
temptarget.executeTempTarget = false;
newDialog.setOptions(temptarget);
newDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
break;
default:
newDialog = null;

View file

@ -15,12 +15,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
@ -44,6 +42,8 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
@ -52,12 +52,10 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.NSUpload;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.Translator;
@ -68,53 +66,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
private Activity context;
private static OptionsToShow options;
private static String event;
Profile profile;
ProfileStore profileStore;
String units;
RelativeLayout layoutBg;
TextView eventTypeText;
LinearLayout layoutBg;
LinearLayout layoutBgSource;
RelativeLayout layoutInsulin;
RelativeLayout layoutCarbs;
RelativeLayout layoutSplit;
RelativeLayout layoutDuration;
RelativeLayout layoutPercent;
RelativeLayout layoutAbsolute;
RelativeLayout layoutCarbTime;
RelativeLayout layoutProfile;
LinearLayout layoutInsulin;
LinearLayout layoutCarbs;
LinearLayout layoutSplit;
LinearLayout layoutDuration;
LinearLayout layoutPercent;
LinearLayout layoutAbsolute;
LinearLayout layoutCarbTime;
LinearLayout layoutProfile;
LinearLayout layoutTempTarget;
Button dateButton;
Button timeButton;
Button okButton;
Button cancelButton;
TextView dateButton;
TextView timeButton;
TextView bgUnitsView;
RadioButton meterRadioButton;
RadioButton sensorRadioButton;
RadioButton otherRadioButton;
EditText notesEdit;
EditText bgInputEdit;
EditText insulinEdit;
EditText carbsEdit;
EditText percentEdit;
EditText absoluteEdit;
EditText durationeEdit;
EditText carbTimeEdit;
EditText splitEdit;
Spinner profileSpinner;
EditText low;
EditText high;
Spinner reasonSpinner;
PlusMinusEditText editBg;
PlusMinusEditText editCarbs;
PlusMinusEditText editInsulin;
PlusMinusEditText editSplit;
PlusMinusEditText editDuration;
PlusMinusEditText editPercent;
PlusMinusEditText editAbsolute;
PlusMinusEditText editCarbTime;
NumberPicker editBg;
NumberPicker editCarbs;
NumberPicker editInsulin;
NumberPicker editSplit;
NumberPicker editDuration;
NumberPicker editPercent;
NumberPicker editAbsolute;
NumberPicker editCarbTime;
NumberPicker editTemptarget;
Date eventTime;
@ -122,8 +111,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
private static HandlerThread sHandlerThread;
public void setOptions(OptionsToShow options) {
public void setOptions(OptionsToShow options, int event) {
this.options = options;
this.event = MainApp.sResources.getString(event);
}
public NewNSTreatmentDialog() {
@ -141,6 +131,12 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
super.onAttach(activity);
}
@Override
public void onDetach() {
super.onDetach();
this.context = null;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@ -148,88 +144,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
setStyle(DialogFragment.STYLE_NORMAL, getTheme());
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false);
layoutBg = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_bg_layout);
layoutBg = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bg_layout);
layoutBgSource = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bgsource_layout);
layoutInsulin = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
layoutCarbs = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
layoutSplit = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
layoutDuration = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
layoutPercent = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
layoutAbsolute = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
layoutCarbTime = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
layoutProfile = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
layoutInsulin = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
layoutCarbs = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
layoutSplit = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
layoutDuration = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
layoutPercent = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
layoutAbsolute = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
layoutCarbTime = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
layoutProfile = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
layoutTempTarget = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout);
eventTypeText = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtype);
eventTypeText.setText(event);
bgUnitsView = (TextView) view.findViewById(R.id.careportal_newnstreatment_bgunits);
meterRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_meter);
sensorRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_sensor);
otherRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_other);
profileSpinner = (Spinner) view.findViewById(R.id.careportal_newnstreatment_profile);
bgInputEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_bginput);
insulinEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_insulininput);
carbsEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
percentEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_percentinput);
percentEdit.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
layoutPercent.setVisibility(View.VISIBLE);
layoutAbsolute.setVisibility(View.GONE);
}
});
absoluteEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
absoluteEdit.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
layoutPercent.setVisibility(View.GONE);
layoutAbsolute.setVisibility(View.VISIBLE);
}
});
durationeEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_durationinput);
carbTimeEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
notesEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_notes);
splitEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_splitinput);
reasonSpinner = (Spinner) view.findViewById(R.id.careportal_newnstreatment_temptarget_reason);
low = (EditText) view.findViewById(R.id.careportal_temptarget_low);
high = (EditText) view.findViewById(R.id.careportal_temptarget_high);
eventTime = new Date();
dateButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventdate);
timeButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventtime);
dateButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventdate);
timeButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtime);
dateButton.setText(DateUtil.dateString(eventTime));
timeButton.setText(DateUtil.timeString(eventTime));
dateButton.setOnClickListener(this);
timeButton.setOnClickListener(this);
okButton = (Button) view.findViewById(R.id.ok);
okButton.setOnClickListener(this);
cancelButton = (Button) view.findViewById(R.id.cancel);
cancelButton.setOnClickListener(this);
view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
// profile
profile = MainApp.getConfigBuilder().getProfile();
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
ArrayList<CharSequence> profileList;
units = profile.getUnits();
profileList = profileStore.getProfileList();
@ -254,25 +206,20 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
// bg
bgUnitsView.setText(units);
// Set BG if not old
// BgReading lastBg = MainApp.getDbHelper().lastBg();
// Double lastBgValue = 0d;
// if (lastBg != null) {
// lastBgValue = lastBg.valueToUnits(units);
// sensorRadioButton.setChecked(true);
// } else {
// meterRadioButton.setChecked(true);
// }
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
if (profile == null)
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
else if (profile.getUnits().equals(Constants.MMOL))
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
else
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
bgInputEdit.addTextChangedListener(new TextWatcher() {
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
if (profile == null) {
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
editTemptarget.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
} else if (profile.getUnits().equals(Constants.MMOL)) {
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
editTemptarget.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
} else {
editBg.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
editTemptarget.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
}
editBg.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
@ -283,6 +230,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
if (sensorRadioButton.isChecked()) meterRadioButton.setChecked(true);
}
});
sensorRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -292,21 +240,63 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
});
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
editCarbs = new PlusMinusEditText(view, R.id.careportal_newnstreatment_carbsinput, R.id.careportal_newnstreatment_carbs_plus, R.id.careportal_newnstreatment_carbs_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
editInsulin = new PlusMinusEditText(view, R.id.careportal_newnstreatment_insulininput, R.id.careportal_newnstreatment_insulin_plus, R.id.careportal_newnstreatment_insulin_minus, 0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
editSplit = new PlusMinusEditText(view, R.id.careportal_newnstreatment_splitinput, R.id.careportal_newnstreatment_split_plus, R.id.careportal_newnstreatment_split_minus, 100d, 0d, 100d, 5d, new DecimalFormat("0"), true);
editDuration = new PlusMinusEditText(view, R.id.careportal_newnstreatment_durationinput, R.id.careportal_newnstreatment_duration_plus, R.id.careportal_newnstreatment_duration_minus, 0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false);
editSplit = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_splitinput);
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true);
editDuration = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_durationinput);
editDuration.setParams(0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false);
Integer maxPercent = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalPercentOnlyForCheckLimit);
editPercent = new PlusMinusEditText(view, R.id.careportal_newnstreatment_percentinput, R.id.careportal_newnstreatment_percent_plus, R.id.careportal_newnstreatment_percent_minus, 0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true);
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
editPercent.setParams(0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true);
editPercent.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
layoutPercent.setVisibility(View.VISIBLE);
layoutAbsolute.setVisibility(View.GONE);
}
});
Double maxAbsolute = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalAbsoluteOnlyForCheckLimit);
editAbsolute = new PlusMinusEditText(view, R.id.careportal_newnstreatment_absoluteinput, R.id.careportal_newnstreatment_absolute_plus, R.id.careportal_newnstreatment_absolute_minus, 0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true);
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true);
editAbsolute.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
layoutPercent.setVisibility(View.GONE);
layoutAbsolute.setVisibility(View.VISIBLE);
}
});
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
editCarbTime = new PlusMinusEditText(view, R.id.careportal_newnstreatment_carbtimeinput, R.id.careportal_newnstreatment_carbtime_plus, R.id.careportal_newnstreatment_carbtime_minus, 0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
showOrHide(layoutBg, options.bg);
showOrHide(layoutBgSource, options.bg);
@ -323,13 +313,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
return view;
}
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
@Override
public void onClick(View view) {
Calendar calendar = Calendar.getInstance();
@ -347,7 +330,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
dpd.show(context.getFragmentManager(), "Datepickerdialog");
break;
case R.id.careportal_newnstreatment_eventtime:
android.text.format.DateFormat df = new android.text.format.DateFormat();
TimePickerDialog tpd = TimePickerDialog.newInstance(
this,
calendar.get(Calendar.HOUR_OF_DAY),
@ -411,8 +393,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
data.put("eventType", "Sensor Start");
break;
case R.id.careportal_combobolus:
data.put("splitNow", SafeParse.stringToDouble(splitEdit.getText().toString()));
data.put("splitExt", 100 - SafeParse.stringToDouble(splitEdit.getText().toString()));
data.put("splitNow", SafeParse.stringToDouble(editSplit.getText()));
data.put("splitExt", 100 - SafeParse.stringToDouble(editSplit.getText()));
data.put("eventType", CareportalEvent.COMBOBOLUS);
break;
case R.id.careportal_correctionbolus:
@ -462,42 +444,42 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
if (!reasonSpinner.getSelectedItem().toString().equals(""))
data.put("reason", reasonSpinner.getSelectedItem().toString());
if (SafeParse.stringToDouble(low.getText().toString()) != 0d)
data.put("targetBottom", SafeParse.stringToDouble(low.getText().toString()));
if (SafeParse.stringToDouble(high.getText().toString()) != 0d)
data.put("targetTop", SafeParse.stringToDouble(high.getText().toString()));
if (SafeParse.stringToDouble(editTemptarget.getText()) != 0d) {
data.put("targetBottom", SafeParse.stringToDouble(editTemptarget.getText()));
data.put("targetTop", SafeParse.stringToDouble(editTemptarget.getText()));
}
allowZeroDuration = true;
break;
}
if (SafeParse.stringToDouble(bgInputEdit.getText().toString()) != 0d) {
data.put("glucose", SafeParse.stringToDouble(bgInputEdit.getText().toString()));
if (SafeParse.stringToDouble(editBg.getText()) != 0d) {
data.put("glucose", SafeParse.stringToDouble(editBg.getText()));
if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger");
if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor");
if (otherRadioButton.isChecked()) data.put("glucoseType", "Manual");
}
if (SafeParse.stringToDouble(carbsEdit.getText().toString()) != 0d)
data.put("carbs", SafeParse.stringToDouble(carbsEdit.getText().toString()));
if (SafeParse.stringToDouble(insulinEdit.getText().toString()) != 0d)
data.put("insulin", SafeParse.stringToDouble(insulinEdit.getText().toString()));
if (allowZeroDuration || SafeParse.stringToDouble(durationeEdit.getText().toString()) != 0d)
data.put("duration", SafeParse.stringToDouble(durationeEdit.getText().toString()));
if (SafeParse.stringToDouble(editCarbs.getText()) != 0d)
data.put("carbs", SafeParse.stringToDouble(editCarbs.getText()));
if (SafeParse.stringToDouble(editInsulin.getText()) != 0d)
data.put("insulin", SafeParse.stringToDouble(editInsulin.getText()));
if (allowZeroDuration || SafeParse.stringToDouble(editDuration.getText()) != 0d)
data.put("duration", SafeParse.stringToDouble(editDuration.getText()));
if (layoutPercent.getVisibility() != View.GONE)
data.put("percent", SafeParse.stringToDouble(percentEdit.getText().toString()));
data.put("percent", SafeParse.stringToDouble(editPercent.getText()));
if (layoutAbsolute.getVisibility() != View.GONE)
data.put("absolute", SafeParse.stringToDouble(absoluteEdit.getText().toString()));
data.put("absolute", SafeParse.stringToDouble(editAbsolute.getText()));
if (options.profile && profileSpinner.getSelectedItem() != null)
data.put("profile", profileSpinner.getSelectedItem().toString());
if (SafeParse.stringToDouble(carbTimeEdit.getText().toString()) != 0d)
data.put("preBolus", SafeParse.stringToDouble(carbTimeEdit.getText().toString()));
if (SafeParse.stringToDouble(editCarbTime.getText()) != 0d)
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
if (!notesEdit.getText().toString().equals(""))
data.put("notes", notesEdit.getText().toString());
data.put("units", units);
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
if (options.eventType == R.id.careportal_combobolus) {
Double enteredInsulin = SafeParse.stringToDouble(insulinEdit.getText().toString());
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
data.put("enteredinsulin", enteredInsulin);
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(splitEdit.getText().toString()) / 100);
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(splitEdit.getText().toString())) / 100 / SafeParse.stringToDouble(durationeEdit.getText().toString()) * 60);
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editInsulin.getText()) / 100);
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
}
} catch (JSONException e) {
e.printStackTrace();

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.ConfigBuilder;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.PowerManager;
import android.preference.PreferenceManager;
@ -45,6 +46,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@ -441,8 +443,15 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin);
bolusProgressDialog.show(((AppCompatActivity) detailedBolusInfo.context).getSupportFragmentManager(), "BolusProgress");
} else {
Intent i = new Intent();
i.putExtra("insulin", detailedBolusInfo.insulin);
i.setClass(MainApp.instance(), BolusProgressHelperActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
result = activePump.deliverTreatment(detailedBolusInfo);

View file

@ -71,7 +71,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(1000, ViewGroup.LayoutParams.WRAP_CONTENT);
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
MainApp.bus().register(this);
running = true;
if (bolusEnded) dismiss();

View file

@ -9,7 +9,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.crashlytics.android.answers.Answers;
@ -25,17 +24,15 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.XdripCalibrations;
public class CalibrationDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(CalibrationDialog.class);
Button okButton;
PlusMinusEditText bgText;
NumberPicker bgNumber;
TextView unitsView;
TextView bgView;
Context context;
@ -49,6 +46,12 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
this.context = context;
}
@Override
public void onDetach() {
super.onDetach();
this.context = null;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@ -57,20 +60,21 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
okButton = (Button) view.findViewById(R.id.overview_calibration_okbutton);
okButton.setOnClickListener(this);
view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
String units = MainApp.getConfigBuilder().getProfileUnits();
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
bgNumber = (NumberPicker) view.findViewById(R.id.overview_calibration_bg);
if (units.equals(Constants.MMOL))
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
bgNumber.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
else
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
bgNumber.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
unitsView.setText(units);
bgView = (TextView) view.findViewById(R.id.overview_calibration_bg);
return view;
}
@ -78,13 +82,15 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.overview_calibration_okbutton:
final Double bg = SafeParse.stringToDouble(this.bgView.getText().toString());
;
case R.id.ok:
final Double bg = SafeParse.stringToDouble(bgNumber.getText());
XdripCalibrations.confirmAndSendCalibration(bg, context);
dismiss();
Answers.getInstance().logCustom(new CustomEvent("Calibration"));
break;
case R.id.cancel:
dismiss();
break;
}
}
}

View file

@ -29,13 +29,14 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.SafeParse;
public class NewTreatmentDialog extends DialogFragment implements OnClickListener {
PlusMinusEditText editCarbs;
PlusMinusEditText editInsulin;
NumberPicker editCarbs;
NumberPicker editInsulin;
Handler mHandler;
public static HandlerThread mHandlerThread;
@ -60,19 +61,15 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
editCarbs = new PlusMinusEditText(view, R.id.treatments_newtreatment_carbsamount, R.id.treatments_newtreatment_carbsamount_plus, R.id.treatments_newtreatment_carbsamount_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
editInsulin = new PlusMinusEditText(view, R.id.treatments_newtreatment_insulinamount, R.id.treatments_newtreatment_insulinamount_plus, R.id.treatments_newtreatment_insulinamount_minus, 0d, 0d, maxInsulin, MainApp.getConfigBuilder().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false);
editCarbs = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_carbsamount);
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
editInsulin.setParams(0d, 0d, maxInsulin, MainApp.getConfigBuilder().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false);
return view;
}
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
@Override
public void onClick(View view) {
switch (view.getId()) {

View file

@ -21,7 +21,6 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
@ -60,8 +59,8 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui
import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.OKDialog;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils;
@ -69,10 +68,7 @@ import info.nightscout.utils.ToastUtils;
public class WizardDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener, Spinner.OnItemSelectedListener {
private static Logger log = LoggerFactory.getLogger(WizardDialog.class);
Button wizardDialogDeliverButton;
TextView correctionInput;
TextView carbsInput;
TextView bgInput;
Button okButton;
TextView bg;
TextView bgInsulin;
TextView bgUnits;
@ -85,8 +81,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
CheckBox basalIobCheckbox;
TextView correctionInsulin;
TextView total;
TextView totalInsulin;
EditText carbTimeEdit;
Spinner profileSpinner;
CheckBox superbolusCheckbox;
TextView superbolus;
@ -99,10 +93,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
TextView cob;
TextView cobInsulin;
PlusMinusEditText editBg;
PlusMinusEditText editCarbs;
PlusMinusEditText editCorr;
PlusMinusEditText editCarbTime;
NumberPicker editBg;
NumberPicker editCarbs;
NumberPicker editCorr;
NumberPicker editCarbTime;
Integer calculatedCarbs = 0;
Double calculatedTotalInsulin = 0d;
@ -127,11 +121,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
this.context = context;
}
@Override
public void onDetach() {
super.onDetach();
this.context = null;
}
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
super.onPause();
MainApp.bus().register(this);
}
@ -195,8 +193,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
wizardDialogDeliverButton = (Button) view.findViewById(R.id.treatments_wizard_deliverButton);
wizardDialogDeliverButton.setOnClickListener(this);
okButton = (Button) view.findViewById(R.id.ok);
okButton.setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
bg = (TextView) view.findViewById(R.id.treatments_wizard_bg);
bgInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bginsulin);
@ -207,8 +206,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
basalIobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_basaliobinsulin);
correctionInsulin = (TextView) view.findViewById(R.id.treatments_wizard_correctioninsulin);
total = (TextView) view.findViewById(R.id.treatments_wizard_total);
totalInsulin = (TextView) view.findViewById(R.id.treatments_wizard_totalinsulin);
carbTimeEdit = (EditText) view.findViewById(R.id.treatments_wizard_carbtimeinput);
superbolus = (TextView) view.findViewById(R.id.treatments_wizard_sb);
superbolusInsulin = (TextView) view.findViewById(R.id.treatments_wizard_sbinsulin);
@ -236,22 +233,20 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
profileSpinner = (Spinner) view.findViewById(R.id.treatments_wizard_profile);
profileSpinner.setOnItemSelectedListener(this);
correctionInput = (TextView) view.findViewById(R.id.treatments_wizard_correctioninput);
carbsInput = (TextView) view.findViewById(R.id.treatments_wizard_carbsinput);
bgInput = (TextView) view.findViewById(R.id.treatments_wizard_bginput);
correctionInput.addTextChangedListener(textWatcher);
carbsInput.addTextChangedListener(textWatcher);
bgInput.addTextChangedListener(textWatcher);
editCarbTime = (NumberPicker) view.findViewById(R.id.treatments_wizard_carbtimeinput);
editCorr = (NumberPicker) view.findViewById(R.id.treatments_wizard_correctioninput);
editCarbs = (NumberPicker) view.findViewById(R.id.treatments_wizard_carbsinput);
editBg = (NumberPicker) view.findViewById(R.id.treatments_wizard_bginput);
superbolusCheckbox.setVisibility(SP.getBoolean(R.string.key_usesuperbolus, false) ? View.VISIBLE : View.GONE);
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
Double maxCorrection = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
editBg = new PlusMinusEditText(view, R.id.treatments_wizard_bginput, R.id.treatments_wizard_bginput_plus, R.id.treatments_wizard_bginput_minus, 0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
editCarbs = new PlusMinusEditText(view, R.id.treatments_wizard_carbsinput, R.id.treatments_wizard_carbsinput_plus, R.id.treatments_wizard_carbsinput_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
editCorr = new PlusMinusEditText(view, R.id.treatments_wizard_correctioninput, R.id.treatments_wizard_correctioninput_plus, R.id.treatments_wizard_correctioninput_minus, 0d, -maxCorrection, maxCorrection, 0.05d, new DecimalFormat("0.00"), false);
editCarbTime = new PlusMinusEditText(view, R.id.treatments_wizard_carbtimeinput, R.id.treatments_wizard_carbtime_plus, R.id.treatments_wizard_carbtime_minus, 0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
editCorr.setParams(0d, -maxCorrection, maxCorrection, 0.05d, new DecimalFormat("0.00"), false, textWatcher);
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
initDialog();
return view;
@ -265,19 +260,19 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
calculateInsulin();
wizardDialogDeliverButton.setVisibility(View.VISIBLE);
okButton.setVisibility(View.VISIBLE);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.noprofileselected));
wizardDialogDeliverButton.setVisibility(View.GONE);
okButton.setVisibility(View.GONE);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.treatments_wizard_deliverButton:
case R.id.ok:
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
String confirmMessage = getString(R.string.entertreatmentquestion);
@ -299,8 +294,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
final Double bg = SafeParse.stringToDouble(bgInput.getText().toString());
final int carbTime = SafeParse.stringToInt(carbTimeEdit.getText().toString());
final Double bg = SafeParse.stringToDouble(editBg.getText());
final int carbTime = SafeParse.stringToInt(editCarbTime.getText());
final boolean useSuperBolus = superbolusCheckbox.isChecked();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@ -350,6 +345,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
dismiss();
}
break;
case R.id.cancel:
dismiss();
break;
}
}
@ -396,17 +394,17 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
bg.setText(lastBg.valueToUnitsToString(units) + " ISF: " + DecimalFormatter.to1Decimal(sens));
bgInsulin.setText(DecimalFormatter.to2Decimal(bgDiff / sens) + "U");
bgInput.removeTextChangedListener(textWatcher);
editBg.removeTextChangedListener(textWatcher);
//bgInput.setText(lastBg.valueToUnitsToString(units));
editBg.setValue(lastBg.valueToUnits(units));
bgInput.addTextChangedListener(textWatcher);
editBg.addTextChangedListener(textWatcher);
} else {
bg.setText("");
bgInsulin.setText("");
bgInput.removeTextChangedListener(textWatcher);
editBg.removeTextChangedListener(textWatcher);
//bgInput.setText("");
editBg.setValue(0d);
bgInput.addTextChangedListener(textWatcher);
editBg.addTextChangedListener(textWatcher);
}
// IOB calculation
@ -418,9 +416,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
totalInsulin.setText("");
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
// COB only if AMA is selected
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
cobLayout.setVisibility(View.VISIBLE);
@ -429,6 +424,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
cobLayout.setVisibility(View.GONE);
cobAvailable = false;
}
calculateInsulin();
}
private void calculateInsulin() {
@ -439,23 +435,23 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
Profile specificProfile = profile.getSpecificProfile(selectedAlternativeProfile);
// Entered values
Double c_bg = SafeParse.stringToDouble(bgInput.getText().toString());
Integer c_carbs = SafeParse.stringToInt(carbsInput.getText().toString());
Double c_correction = SafeParse.stringToDouble(correctionInput.getText().toString());
Double c_bg = SafeParse.stringToDouble(editBg.getText());
Integer c_carbs = SafeParse.stringToInt(editCarbs.getText());
Double c_correction = SafeParse.stringToDouble(editCorr.getText());
Double corrAfterConstraint = MainApp.getConfigBuilder().applyBolusConstraints(c_correction);
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
correctionInput.removeTextChangedListener(textWatcher);
correctionInput.setText("");
correctionInput.addTextChangedListener(textWatcher);
editCorr.removeTextChangedListener(textWatcher);
editCorr.setValue(0d);
editCorr.addTextChangedListener(textWatcher);
//wizardDialogDeliverButton.setVisibility(Button.GONE);
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied));
return;
}
Integer carbsAfterConstraint = MainApp.getConfigBuilder().applyCarbsConstraints(c_carbs);
if (c_carbs - carbsAfterConstraint != 0) {
carbsInput.removeTextChangedListener(textWatcher);
carbsInput.setText("");
carbsInput.addTextChangedListener(textWatcher);
editCarbs.removeTextChangedListener(textWatcher);
editCarbs.setValue(0d);
editCarbs.addTextChangedListener(textWatcher);
//wizardDialogDeliverButton.setVisibility(Button.GONE);
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.carbsconstraintapplied));
return;
@ -489,14 +485,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
correctionInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCorrection) + "U");
calculatedTotalInsulin = wizard.calculatedTotalInsulin;
if (calculatedTotalInsulin <= 0) {
total.setText(getString(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g");
totalInsulin.setText("");
} else {
total.setText("");
totalInsulin.setText(DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U");
}
calculatedCarbs = carbsAfterConstraint;
// Superbolus
@ -531,10 +519,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U") : "";
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
wizardDialogDeliverButton.setText(getString(R.string.send) + " " + insulinText + " " + carbsText);
wizardDialogDeliverButton.setVisibility(Button.VISIBLE);
total.setText(getString(R.string.result) + ": " + insulinText + " " + carbsText);
okButton.setVisibility(View.VISIBLE);
} else {
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
total.setText(getString(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g");
okButton.setVisibility(View.INVISIBLE);
}
boluscalcJSON = new JSONObject();

View file

@ -1026,7 +1026,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch);
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
return true;
}
@ -1041,7 +1041,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
final OptionsToShow temptarget = CareportalFragment.temptarget;
temptarget.executeTempTarget = true;
newTTDialog.setOptions(temptarget);
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
return true;
}

View file

@ -143,7 +143,7 @@ public class CircadianPercentageProfileFragment extends Fragment {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch);
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
});

View file

@ -104,7 +104,7 @@ public class LocalProfileFragment extends Fragment {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch);
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
});

View file

@ -102,7 +102,7 @@ public class SimpleProfileFragment extends Fragment {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch);
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
});

View file

@ -35,7 +35,9 @@ import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import info.nightscout.androidaps.MainApp;
@ -73,6 +75,7 @@ public class DanaRStatsActivity extends Activity {
DecimalFormat decimalFormat;
List<DanaRHistoryRecord> historyList = new ArrayList<>();
List<DanaRHistoryRecord> dummies;
public DanaRStatsActivity() {
super();
@ -302,6 +305,34 @@ public class DanaRStatsActivity extends Activity {
private void loadDataFromDB(byte type) {
historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(type);
//only use newest 10
historyList = historyList.subList(0, Math.min(10, historyList.size()));
//fill single gaps
dummies = new LinkedList();
DateFormat df = new SimpleDateFormat("dd.MM.");
for(int i = 0; i < historyList.size()-1; i++){
DanaRHistoryRecord elem1 = historyList.get(i);
DanaRHistoryRecord elem2 = historyList.get(i+1);
if (!df.format(new Date(elem1.recordDate)).equals(df.format(new Date(elem2.recordDate + 25*60*60*1000)))){
DanaRHistoryRecord dummy = new DanaRHistoryRecord();
dummy.recordDate = elem1.recordDate - 24*60*60*1000;
dummy.recordDailyBasal = elem1.recordDailyBasal/2;
dummy.recordDailyBolus = elem1.recordDailyBolus/2;
dummies.add(dummy);
elem1.recordDailyBasal /= 2;
elem1.recordDailyBolus /= 2;
}
}
historyList.addAll(dummies);
Collections.sort(historyList, new Comparator<DanaRHistoryRecord>() {
@Override
public int compare(DanaRHistoryRecord lhs, DanaRHistoryRecord rhs) {
return (int) (rhs.recordDate-lhs.recordDate);
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
@ -332,6 +363,9 @@ public class DanaRStatsActivity extends Activity {
// Create the table row
TableRow tr = new TableRow(DanaRStatsActivity.this);
if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY);
if(dummies.contains(record)){
tr.setBackgroundColor(Color.argb(125, 255, 0, 0));
}
tr.setId(100 + i);
tr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.MATCH_PARENT,

View file

@ -182,7 +182,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
Iob tIOB = t.iobCalc(time, dia);
total.iob += tIOB.iobContrib;
total.activity += tIOB.activityContrib;
Iob bIOB = t.iobCalc(time, dia / SP.getInt("openapsama_bolussnooze_dia_divisor", 2));
Iob bIOB = t.iobCalc(time, dia / SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
total.bolussnooze += bIOB.iobContrib;
}

View file

@ -0,0 +1,248 @@
package info.nightscout.utils;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.NumberFormat;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
/**
* Created by mike on 28.06.2016.
*/
public class NumberPicker extends LinearLayout implements View.OnKeyListener,
View.OnTouchListener, View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(NumberPicker.class);
TextView editText;
Button minusButton;
Button plusButton;
Double value;
Double minValue = 0d;
Double maxValue = 1d;
Double step = 1d;
NumberFormat formater;
boolean allowZero = false;
private Handler mHandler;
private ScheduledExecutorService mUpdater;
private class UpdateCounterTask implements Runnable {
private boolean mInc;
private int repeated = 0;
private int multiplier = 1;
private final int doubleLimit = 5;
public UpdateCounterTask(boolean inc) {
mInc = inc;
}
public void run() {
Message msg = new Message();
if (repeated % doubleLimit == 0) multiplier *= 2;
repeated++;
msg.arg1 = multiplier;
msg.arg2 = repeated;
if (mInc) {
msg.what = MSG_INC;
} else {
msg.what = MSG_DEC;
}
mHandler.sendMessage(msg);
}
}
private static final int MSG_INC = 0;
private static final int MSG_DEC = 1;
public NumberPicker(Context context) {
super(context, null);
}
public NumberPicker(Context context, AttributeSet attrs) {
super(context, attrs);
this.initialize(context, attrs);
}
public NumberPicker(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
private void initialize(Context context, AttributeSet attrs) {
// set layout view
LayoutInflater.from(context).inflate(R.layout.number_picker_layout, this, true);
// init ui components
this.minusButton = (Button) findViewById(R.id.decrement);
this.plusButton = (Button) findViewById(R.id.increment);
this.editText = (EditText) findViewById(R.id.display);
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_INC:
inc(msg.arg1);
return;
case MSG_DEC:
dec(msg.arg1);
return;
}
super.handleMessage(msg);
}
};
minusButton.setOnTouchListener(this);
minusButton.setOnKeyListener(this);
minusButton.setOnClickListener(this);
plusButton.setOnTouchListener(this);
plusButton.setOnKeyListener(this);
plusButton.setOnClickListener(this);
}
public void removeTextChangedListener(TextWatcher textWatcher) {
editText.removeTextChangedListener(textWatcher);
}
public void addTextChangedListener(TextWatcher textWatcher) {
editText.addTextChangedListener(textWatcher);
}
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, TextWatcher textWatcher) {
setParams(initValue, minValue, maxValue, step, formater, allowZero);
editText.addTextChangedListener(textWatcher);
}
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero) {
this.value = initValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.step = step;
this.formater = formater;
this.allowZero = allowZero;
updateEditText();
}
public void setValue(Double value) {
this.value = value;
updateEditText();
}
public Double getValue() {
return value;
}
public String getText() {
return editText.getText().toString();
}
public void setStep(Double step) {
this.step = step;
}
private void inc(int multiplier) {
value += step * multiplier;
if (value > maxValue) {
value = maxValue;
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit));
stopUpdating();
}
updateEditText();
}
private void dec( int multiplier) {
value -= step * multiplier;
if (value < minValue) {
value = minValue;
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit));
stopUpdating();
}
updateEditText();
}
private void updateEditText() {
if (value == 0d && !allowZero)
editText.setText("");
else
editText.setText(formater.format(value));
}
private void startUpdating(boolean inc) {
if (mUpdater != null) {
log.debug("Another executor is still active");
return;
}
mUpdater = Executors.newSingleThreadScheduledExecutor();
mUpdater.scheduleAtFixedRate(new UpdateCounterTask(inc), 200, 200,
TimeUnit.MILLISECONDS);
}
private void stopUpdating() {
if (mUpdater != null) {
mUpdater.shutdownNow();
mUpdater = null;
}
}
@Override
public void onClick(View v) {
if (mUpdater == null) {
if (v == plusButton) {
inc(1);
} else {
dec(1);
}
}
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
boolean isKeyOfInterest = keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER;
boolean isReleased = event.getAction() == KeyEvent.ACTION_UP;
boolean isPressed = event.getAction() == KeyEvent.ACTION_DOWN
&& event.getAction() != KeyEvent.ACTION_MULTIPLE;
if (isKeyOfInterest && isReleased) {
stopUpdating();
} else if (isKeyOfInterest && isPressed) {
startUpdating(v == plusButton);
}
return false;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean isReleased = event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL;
boolean isPressed = event.getAction() == MotionEvent.ACTION_DOWN;
if (isReleased) {
stopUpdating();
} else if (isPressed) {
startUpdating(v == plusButton);
}
return false;
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#505050"/>
<stroke android:width="1dp" android:color="@color/colorLightGray"/>
<corners android:radius="4dp" />
</shape>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
<item android:bottom="0.5dp">
<shape
android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/colorLightGray" />
<solid android:color="@android:color/white" />
<corners android:radius="4dp" />
</shape>
</item>
</layer-list>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="130dp"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="@drawable/background_darkgray">
<Button
android:id="@+id/decrement"
android:layout_width="30dp"
android:layout_height="match_parent"
android:padding="0dp"
android:textColor="@color/mdtp_white"
android:background="@null"
android:textStyle="bold"
android:text="—"/>
<EditText
android:id="@+id/display"
android:layout_width="70dp"
android:background="@drawable/border_gray"
android:layout_height="match_parent"
android:text="1"
android:textColor="@android:color/black"
android:inputType="number"
android:gravity="center"
android:imeOptions="actionDone"
/>
<Button
android:id="@+id/increment"
android:layout_width="30dp"
android:layout_height="match_parent"
android:padding="0dp"
android:textSize="25sp"
android:textColor="@color/mdtp_white"
android:background="@null"
android:text="+"/>
</LinearLayout>

View file

@ -380,7 +380,7 @@
android:layout_weight="2"
android:gravity="center_horizontal"
android:paddingRight="5dp"
android:text="@string/openapsma_result_label"
android:text="@string/result"
android:textColor="@android:color/white"
android:textSize="14sp" />
@ -451,7 +451,7 @@
android:layout_weight="2"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/openapsma_result_label"
android:text="@string/result"
android:textSize="14sp" />
<TextView

View file

@ -335,7 +335,7 @@
android:layout_weight="2"
android:gravity="center_horizontal"
android:paddingRight="5dp"
android:text="@string/openapsma_result_label"
android:text="@string/result"
android:textColor="@android:color/white"
android:textSize="14sp" />
@ -361,7 +361,7 @@
android:layout_weight="2"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/openapsma_result_label"
android:text="@string/result"
android:textSize="14sp" />
<TextView

View file

@ -9,17 +9,13 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -29,70 +25,27 @@
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/overview_calibration_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:id="@+id/overview_calibration_units"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="@+id/overview_calibration_bg_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
<info.nightscout.utils.NumberPicker
android:id="@+id/overview_calibration_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
<ImageView
android:id="@+id/overview_calibration_bg_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<include layout="@layout/mdtp_done_button" />
</LinearLayout>
<Button
android:id="@+id/overview_calibration_okbutton"
style="?android:attr/buttonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="OK"
android:textSize="20sp"
android:layout_marginTop="30dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</FrameLayout>

View file

@ -12,135 +12,57 @@
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/bolus"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="15dp"
android:text="@string/treatments_newtreatment_insulinamount_label"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="50dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/treatments_newtreatment_insulinamount_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
<info.nightscout.utils.NumberPicker
android:id="@+id/treatments_newtreatment_insulinamount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_newtreatment_insulinamount_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_gravity="end"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="15dp"
android:text="@string/treatments_newtreatment_carbsamount_label"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/treatments_newtreatment_carbsamount_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
<info.nightscout.utils.NumberPicker
android:id="@+id/treatments_newtreatment_carbsamount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_newtreatment_carbsamount_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
</LinearLayout>
</RelativeLayout>
android:layout_marginBottom="15dp" />
<include layout="@layout/mdtp_done_button" />
</LinearLayout>
</ScrollView>
</FrameLayout>

View file

@ -11,7 +11,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
@ -26,38 +25,13 @@
android:width="120dp"
android:padding="10dp"
android:text="@string/treatments_wizard_bg_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<ImageView
android:id="@+id/treatments_wizard_bginput_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
<info.nightscout.utils.NumberPicker
android:id="@+id/treatments_wizard_bginput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_wizard_bginput_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
android:layout_width="130dp"
android:layout_height="40dp" />
<TextView
android:id="@+id/treatments_wizard_bgunits"
@ -65,7 +39,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:minWidth="40dp"
android:minWidth="45dp"
android:paddingLeft="5dp"
android:text="mg/dl"
android:textAppearance="?android:attr/textAppearanceSmall" />
@ -84,40 +58,15 @@
android:width="120dp"
android:padding="10dp"
android:text="@string/treatments_wizard_carbs_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<ImageView
android:id="@+id/treatments_wizard_carbsinput_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
<info.nightscout.utils.NumberPicker
android:id="@+id/treatments_wizard_carbsinput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal" />
<ImageView
android:id="@+id/treatments_wizard_carbsinput_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
<TextView
android:layout_width="wrap_content"
@ -143,47 +92,21 @@
android:width="120dp"
android:padding="10dp"
android:text="@string/treatments_wizard_correction_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<ImageView
android:id="@+id/treatments_wizard_correctioninput_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
<info.nightscout.utils.NumberPicker
android:id="@+id/treatments_wizard_correctioninput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberSigned|numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_wizard_correctioninput_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:minWidth="40dp"
android:minWidth="45dp"
android:paddingLeft="5dp"
android:text="@string/treatments_wizard_unit_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
@ -194,57 +117,30 @@
android:id="@+id/treatments_wizard_carbtime_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:width="120dp"
android:padding="10dp"
android:text="@string/careportal_newnstreatment_carbtime_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<ImageView
android:id="@+id/treatments_wizard_carbtime_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
<info.nightscout.utils.NumberPicker
android:id="@+id/treatments_wizard_carbtimeinput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/treatments_wizard_carbtime_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:minWidth="40dp"
android:minWidth="45dp"
android:paddingLeft="5dp"
android:text="min"
android:textAppearance="?android:attr/textAppearanceSmall" />
@ -263,7 +159,8 @@
android:layout_height="wrap_content"
android:padding="10dp"
android:text="@string/careportal_newnstreatment_profile_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<Spinner
android:id="@+id/treatments_wizard_profile"
@ -284,28 +181,34 @@
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="horizontal"
android:padding="10dp">
<Button
android:id="@+id/treatments_wizard_deliverButton"
style="?android:attr/buttonStyle"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:text="SEND TO PUMP"
android:textAllCaps="false"
android:textSize="20sp" />
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/treatments_wizard_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_darkgray"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="2.35U 28g"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<include layout="@layout/mdtp_done_button" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="-15dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -589,45 +492,5 @@
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="80dp"
android:height="30dp"
android:gravity="center_vertical"
android:text="@string/treatments_wizard_total_label"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent_material_light"
android:textStyle="bold" />
<TextView
android:id="@+id/treatments_wizard_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/treatments_wizard_totalinsulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="50dp"
android:gravity="center_vertical|end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent_material_light"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View file

@ -111,7 +111,7 @@
<string name="openapsma_nopump">Няма данни за помпа</string>
<string name="openapsma_profile_label">Профил</string>
<string name="openapsma_request_label">Искане</string>
<string name="openapsma_result_label">Резултат</string>
<string name="result">Резултат</string>
<string name="openapsma_run">Старт сега</string>
<string name="openloop_newsuggestion">Достъпно е ново предложение</string>
<string name="overview">Преглед</string>

View file

@ -111,7 +111,7 @@
<string name="openapsma_nopump">Žádná pumpa</string>
<string name="openapsma_profile_label">Profil</string>
<string name="openapsma_request_label">Požadavek</string>
<string name="openapsma_result_label">Výsledek</string>
<string name="result">Výsledek</string>
<string name="openapsma_run">Sputit teď</string>
<string name="openloop_newsuggestion">Dostupné nové doporučení</string>
<string name="overview">Přehled</string>

View file

@ -124,7 +124,7 @@
<string name="overview_extendedbolus_button">Extended Bolus</string>
<string name="overview">Übersicht</string>
<string name="openloop_newsuggestion">Neue Empfehlung verfügbar</string>
<string name="openapsma_result_label">Ergebnis</string>
<string name="result">Ergebnis</string>
<string name="openapsma_request_label">Anfrage</string>
<string name="openapsma_run">Run now</string>
<string name="openapsma_nopump">Keine Pumpe verfügbar</string>

View file

@ -60,7 +60,7 @@
<string name="openapsma_iobdata_label">IOB datos</string>
<string name="openapsma_profile_label">Perfil</string>
<string name="openapsma_mealdata_label">Datos de comidas</string>
<string name="openapsma_result_label">Resultado</string>
<string name="result">Resultado</string>
<string name="openapsma_noglucosedata">No hay disponibles datos de glucosa</string>
<string name="openapsma_noprofile">Sin perfil disponible</string>
<string name="openapsma_nopump">No se dispone de bomba</string>

View file

@ -299,7 +299,7 @@
<string name="dont_show_again">Non mostrarlo più</string>
<string name="enablesuperbolus_summary">Abilita funzionalità superbolus nella procedura guidata. Non abilitare fino a quando non impari quello che realmente fa. PUÒ CAUSARE L\'INVERTIMENTO INSULINO SE USATO BLINDLY!</string>
<string name="openapsma_request_label">Richiesta</string>
<string name="openapsma_result_label">Esito</string>
<string name="result">Esito</string>
<string name="openapsma_run">Avvia ora</string>
<string name="openloop">Apertura Loop</string>
<string name="othersettings_title">Altro</string>

View file

@ -62,7 +62,7 @@
<string name="openapsma_iobdata_label">IOB 데이터</string>
<string name="openapsma_profile_label">프로파일</string>
<string name="openapsma_mealdata_label">식사 데이터</string>
<string name="openapsma_result_label">결과</string>
<string name="result">결과</string>
<string name="openapsma_noglucosedata">혈당 데이터 없음</string>
<string name="openapsma_noprofile">프로파일 없음</string>
<string name="openapsma_nopump">No pump available</string>

View file

@ -366,7 +366,7 @@
<string name="openapsma_nopump">помпа недоступна</string>
<string name="openapsma_profile_label">профиль</string>
<string name="openapsma_request_label">запрос</string>
<string name="openapsma_result_label">результат</string>
<string name="result">результат</string>
<string name="openapsma_run">выполнить сейчас</string>
<string name="openapsma_scriptdebugdata_label">отладка скрипта</string>
<string name="openapsma_target_bg">целевое значение для расчетов</string>

View file

@ -17,6 +17,7 @@
<color name="tempbasal">#C803A9F4</color>
<color name="graphgrid">#757575</color>
<color name="updating">#50ffffff</color>
<color name="colorLightGray">#d8d8d8</color>
<color name="defaultbackground">#424242</color>

View file

@ -39,8 +39,8 @@
<string name="tempbasals_netinsulin_label_string">Ins:</string>
<string name="tempbasals_iob_label_string">IOB:</string>
<string name="tempbasals_iobtotal_label_string">Total IOB:</string>
<string name="treatments_newtreatment_insulinamount_label">Insulin amount</string>
<string name="treatments_newtreatment_carbsamount_label">Carbs amount</string>
<string name="treatments_newtreatment_insulinamount_label">Insulin</string>
<string name="treatments_newtreatment_carbsamount_label">Carbs</string>
<string name="treatments_wizard_bg_label">BG</string>
<string name="treatments_wizard_carbs_label">Carbs</string>
<string name="treatments_wizard_correction_label">Corr</string>
@ -63,7 +63,7 @@
<string name="openapsma_iobdata_label">IOB data</string>
<string name="openapsma_profile_label">Profile</string>
<string name="openapsma_mealdata_label">Meal data</string>
<string name="openapsma_result_label">Result</string>
<string name="result">Result</string>
<string name="openapsma_noglucosedata">No glucose data available</string>
<string name="openapsma_noprofile">No profile available</string>
<string name="openapsma_nopump">No pump available</string>
@ -483,7 +483,7 @@
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="nav_show_logcat">Show log</string>
<string name="overview_calibration">Calibration</string>
<string name="overview_calibration_bg_label">Calibration BG</string>
<string name="overview_calibration_bg_label">Calibration</string>
<string name="send_calibration" formatted="false">Send calibration %.1f to xDrip?</string>
<string name="xdripnotinstalled">xDrip+ not installed</string>
<string name="calibrationsent">Calibration sent to xDrip</string>
@ -532,6 +532,7 @@
<string name="key_danar_bt_name" translatable="false">danar_bt_name</string>
<string name="key_danar_password" translatable="false">danar_password</string>
<string name="key_danar_useextended" translatable="false">danar_useextended</string>
<string name="key_danar_visualizeextendedaspercentage" translatable="false">danar_visualizeextendedaspercentage"</string>
<string name="key_danarprofile_dia" translatable="false">danarprofile_dia</string>
<string name="clearlog">Clear log</string>
<string name="key_nsclientinternal_autoscroll" translatable="false">nsclientinternal_autoscroll</string>
@ -666,4 +667,5 @@
<string name="absorption_maxtime_title">Meal max absorption time</string>
<string name="absorption_maxtime_summary">Time in hours where is expected all carbs from meal will be absorbed</string>
<string name="key_rangetodisplay" translatable="false">rangetodisplay</string>
<string name="danar_visualizeextendedaspercentage_title">Visualize extended bolus as %</string>
</resources>

View file

@ -103,14 +103,14 @@
android:title="@string/openapsama_autosens_adjusttargets"
android:summary="@string/openapsama_autosens_adjusttargets_summary"/>
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:testType="floatNumericRange"
validate:minNumber="1"
validate:maxNumber="5"
validate:maxNumber="10"
android:digits="0123456789.,"
android:defaultValue="2"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="number"
android:inputType="numberDecimal"
android:maxLines="20"
android:title="@string/openapsama_bolussnooze_dia_divisor"
android:dialogMessage="@string/openapsama_bolussnooze_dia_divisor_summary"

View file

@ -17,6 +17,11 @@
android:defaultValue="false"
android:key="@string/key_danar_useextended"
android:title="@string/danar_useextended_title" />
<SwitchPreference
android:defaultValue="false"
android:dependency="@string/key_danar_useextended"
android:key="@string/key_danar_visualizeextendedaspercentage"
android:title="@string/danar_visualizeextendedaspercentage_title" />
</PreferenceCategory>
</PreferenceScreen>

View file

@ -27,6 +27,7 @@ android {
resValue "string", "label_xdrip", "AAPS"
resValue "string", "label_xdrip_large", "AAPS(Large)"
resValue "string", "label_xdrip_big_chart", "AAPS(BigChart)"
resValue "string", "label_xdrip_no_chart", "AAPS(NoChart)"
resValue "string", "label_xdrip_circle", "AAPS(Circle)"
resValue "string", "label_xdrip_activity", "AAPS Prefs."
resValue "string", "app_settings", "AAPS Settings"
@ -39,6 +40,7 @@ android {
resValue "string", "label_xdrip", "AAPS"
resValue "string", "label_xdrip_large", "AAPS(Large)"
resValue "string", "label_xdrip_big_chart", "AAPS(BigChart)"
resValue "string", "label_xdrip_no_chart", "AAPS(NoChart)"
resValue "string", "label_xdrip_circle", "AAPS(Circle)"
resValue "string", "label_xdrip_activity", "AAPS Prefs."
resValue "string", "app_settings", "AAPS Settings"

View file

@ -34,6 +34,24 @@
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<service
android:name=".watchfaces.NOChart"
android:allowEmbedded="true"
android:label="@string/label_xdrip_no_chart"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/watchface_nochart" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<service
android:name=".watchfaces.Home"
android:allowEmbedded="true"

View file

@ -0,0 +1,520 @@
package info.nightscout.androidaps.watchfaces;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Shader;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.wearable.view.WatchViewStub;
import android.support.wearable.watchface.WatchFaceStyle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.android.gms.wearable.DataMap;
import com.ustwo.clockwise.common.WatchFaceTime;
import com.ustwo.clockwise.common.WatchMode;
import com.ustwo.clockwise.common.WatchShape;
import com.ustwo.clockwise.wearable.WatchFace;
import java.util.ArrayList;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.data.TempWatchData;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
import lecho.lib.hellocharts.view.LineChartView;
/**
* Created by adrianLxM.
*/
public class NOChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
public final static IntentFilter INTENT_FILTER;
public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta;
public RelativeLayout mRelativeLayout;
public long sgvLevel = 0;
public int batteryLevel = 1;
public int ageLevel = 1;
public boolean lowResMode = false;
public boolean layoutSet = false;
public double datetime;
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
public PowerManager.WakeLock wakeLock;
public View layoutView;
private final Point displaySize = new Point();
private int specW, specH;
private int animationAngle = 0;
private boolean isAnimated = false;
private LocalBroadcastManager localBroadcastManager;
private MessageReceiver messageReceiver;
protected SharedPreferences sharedPrefs;
private String sgvString = "--";
private String externalStatusString = "no status";
private TextView statusView;
private long sgvTapTime = 0l;
@Override
public void onCreate() {
super.onCreate();
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
display.getSize(displaySize);
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
View.MeasureSpec.EXACTLY);
specH = View.MeasureSpec.makeMeasureSpec(displaySize.y,
View.MeasureSpec.EXACTLY);
sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this);
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutView = inflater.inflate(R.layout.activity_nochart, null);
performViewSetup();
}
@Override
protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) {
super.onLayout(shape, screenBounds, screenInsets);
layoutView.onApplyWindowInsets(screenInsets);
}
public void performViewSetup() {
final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
messageReceiver = new MessageReceiver();
localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTime = (TextView) stub.findViewById(R.id.watch_time);
mSgv = (TextView) stub.findViewById(R.id.sgv);
mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
mDelta = (TextView) stub.findViewById(R.id.delta);
mAvgDelta = (TextView) stub.findViewById(R.id.avgdelta);
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
statusView = (TextView) stub.findViewById(R.id.aps_status);
layoutSet = true;
showAgeAndStatus();
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
}
});
ListenerService.requestData(this);
wakeLock.acquire(50);
}
@Override
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0;
if (tapType == TAP_TYPE_TAP&&
x + extra >=mSgv.getLeft() &&
x - extra <= mSgv.getRight()&&
y >= mSgv.getTop() &&
y <= mSgv.getBottom()){
if (eventTime - sgvTapTime < 800){
Intent intent = new Intent(this, MainMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
sgvTapTime = eventTime;
}
}
protected void onWatchModeChanged(WatchMode watchMode) {
if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode
lowResMode = isLowRes(watchMode);
setColor();
} else if (! sharedPrefs.getBoolean("dark", true)){
//in bright mode: different colours if active:
setColor();
}
}
private boolean isLowRes(WatchMode watchMode) {
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN);
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build();
}
public int ageLevel() {
if(timeSince() <= (1000 * 60 * 12)) {
return 1;
} else {
return 0;
}
}
public double timeSince() {
return System.currentTimeMillis() - datetime;
}
public String readingAge(boolean shortString) {
if (datetime == 0) { return shortString?"--'":"-- Minute ago"; }
int minutesAgo = (int) Math.floor(timeSince()/(1000*60));
if (minutesAgo == 1) {
return minutesAgo + (shortString?"'":" Minute ago");
}
return minutesAgo + (shortString?"'":" Minutes ago");
}
@Override
public void onDestroy() {
if(localBroadcastManager != null && messageReceiver != null){
localBroadcastManager.unregisterReceiver(messageReceiver);}
if (sharedPrefs != null){
sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
}
super.onDestroy();
}
static {
INTENT_FILTER = new IntentFilter();
INTENT_FILTER.addAction(Intent.ACTION_TIME_TICK);
INTENT_FILTER.addAction(Intent.ACTION_TIMEZONE_CHANGED);
INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED);
}
@Override
protected void onDraw(Canvas canvas) {
if(layoutSet) {
this.mRelativeLayout.draw(canvas);
Log.d("onDraw", "draw");
}
}
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
wakeLock.acquire(50);
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(NOChart.this);
mTime.setText(timeFormat.format(System.currentTimeMillis()));
showAgeAndStatus();
if(ageLevel()<=0) {
mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else {
mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
missedReadingAlert();
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
}
}
public class MessageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getBundleExtra("data");
if (layoutSet && bundle !=null) {
DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(50);
sgvLevel = dataMap.getLong("sgvLevel");
batteryLevel = dataMap.getInt("batteryLevel");
datetime = dataMap.getDouble("timestamp");
sgvString = dataMap.getString("sgvString");
mSgv.setText(dataMap.getString("sgvString"));
if(ageLevel()<=0) {
mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else {
mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(NOChart.this);
mTime.setText(timeFormat.format(System.currentTimeMillis()));
showAgeAndStatus();
String delta = dataMap.getString("delta");
if (delta.endsWith(" mg/dl")) {
mDelta.setText(delta.substring(0, delta.length() - 6));
} else if (delta.endsWith(" mmol/l")||delta.endsWith(" mmol")) {
mDelta.setText(delta.substring(0, delta.length() - 5));
} else {
mDelta.setText(delta);
}
String avgDelta = dataMap.getString("avgDelta");
if (delta.endsWith(" mg/dl")) {
mAvgDelta.setText(avgDelta.substring(0, avgDelta.length() - 6));
} else if (avgDelta.endsWith(" mmol/l")||avgDelta.endsWith(" mmol")) {
mAvgDelta.setText(avgDelta.substring(0, avgDelta.length() - 5));
} else {
mAvgDelta.setText(avgDelta);
}
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
invalidate();
setColor();
//start animation?
// dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
if (!lowResMode && (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5")))) {
startAnimation();
}
}
//status
bundle = intent.getBundleExtra("status");
if (layoutSet && bundle != null) {
DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(50);
externalStatusString = dataMap.getString("externalStatusString");
showAgeAndStatus();
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
invalidate();
setColor();
}
//basals and temps
bundle = intent.getBundleExtra("basals");
if (layoutSet && bundle != null) {
DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(500);
loadBasalsAndTemps(dataMap);
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
invalidate();
setColor();
}
}
}
private void loadBasalsAndTemps(DataMap dataMap) {
ArrayList<DataMap> temps = dataMap.getDataMapArrayList("temps");
if (temps != null) {
tempWatchDataList = new ArrayList<>();
for (DataMap temp : temps) {
TempWatchData twd = new TempWatchData();
twd.startTime = temp.getLong("starttime");
twd.startBasal = temp.getDouble("startBasal");
twd.endTime = temp.getLong("endtime");
twd.endBasal = temp.getDouble("endbasal");
twd.amount = temp.getDouble("amount");
tempWatchDataList.add(twd);
}
}
ArrayList<DataMap> basals = dataMap.getDataMapArrayList("basals");
if (basals != null) {
basalWatchDataList = new ArrayList<>();
for (DataMap basal : basals) {
BasalWatchData bwd = new BasalWatchData();
bwd.startTime = basal.getLong("starttime");
bwd.endTime = basal.getLong("endtime");
bwd.amount = basal.getDouble("amount");
basalWatchDataList.add(bwd);
}
}
}
private void showAgeAndStatus() {
if( mTimestamp != null){
mTimestamp.setText(readingAge(true));
}
boolean showAvgDelta = sharedPrefs.getBoolean("showAvgDelta", true);
if(showAvgDelta){
mAvgDelta.setVisibility(View.VISIBLE);
} else {
mAvgDelta.setVisibility(View.GONE);
}
statusView.setText(externalStatusString);
statusView.setVisibility(View.VISIBLE);
}
public void setColor() {
if(lowResMode){
setColorLowRes();
} else if (sharedPrefs.getBoolean("dark", true)) {
setColorDark();
} else {
setColorBright();
}
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
setColor();
if(layoutSet){
showAgeAndStatus();
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
}
invalidate();
}
protected void updateRainbow() {
animationAngle = (animationAngle + 1) % 360;
//Animation matrix:
int[] rainbow = {Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE
, Color.CYAN};
Shader shader = new LinearGradient(0, 0, 0, 20, rainbow,
null, Shader.TileMode.MIRROR);
Matrix matrix = new Matrix();
matrix.setRotate(animationAngle);
shader.setLocalMatrix(matrix);
mSgv.getPaint().setShader(shader);
invalidate();
}
private synchronized void setIsAnimated(boolean isAnimated) {
this.isAnimated = isAnimated;
}
void startAnimation() {
Log.d("CircleWatchface", "start startAnimation");
Thread animator = new Thread() {
public void run() {
setIsAnimated(true);
for (int i = 0; i <= 8 * 1000 / 40; i++) {
updateRainbow();
try {
Thread.sleep(40);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
mSgv.getPaint().setShader(null);
setIsAnimated(false);
invalidate();
setColor();
System.gc();
}
};
animator.start();
}
protected void setColorLowRes() {
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
}
protected void setColorDark() {
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
if (sgvLevel == 1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
} else if (sgvLevel == 0) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
} else if (sgvLevel == -1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
}
if (ageLevel == 1) {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
} else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
}
}
protected void setColorBright() {
if (getCurrentWatchMode() == WatchMode.INTERACTIVE) {
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_bigchart_time));
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_bigchart_status));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background));
if (sgvLevel == 1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
} else if (sgvLevel == 0) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
} else if (sgvLevel == -1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
}
if (ageLevel == 1) {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_mTimestamp1));
} else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_mTimestamp));
}
} else {
setColorDark();
}
}
public void missedReadingAlert() {
int minutes_since = (int) Math.floor(timeSince()/(1000*60));
if(minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
ListenerService.requestData(this); // attempt endTime recover missing data
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_nochart"
app:roundLayout="@layout/round_activity_nochart"
tools:context=".watchfaces.Home"
tools:deviceIds="wear"/>

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:gravity="center_horizontal">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:paddingTop="5dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5dp"
android:gravity="center_horizontal">
<TextView
android:id="@+id/delta"
android:textSize="40sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:layout_marginRight="5dp" />
<TextView
android:id="@+id/sgv"
android:textSize="55sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/avgdelta"
android:textSize="40sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:layout_marginLeft="5dp" />
</LinearLayout>
<TextView
android:id="@+id/aps_status"
android:textSize="24sp"
android:text="E xU/h IOB: x (x+x)"
android:layout_width="wrap_content"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
<View
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:gravity="center_horizontal" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:gravity="center_horizontal|bottom">
<TextView
android:id="@+id/watch_time"
android:textSize="47sp"
android:text="12:00"
android:textColor="#FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginRight="6dp"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/timestamp"
android:textSize="35sp"
android:text="-- '"
android:layout_width="wrap_content"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:gravity="center_horizontal">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:paddingTop="5dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-5dp"
android:gravity="center_horizontal">
<TextView
android:id="@+id/delta"
android:textSize="40sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:layout_marginRight="5dp" />
<TextView
android:id="@+id/sgv"
android:textSize="55sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/avgdelta"
android:textSize="40sp"
android:text="---"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:layout_marginLeft="5dp" />
</LinearLayout>
<TextView
android:id="@+id/aps_status"
android:textSize="24sp"
android:text="E xU/h IOB: x (x+x)"
android:layout_width="wrap_content"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
<View
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:gravity="center_horizontal" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:gravity="center_horizontal|bottom">
<TextView
android:id="@+id/watch_time"
android:textSize="47sp"
android:text="12:00"
android:textColor="#FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginRight="6dp"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/timestamp"
android:textSize="35sp"
android:text="-- '"
android:layout_width="wrap_content"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>