use validation lib in cpp
This commit is contained in:
parent
4857259eda
commit
80de9c0cd8
|
@ -20,6 +20,7 @@ import android.widget.LinearLayout;
|
|||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.andreabaccega.widget.FormEditText;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -50,8 +51,8 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
|||
RadioButton mmolView;
|
||||
EditText targetlowView;
|
||||
EditText targethighView;
|
||||
EditText percentageView;
|
||||
EditText timeshiftView;
|
||||
FormEditText percentageView;
|
||||
FormEditText timeshiftView;
|
||||
TextView profileView;
|
||||
TextView baseprofileIC;
|
||||
TextView baseprofileBasal;
|
||||
|
@ -75,8 +76,8 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
|||
mmolView = (RadioButton) layout.findViewById(R.id.circadianpercentageprofile_mmol);
|
||||
targetlowView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_targetlow);
|
||||
targethighView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_targethigh);
|
||||
percentageView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_percentage);
|
||||
timeshiftView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
|
||||
percentageView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_percentage);
|
||||
timeshiftView = (FormEditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
|
||||
profileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_profileview);
|
||||
baseprofileBasal = (TextView) layout.findViewById(R.id.circadianpercentageprofile_baseprofilebasal);
|
||||
baseprofileBasalLayout = (LinearLayout) layout.findViewById(R.id.circadianpercentageprofile_baseprofilebasal_layout);
|
||||
|
@ -217,15 +218,21 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
|||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
|
||||
if (SafeParse.stringToInt(percentageView.getText().toString()) == 0) {
|
||||
circadianPercentageProfilePlugin.percentage = 100;
|
||||
} else {
|
||||
circadianPercentageProfilePlugin.percentage = SafeParse.stringToInt(percentageView.getText().toString());
|
||||
if (percentageView.testValidity()) {
|
||||
if (SafeParse.stringToInt(percentageView.getText().toString()) == 0) {
|
||||
circadianPercentageProfilePlugin.percentage = 100;
|
||||
} else {
|
||||
circadianPercentageProfilePlugin.percentage = SafeParse.stringToInt(percentageView.getText().toString());
|
||||
}
|
||||
updateProfileInfo();
|
||||
}
|
||||
if (timeshiftView.testValidity()) {
|
||||
circadianPercentageProfilePlugin.timeshift = SafeParse.stringToInt(timeshiftView.getText().toString());
|
||||
updateProfileInfo();
|
||||
}
|
||||
circadianPercentageProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
|
||||
circadianPercentageProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
||||
circadianPercentageProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
||||
circadianPercentageProfilePlugin.timeshift = SafeParse.stringToInt(timeshiftView.getText().toString());
|
||||
circadianPercentageProfilePlugin.storeSettings();
|
||||
updateProfileInfo();
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
@Override
|
||||
public NSProfile getProfile() {
|
||||
|
||||
performLimitCheck();
|
||||
// performLimitCheck();
|
||||
|
||||
return convertedProfile;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:validate="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -33,9 +34,11 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@drawable/pillborder"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp">
|
||||
android:padding="5dp"
|
||||
android:backgroundTint="@color/mdtp_transparent_black"
|
||||
android:background="@drawable/pillborder"
|
||||
android:backgroundTintMode="src_over">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/circadianpercentageprofile_percentageicon"
|
||||
|
@ -44,23 +47,34 @@
|
|||
android:src="@mipmap/ic_percentage"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
|
||||
<EditText
|
||||
<com.andreabaccega.widget.FormEditText
|
||||
validate:testType="numericRange"
|
||||
validate:minNumber="50"
|
||||
validate:maxNumber="200"
|
||||
android:digits="0123456789.,"
|
||||
android:id="@+id/circadianpercentageprofile_percentage"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/percentagefactor_hint"
|
||||
android:inputType="number"/>
|
||||
|
||||
android:inputType="number"
|
||||
android:selectAllOnFocus="true"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@drawable/pillborder"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp">
|
||||
android:padding="5dp"
|
||||
android:backgroundTint="@color/mdtp_transparent_black"
|
||||
android:background="@drawable/pillborder"
|
||||
android:backgroundTintMode="src_over">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/circadianpercentageprofile_timeicon"
|
||||
|
@ -69,12 +83,17 @@
|
|||
android:src="@mipmap/ic_time"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
|
||||
<EditText
|
||||
<com.andreabaccega.widget.FormEditText
|
||||
validate:testType="numericRange"
|
||||
validate:minNumber="0"
|
||||
validate:maxNumber="24"
|
||||
android:digits="0123456789.,"
|
||||
android:id="@+id/circadianpercentageprofile_timeshift"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/timeshift_hint"
|
||||
android:inputType="number"/>
|
||||
android:inputType="number"
|
||||
android:selectAllOnFocus="true"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in a new issue