MinutesNumberPicker

This commit is contained in:
Milos Kozak 2020-07-27 21:11:57 +02:00
parent b7221aa286
commit 400e9399a5
32 changed files with 113 additions and 658 deletions

View file

@ -62,7 +62,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
override fun submit(): Boolean { override fun submit(): Boolean {
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin.text) 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 actions: LinkedList<String> = LinkedList()
val insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value() val insulinAfterConstraint = constraintChecker.applyExtendedBolusConstraints(Constraint(insulin)).value()
actions.add(resourceHelper.gs(R.string.formatinsulinunits, insulinAfterConstraint)) actions.add(resourceHelper.gs(R.string.formatinsulinunits, insulinAfterConstraint))

View file

@ -83,7 +83,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
override fun submit(): Boolean { override fun submit(): Boolean {
var percent = 0 var percent = 0
var absolute = 0.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 profile = profileFunction.getProfile() ?: return false
val actions: LinkedList<String> = LinkedList() val actions: LinkedList<String> = LinkedList()
if (isPercentPump) { if (isPercentPump) {

View file

@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.NumberPicker import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat import java.text.DecimalFormat
import javax.inject.Inject import javax.inject.Inject

View file

@ -9,7 +9,7 @@ import android.widget.Spinner
import androidx.annotation.StringRes import androidx.annotation.StringRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R 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 info.nightscout.androidaps.utils.resources.ResourceHelper
import java.text.DecimalFormat import java.text.DecimalFormat
import java.util.* import java.util.*

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout import android.widget.LinearLayout
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.utils.NumberPicker import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat import java.text.DecimalFormat
class InputDouble(injector: HasAndroidInjector) : Element(injector) { class InputDouble(injector: HasAndroidInjector) : Element(injector) {

View file

@ -3,7 +3,8 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout import android.widget.LinearLayout
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R 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 import java.text.DecimalFormat
class InputDuration(injector: HasAndroidInjector) : Element(injector) { class InputDuration(injector: HasAndroidInjector) : Element(injector) {
@ -20,11 +21,14 @@ class InputDuration(injector: HasAndroidInjector) : Element(injector) {
var value: Int = 0 var value: Int = 0
override fun addToLayout(root: LinearLayout) { override fun addToLayout(root: LinearLayout) {
val numberPicker = NumberPicker(root.context, null) val numberPicker : NumberPicker
if (unit == TimeUnit.MINUTES) 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)) 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.setParams(0.0, 0.0, 24.0, 1.0, DecimalFormat("0"), false, root.findViewById(R.id.ok))
}
numberPicker.value = value.toDouble() numberPicker.value = value.toDouble()
numberPicker.setOnValueChangedListener { value: Double -> this.value = value.toInt() } numberPicker.setOnValueChangedListener { value: Double -> this.value = value.toInt() }
root.addView(numberPicker) root.addView(numberPicker)

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout import android.widget.LinearLayout
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.utils.NumberPicker import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat import java.text.DecimalFormat
class InputInsulin(injector: HasAndroidInjector) : Element(injector) { class InputInsulin(injector: HasAndroidInjector) : Element(injector) {

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.widget.LinearLayout import android.widget.LinearLayout
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.utils.NumberPicker import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat import java.text.DecimalFormat
class InputPercent(injector: HasAndroidInjector) : Element(injector) { class InputPercent(injector: HasAndroidInjector) : Element(injector) {

View file

@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.NumberPicker import info.nightscout.androidaps.utils.ui.NumberPicker
import java.text.DecimalFormat import java.text.DecimalFormat
import javax.inject.Inject import javax.inject.Inject

View file

@ -11,7 +11,7 @@ import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.setupwizard.SWNumberValidator 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 info.nightscout.androidaps.utils.SafeParse
import java.text.DecimalFormat import java.text.DecimalFormat
import javax.inject.Inject import javax.inject.Inject

View file

@ -1,30 +1,11 @@
package info.nightscout.androidaps.utils; package info.nightscout.androidaps.utils;
import android.content.Context; 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.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater; 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.R;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.utils.ui.NumberPicker;
/** /**
* Created by mike on 28.06.2016. * Created by mike on 28.06.2016.

View file

@ -13,24 +13,20 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat; import androidx.core.widget.TextViewCompat;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.AAPSLogger; 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. * Created by mike on 29.12.2016.

View file

@ -94,7 +94,7 @@
android:text="@string/age" android:text="@string/age"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/profilehelper_age" android:id="@+id/profilehelper_age"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -115,7 +115,7 @@
android:text="@string/tdd_total" android:text="@string/tdd_total"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/profilehelper_tdd" android:id="@+id/profilehelper_tdd"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -136,7 +136,7 @@
android:text="@string/weight_label" android:text="@string/weight_label"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/profilehelper_weight" android:id="@+id/profilehelper_weight"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -157,7 +157,7 @@
android:text="@string/basalpctfromtdd_label" android:text="@string/basalpctfromtdd_label"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/profilehelper_basalpctfromtdd" android:id="@+id/profilehelper_basalpctfromtdd"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -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>

View file

@ -66,7 +66,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_calibration_bg" android:id="@+id/overview_calibration_bg"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -89,7 +89,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.MinutesNumberPicker
android:id="@+id/overview_carbs_time" android:id="@+id/overview_carbs_time"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -122,7 +122,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_carbs_duration" android:id="@+id/overview_carbs_duration"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -155,7 +155,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_carbs_carbs" android:id="@+id/overview_carbs_carbs"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -94,7 +94,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/actions_care_bg" android:id="@+id/actions_care_bg"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -129,7 +129,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.MinutesNumberPicker
android:id="@+id/actions_care_duration" android:id="@+id/actions_care_duration"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -61,7 +61,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/actions_extendedbolus_insulin" android:id="@+id/actions_extendedbolus_insulin"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -94,7 +94,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.MinutesNumberPicker
android:id="@+id/actions_extendedbolus_duration" android:id="@+id/actions_extendedbolus_duration"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -82,7 +82,7 @@
android:text="@string/overview_insulin_label" android:text="@string/overview_insulin_label"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/fill_insulinamount" android:id="@+id/fill_insulinamount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="40dp"

View file

@ -84,7 +84,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_insulin_time" android:id="@+id/overview_insulin_time"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -117,7 +117,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_insulin_amount" android:id="@+id/overview_insulin_amount"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -62,7 +62,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.MinutesNumberPicker
android:id="@+id/overview_profileswitch_duration" android:id="@+id/overview_profileswitch_duration"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -154,7 +154,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_profileswitch_percentage" android:id="@+id/overview_profileswitch_percentage"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -187,7 +187,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_profileswitch_timeshift" android:id="@+id/overview_profileswitch_timeshift"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -62,7 +62,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/actions_tempbasal_basalpercentinput" android:id="@+id/actions_tempbasal_basalpercentinput"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -96,7 +96,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/actions_tempbasal_basalabsoluteinput" android:id="@+id/actions_tempbasal_basalabsoluteinput"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -129,7 +129,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.MinutesNumberPicker
android:id="@+id/actions_tempbasal_duration" android:id="@+id/actions_tempbasal_duration"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -85,7 +85,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_temptarget_temptarget" android:id="@+id/overview_temptarget_temptarget"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" android:layout_height="40dp"
@ -120,7 +120,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.MinutesNumberPicker
android:id="@+id/overview_temptarget_duration" android:id="@+id/overview_temptarget_duration"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -76,7 +76,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_treatment_insulin" android:id="@+id/overview_treatment_insulin"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -109,7 +109,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/overview_treatment_carbs" android:id="@+id/overview_treatment_carbs"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -65,7 +65,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/treatments_wizard_bg_input" android:id="@+id/treatments_wizard_bg_input"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />
@ -95,7 +95,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/treatments_wizard_carbs_input" android:id="@+id/treatments_wizard_carbs_input"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" android:layout_height="40dp"
@ -126,7 +126,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/treatments_wizard_correction_input" android:id="@+id/treatments_wizard_correction_input"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" android:layout_height="40dp"
@ -156,7 +156,7 @@
android:textAppearance="@android:style/TextAppearance.Material.Small" android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" /> android:textStyle="bold" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/treatments_wizard_carb_time_input" android:id="@+id/treatments_wizard_carb_time_input"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" android:layout_height="40dp"

View file

@ -198,7 +198,7 @@
android:text="@string/dia" android:text="@string/dia"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/localprofile_dia" android:id="@+id/localprofile_dia"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" android:layout_height="40dp"

View file

@ -19,13 +19,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/timelistedit_edit1" android:id="@+id/timelistedit_edit1"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginRight="5dp" /> android:layout_marginRight="5dp" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/timelistedit_edit2" android:id="@+id/timelistedit_edit2"
android:layout_width="130dp" android:layout_width="130dp"
android:layout_height="40dp" /> android:layout_height="40dp" />

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.utils; package info.nightscout.androidaps.utils.ui;
import android.text.InputType; import android.text.InputType;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;

View file

@ -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)
}
}
}
}

View file

@ -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.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -10,6 +11,7 @@ import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -20,6 +22,8 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.core.R; 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. * Created by mike on 28.06.2016.
@ -39,12 +43,14 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
Double minValue = 0d; Double minValue = 0d;
Double maxValue = 1d; Double maxValue = 1d;
Double step = 1d; Double step = 1d;
NumberFormat formater; NumberFormat formatter;
boolean allowZero = false; boolean allowZero = false;
TextWatcher textWatcher = null; TextWatcher textWatcher = null;
Button okButton = null; Button okButton = null;
protected Boolean focused = false;
private Handler mHandler; private Handler mHandler;
private ScheduledExecutorService mUpdater; private ScheduledExecutorService mUpdater;
private OnValueChangedListener mOnValueChangedListener; 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); LayoutInflater.from(context).inflate(R.layout.number_picker_layout, this, true);
} }
private void initialize(Context context) { protected void initialize(Context context) {
// set layout view // set layout view
inflate(context); inflate(context);
@ -136,7 +142,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
value = SafeParse.stringToDouble(editText.getText().toString()); if (focused) value = SafeParse.stringToDouble(editText.getText().toString());
callValueChangedListener(); callValueChangedListener();
if (okButton != null) { if (okButton != null) {
if (value > maxValue || value < minValue) 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 @Override
@ -196,7 +209,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
this.minValue = minValue; this.minValue = minValue;
this.maxValue = maxValue; this.maxValue = maxValue;
this.step = step; this.step = step;
this.formater = formater; this.formatter = formater;
this.allowZero = allowZero; this.allowZero = allowZero;
callValueChangedListener(); callValueChangedListener();
this.okButton = okButton; this.okButton = okButton;
@ -254,11 +267,11 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
updateEditText(); updateEditText();
} }
private void updateEditText() { protected void updateEditText() {
if (value == 0d && !allowZero) if (value == 0d && !allowZero)
editText.setText(""); editText.setText("");
else else
editText.setText(formater.format(value)); editText.setText(formatter.format(value));
} }
private void callValueChangedListener() { private void callValueChangedListener() {
@ -286,6 +299,9 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mUpdater == null) { if (mUpdater == null) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Service.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
editText.clearFocus();
if (v == plusButton) { if (v == plusButton) {
inc(1); inc(1);
} else { } else {

View file

@ -220,5 +220,6 @@
<!-- Ntp--> <!-- Ntp-->
<string name="timedetection">Time detection</string> <string name="timedetection">Time detection</string>
<string name="format_hour_minute">%1$dh %2$dm</string>
</resources> </resources>

View file

@ -175,7 +175,7 @@
android:text="@string/danar_screentimeout" android:text="@string/danar_screentimeout"
android:textSize="14sp" /> android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_screentimeout" android:id="@+id/danar_screentimeout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="40dp"
@ -212,7 +212,7 @@
android:text="@string/danar_backlight" android:text="@string/danar_backlight"
android:textSize="14sp" /> android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_backlight" android:id="@+id/danar_backlight"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="40dp"
@ -268,7 +268,7 @@
android:text="@string/danar_shutdown" android:text="@string/danar_shutdown"
android:textSize="14sp" /> android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_shutdown" android:id="@+id/danar_shutdown"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="40dp"
@ -305,7 +305,7 @@
android:text="@string/danar_lowreservoir" android:text="@string/danar_lowreservoir"
android:textSize="14sp" /> android:textSize="14sp" />
<info.nightscout.androidaps.utils.NumberPicker <info.nightscout.androidaps.utils.ui.NumberPicker
android:id="@+id/danar_lowreservoir" android:id="@+id/danar_lowreservoir"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="40dp"