mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-15 21:48:50 -06:00
Skip button on measurable dialog
This commit is contained in:
@@ -30,6 +30,7 @@ import android.widget.NumberPicker
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.core.models.Entry
|
||||
import org.isoron.uhabits.core.ui.screens.habits.list.ListHabitsBehavior
|
||||
import org.isoron.uhabits.inject.ActivityContext
|
||||
import org.isoron.uhabits.utils.InterfaceUtils
|
||||
@@ -76,6 +77,11 @@ class NumberPickerFactory
|
||||
val v = picker.value + 0.05 * picker2.value
|
||||
callback.onNumberPicked(v)
|
||||
}
|
||||
.setNegativeButton(R.string.skip_button) { _, _ ->
|
||||
picker.clearFocus()
|
||||
val v = Entry.SKIP.toDouble() / 1000
|
||||
callback.onNumberPicked(v)
|
||||
}
|
||||
.setOnDismissListener {
|
||||
callback.onNumberPickerDismissed()
|
||||
}
|
||||
|
||||
@@ -173,7 +173,8 @@ class FrequencyChart : ScrollableChart {
|
||||
rect[0f, 0f, baseSize.toFloat()] = baseSize.toFloat()
|
||||
rect.offset(prevRect!!.left, prevRect!!.top + baseSize * j)
|
||||
val i = localeWeekdayList[j] % 7
|
||||
if (values != null) drawMarker(canvas, rect, values[i])
|
||||
if (values != null)
|
||||
drawMarker(canvas, rect, values[i])
|
||||
rect.offset(0f, rowHeight)
|
||||
}
|
||||
drawFooter(canvas, rect, date)
|
||||
@@ -222,11 +223,12 @@ class FrequencyChart : ScrollableChart {
|
||||
}
|
||||
|
||||
private fun drawMarker(canvas: Canvas, rect: RectF?, value: Int?) {
|
||||
val valueCopy = value?.let { max(0, it) }
|
||||
val padding = rect!!.height() * 0.2f
|
||||
// maximal allowed mark radius
|
||||
val maxRadius = (rect.height() - 2 * padding) / 2.0f
|
||||
// the real mark radius is scaled down by a factor depending on the maximal frequency
|
||||
val scale = 1.0f / maxFreq * value!!
|
||||
val scale = 1.0f / maxFreq * valueCopy!!
|
||||
val radius = maxRadius * scale
|
||||
val colorIndex = min((colors.size - 1), ((colors.size - 1) * scale).roundToInt())
|
||||
pGraph!!.color = colors[colorIndex]
|
||||
|
||||
Reference in New Issue
Block a user