mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-16 11:11:41 +00:00
tweak bulk allocation visuals. Fixes #842
This commit is contained in:
parent
760c3c2340
commit
e250d42fa5
3 changed files with 32 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
|
@ -32,21 +33,24 @@
|
|||
android:id="@+id/statsSeekBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_weight="1"
|
||||
android:maxHeight="4dp"
|
||||
android:minHeight="4dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="+"
|
||||
android:textColor="@color/gray_100"
|
||||
android:textSize="16sp"/>
|
||||
<EditText
|
||||
<android.support.v7.widget.AppCompatEditText
|
||||
android:id="@+id/valueEditText"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="0"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@color/gray_100"
|
||||
style="@style/Body3"
|
||||
style="@style/Body1"
|
||||
app:backgroundTint="@color/gray_500"
|
||||
android:textSize="16sp"
|
||||
android:inputType="number"/>
|
||||
</merge>
|
||||
|
|
@ -422,5 +422,4 @@
|
|||
<style name="PurpleTextLabel" parent="TextAppearance.AppCompat">
|
||||
<item name="android:textColor">@color/brand_300</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -5,6 +5,8 @@ import android.content.res.ColorStateList
|
|||
import android.graphics.PorterDuff
|
||||
import android.os.Build
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
|
|
@ -57,6 +59,27 @@ class StatsSliderView(context: Context, attrs: AttributeSet?) : LinearLayout(con
|
|||
statsSeekBar.thumb = thumbDrawable
|
||||
}
|
||||
|
||||
valueEditText.addTextChangedListener(object: TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val newValue = try {
|
||||
s.toString().toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
0
|
||||
}
|
||||
if (newValue != currentValue && newValue < maxValue) {
|
||||
currentValue = newValue
|
||||
allocateAction?.invoke(currentValue)
|
||||
} else if (newValue > maxValue) {
|
||||
valueEditText.setText(currentValue.toString())
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
statsSeekBar.setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
||||
currentValue = progress
|
||||
|
|
@ -65,11 +88,9 @@ class StatsSliderView(context: Context, attrs: AttributeSet?) : LinearLayout(con
|
|||
}
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {
|
||||
}
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar?) {
|
||||
}
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
|
||||
})
|
||||
|
||||
currentValue = 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue