mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Make skip days an opt-in feature
This commit is contained in:
@@ -82,6 +82,7 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
|
||||
historyChart = new HistoryChart(context);
|
||||
historyChart.setController(controller);
|
||||
historyChart.setFirstWeekday(prefs.getFirstWeekday());
|
||||
historyChart.setSkipEnabled(prefs.isSkipEnabled());
|
||||
|
||||
if (savedInstanceState != null)
|
||||
{
|
||||
|
||||
@@ -102,6 +102,8 @@ public class HistoryChart extends ScrollableChart
|
||||
@NonNull
|
||||
private Controller controller;
|
||||
|
||||
private boolean skipsEnabled;
|
||||
|
||||
public HistoryChart(Context context)
|
||||
{
|
||||
super(context);
|
||||
@@ -153,7 +155,10 @@ public class HistoryChart extends ScrollableChart
|
||||
int offset = timestamp.daysUntil(today);
|
||||
if (offset < checkmarks.length)
|
||||
{
|
||||
newValue = Repetition.nextToggleValue(checkmarks[offset]);
|
||||
if(skipsEnabled)
|
||||
newValue = Repetition.nextToggleValueWithSkip(checkmarks[offset]);
|
||||
else
|
||||
newValue = Repetition.nextToggleValueWithoutSkip(checkmarks[offset]);
|
||||
checkmarks[offset] = newValue;
|
||||
}
|
||||
|
||||
@@ -211,6 +216,11 @@ public class HistoryChart extends ScrollableChart
|
||||
initColors();
|
||||
}
|
||||
|
||||
public void setSkipEnabled(boolean value)
|
||||
{
|
||||
this.skipsEnabled = value;
|
||||
}
|
||||
|
||||
public void setIsEditable(boolean isEditable)
|
||||
{
|
||||
this.isEditable = isEditable;
|
||||
|
||||
@@ -62,7 +62,11 @@ class CheckmarkButtonView(
|
||||
}
|
||||
|
||||
fun performToggle() {
|
||||
value = Repetition.nextToggleValue(value)
|
||||
value = if(preferences.isSkipEnabled) {
|
||||
Repetition.nextToggleValueWithSkip(value)
|
||||
} else {
|
||||
Repetition.nextToggleValueWithoutSkip(value)
|
||||
}
|
||||
onToggle(value)
|
||||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
invalidate()
|
||||
|
||||
@@ -120,7 +120,11 @@ public class HistoryCard extends HabitCard
|
||||
{
|
||||
if (isCanceled()) return;
|
||||
int[] checkmarks = habit.getCheckmarks().getAllValues();
|
||||
if(prefs != null) chart.setFirstWeekday(prefs.getFirstWeekday());
|
||||
if(prefs != null)
|
||||
{
|
||||
chart.setFirstWeekday(prefs.getFirstWeekday());
|
||||
chart.setSkipEnabled(prefs.isSkipEnabled());
|
||||
}
|
||||
chart.setCheckmarks(checkmarks);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class HistoryWidget(
|
||||
if (preferedBackgroundAlpha >= 255) widgetView.setShadowAlpha(0x4f)
|
||||
(widgetView.dataView as HistoryChart).apply {
|
||||
setFirstWeekday(firstWeekday)
|
||||
setSkipEnabled(prefs.isSkipEnabled)
|
||||
setColor(PaletteUtils.getColor(context, habit.color))
|
||||
setCheckmarks(habit.checkmarks.allValues)
|
||||
setNumerical(habit.isNumerical)
|
||||
|
||||
@@ -49,7 +49,8 @@ class NumericalCheckmarkWidgetActivity : Activity(), ListHabitsBehavior.NumberPi
|
||||
data = parser.parseCheckmarkIntent(intent)
|
||||
behavior = WidgetBehavior(component.habitList,
|
||||
component.commandRunner,
|
||||
component.notificationTray)
|
||||
component.notificationTray,
|
||||
component.preferences)
|
||||
widgetUpdater = component.widgetUpdater
|
||||
showNumberSelector(this)
|
||||
|
||||
|
||||
@@ -200,4 +200,6 @@
|
||||
<string name="no_boolean_habits">No yes-or-no habits found</string>
|
||||
<string name="increment">Increment</string>
|
||||
<string name="decrement">Decrement</string>
|
||||
<string name="pref_skip_title">Enable skip days</string>
|
||||
<string name="pref_skip_description">Toggle twice to add a skip instead of a checkmark. Skips keep your score unchanged and don\'t break your streak.</string>
|
||||
</resources>
|
||||
@@ -31,6 +31,13 @@
|
||||
android:title="@string/pref_toggle_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_skip_enabled"
|
||||
android:summary="@string/pref_skip_description"
|
||||
android:title="@string/pref_skip_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_checkmark_reverse_order"
|
||||
|
||||
Reference in New Issue
Block a user