mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-14 21:18:51 -06:00
Revert "Skip days implemented. Scores not correct yet"
This reverts commit ec08b602
This commit is contained in:
@@ -51,7 +51,6 @@ 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
|
||||
@@ -82,8 +81,6 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
var androidColor = 0
|
||||
var freqNum = 1
|
||||
var freqDen = 1
|
||||
var isSkipDays = false
|
||||
var listSkipDays: WeekdayList = WeekdayList.NO_DAY
|
||||
var reminderHour = -1
|
||||
var reminderMin = -1
|
||||
var reminderDays: WeekdayList = WeekdayList.EVERY_DAY
|
||||
@@ -107,8 +104,6 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
color = habit.color
|
||||
freqNum = habit.frequency.numerator
|
||||
freqDen = habit.frequency.denominator
|
||||
isSkipDays = habit.skipDays.isSkipDays
|
||||
listSkipDays = habit.skipDays.days
|
||||
targetType = habit.targetType
|
||||
habit.reminder?.let {
|
||||
reminderHour = it.hour
|
||||
@@ -130,8 +125,6 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
color = PaletteColor(state.getInt("paletteColor"))
|
||||
freqNum = state.getInt("freqNum")
|
||||
freqDen = state.getInt("freqDen")
|
||||
isSkipDays = state.getBoolean("isSkipDays", false)
|
||||
listSkipDays = WeekdayList(state.getInt("listSkipDays", 0))
|
||||
reminderHour = state.getInt("reminderHour")
|
||||
reminderMin = state.getInt("reminderMin")
|
||||
reminderDays = WeekdayList(state.getInt("reminderDays"))
|
||||
@@ -248,31 +241,12 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
dialog.setListener { days: WeekdayList ->
|
||||
reminderDays = days
|
||||
if (reminderDays.isEmpty) reminderDays = WeekdayList.EVERY_DAY
|
||||
if (isSkipDays) reminderDays = WeekdayList(reminderDays.toArray(), listSkipDays.toArray())
|
||||
populateReminder()
|
||||
}
|
||||
dialog.setSelectedDays(reminderDays)
|
||||
dialog.dismissCurrentAndShow(supportFragmentManager, "dayPicker")
|
||||
}
|
||||
|
||||
populateSkipDays()
|
||||
binding.skipDaysPicker.setOnClickListener {
|
||||
val dialog = WeekdayPickerDialog()
|
||||
|
||||
dialog.setListener { days: WeekdayList ->
|
||||
listSkipDays = days
|
||||
if (listSkipDays.isEmpty) listSkipDays = WeekdayList.NO_DAY
|
||||
isSkipDays = (listSkipDays != WeekdayList.NO_DAY)
|
||||
if (reminderHour >= 0 && isSkipDays) {
|
||||
reminderDays = WeekdayList(reminderDays.toArray(), listSkipDays.toArray())
|
||||
populateReminder()
|
||||
}
|
||||
populateSkipDays()
|
||||
}
|
||||
dialog.setSelectedDays(listSkipDays)
|
||||
dialog.dismissCurrentAndShow(supportFragmentManager, "dayPicker")
|
||||
}
|
||||
|
||||
binding.buttonSave.setOnClickListener {
|
||||
if (validate()) save()
|
||||
}
|
||||
@@ -303,7 +277,6 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
habit.frequency = Frequency(freqNum, freqDen)
|
||||
habit.skipDays = SkipDays(isSkipDays, listSkipDays)
|
||||
if (habitType == HabitType.NUMERICAL) {
|
||||
habit.targetValue = binding.targetInput.text.toString().toDouble()
|
||||
habit.targetType = targetType
|
||||
@@ -357,20 +330,6 @@ 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 {
|
||||
binding.skipDaysPicker.text = getString(R.string.skip_days_off)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("StringFormatMatches")
|
||||
private fun populateFrequency() {
|
||||
binding.booleanFrequencyPicker.text = formatFrequency(freqNum, freqDen, resources)
|
||||
@@ -413,8 +372,6 @@ class EditHabitActivity : AppCompatActivity() {
|
||||
putInt("androidColor", androidColor)
|
||||
putInt("freqNum", freqNum)
|
||||
putInt("freqDen", freqDen)
|
||||
putBoolean("isSkipDays", isSkipDays)
|
||||
putInt("listSkipDays", listSkipDays.toInteger())
|
||||
putInt("reminderHour", reminderHour)
|
||||
putInt("reminderMin", reminderMin)
|
||||
putInt("reminderDays", reminderDays.toInteger())
|
||||
|
||||
@@ -73,7 +73,6 @@
|
||||
android:paddingRight="4dp">
|
||||
|
||||
<!-- Title and color -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -250,25 +249,6 @@
|
||||
|
||||
|
||||
<!-- Notes -->
|
||||
<FrameLayout
|
||||
android:id="@+id/skipDaysOuterBox"
|
||||
style="@style/FormOuterBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout style="@style/FormInnerBox">
|
||||
|
||||
<TextView
|
||||
style="@style/FormLabel"
|
||||
android:text="@string/skip_days" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/skipDaysPicker"
|
||||
style="@style/FormDropdown"
|
||||
android:text="@string/skip_days_off" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout style="@style/FormOuterBox">
|
||||
<LinearLayout style="@style/FormInnerBox">
|
||||
<TextView
|
||||
|
||||
@@ -54,14 +54,12 @@
|
||||
<string name="history">History</string>
|
||||
<string name="clear">Clear</string>
|
||||
<string name="reminder">Reminder</string>
|
||||
<string name="skip_days">Skip days</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="streaks">Streaks</string>
|
||||
<string name="no_habits_found">You have no active habits</string>
|
||||
<string name="no_habits_left_to_do">You\'re all done for today!</string>
|
||||
<string name="long_press_to_toggle">Press-and-hold to check or uncheck</string>
|
||||
<string name="reminder_off">Off</string>
|
||||
<string name="skip_days_off">Off</string>
|
||||
<string name="create_habit">Create habit</string>
|
||||
<string name="edit_habit">Edit habit</string>
|
||||
<string name="create_habit_group">Create habit group</string>
|
||||
|
||||
Reference in New Issue
Block a user