mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-14 21:18:51 -06:00
All scores, frequency, history, etc. corrected for the skip days features.
This commit is contained in:
@@ -51,6 +51,7 @@ import org.isoron.uhabits.core.models.HabitType
|
||||
import org.isoron.uhabits.core.models.NumericalHabitType
|
||||
import org.isoron.uhabits.core.models.PaletteColor
|
||||
import org.isoron.uhabits.core.models.Reminder
|
||||
import org.isoron.uhabits.core.models.SkipDays
|
||||
import org.isoron.uhabits.core.models.WeekdayList
|
||||
import org.isoron.uhabits.databinding.ActivityEditHabitBinding
|
||||
import org.isoron.uhabits.utils.ColorUtils
|
||||
@@ -106,8 +107,8 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
color = habit.color
|
||||
freqNum = habit.frequency.numerator
|
||||
freqDen = habit.frequency.denominator
|
||||
isSkipDays = habit.skipDays
|
||||
listSkipDays = habit.skipDaysList
|
||||
isSkipDays = habit.skipDays.isSkipDays
|
||||
listSkipDays = habit.skipDays.days
|
||||
targetType = habit.targetType
|
||||
habit.reminder?.let {
|
||||
reminderHour = it.hour
|
||||
@@ -302,8 +303,7 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
habit.frequency = Frequency(freqNum, freqDen)
|
||||
habit.skipDays = isSkipDays
|
||||
habit.skipDaysList = listSkipDays
|
||||
habit.skipDays = SkipDays(isSkipDays, listSkipDays)
|
||||
if (habitType == HabitType.NUMERICAL) {
|
||||
habit.targetValue = binding.targetInput.text.toString().toDouble()
|
||||
habit.targetType = targetType
|
||||
@@ -358,6 +358,12 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun populateSkipDays() {
|
||||
val preferences = (application as HabitsApplication).component.preferences
|
||||
if (preferences.isSkipEnabled || isSkipDays) {
|
||||
binding.skipDaysOuterBox.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.skipDaysOuterBox.visibility = View.GONE
|
||||
}
|
||||
if (isSkipDays) {
|
||||
binding.skipDaysPicker.text = listSkipDays.toFormattedString(this)
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.isoron.uhabits.core.ui.screens.habits.show.views.SubtitleCardState
|
||||
import org.isoron.uhabits.databinding.ShowHabitSubtitleBinding
|
||||
import org.isoron.uhabits.utils.InterfaceUtils
|
||||
import org.isoron.uhabits.utils.formatTime
|
||||
import org.isoron.uhabits.utils.toFormattedString
|
||||
|
||||
class SubtitleCardView(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
|
||||
|
||||
@@ -78,6 +79,12 @@ class SubtitleCardView(context: Context, attrs: AttributeSet) : LinearLayout(con
|
||||
if (state.question.isEmpty()) {
|
||||
binding.questionLabel.visibility = View.GONE
|
||||
}
|
||||
if (state.skipDays.isSkipDays) {
|
||||
binding.skipLabel.visibility = View.VISIBLE
|
||||
binding.skipLabel.text = context.getString(R.string.skip_day) + " " + state.skipDays.days.toFormattedString(context)
|
||||
} else {
|
||||
binding.skipLabel.visibility = View.GONE
|
||||
}
|
||||
|
||||
postInvalidate()
|
||||
}
|
||||
|
||||
@@ -251,6 +251,7 @@
|
||||
|
||||
<!-- Notes -->
|
||||
<FrameLayout
|
||||
android:id="@+id/skipDaysOuterBox"
|
||||
style="@style/FormOuterBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@@ -76,6 +76,17 @@
|
||||
android:text="@string/every_day"
|
||||
android:textColor="?attr/contrast60"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textSize="@dimen/smallTextSize" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/skipLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="1dp"
|
||||
android:textColor="?attr/contrast60"
|
||||
android:text=""
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textSize="@dimen/smallTextSize" />
|
||||
|
||||
@@ -95,6 +106,7 @@
|
||||
android:textColor="?attr/contrast60"
|
||||
android:text="8:00 AM"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textSize="@dimen/smallTextSize" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user