chore: wear: plus minus view adapter
This commit is contained in:
parent
4628f3136d
commit
14d1ba80ab
19 changed files with 544 additions and 386 deletions
|
@ -56,10 +56,9 @@ class AcceptActivity : ViewSelectorActivity() {
|
|||
override fun getColumnCount(arg0: Int): Int = 2
|
||||
override fun getRowCount(): Int = 1
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
val view: View
|
||||
if (col == 0) {
|
||||
view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_text, container, false)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) {
|
||||
0 -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_text, container, false)
|
||||
val textView = view.findViewById<TextView>(R.id.message)
|
||||
val scrollView = view.findViewById<View>(R.id.message_scroll)
|
||||
textView.text = message
|
||||
|
@ -79,8 +78,11 @@ class AcceptActivity : ViewSelectorActivity() {
|
|||
false
|
||||
}
|
||||
scrollView.requestFocus()
|
||||
} else {
|
||||
view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
view
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
if (actionKey.isNotEmpty()) startService(IntentWearToMobile(this@AcceptActivity, actionKey))
|
||||
|
@ -88,8 +90,8 @@ class AcceptActivity : ViewSelectorActivity() {
|
|||
finishAffinity()
|
||||
}
|
||||
container.addView(view)
|
||||
view
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
override fun destroyItem(container: ViewGroup, row: Int, col: Int, view: Any) {
|
||||
|
@ -127,4 +129,4 @@ class AcceptActivity : ViewSelectorActivity() {
|
|||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,20 +37,23 @@ class BolusActivity : ViewSelectorActivity() {
|
|||
|
||||
val increment1 = (sp.getDouble(R.string.key_insulin_button_increment_1, 0.5) * 10).roundToInt() / 10.0
|
||||
val increment2 = (sp.getDouble(R.string.key_insulin_button_increment_2, 1.0) * 10).roundToInt() / 10.0
|
||||
val stepValues = listOf(0.1, increment1, increment2)
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
val view: View
|
||||
if (col == 0) {
|
||||
view = EditPlusMinusViewAdapter.getInflatedPlusMinusView(sp, applicationContext, container, true).root
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) {
|
||||
0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true)
|
||||
val initValue = if (editInsulin != null) SafeParse.stringToDouble(editInsulin?.editText?.text.toString()) else 0.0
|
||||
val maxBolus = sp.getDouble(getString(R.string.key_treatments_safety_max_bolus), 3.0)
|
||||
val buttons = listOf(Pair(R.id.plusbutton, 0.1), Pair(R.id.plusbutton2, increment1), Pair(R.id.plusbutton3, increment2)) // When taken form phone settings round.
|
||||
editInsulin = PlusMinusEditText(view, R.id.amountfield, buttons, R.id.minusbutton, initValue, 0.0, maxBolus, 0.1, DecimalFormat("#0.0"), false)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_insulin))
|
||||
val title = getString(R.string.action_insulin)
|
||||
editInsulin = PlusMinusEditText(viewAdapter, initValue, 0.0, maxBolus, stepValues, DecimalFormat("#0.0"), false, title)
|
||||
val view = viewAdapter.root
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
} else {
|
||||
view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
view
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
rxBus.send(EventWearToMobile(ActionBolusPreCheck(SafeParse.stringToDouble(editInsulin?.editText?.text.toString()), 0)))
|
||||
|
@ -58,8 +61,8 @@ class BolusActivity : ViewSelectorActivity() {
|
|||
finishAffinity()
|
||||
}
|
||||
container.addView(view)
|
||||
view
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
override fun destroyItem(container: ViewGroup, row: Int, col: Int, view: Any) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.shared.weardata.EventData.ActionECarbsPreCheck
|
||||
|
@ -32,26 +33,28 @@ class CarbActivity : ViewSelectorActivity() {
|
|||
|
||||
val increment1 = sp.getInt(R.string.key_carbs_button_increment_1, 5).toDouble()
|
||||
val increment2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble()
|
||||
val stepValues = listOf(1.0, increment1, increment2)
|
||||
|
||||
override fun getColumnCount(arg0: Int): Int = 2
|
||||
override fun getRowCount(): Int = 1
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
val view: View
|
||||
if (col == 0) {
|
||||
view = getInflatedPlusMinusView(container, true)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) {
|
||||
0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true)
|
||||
val view = viewAdapter.root
|
||||
var def = 0.0
|
||||
if (editCarbs != null) {
|
||||
def = SafeParse.stringToDouble(editCarbs?.editText?.text.toString())
|
||||
}
|
||||
val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48)
|
||||
val buttons = listOf(Pair(R.id.plusbutton, 1.0), Pair(R.id.plusbutton2, increment1), Pair(R.id.plusbutton3, increment2))
|
||||
editCarbs = PlusMinusEditText(view, R.id.amountfield, buttons, R.id.minusbutton, def, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), true)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs))
|
||||
editCarbs = PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), stepValues, DecimalFormat("0"), true, getString(R.string.action_carbs))
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
} else {
|
||||
view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
view
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
// With start time 0 and duration 0
|
||||
|
@ -61,8 +64,8 @@ class CarbActivity : ViewSelectorActivity() {
|
|||
finishAffinity()
|
||||
}
|
||||
container.addView(view)
|
||||
view
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
override fun destroyItem(container: ViewGroup, row: Int, col: Int, view: Any) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.shared.SafeParse.stringToDouble
|
||||
import info.nightscout.shared.SafeParse.stringToInt
|
||||
|
@ -36,44 +37,50 @@ class ECarbActivity : ViewSelectorActivity() {
|
|||
override fun getColumnCount(arg0: Int): Int = 4
|
||||
override fun getRowCount(): Int = 1
|
||||
|
||||
private val increment1 = sp.getInt(R.string.key_carbs_button_increment_1, 5).toDouble()
|
||||
private val increment2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble()
|
||||
val increment1 = sp.getInt(R.string.key_carbs_button_increment_1, 5).toDouble()
|
||||
val increment2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble()
|
||||
val stepValues = listOf(1.0, increment1, increment2)
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
return if (col == 0) {
|
||||
val view = getInflatedPlusMinusView(container, true)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) {
|
||||
0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true)
|
||||
val view = viewAdapter.root
|
||||
var def = 0.0
|
||||
if (editCarbs != null) {
|
||||
def = stringToDouble(editCarbs?.editText?.text.toString())
|
||||
}
|
||||
val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48)
|
||||
val buttons = listOf(Pair(R.id.plusbutton, 1.0), Pair(R.id.plusbutton2, increment1), Pair(R.id.plusbutton3, increment2))
|
||||
editCarbs = PlusMinusEditText(view, R.id.amountfield, buttons, R.id.minusbutton, def, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), true)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs))
|
||||
editCarbs = PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), stepValues, DecimalFormat("0"), true, getString(R.string.action_carbs))
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
view
|
||||
} else if (col == 1) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
var def = 0.0
|
||||
if (editStartTime != null) {
|
||||
def = stringToDouble(editStartTime?.editText?.text.toString())
|
||||
}
|
||||
editStartTime = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, -60.0, 300.0, 15.0, DecimalFormat("0"), false)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_start_min))
|
||||
editStartTime = PlusMinusEditText(viewAdapter, 15.0, def, -60.0, 300.0, DecimalFormat("0"), false, getString(R.string.action_start_min))
|
||||
container.addView(view)
|
||||
view
|
||||
} else if (col == 2) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
}
|
||||
|
||||
2 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
var def = 0.0
|
||||
if (editDuration != null) {
|
||||
def = stringToDouble(editDuration?.editText?.text.toString())
|
||||
}
|
||||
editDuration = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0.0, 8.0, 1.0, DecimalFormat("0"), false)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_duration_h))
|
||||
editDuration = PlusMinusEditText(viewAdapter, 1.0, def, 0.0, 8.0, DecimalFormat("0"), false, getString(R.string.action_duration_h))
|
||||
container.addView(view)
|
||||
view
|
||||
} else {
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
|
@ -102,4 +109,4 @@ class ECarbActivity : ViewSelectorActivity() {
|
|||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean = view === `object`
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.shared.SafeParse.stringToDouble
|
||||
import info.nightscout.shared.weardata.EventData.ActionFillPreCheck
|
||||
|
@ -33,19 +34,21 @@ class FillActivity : ViewSelectorActivity() {
|
|||
override fun getColumnCount(arg0: Int): Int = 2
|
||||
override fun getRowCount(): Int = 1
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
return if (col == 0) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) {
|
||||
0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
var def = 0.0
|
||||
if (editInsulin != null) {
|
||||
def = stringToDouble(editInsulin?.editText?.text.toString())
|
||||
}
|
||||
editInsulin = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0.0, 30.0, 0.1, DecimalFormat("#0.0"), false)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_insulin))
|
||||
editInsulin = PlusMinusEditText(viewAdapter, def, 0.0, 30.0, 0.1, DecimalFormat("#0.0"), false, getString(R.string.action_insulin))
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
view
|
||||
} else {
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
|
@ -68,4 +71,4 @@ class FillActivity : ViewSelectorActivity() {
|
|||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean = view === `object`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.shared.weardata.EventData.ActionProfileSwitchPreCheck
|
||||
|
@ -43,29 +44,34 @@ class ProfileSwitchActivity : ViewSelectorActivity() {
|
|||
override fun getColumnCount(arg0: Int): Int = 3
|
||||
override fun getRowCount(): Int = 1
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
return if (col == 0) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) {
|
||||
0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
var def = timeshift.toDouble()
|
||||
if (editTimeshift != null) {
|
||||
def = SafeParse.stringToDouble(editTimeshift?.editText?.text.toString())
|
||||
}
|
||||
editTimeshift = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0.0, 23.0, 1.0, DecimalFormat("0"), true, true)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_timeshift))
|
||||
editTimeshift = PlusMinusEditText(viewAdapter, def, 0.0, 23.0, 1.0, DecimalFormat("0"), true, getString(R.string.action_timeshift), true)
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
view
|
||||
} else if (col == 1) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
var def = percentage.toDouble()
|
||||
if (editPercentage != null) {
|
||||
def = SafeParse.stringToDouble(editPercentage?.editText?.text.toString())
|
||||
}
|
||||
editPercentage = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 30.0, 250.0, 1.0, DecimalFormat("0"), false)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_percentage))
|
||||
editPercentage = PlusMinusEditText(viewAdapter, def, 30.0, 250.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage))
|
||||
|
||||
container.addView(view)
|
||||
view
|
||||
} else {
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.shared.weardata.EventData.ActionTempTargetPreCheck
|
||||
|
@ -45,49 +46,56 @@ class TempTargetActivity : ViewSelectorActivity() {
|
|||
return 1
|
||||
}
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
return if (col == 0) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when {
|
||||
col == 0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
time = if (time == null) {
|
||||
PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60.0, 0.0, 24 * 60.0, 5.0, DecimalFormat("0"), false)
|
||||
PlusMinusEditText(viewAdapter, 60.0, 0.0, 24 * 60.0, 5.0, DecimalFormat("0"), false, getString(R.string.action_duration))
|
||||
} else {
|
||||
val def = SafeParse.stringToDouble(time?.editText?.text.toString())
|
||||
PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0.0, 24 * 60.0, 5.0, DecimalFormat("0"), false)
|
||||
PlusMinusEditText(viewAdapter, def, 0.0, 24 * 60.0, 5.0, DecimalFormat("0"), false, getString(R.string.action_duration))
|
||||
}
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_duration))
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
view
|
||||
} else if (col == 1) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
}
|
||||
|
||||
col == 1 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
val title = if (isSingleTarget) getString(R.string.action_target) else getString(R.string.action_low)
|
||||
if (isMGDL) {
|
||||
var def = 100.0
|
||||
if (lowRange != null) def = SafeParse.stringToDouble(lowRange?.editText?.text.toString())
|
||||
lowRange = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72.0, 180.0, 1.0, DecimalFormat("0"), false)
|
||||
lowRange = PlusMinusEditText(viewAdapter, def, 72.0, 180.0, 1.0, DecimalFormat("0"), false, title)
|
||||
} else {
|
||||
var def = 5.5
|
||||
if (lowRange != null) def = SafeParse.stringToDouble(lowRange?.editText?.text.toString())
|
||||
lowRange = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false)
|
||||
lowRange = PlusMinusEditText(viewAdapter, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, title)
|
||||
}
|
||||
if (isSingleTarget) setLabelToPlusMinusView(view, getString(R.string.action_target))
|
||||
else setLabelToPlusMinusView(view, getString(R.string.action_low))
|
||||
|
||||
container.addView(view)
|
||||
view
|
||||
} else if (col == 2 && !isSingleTarget) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
}
|
||||
|
||||
col == 2 && !isSingleTarget -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
if (isMGDL) {
|
||||
var def = 100.0
|
||||
if (highRange != null) def = SafeParse.stringToDouble(highRange?.editText?.text.toString())
|
||||
highRange = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72.0, 180.0, 1.0, DecimalFormat("0"), false)
|
||||
highRange = PlusMinusEditText(viewAdapter, def, 72.0, 180.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_high))
|
||||
} else {
|
||||
var def = 5.5
|
||||
if (highRange != null) def = SafeParse.stringToDouble(highRange?.editText?.text.toString())
|
||||
highRange = PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false)
|
||||
highRange = PlusMinusEditText(viewAdapter, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, getString(R.string.action_high))
|
||||
}
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_high))
|
||||
container.addView(view)
|
||||
view
|
||||
} else {
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
|
@ -119,4 +127,4 @@ class TempTargetActivity : ViewSelectorActivity() {
|
|||
return view === `object`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.shared.SafeParse.stringToDouble
|
||||
import info.nightscout.shared.SafeParse.stringToInt
|
||||
|
@ -38,32 +39,37 @@ class TreatmentActivity : ViewSelectorActivity() {
|
|||
|
||||
val incrementInsulin1 = (sp.getDouble(R.string.key_insulin_button_increment_1, 0.5) * 10).roundToInt() / 10.0
|
||||
val incrementInsulin2 = (sp.getDouble(R.string.key_insulin_button_increment_2, 1.0) * 10).roundToInt() / 10.0
|
||||
val stepValuesInsulin = listOf(0.1, incrementInsulin1, incrementInsulin2)
|
||||
val incrementCarbs1 = sp.getInt(R.string.key_carbs_button_increment_1, 5).toDouble()
|
||||
val incrementCarbs2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble()
|
||||
val stepValuesCarbs = listOf(1.0, incrementCarbs1, incrementCarbs2)
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
return if (col == 0) {
|
||||
val view = getInflatedPlusMinusView(container, true)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) {
|
||||
0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true)
|
||||
val view = viewAdapter.root
|
||||
var def = 0.0
|
||||
if (editInsulin != null) def = stringToDouble(editInsulin?.editText?.text.toString())
|
||||
val maxBolus = sp.getDouble(getString(R.string.key_treatments_safety_max_bolus), 3.0)
|
||||
val buttons = listOf(Pair(R.id.plusbutton, 0.1), Pair(R.id.plusbutton2, incrementInsulin1), Pair(R.id.plusbutton3, incrementInsulin2))
|
||||
editInsulin = PlusMinusEditText(view, R.id.amountfield, buttons, R.id.minusbutton, def, 0.0, maxBolus, 0.1, DecimalFormat("#0.0"), false)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_insulin))
|
||||
editInsulin = PlusMinusEditText(viewAdapter, def, 0.0, maxBolus, stepValuesInsulin, DecimalFormat("#0.0"), false, getString(R.string.action_insulin))
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
view
|
||||
} else if (col == 1) {
|
||||
val view = getInflatedPlusMinusView(container, true)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true)
|
||||
val view = viewAdapter.root
|
||||
var def = 0.0
|
||||
val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48)
|
||||
if (editCarbs != null) def = stringToDouble(editCarbs?.editText?.text.toString())
|
||||
val buttons = listOf(Pair(R.id.plusbutton, 1.0), Pair(R.id.plusbutton2, incrementCarbs1), Pair(R.id.plusbutton3, incrementCarbs2))
|
||||
editCarbs = PlusMinusEditText(view, R.id.amountfield, buttons, R.id.minusbutton, def, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false)
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs))
|
||||
|
||||
editCarbs = PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), stepValuesCarbs, DecimalFormat("0"), false, getString(R.string.action_carbs))
|
||||
container.addView(view)
|
||||
view
|
||||
} else {
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
val confirmButton = view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
confirmButton.setOnClickListener {
|
||||
|
|
|
@ -73,22 +73,6 @@ open class ViewSelectorActivity : DaggerActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun getInflatedPlusMinusView(container: ViewGroup?, mulitple: Boolean = false): View {
|
||||
val layoutRight = if (mulitple) R.layout.action_editplusminus_item_quickrighty_plus else R.layout.action_editplusminus_item_quickrighty
|
||||
val layoutLeft = if (mulitple) R.layout.action_editplusminus_item_quicklefty_plus else R.layout.action_editplusminus_item_quicklefty
|
||||
return when (sp.getInt(R.string.key_input_design, 1)) {
|
||||
2 -> LayoutInflater.from(applicationContext).inflate(layoutRight, container, false)
|
||||
3 -> LayoutInflater.from(applicationContext).inflate(layoutLeft, container, false)
|
||||
4 -> LayoutInflater.from(applicationContext).inflate(R.layout.action_editplusminus_item_viktoria, container, false)
|
||||
else -> LayoutInflater.from(applicationContext).inflate(R.layout.action_editplusminus_item, container, false)
|
||||
}
|
||||
}
|
||||
|
||||
fun setLabelToPlusMinusView(view: View, labelText: String?) {
|
||||
val textView = view.findViewById<TextView>(R.id.label)
|
||||
textView.text = labelText
|
||||
}
|
||||
|
||||
fun showToast(context: Context?, text: Int) {
|
||||
Toast.makeText(context, getString(text), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventWearToMobile
|
||||
import info.nightscout.androidaps.interaction.utils.EditPlusMinusViewAdapter
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText
|
||||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.shared.weardata.EventData.ActionWizardPreCheck
|
||||
|
@ -37,35 +38,39 @@ class WizardActivity : ViewSelectorActivity() {
|
|||
override fun getRowCount(): Int = 1
|
||||
private val increment1 = sp.getInt(R.string.key_carbs_button_increment_1, 5).toDouble()
|
||||
private val increment2 = sp.getInt(R.string.key_carbs_button_increment_2, 10).toDouble()
|
||||
val stepValues = listOf(1.0, increment1, increment2)
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): Any {
|
||||
return if (col == 0) {
|
||||
val view = getInflatedPlusMinusView(container, true)
|
||||
override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when {
|
||||
col == 0 -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true)
|
||||
val view = viewAdapter.root
|
||||
val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48)
|
||||
val buttons = listOf(Pair(R.id.plusbutton, 1.0), Pair(R.id.plusbutton2, increment1), Pair(R.id.plusbutton3, increment2))
|
||||
editCarbs = if (editCarbs == null) {
|
||||
PlusMinusEditText(view, R.id.amountfield, buttons, R.id.minusbutton, 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false)
|
||||
PlusMinusEditText(viewAdapter, 0.0, 0.0, maxCarbs.toDouble(), stepValues, DecimalFormat("0"), false, getString(R.string.action_carbs))
|
||||
} else {
|
||||
val def = SafeParse.stringToDouble(editCarbs?.editText?.text.toString())
|
||||
PlusMinusEditText(view, R.id.amountfield, buttons, R.id.minusbutton, def, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false)
|
||||
PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, getString(R.string.action_carbs))
|
||||
}
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs))
|
||||
container.addView(view)
|
||||
view.requestFocus()
|
||||
view
|
||||
} else if (col == 1 && hasPercentage) {
|
||||
val view = getInflatedPlusMinusView(container)
|
||||
}
|
||||
|
||||
col == 1 && hasPercentage -> {
|
||||
val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false)
|
||||
val view = viewAdapter.root
|
||||
val percentage = sp.getInt(getString(R.string.key_bolus_wizard_percentage), 100)
|
||||
editPercentage = if (editPercentage == null) {
|
||||
PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, percentage.toDouble(), 50.0, 150.0, 1.0, DecimalFormat("0"), false)
|
||||
PlusMinusEditText(viewAdapter, percentage.toDouble(), 50.0, 150.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage))
|
||||
} else {
|
||||
val def = SafeParse.stringToDouble(editPercentage?.editText?.text.toString())
|
||||
PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 50.0, 150.0, 1.0, DecimalFormat("0"), false)
|
||||
PlusMinusEditText(viewAdapter, def, 50.0, 150.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage))
|
||||
}
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_percentage))
|
||||
container.addView(view)
|
||||
view
|
||||
} else {
|
||||
}
|
||||
|
||||
else -> {
|
||||
val view = LayoutInflater.from(applicationContext).inflate(R.layout.action_confirm_ok, container, false)
|
||||
view.findViewById<ImageView>(R.id.confirmbutton)
|
||||
.setOnClickListener {
|
||||
|
|
|
@ -2,10 +2,10 @@ package info.nightscout.androidaps.interaction.utils
|
|||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminusItemBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminusItemPlusBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminusItemQuickleftyPlusBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminusItemQuickleftyBinding
|
||||
import info.nightscout.androidaps.databinding.ActionEditplusminusItemQuickrightyBinding
|
||||
|
@ -14,65 +14,84 @@ import info.nightscout.androidaps.databinding.ActionEditplusminusItemViktoriaBin
|
|||
import info.nightscout.shared.sharedPreferences.SP
|
||||
|
||||
/**
|
||||
* NumberPickerViewAdapter binds both NumberPickerLayoutBinding and NumberPickerLayoutVerticalBinding shared attributes to one common view adapter.
|
||||
* EditPlusMinusViewAdapter binds both ActionEditplusminusItemBinding variants shared attributes to one common view adapter.
|
||||
* Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding.
|
||||
*/
|
||||
class EditPlusMinusViewAdapter(
|
||||
val eS: ActionEditplusminusItemBinding?,
|
||||
val eQLP: ActionEditplusminusItemQuickleftyPlusBinding?,
|
||||
val eQL: ActionEditplusminusItemQuickleftyBinding?,
|
||||
val eQRP: ActionEditplusminusItemQuickleftyPlusBinding?,
|
||||
val qQR: ActionEditplusminusItemQuickrightyBinding?,
|
||||
val nQRP: ActionEditplusminusItemQuickrightyPlusBinding?,
|
||||
val eV: ActionEditplusminusItemViktoriaBinding?
|
||||
eD: ActionEditplusminusItemBinding?,
|
||||
eDP: ActionEditplusminusItemPlusBinding?,
|
||||
eQL: ActionEditplusminusItemQuickleftyBinding?,
|
||||
eQLP: ActionEditplusminusItemQuickleftyPlusBinding?,
|
||||
eQR: ActionEditplusminusItemQuickrightyBinding?,
|
||||
eQRP: ActionEditplusminusItemQuickrightyPlusBinding?,
|
||||
eV: ActionEditplusminusItemViktoriaBinding?
|
||||
) {
|
||||
|
||||
init {
|
||||
if (eS == null && eQLP == null && eQL == null && eQRP == null && qQR == null && nQRP == null && eV == null) {
|
||||
if (eD == null && eDP == null && eQL == null && eQLP == null && eQR == null && eQRP == null && eV == null) {
|
||||
throw IllegalArgumentException("Require at least on Binding parameter")
|
||||
}
|
||||
}
|
||||
|
||||
val amountField =
|
||||
eS?.amountfield ?: eQLP?.amountfield ?: eQL?.amountfield ?: eQRP?.amountfield ?: qQR?.amountfield ?: nQRP?.amountfield ?: eV?.amountfield
|
||||
val editText =
|
||||
eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText
|
||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
||||
val minusButton =
|
||||
eS?.minusbutton ?: eQLP?.minusbutton ?: eQL?.minusbutton ?: eQRP?.minusbutton ?: qQR?.minusbutton ?: nQRP?.minusbutton ?: eV?.minusbutton
|
||||
eD?.minusButton ?: eDP?.minusButton ?: eQL?.minusButton ?: eQLP?.minusButton ?: eQR?.minusButton ?: eQRP?.minusButton ?: eV?.minusButton
|
||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
||||
val plusButton =
|
||||
eS?.plusbutton ?: eQLP?.plusbutton ?: eQL?.plusbutton ?: eQRP?.plusbutton ?: qQR?.plusbutton ?: nQRP?.plusbutton ?: eV?.plusbutton
|
||||
val plusButton1 =
|
||||
eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1
|
||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
||||
val label =
|
||||
eS?.label ?: eQLP?.label ?: eQL?.label ?: eQRP?.label ?: qQR?.label ?: nQRP?.label ?: eV?.label
|
||||
eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label
|
||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
||||
val plusButton2 = eQLP?.plusbutton2 ?: eQRP?.plusbutton2
|
||||
val plusButton3 = eQLP?.plusbutton3 ?: eQRP?.plusbutton3
|
||||
val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2
|
||||
val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3
|
||||
val root =
|
||||
eS?.root ?: eQLP?.root ?: eQL?.root ?: eQRP?.root ?: qQR?.root ?: nQRP?.root ?: eV?.root
|
||||
eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root
|
||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
||||
|
||||
companion object {
|
||||
|
||||
fun getInflatedPlusMinusView(sp: SP, context: Context, container: ViewGroup?, mulitple: Boolean = false): EditPlusMinusViewAdapter {
|
||||
fun getViewAdapter(sp: SP, context: Context, container: ViewGroup?, multiple: Boolean = false): EditPlusMinusViewAdapter {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val bindLayout = ActionEditplusminusItemBinding.inflate(inflater, container, false)
|
||||
val binding = EditPlusMinusViewAdapter(bindLayout, null, null, null, null, null, null)
|
||||
return binding
|
||||
// val layoutRight = if (mulitple) R.layout.action_editplusminus_item_quickrighty_plus else R.layout.action_editplusminus_item_quickrighty
|
||||
// val layoutLeft = if (mulitple) R.layout.action_editplusminus_item_quicklefty_plus else R.layout.action_editplusminus_item_quicklefty
|
||||
// return when (sp.getInt(R.string.key_input_design, 1)) {
|
||||
// 2 -> LayoutInflater.from(applicationContext).inflate(layoutRight, container, false)
|
||||
// 3 -> LayoutInflater.from(applicationContext).inflate(layoutLeft, container, false)
|
||||
// 4 -> LayoutInflater.from(applicationContext).inflate(R.layout.action_editplusminus_item_viktoria, container, false)
|
||||
// else -> LayoutInflater.from(applicationContext).inflate(R.layout.action_editplusminus_item, container, false)
|
||||
// }
|
||||
|
||||
return when (sp.getInt(R.string.key_input_design, 1)) {
|
||||
2 -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminusItemQuickrightyPlusBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, null, bindLayout, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminusItemQuickrightyBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, bindLayout, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminusItemQuickleftyPlusBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, bindLayout, null, null, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminusItemQuickleftyBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, bindLayout, null, null, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
4 -> {
|
||||
val bindLayout = ActionEditplusminusItemViktoriaBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, null, null, null, null, null, bindLayout)
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (multiple) {
|
||||
val bindLayout = ActionEditplusminusItemPlusBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(null, bindLayout, null, null, null, null, null)
|
||||
} else {
|
||||
val bindLayout = ActionEditplusminusItemBinding.inflate(inflater, container, false)
|
||||
EditPlusMinusViewAdapter(bindLayout, null, null, null, null, null, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// fun getBinding(bindLayout: NumberPickerLayoutBinding): NumberPickerViewAdapter {
|
||||
// return NumberPickerViewAdapter(bindLayout, null)
|
||||
// }
|
||||
//
|
||||
// fun getBinding(bindLayout: NumberPickerLayoutVerticalBinding): NumberPickerViewAdapter {
|
||||
// return NumberPickerViewAdapter(null, bindLayout)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.view.View
|
|||
import android.view.View.OnGenericMotionListener
|
||||
import android.view.View.OnTouchListener
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatButton
|
||||
import androidx.core.view.InputDeviceCompat
|
||||
import androidx.core.view.MotionEventCompat
|
||||
import java.text.DecimalFormat
|
||||
|
@ -17,47 +16,38 @@ import java.text.NumberFormat
|
|||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.ScheduledExecutorService
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.Pair
|
||||
|
||||
/**
|
||||
* Created by mike on 28.06.2016.
|
||||
*/
|
||||
@SuppressLint("SetTextI18n") class PlusMinusEditText @JvmOverloads constructor(
|
||||
view: View,
|
||||
editTextID: Int,
|
||||
private var plusButtons: List<Pair<Int, Double>>,
|
||||
minusID: Int,
|
||||
private val binding: EditPlusMinusViewAdapter,
|
||||
initValue: Double,
|
||||
private val minValue: Double,
|
||||
private val maxValue: Double,
|
||||
private val stepGeneral: Double,
|
||||
private val stepValues: List<Double>,
|
||||
private val formatter: NumberFormat,
|
||||
private val allowZero: Boolean,
|
||||
label: String,
|
||||
private val roundRobin: Boolean = false,
|
||||
) : View.OnKeyListener, OnTouchListener, View.OnClickListener, OnGenericMotionListener {
|
||||
|
||||
constructor(
|
||||
view: View,
|
||||
editTextID: Int,
|
||||
plusID: Int,
|
||||
minusID: Int,
|
||||
binding: EditPlusMinusViewAdapter,
|
||||
initValue: Double,
|
||||
minValue: Double,
|
||||
maxValue: Double,
|
||||
stepGeneral: Double,
|
||||
step: Double,
|
||||
formatter: NumberFormat,
|
||||
allowZero: Boolean,
|
||||
label: String,
|
||||
roundRobin: Boolean = false
|
||||
) : this(view, editTextID, listOf(Pair(plusID, stepGeneral)), minusID, initValue, minValue, maxValue, stepGeneral, formatter, allowZero, roundRobin)
|
||||
) : this(binding, initValue, minValue, maxValue, listOf(step), formatter, allowZero, label, roundRobin)
|
||||
|
||||
private val stepGeneral: Double = stepValues[0]
|
||||
var editText: TextView
|
||||
private set
|
||||
private var minusImage: View
|
||||
private var plusImage1: View
|
||||
private var plusImage2: AppCompatButton? = null
|
||||
private var plusImage3: AppCompatButton? = null
|
||||
private var value: Double
|
||||
private val context: Context
|
||||
private var mChangeCounter = 0
|
||||
private var mLastChange: Long = 0
|
||||
private val mHandler: Handler
|
||||
|
@ -70,11 +60,11 @@ import kotlin.Pair
|
|||
override fun run() {
|
||||
val msg = Message()
|
||||
val doubleLimit = 5
|
||||
val multipleButtons = mInc && (plusImage2 != null || plusImage3 != null)
|
||||
val multipleButtons = mInc && (binding.plusButton2 != null || binding.plusButton3 != null)
|
||||
if (!multipleButtons && repeated % doubleLimit == 0) multiplier *= 2
|
||||
val bundle = Bundle()
|
||||
bundle.putDouble("step", step)
|
||||
bundle.putInt("multiplier", multiplier)
|
||||
bundle.putDouble(STEP, step)
|
||||
bundle.putInt(MULTIPLIER, multiplier)
|
||||
msg.data = bundle
|
||||
|
||||
if (mInc) {
|
||||
|
@ -114,14 +104,14 @@ import kotlin.Pair
|
|||
if (vibrate) vibrateDevice()
|
||||
}
|
||||
|
||||
fun vibrateDevice() {
|
||||
private fun vibrateDevice() {
|
||||
val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val vibratorManager =
|
||||
context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
|
||||
binding.root.context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
|
||||
vibratorManager.defaultVibrator
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||
binding.root.context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
@ -155,19 +145,19 @@ import kotlin.Pair
|
|||
|
||||
private fun getStep(v: View): Double {
|
||||
return when (v) {
|
||||
plusImage1 -> plusButtons[0].second
|
||||
plusImage2 -> plusButtons[1].second
|
||||
plusImage3 -> plusButtons[2].second
|
||||
else -> stepGeneral
|
||||
binding.plusButton1 -> stepValues[0]
|
||||
binding.plusButton2 -> stepValues[1]
|
||||
binding.plusButton3 -> stepValues[2]
|
||||
else -> stepValues[0]
|
||||
}
|
||||
}
|
||||
|
||||
private fun isIncrement(v: View): Boolean {
|
||||
return when (v) {
|
||||
plusImage1 -> true
|
||||
plusImage2 -> true
|
||||
plusImage3 -> true
|
||||
else -> false
|
||||
binding.plusButton1 -> true
|
||||
binding.plusButton2 -> true
|
||||
binding.plusButton3 -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,30 +219,22 @@ import kotlin.Pair
|
|||
private const val THRESHOLD_TIME = 100
|
||||
private const val MSG_INC = 0
|
||||
private const val MSG_DEC = 1
|
||||
private const val STEP = "step"
|
||||
private const val MULTIPLIER = "multiplier"
|
||||
}
|
||||
|
||||
init {
|
||||
context = view.context
|
||||
editText = view.findViewById(editTextID)
|
||||
minusImage = view.findViewById(minusID)
|
||||
plusImage1 = view.findViewById(plusButtons.first().first)
|
||||
editText = binding.editText
|
||||
binding.label.text = label
|
||||
val format = DecimalFormat("#.#")
|
||||
plusButtons.getOrNull(1)?.let {
|
||||
plusImage2 = view.findViewById(it.first)
|
||||
plusImage2?.text = "+${format.format(it.second).replaceFirst("^0+(?!$)".toRegex(), "")}"
|
||||
plusImage2?.visibility = View.VISIBLE
|
||||
}
|
||||
plusButtons.getOrNull(2)?.let {
|
||||
plusImage3 = view.findViewById(it.first)
|
||||
plusImage3?.text = "+${format.format(it.second).replaceFirst("^0+(?!$)".toRegex(), "")}"
|
||||
plusImage3?.visibility = View.VISIBLE
|
||||
}
|
||||
binding.plusButton2?.text = "+${format.format(stepValues[1]).replaceFirst("^0+(?!$)".toRegex(), "")}"
|
||||
binding.plusButton3?.text = "+${format.format(stepValues[2]).replaceFirst("^0+(?!$)".toRegex(), "")}"
|
||||
|
||||
value = initValue
|
||||
mHandler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
val multiplier = msg.data.getInt("multiplier")
|
||||
val step = msg.data.getDouble("step")
|
||||
val multiplier = msg.data.getInt(MULTIPLIER)
|
||||
val step = msg.data.getDouble(STEP)
|
||||
|
||||
when (msg.what) {
|
||||
MSG_INC -> {
|
||||
|
@ -271,18 +253,18 @@ import kotlin.Pair
|
|||
|
||||
editText.showSoftInputOnFocus = false
|
||||
editText.setTextIsSelectable(false)
|
||||
minusImage.setOnTouchListener(this)
|
||||
minusImage.setOnKeyListener(this)
|
||||
minusImage.setOnClickListener(this)
|
||||
plusImage1.setOnTouchListener(this)
|
||||
plusImage1.setOnKeyListener(this)
|
||||
plusImage1.setOnClickListener(this)
|
||||
plusImage2?.setOnTouchListener(this)
|
||||
plusImage2?.setOnKeyListener(this)
|
||||
plusImage2?.setOnClickListener(this)
|
||||
plusImage3?.setOnTouchListener(this)
|
||||
plusImage3?.setOnKeyListener(this)
|
||||
plusImage3?.setOnClickListener(this)
|
||||
binding.minusButton.setOnTouchListener(this)
|
||||
binding.minusButton.setOnKeyListener(this)
|
||||
binding.minusButton.setOnClickListener(this)
|
||||
binding.plusButton1.setOnTouchListener(this)
|
||||
binding.plusButton1.setOnKeyListener(this)
|
||||
binding.plusButton1.setOnClickListener(this)
|
||||
binding.plusButton2?.setOnTouchListener(this)
|
||||
binding.plusButton2?.setOnKeyListener(this)
|
||||
binding.plusButton2?.setOnClickListener(this)
|
||||
binding.plusButton3?.setOnTouchListener(this)
|
||||
binding.plusButton3?.setOnKeyListener(this)
|
||||
binding.plusButton3?.setOnClickListener(this)
|
||||
editText.setOnGenericMotionListener(this)
|
||||
updateEditText()
|
||||
}
|
||||
|
|
|
@ -1,67 +1,131 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minusbutton"
|
||||
<View
|
||||
android:id="@+id/center"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:cursorVisible="false"
|
||||
android:inputType="numberDecimal"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp"
|
||||
android:gravity="center"
|
||||
app:layout_constraintEnd_toEndOf="@+id/value_background"
|
||||
app:layout_constraintStart_toStartOf="@+id/value_background"
|
||||
app:layout_constraintTop_toTopOf="@+id/value_background"
|
||||
tools:text="123" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="-8dp"
|
||||
android:layout_below="@+id/edit_text"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/edit_text"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/edit_text"
|
||||
app:layout_constraintStart_toStartOf="@+id/edit_text"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_text"
|
||||
tools:ignore="LabelFor"
|
||||
tools:text="label" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minus_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:contentDescription="@string/decrement"
|
||||
android:src="@drawable/ic_action_minus"
|
||||
android:tint="@color/white" />
|
||||
android:tint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="145"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plus_button3"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="325"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="+10" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plus_button2"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/plus_button1"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="270"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/plus_button3"
|
||||
tools:text="+5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/value_background"
|
||||
android:layout_width="108dp"
|
||||
android:layout_height="108dp"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/gray_700"
|
||||
android:contentDescription="@string/increment"
|
||||
app:layout_constraintBottom_toTopOf="@+id/minus_button"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="55"
|
||||
app:layout_constraintCircleRadius="40dp"
|
||||
app:layout_constraintRight_toLeftOf="@id/plus_button1">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:cursorVisible="false"
|
||||
android:gravity="center_horizontal"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="50dp"
|
||||
android:padding="10dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="45sp"
|
||||
tools:text="112" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/amountfield"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
tools:ignore="LabelFor"
|
||||
tools:text="label" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.AppCompatImageView>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/plusbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/plus_button1"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:contentDescription="@string/increment"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:tint="@color/white" />
|
||||
android:tint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="215"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
126
wear/src/main/res/layout/action_editplusminus_item_plus.xml
Normal file
126
wear/src/main/res/layout/action_editplusminus_item_plus.xml
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
android:id="@+id/center"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-6dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:cursorVisible="false"
|
||||
android:inputType="numberDecimal"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp"
|
||||
android:gravity="center"
|
||||
app:layout_constraintEnd_toEndOf="@+id/value_background"
|
||||
app:layout_constraintStart_toStartOf="@+id/value_background"
|
||||
app:layout_constraintTop_toTopOf="@+id/value_background"
|
||||
tools:text="123" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:layout_below="@+id/edit_text"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/edit_text"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/edit_text"
|
||||
app:layout_constraintStart_toStartOf="@+id/edit_text"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_text"
|
||||
tools:ignore="LabelFor"
|
||||
tools:text="label" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minus_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:contentDescription="@string/decrement"
|
||||
android:src="@drawable/ic_action_minus"
|
||||
android:tint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="215"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plus_button3"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="325"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="+10" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plus_button2"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/plus_button1"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="35"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/plus_button3"
|
||||
tools:text="+5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/value_background"
|
||||
android:layout_width="108dp"
|
||||
android:layout_height="108dp"
|
||||
android:layout_gravity="center"
|
||||
android:backgroundTint="@color/gray_700"
|
||||
android:contentDescription="@string/increment"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/plus_button1"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:contentDescription="@string/increment"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:tint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="145"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -14,38 +14,11 @@
|
|||
android:layout_marginEnd="-8dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton3"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
android:visibility="gone"
|
||||
tools:text="+10" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton2"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginVertical="7dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
android:visibility="gone"
|
||||
tools:text="+5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/plusbutton"
|
||||
android:id="@+id/plus_button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:contentDescription="@string/increment"
|
||||
|
@ -62,7 +35,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
@ -81,7 +54,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/amountfield"
|
||||
android:labelFor="@+id/edit_text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
|
@ -89,7 +62,7 @@
|
|||
tools:text="label" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minusbutton"
|
||||
android:id="@+id/minus_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:cursorVisible="false"
|
||||
android:gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp"
|
||||
android:gravity="center"
|
||||
app:layout_constraintEnd_toEndOf="@+id/value_background"
|
||||
app:layout_constraintStart_toStartOf="@+id/value_background"
|
||||
app:layout_constraintTop_toTopOf="@+id/value_background"
|
||||
|
@ -34,20 +34,20 @@
|
|||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/edit_text"
|
||||
android:layout_marginTop="-8dp"
|
||||
android:layout_below="@+id/amountfield"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/amountfield"
|
||||
android:labelFor="@+id/edit_text"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/amountfield"
|
||||
app:layout_constraintStart_toStartOf="@+id/amountfield"
|
||||
app:layout_constraintTop_toBottomOf="@id/amountfield"
|
||||
app:layout_constraintEnd_toEndOf="@+id/edit_text"
|
||||
app:layout_constraintStart_toStartOf="@+id/edit_text"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_text"
|
||||
tools:ignore="LabelFor"
|
||||
tools:text="label" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minusbutton"
|
||||
android:id="@+id/minus_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
|
@ -58,11 +58,11 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="145"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintCircleRadius="65dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton3"
|
||||
android:id="@+id/plus_button3"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
|
@ -73,13 +73,13 @@
|
|||
android:visibility="visible"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="325"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintCircleRadius="65dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="+10" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton2"
|
||||
android:id="@+id/plus_button2"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
|
@ -87,33 +87,31 @@
|
|||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/plusbutton"
|
||||
app:layout_constraintBottom_toTopOf="@+id/plus_button1"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="270"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintCircleRadius="65dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/plusbutton3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/plus_button3"
|
||||
tools:text="+5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/value_background"
|
||||
android:layout_width="108dp"
|
||||
android:layout_height="108dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/gray_700"
|
||||
android:contentDescription="@string/increment"
|
||||
app:layout_constraintBottom_toTopOf="@+id/minusbutton"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="55"
|
||||
app:layout_constraintCircleRadius="40dp"
|
||||
app:layout_constraintRight_toLeftOf="@id/plusbutton">
|
||||
|
||||
</androidx.appcompat.widget.AppCompatImageView>
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintBottom_toTopOf="@+id/minus_button"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintLeft_toRightOf="@+id/plus_button3"
|
||||
app:layout_constraintTop_toTopOf="@+id/plus_button3" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/plusbutton"
|
||||
android:id="@+id/plus_button1"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
|
@ -125,7 +123,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="215"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintCircleRadius="65dp"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
@ -34,7 +34,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/amountfield"
|
||||
android:labelFor="@+id/edit_text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
|
@ -42,7 +42,7 @@
|
|||
tools:text="label" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minusbutton"
|
||||
android:id="@+id/minus_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
@ -62,35 +62,8 @@
|
|||
android:orientation="vertical"
|
||||
tools:visibility="visible">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton3"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
android:visibility="gone"
|
||||
tools:text="+10" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton2"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginVertical="7dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/white"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:visibility="gone"
|
||||
android:textSize="25sp"
|
||||
tools:text="+5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/plusbutton"
|
||||
android:id="@+id/plus_button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:layout_marginTop="-1dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:cursorVisible="false"
|
||||
android:gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp"
|
||||
android:gravity="center"
|
||||
app:layout_constraintEnd_toEndOf="@+id/value_background"
|
||||
app:layout_constraintStart_toStartOf="@+id/value_background"
|
||||
app:layout_constraintTop_toTopOf="@+id/value_background"
|
||||
|
@ -34,20 +34,20 @@
|
|||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/edit_text"
|
||||
android:layout_marginTop="-8dp"
|
||||
android:layout_below="@+id/amountfield"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/amountfield"
|
||||
android:labelFor="@+id/edit_text"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/amountfield"
|
||||
app:layout_constraintStart_toStartOf="@+id/amountfield"
|
||||
app:layout_constraintTop_toBottomOf="@id/amountfield"
|
||||
app:layout_constraintEnd_toEndOf="@+id/edit_text"
|
||||
app:layout_constraintStart_toStartOf="@+id/edit_text"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_text"
|
||||
tools:ignore="LabelFor"
|
||||
tools:text="label" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minusbutton"
|
||||
android:id="@+id/minus_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
|
@ -62,7 +62,7 @@
|
|||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton3"
|
||||
android:id="@+id/plus_button3"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
|
@ -79,7 +79,7 @@
|
|||
tools:text="+10" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/plusbutton2"
|
||||
android:id="@+id/plus_button2"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/circle"
|
||||
|
@ -87,12 +87,12 @@
|
|||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/plusbutton"
|
||||
app:layout_constraintBottom_toTopOf="@+id/plus_button1"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="90"
|
||||
app:layout_constraintCircleRadius="70dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/plusbutton3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/plus_button3"
|
||||
tools:text="+5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
|
@ -101,19 +101,15 @@
|
|||
android:layout_height="108dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="@color/gray_700"
|
||||
android:contentDescription="@string/increment"
|
||||
app:layout_constraintBottom_toTopOf="@+id/minusbutton"
|
||||
app:layout_constraintCircle="@+id/center"
|
||||
app:layout_constraintCircleAngle="305"
|
||||
app:layout_constraintCircleRadius="40dp"
|
||||
app:layout_constraintRight_toLeftOf="@id/plusbutton">
|
||||
android:importantForAccessibility="no"
|
||||
|
||||
</androidx.appcompat.widget.AppCompatImageView>
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/plusbutton"
|
||||
android:id="@+id/plus_button1"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:gravity="center"
|
||||
android:labelFor="@+id/amountfield"
|
||||
android:labelFor="@+id/edit_text"
|
||||
android:rotation="90"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/white"
|
||||
|
@ -26,7 +26,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/plusbutton"
|
||||
android:id="@+id/plus_button1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
|
@ -36,7 +36,7 @@
|
|||
android:tint="@color/white" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:id="@+id/edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
|
@ -51,7 +51,7 @@
|
|||
tools:text="112" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/minusbutton"
|
||||
android:id="@+id/minus_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
|
|
Loading…
Reference in a new issue