MinutesNumberPicker
This commit is contained in:
parent
b7221aa286
commit
400e9399a5
32 changed files with 113 additions and 658 deletions
|
@ -62,7 +62,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun submit(): Boolean {
|
||||
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin.text)
|
||||
val durationInMinutes = SafeParse.stringToInt(actions_extendedbolus_duration.text)
|
||||
val durationInMinutes = actions_extendedbolus_duration.value.toInt()
|
||||
val actions: LinkedList<String> = LinkedList()
|
||||
val insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value()
|
||||
actions.add(resourceHelper.gs(R.string.formatinsulinunits, insulinAfterConstraint))
|
||||
|
|
|
@ -83,7 +83,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
override fun submit(): Boolean {
|
||||
var percent = 0
|
||||
var absolute = 0.0
|
||||
val durationInMinutes = SafeParse.stringToInt(actions_tempbasal_duration.text)
|
||||
val durationInMinutes = actions_tempbasal_duration.value.toInt()
|
||||
val profile = profileFunction.getProfile() ?: return false
|
||||
val actions: LinkedList<String> = LinkedList()
|
||||
if (isPercentPump) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import java.text.DecimalFormat
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import android.widget.Spinner
|
|||
import androidx.annotation.StringRes
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
|
|||
import android.widget.LinearLayout
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class InputDouble(injector: HasAndroidInjector) : Element(injector) {
|
||||
|
|
|
@ -3,7 +3,8 @@ package info.nightscout.androidaps.plugins.general.automation.elements
|
|||
import android.widget.LinearLayout
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.MinutesNumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class InputDuration(injector: HasAndroidInjector) : Element(injector) {
|
||||
|
@ -20,11 +21,14 @@ class InputDuration(injector: HasAndroidInjector) : Element(injector) {
|
|||
var value: Int = 0
|
||||
|
||||
override fun addToLayout(root: LinearLayout) {
|
||||
val numberPicker = NumberPicker(root.context, null)
|
||||
if (unit == TimeUnit.MINUTES)
|
||||
val numberPicker : NumberPicker
|
||||
if (unit == TimeUnit.MINUTES) {
|
||||
numberPicker = MinutesNumberPicker(root.context, null)
|
||||
numberPicker.setParams(0.0, 0.0, 24 * 60.0, 10.0, DecimalFormat("0"), false, root.findViewById(R.id.ok))
|
||||
else
|
||||
} else {
|
||||
numberPicker = NumberPicker(root.context, null)
|
||||
numberPicker.setParams(0.0, 0.0, 24.0, 1.0, DecimalFormat("0"), false, root.findViewById(R.id.ok))
|
||||
}
|
||||
numberPicker.value = value.toDouble()
|
||||
numberPicker.setOnValueChangedListener { value: Double -> this.value = value.toInt() }
|
||||
root.addView(numberPicker)
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
|
|||
import android.widget.LinearLayout
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class InputInsulin(injector: HasAndroidInjector) : Element(injector) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
|
|||
import android.widget.LinearLayout
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class InputPercent(injector: HasAndroidInjector) : Element(injector) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import java.text.DecimalFormat
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.Constants
|
|||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.setupwizard.SWNumberValidator
|
||||
import info.nightscout.androidaps.utils.NumberPicker
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
import info.nightscout.androidaps.utils.SafeParse
|
||||
import java.text.DecimalFormat
|
||||
import javax.inject.Inject
|
||||
|
|
|
@ -1,30 +1,11 @@
|
|||
package info.nightscout.androidaps.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
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 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;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker;
|
||||
|
||||
/**
|
||||
* Created by mike on 28.06.2016.
|
||||
|
|
|
@ -13,24 +13,20 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.utils.ui.NumberPicker;
|
||||
|
||||
/**
|
||||
* Created by mike on 29.12.2016.
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
android:text="@string/age"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/profilehelper_age"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -115,7 +115,7 @@
|
|||
android:text="@string/tdd_total"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/profilehelper_tdd"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -136,7 +136,7 @@
|
|||
android:text="@string/weight_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/profilehelper_weight"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -157,7 +157,7 @@
|
|||
android:text="@string/basalpctfromtdd_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/profilehelper_basalpctfromtdd"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -1,576 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="300dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/careportal_newnstreatment_eventtype"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="Temp target"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_bg_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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/treatments_wizard_bg_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_bginput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/careportal_newnstreatment_bgunits"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="mg/dl"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_bgsource_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/careportal_newnstreatment_meter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
android:text="@string/careportal_newnstreatment_meter" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/careportal_newnstreatment_sensor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/careportal_newnstreatment_sensor" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/careportal_newnstreatment_other"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/careportal_newnstreatment_other" />
|
||||
</RadioGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_carbs_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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/treatments_wizard_carbs_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_carbsinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="g"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_insulin_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_insulin_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_insulininput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="U"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_split_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_split_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_splitinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="%"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_temptarget_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reason"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/careportal_newnstreatment_temptarget_reason"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/target_label"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_temptarget"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_duration_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_duration_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_durationinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="min"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_percent_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_percent_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_percentinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="%"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_absolute_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_absolute_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_absoluteinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="U/h"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_carbtime_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_carbtimeinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="min"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_profile_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_profile_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/careportal_newnstreatment_profile"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_reuse_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:text=""
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/careportal_newnstreatment_reusebutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reuse"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text=" "
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_percentage_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_percentage_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_percentage"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="%"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_timeshift_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_timeshift_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
android:id="@+id/careportal_newnstreatment_timeshift"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="h"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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_notes_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/careportal_newnstreatment_notes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="180dp"
|
||||
android:inputType="text" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_eventtime_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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/event_time_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/careportal_newnstreatment_eventdate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:text="2017/05/05" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/careportal_newnstreatment_eventtime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:text="08:20pm" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/okcancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
|
@ -66,7 +66,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_calibration_bg"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.MinutesNumberPicker
|
||||
android:id="@+id/overview_carbs_time"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -122,7 +122,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_carbs_duration"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -155,7 +155,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_carbs_carbs"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/actions_care_bg"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -129,7 +129,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.MinutesNumberPicker
|
||||
android:id="@+id/actions_care_duration"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/actions_extendedbolus_insulin"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -94,7 +94,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.MinutesNumberPicker
|
||||
android:id="@+id/actions_extendedbolus_duration"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
android:text="@string/overview_insulin_label"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/fill_insulinamount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_insulin_time"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -117,7 +117,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_insulin_amount"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.MinutesNumberPicker
|
||||
android:id="@+id/overview_profileswitch_duration"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -154,7 +154,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_profileswitch_percentage"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -187,7 +187,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_profileswitch_timeshift"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/actions_tempbasal_basalpercentinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -96,7 +96,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/actions_tempbasal_basalabsoluteinput"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -129,7 +129,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.MinutesNumberPicker
|
||||
android:id="@+id/actions_tempbasal_duration"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_temptarget_temptarget"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
|
@ -120,7 +120,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.MinutesNumberPicker
|
||||
android:id="@+id/overview_temptarget_duration"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_treatment_insulin"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -109,7 +109,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/overview_treatment_carbs"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/treatments_wizard_bg_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
@ -95,7 +95,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/treatments_wizard_carbs_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
|
@ -126,7 +126,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/treatments_wizard_correction_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
|
@ -156,7 +156,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/treatments_wizard_carb_time_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
android:text="@string/dia"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/localprofile_dia"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/timelistedit_edit1"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginRight="5dp" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/timelistedit_edit2"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.utils;
|
||||
package info.nightscout.androidaps.utils.ui;
|
||||
|
||||
import android.text.InputType;
|
||||
import android.text.SpannableStringBuilder;
|
|
@ -0,0 +1,33 @@
|
|||
package info.nightscout.androidaps.utils.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextWatcher
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.View.OnFocusChangeListener
|
||||
import android.widget.Button
|
||||
import info.nightscout.androidaps.core.R
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class MinutesNumberPicker constructor(context: Context, attrs: AttributeSet? = null) : NumberPicker(context, attrs) {
|
||||
|
||||
fun setParams(initValue: Double, minValue: Double, maxValue: Double, step: Double, allowZero: Boolean, okButton: Button? = null, textWatcher: TextWatcher? = null) {
|
||||
super.setParams(initValue, minValue, maxValue, step, null, allowZero, okButton)
|
||||
}
|
||||
|
||||
override fun updateEditText() {
|
||||
if (value == 0.0 && !allowZero) editText.setText("")
|
||||
else {
|
||||
if (focused) editText.setText(DecimalFormat("0").format(value))
|
||||
else {
|
||||
val hours = (value / 60).toInt()
|
||||
val minutes = (value - hours * 60).toInt()
|
||||
val formatted =
|
||||
if (hours != 0) String.format(context.getString(R.string.format_hour_minute), hours, minutes)
|
||||
else DecimalFormat("0").format(value)
|
||||
editText.setText(formatted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.utils;
|
||||
package info.nightscout.androidaps.utils.ui;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
@ -10,6 +11,7 @@ import android.view.KeyEvent;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -20,6 +22,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import info.nightscout.androidaps.core.R;
|
||||
import info.nightscout.androidaps.utils.SafeParse;
|
||||
import info.nightscout.androidaps.utils.ToastUtils;
|
||||
|
||||
/**
|
||||
* Created by mike on 28.06.2016.
|
||||
|
@ -39,12 +43,14 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
Double minValue = 0d;
|
||||
Double maxValue = 1d;
|
||||
Double step = 1d;
|
||||
NumberFormat formater;
|
||||
NumberFormat formatter;
|
||||
boolean allowZero = false;
|
||||
TextWatcher textWatcher = null;
|
||||
|
||||
Button okButton = null;
|
||||
|
||||
protected Boolean focused = false;
|
||||
|
||||
private Handler mHandler;
|
||||
private ScheduledExecutorService mUpdater;
|
||||
private OnValueChangedListener mOnValueChangedListener;
|
||||
|
@ -93,7 +99,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
LayoutInflater.from(context).inflate(R.layout.number_picker_layout, this, true);
|
||||
}
|
||||
|
||||
private void initialize(Context context) {
|
||||
protected void initialize(Context context) {
|
||||
// set layout view
|
||||
inflate(context);
|
||||
|
||||
|
@ -136,7 +142,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
value = SafeParse.stringToDouble(editText.getText().toString());
|
||||
if (focused) value = SafeParse.stringToDouble(editText.getText().toString());
|
||||
callValueChangedListener();
|
||||
if (okButton != null) {
|
||||
if (value > maxValue || value < minValue)
|
||||
|
@ -146,6 +152,13 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
|
||||
@Override public void onFocusChange(View v, boolean hasFocus) {
|
||||
focused = hasFocus;
|
||||
updateEditText();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,7 +209,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
this.step = step;
|
||||
this.formater = formater;
|
||||
this.formatter = formater;
|
||||
this.allowZero = allowZero;
|
||||
callValueChangedListener();
|
||||
this.okButton = okButton;
|
||||
|
@ -254,11 +267,11 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
updateEditText();
|
||||
}
|
||||
|
||||
private void updateEditText() {
|
||||
protected void updateEditText() {
|
||||
if (value == 0d && !allowZero)
|
||||
editText.setText("");
|
||||
else
|
||||
editText.setText(formater.format(value));
|
||||
editText.setText(formatter.format(value));
|
||||
}
|
||||
|
||||
private void callValueChangedListener() {
|
||||
|
@ -286,6 +299,9 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mUpdater == null) {
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Service.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
editText.clearFocus();
|
||||
if (v == plusButton) {
|
||||
inc(1);
|
||||
} else {
|
|
@ -220,5 +220,6 @@
|
|||
|
||||
<!-- Ntp-->
|
||||
<string name="timedetection">Time detection</string>
|
||||
<string name="format_hour_minute">%1$dh %2$dm</string>
|
||||
|
||||
</resources>
|
|
@ -175,7 +175,7 @@
|
|||
android:text="@string/danar_screentimeout"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/danar_screentimeout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
|
@ -212,7 +212,7 @@
|
|||
android:text="@string/danar_backlight"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/danar_backlight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
|
@ -268,7 +268,7 @@
|
|||
android:text="@string/danar_shutdown"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/danar_shutdown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
|
@ -305,7 +305,7 @@
|
|||
android:text="@string/danar_lowreservoir"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<info.nightscout.androidaps.utils.NumberPicker
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/danar_lowreservoir"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
|
|
Loading…
Reference in a new issue