mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 17:48:52 -06:00
HistoryChart: Customizable first day of week
This commit is contained in:
@@ -22,12 +22,12 @@ package org.isoron.uhabits.activities.common.dialogs;
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.os.*;
|
||||
import android.util.*;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.*;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.*;
|
||||
import android.util.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.commands.*;
|
||||
|
||||
@@ -47,15 +47,12 @@ class HistoryCardView(context: Context, attrs: AttributeSet) : LinearLayout(cont
|
||||
today = data.today,
|
||||
paletteColor = data.color,
|
||||
theme = data.theme,
|
||||
dateFormatter = JavaLocalDateFormatter(Locale.getDefault())
|
||||
).apply {
|
||||
series = data.series
|
||||
}
|
||||
dateFormatter = JavaLocalDateFormatter(Locale.getDefault()),
|
||||
series = data.series,
|
||||
firstWeekday = data.firstWeekday,
|
||||
)
|
||||
|
||||
// binding.historyChart.setFirstWeekday(data.firstWeekday)
|
||||
// binding.historyChart.setSkipEnabled(data.isSkipEnabled)
|
||||
// binding.historyChart.setEntries(data.entries)
|
||||
// binding.historyChart.setColor(androidColor)
|
||||
// if (data.isNumerical) {
|
||||
// binding.historyChart.setNumerical(true)
|
||||
// }
|
||||
|
||||
@@ -177,7 +177,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
private void updateWeekdayPreference()
|
||||
{
|
||||
ListPreference weekdayPref = (ListPreference) findPreference("pref_first_weekday");
|
||||
int currentFirstWeekday = prefs.getFirstWeekday();
|
||||
int currentFirstWeekday = prefs.getFirstWeekday().getDaysSinceSunday() + 1;
|
||||
String[] dayNames = DateUtils.getLongWeekdayNames(Calendar.SATURDAY);
|
||||
String[] dayValues = {"7", "1", "2", "3", "4", "5", "6"};
|
||||
weekdayPref.setEntries(dayNames);
|
||||
|
||||
@@ -28,7 +28,7 @@ class FrequencyWidgetProvider : BaseWidgetProvider() {
|
||||
context,
|
||||
id,
|
||||
habits[0],
|
||||
preferences.firstWeekday
|
||||
preferences.firstWeekdayInt
|
||||
)
|
||||
else return StackWidget(context, id, StackWidgetType.FREQUENCY, habits)
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ import java.util.Locale
|
||||
class HistoryWidget(
|
||||
context: Context,
|
||||
id: Int,
|
||||
private val habit: Habit,
|
||||
private val firstWeekday: Int
|
||||
private val habit: Habit
|
||||
) : BaseWidget(context, id) {
|
||||
|
||||
override fun getOnClickPendingIntent(context: Context): PendingIntent {
|
||||
@@ -66,7 +65,9 @@ class HistoryWidget(
|
||||
today = DateUtils.getTodayWithOffset().toLocalDate(),
|
||||
paletteColor = habit.color,
|
||||
theme = WidgetTheme(),
|
||||
dateFormatter = JavaLocalDateFormatter(Locale.getDefault())
|
||||
dateFormatter = JavaLocalDateFormatter(Locale.getDefault()),
|
||||
firstWeekday = prefs.firstWeekday,
|
||||
series = listOf(),
|
||||
)
|
||||
}
|
||||
).apply {
|
||||
|
||||
@@ -26,8 +26,7 @@ class HistoryWidgetProvider : BaseWidgetProvider() {
|
||||
if (habits.size == 1) return HistoryWidget(
|
||||
context,
|
||||
id,
|
||||
habits[0],
|
||||
preferences.firstWeekday
|
||||
habits[0]
|
||||
)
|
||||
else return StackWidget(context, id, StackWidgetType.HISTORY, habits)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class ScoreWidget(
|
||||
val presenter = ScoreCardPresenter()
|
||||
val viewModel = presenter.present(
|
||||
habit = habit,
|
||||
firstWeekday = prefs.firstWeekday,
|
||||
firstWeekday = prefs.firstWeekdayInt,
|
||||
spinnerPosition = prefs.scoreCardSpinnerPosition
|
||||
)
|
||||
val widgetView = view as GraphWidgetView
|
||||
|
||||
@@ -97,11 +97,11 @@ class StackRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory
|
||||
case CHECKMARK:
|
||||
return new CheckmarkWidget(context, widgetId, habit);
|
||||
case FREQUENCY:
|
||||
return new FrequencyWidget(context, widgetId, habit, prefs.getFirstWeekday());
|
||||
return new FrequencyWidget(context, widgetId, habit, prefs.getFirstWeekdayInt());
|
||||
case SCORE:
|
||||
return new ScoreWidget(context, widgetId, habit);
|
||||
case HISTORY:
|
||||
return new HistoryWidget(context, widgetId, habit, prefs.getFirstWeekday());
|
||||
return new HistoryWidget(context, widgetId, habit);
|
||||
case STREAKS:
|
||||
return new StreakWidget(context, widgetId, habit);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class TargetWidget(
|
||||
if (preferedBackgroundAlpha >= 255) widgetView.setShadowAlpha(0x4f)
|
||||
val chart = (widgetView.dataView as TargetChart)
|
||||
val presenter = TargetCardPresenter()
|
||||
val data = presenter.present(habit, prefs.firstWeekday)
|
||||
val data = presenter.present(habit, prefs.firstWeekdayInt)
|
||||
chart.setColor(data.color.toThemedAndroidColor(context))
|
||||
chart.setTargets(data.targets)
|
||||
chart.setLabels(data.intervals.map { intervalToLabel(context.resources, it) })
|
||||
|
||||
Reference in New Issue
Block a user