From 78ed1a51fe2ba7bf332dc453e3255fa88ba39192 Mon Sep 17 00:00:00 2001 From: razeeman Date: Sun, 14 Jul 2024 09:57:30 +0300 Subject: [PATCH] add days count selection for Last days range --- .../core/dialog/DurationDialogListener.kt | 2 +- .../StatisticsDetailNavigationInteractor.kt | 4 +- .../core/mapper/RangeViewDataMapper.kt | 49 +++++++++++---- .../core/mapper/TimeMapper.kt | 2 +- .../core/repo/ResourceRepo.kt | 4 ++ .../core/viewData/SelectLastDaysViewData.kt | 7 +++ .../data_local/repo/PrefsRepoImpl.kt | 30 ++++++++- .../GetProcessedLastDaysCountInteractor.kt | 10 +++ .../domain/interactor/PrefsInteractor.kt | 26 +++++++- .../domain/model/RangeLength.kt | 4 +- .../domain/repo/PrefsRepo.kt | 4 ++ .../view/StatisticsContainerFragment.kt | 6 ++ .../viewModel/StatisticsContainerViewModel.kt | 27 +++++++- .../viewModel/StatisticsSettingsViewModel.kt | 19 ++++-- .../StatisticsDetailChartInteractor.kt | 2 +- .../StatisticsDetailStreaksInteractor.kt | 2 +- .../view/StatisticsDetailFragment.kt | 6 ++ .../viewModel/StatisticsDetailViewModel.kt | 4 ++ .../StatisticsDetailRangeViewModelDelegate.kt | 53 +++++++++++++--- .../src/main/AndroidManifest.xml | 2 +- .../settings/WidgetStatisticsActivity.kt | 47 ++++++++++++++ ...kt => WidgetStatisticsSettingsFragment.kt} | 62 ++++++++----------- .../WidgetStatisticsSettingsViewModel.kt | 48 +++++++++++++- .../res/layout/widget_statistics_activity.xml | 9 +++ ...> widget_statistics_settings_fragment.xml} | 0 .../res/layout/widget_universal_activity.xml | 2 +- .../res/layout/widget_universal_fragment.xml | 2 +- .../widget_statistics_nav_graph.xml | 23 +++++++ ...aph.xml => widget_universal_nav_graph.xml} | 0 .../res/xml/widget_statistics_chart_info.xml | 2 +- .../params/screen/StatisticsDetailParams.kt | 2 +- resources/src/main/res/values-ar/strings.xml | 10 ++- resources/src/main/res/values-ca/strings.xml | 18 ++++-- resources/src/main/res/values-de/strings.xml | 10 ++- resources/src/main/res/values-es/strings.xml | 18 ++++-- resources/src/main/res/values-fa/strings.xml | 18 ++++-- resources/src/main/res/values-fr/strings.xml | 16 +++-- resources/src/main/res/values-hi/strings.xml | 18 ++++-- resources/src/main/res/values-in/strings.xml | 20 ++++-- resources/src/main/res/values-it/strings.xml | 18 ++++-- resources/src/main/res/values-ja/strings.xml | 20 ++++-- resources/src/main/res/values-ko/strings.xml | 20 ++++-- resources/src/main/res/values-nl/strings.xml | 10 ++- resources/src/main/res/values-pl/strings.xml | 14 ++++- .../src/main/res/values-pt-rPT/strings.xml | 20 ++++-- resources/src/main/res/values-pt/strings.xml | 18 ++++-- resources/src/main/res/values-ro/strings.xml | 16 +++-- resources/src/main/res/values-ru/strings.xml | 14 ++++- resources/src/main/res/values-sv/strings.xml | 18 ++++-- resources/src/main/res/values-tr/strings.xml | 18 ++++-- resources/src/main/res/values-uk/strings.xml | 14 ++++- resources/src/main/res/values-vi/strings.xml | 20 ++++-- .../src/main/res/values-zh-rTW/strings.xml | 20 ++++-- resources/src/main/res/values-zh/strings.xml | 12 +++- resources/src/main/res/values/strings.xml | 10 ++- .../presentation/ui/layout/ScrollingColumn.kt | 1 - 56 files changed, 673 insertions(+), 178 deletions(-) create mode 100644 core/src/main/java/com/example/util/simpletimetracker/core/viewData/SelectLastDaysViewData.kt create mode 100644 domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/GetProcessedLastDaysCountInteractor.kt create mode 100644 features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsActivity.kt rename features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/{WidgetStatisticsSettingsActivity.kt => WidgetStatisticsSettingsFragment.kt} (70%) create mode 100644 features/feature_widget/src/main/res/layout/widget_statistics_activity.xml rename features/feature_widget/src/main/res/layout/{widget_statistics_settings_activity.xml => widget_statistics_settings_fragment.xml} (100%) create mode 100644 features/feature_widget/src/main/res/navigation/widget_statistics_nav_graph.xml rename features/feature_widget/src/main/res/navigation/{widget_nav_graph.xml => widget_universal_nav_graph.xml} (100%) diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/dialog/DurationDialogListener.kt b/core/src/main/java/com/example/util/simpletimetracker/core/dialog/DurationDialogListener.kt index d66e3c73a..4211c4c4a 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/dialog/DurationDialogListener.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/dialog/DurationDialogListener.kt @@ -2,7 +2,7 @@ package com.example.util.simpletimetracker.core.dialog interface DurationDialogListener { - fun onDurationSet(duration: Long, tag: String? = null) + fun onDurationSet(duration: Long, tag: String? = null) {} fun onCountSet(count: Long, tag: String? = null) {} diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/interactor/StatisticsDetailNavigationInteractor.kt b/core/src/main/java/com/example/util/simpletimetracker/core/interactor/StatisticsDetailNavigationInteractor.kt index 21346bf8e..8c4e01059 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/interactor/StatisticsDetailNavigationInteractor.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/interactor/StatisticsDetailNavigationInteractor.kt @@ -61,7 +61,9 @@ class StatisticsDetailNavigationInteractor @Inject constructor( start = rangeLength.range.timeStarted, end = rangeLength.range.timeEnded, ) - is RangeLength.Last -> StatisticsDetailParams.RangeLengthParams.Last + is RangeLength.Last -> StatisticsDetailParams.RangeLengthParams.Last( + days = rangeLength.days, + ) }, shift = shift, preview = StatisticsDetailParams.Preview( diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/mapper/RangeViewDataMapper.kt b/core/src/main/java/com/example/util/simpletimetracker/core/mapper/RangeViewDataMapper.kt index 3b06f2647..60e520f44 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/mapper/RangeViewDataMapper.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/mapper/RangeViewDataMapper.kt @@ -5,6 +5,7 @@ import com.example.util.simpletimetracker.core.repo.ResourceRepo import com.example.util.simpletimetracker.core.viewData.RangeViewData import com.example.util.simpletimetracker.core.viewData.RangesViewData import com.example.util.simpletimetracker.core.viewData.SelectDateViewData +import com.example.util.simpletimetracker.core.viewData.SelectLastDaysViewData import com.example.util.simpletimetracker.core.viewData.SelectRangeViewData import com.example.util.simpletimetracker.domain.extension.orZero import com.example.util.simpletimetracker.domain.model.DayOfWeek @@ -16,15 +17,27 @@ class RangeViewDataMapper @Inject constructor( private val timeMapper: TimeMapper, ) { - fun mapToRanges(currentRange: RangeLength, addSelection: Boolean = true): RangesViewData { + fun mapToRanges( + currentRange: RangeLength, + addSelection: Boolean, + lastDaysCount: Int, + ): RangesViewData { val selectDateButton = mapToSelectDateName(currentRange) ?.takeIf { addSelection }?.let(::listOf) ?: emptyList() val selectRangeButton = mapToSelectRange() .takeIf { addSelection }?.let(::listOf) ?: emptyList() + val selectLastDaysButton = mapToSelectLastDays(lastDaysCount) + .let(::listOf) - val data = selectDateButton + selectRangeButton + ranges.map(::mapToRangeName) - val selectedPosition = data.indexOfFirst { - (it as? RangeViewData)?.range == currentRange + val data = selectDateButton + + selectRangeButton + + selectLastDaysButton + + ranges.mapNotNull(::mapToRangeName) + + val selectedPosition = when (currentRange) { + is RangeLength.Custom -> data.indexOfFirst { it is SelectRangeViewData } + is RangeLength.Last -> data.indexOfFirst { it is SelectLastDaysViewData } + else -> data.indexOfFirst { (it as? RangeViewData)?.range == currentRange } }.takeUnless { it == -1 }.orZero() return RangesViewData( @@ -45,8 +58,8 @@ class RangeViewDataMapper @Inject constructor( is RangeLength.Month -> timeMapper.toMonthTitle(position, startOfDayShift) is RangeLength.Year -> timeMapper.toYearTitle(position, startOfDayShift) is RangeLength.All -> resourceRepo.getString(R.string.range_overall) - is RangeLength.Custom -> resourceRepo.getString(R.string.range_custom) - is RangeLength.Last -> resourceRepo.getString(R.string.range_last) + is RangeLength.Custom -> mapToSelectRangeName() + is RangeLength.Last -> mapToSelectLastDaysName(rangeLength.days) } } @@ -68,15 +81,16 @@ class RangeViewDataMapper @Inject constructor( } } - private fun mapToRangeName(rangeLength: RangeLength): RangeViewData { + private fun mapToRangeName(rangeLength: RangeLength): RangeViewData? { val text = when (rangeLength) { is RangeLength.Day -> R.string.range_day is RangeLength.Week -> R.string.range_week is RangeLength.Month -> R.string.range_month is RangeLength.Year -> R.string.range_year is RangeLength.All -> R.string.range_overall - is RangeLength.Custom -> R.string.range_custom - is RangeLength.Last -> R.string.range_last + // These ranges mapped separately + is RangeLength.Custom -> return null + is RangeLength.Last -> return null }.let(resourceRepo::getString) return RangeViewData( @@ -98,12 +112,25 @@ class RangeViewDataMapper @Inject constructor( } private fun mapToSelectRange(): SelectRangeViewData { - return SelectRangeViewData(text = resourceRepo.getString(R.string.range_custom)) + val text = mapToSelectRangeName() + return SelectRangeViewData(text) + } + + private fun mapToSelectRangeName(): String { + return resourceRepo.getString(R.string.range_custom) + } + + private fun mapToSelectLastDays(days: Int): SelectLastDaysViewData { + val text = mapToSelectLastDaysName(days) + return SelectLastDaysViewData(text) + } + + private fun mapToSelectLastDaysName(days: Int): String { + return resourceRepo.getQuantityString(R.plurals.range_last, days, days) } companion object { private val ranges: List = listOf( - RangeLength.Last, RangeLength.All, RangeLength.Year, RangeLength.Month, diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/mapper/TimeMapper.kt b/core/src/main/java/com/example/util/simpletimetracker/core/mapper/TimeMapper.kt index 0d3f17d4a..deead2829 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/mapper/TimeMapper.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/mapper/TimeMapper.kt @@ -444,7 +444,7 @@ class TimeMapper @Inject constructor( is RangeLength.Last -> { rangeEnd = calendar.apply { add(Calendar.DATE, 1) }.timeInMillis - rangeStart = calendar.apply { add(Calendar.DATE, -rangeLength.DAYS) }.timeInMillis + rangeStart = calendar.apply { add(Calendar.DATE, -rangeLength.days) }.timeInMillis } } diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/repo/ResourceRepo.kt b/core/src/main/java/com/example/util/simpletimetracker/core/repo/ResourceRepo.kt index b42df0aec..f699d44b8 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/repo/ResourceRepo.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/repo/ResourceRepo.kt @@ -35,6 +35,10 @@ class ResourceRepo @Inject constructor( return context.resources.getQuantityString(stringResId, quantity) } + fun getQuantityString(@PluralsRes stringResId: Int, quantity: Int, vararg args: Any): String { + return context.resources.getQuantityString(stringResId, quantity, *args) + } + fun getDimenInDp(@DimenRes dimenResId: Int): Int { return context.resources.getDimension(dimenResId).pxToDp() } diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/viewData/SelectLastDaysViewData.kt b/core/src/main/java/com/example/util/simpletimetracker/core/viewData/SelectLastDaysViewData.kt new file mode 100644 index 000000000..0877f8186 --- /dev/null +++ b/core/src/main/java/com/example/util/simpletimetracker/core/viewData/SelectLastDaysViewData.kt @@ -0,0 +1,7 @@ +package com.example.util.simpletimetracker.core.viewData + +import com.example.util.simpletimetracker.feature_views.spinner.CustomSpinner + +data class SelectLastDaysViewData( + override val text: String, +) : CustomSpinner.CustomSpinnerItem() \ No newline at end of file diff --git a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/repo/PrefsRepoImpl.kt b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/repo/PrefsRepoImpl.kt index 09c1e50e0..aa12fba7f 100644 --- a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/repo/PrefsRepoImpl.kt +++ b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/repo/PrefsRepoImpl.kt @@ -62,6 +62,10 @@ class PrefsRepoImpl @Inject constructor( KEY_STATISTICS_RANGE_CUSTOM_END, 0, ) + override var statisticsRangeLastDays: Int by prefs.delegate( + KEY_STATISTICS_RANGE_LAST_DAYS, RANGE_LAST_DAYS_DEFAULT, + ) + override var statisticsDetailRange: Int by prefs.delegate( KEY_STATISTICS_DETAIL_RANGE, 0, ) @@ -74,6 +78,10 @@ class PrefsRepoImpl @Inject constructor( KEY_STATISTICS_DETAIL_RANGE_CUSTOM_END, 0, ) + override var statisticsDetailRangeLastDays: Int by prefs.delegate( + KEY_STATISTICS_DETAIL_RANGE_LAST_DAYS, RANGE_LAST_DAYS_DEFAULT, + ) + override var keepStatisticsRange: Boolean by prefs.delegate( KEY_KEEP_STATISTICS_RANGE, false, ) @@ -328,6 +336,7 @@ class PrefsRepoImpl @Inject constructor( is RangeLength.Last -> 5 is RangeLength.Custom -> 0 // Not possible } + val rangeDataLastDays = (data.rangeLength as? RangeLength.Last)?.days val filteredTypesData = data.filteredTypes.map(Long::toString).toSet() val filteredCategoriesData = data.filteredCategories.map(Long::toString).toSet() val filteredTagsData = data.filteredTags.map(Long::toString).toSet() @@ -335,6 +344,11 @@ class PrefsRepoImpl @Inject constructor( prefs.edit() .putInt(KEY_STATISTICS_WIDGET_FILTER_TYPE + widgetId, filterTypeData) .putInt(KEY_STATISTICS_WIDGET_RANGE + widgetId, rangeData) + .apply { + if (rangeDataLastDays != null) { + putInt(KEY_STATISTICS_WIDGET_RANGE_LAST_DAYS + widgetId, rangeDataLastDays) + } + } .putStringSet(KEY_STATISTICS_WIDGET_FILTERED_TYPES + widgetId, filteredTypesData) .putStringSet(KEY_STATISTICS_WIDGET_FILTERED_CATEGORIES + widgetId, filteredCategoriesData) .putStringSet(KEY_STATISTICS_WIDGET_FILTERED_TAGS + widgetId, filteredTagsData) @@ -355,7 +369,9 @@ class PrefsRepoImpl @Inject constructor( 2 -> RangeLength.Month 3 -> RangeLength.Year 4 -> RangeLength.All - 5 -> RangeLength.Last + 5 -> RangeLength.Last( + days = getStatisticsWidgetLastDays(widgetId), + ) else -> RangeLength.Day } val filteredTypes = prefs @@ -377,11 +393,19 @@ class PrefsRepoImpl @Inject constructor( ) } + override fun getStatisticsWidgetLastDays(widgetId: Int): Int { + return prefs.getInt( + KEY_STATISTICS_WIDGET_RANGE_LAST_DAYS + widgetId, + RANGE_LAST_DAYS_DEFAULT, + ) + } + override fun removeStatisticsWidget(widgetId: Int) { logPrefsDataAccess("removeStatisticsWidget $widgetId") prefs.edit() .remove(KEY_STATISTICS_WIDGET_FILTER_TYPE + widgetId) .remove(KEY_STATISTICS_WIDGET_RANGE + widgetId) + .remove(KEY_STATISTICS_WIDGET_RANGE_LAST_DAYS + widgetId) .remove(KEY_STATISTICS_WIDGET_FILTERED_TYPES + widgetId) .remove(KEY_STATISTICS_WIDGET_FILTERED_CATEGORIES + widgetId) .remove(KEY_STATISTICS_WIDGET_FILTERED_TAGS + widgetId) @@ -492,6 +516,7 @@ class PrefsRepoImpl @Inject constructor( private const val POMODORO_DEFAULT_BREAK_TIME_SEC: Long = 60 * 5 // 5 min private const val POMODORO_DEFAULT_LONG_BREAK_TIME_SEC: Long = 60 * 15 // 15 min private const val POMODORO_DEFAULT_UNTIL_LONG_BREAK: Long = 4 + private const val RANGE_LAST_DAYS_DEFAULT: Int = 7 private const val KEY_RECORD_TYPES_FILTERED_ON_CHART = "recordTypesFilteredOnChart" private const val KEY_CATEGORIES_TYPES_FILTERED_ON_CHART = "categoriesFilteredOnChart" @@ -503,9 +528,11 @@ class PrefsRepoImpl @Inject constructor( private const val KEY_STATISTICS_RANGE = "statisticsRange" private const val KEY_STATISTICS_RANGE_CUSTOM_START = "statisticsRangeCustomStart" private const val KEY_STATISTICS_RANGE_CUSTOM_END = "statisticsRangeCustomEnd" + private const val KEY_STATISTICS_RANGE_LAST_DAYS = "statisticsRangeLastDays" private const val KEY_STATISTICS_DETAIL_RANGE = "statisticsDetailRange" private const val KEY_STATISTICS_DETAIL_RANGE_CUSTOM_START = "statisticsDetailRangeCustomStart" private const val KEY_STATISTICS_DETAIL_RANGE_CUSTOM_END = "statisticsDetailRangeCustomEnd" + private const val KEY_STATISTICS_DETAIL_RANGE_LAST_DAYS = "statisticsDetailRangeLastDays" private const val KEY_KEEP_STATISTICS_RANGE = "keepStatisticsRange" private const val KEY_FIRST_DAY_OF_WEEK = "firstDayOfWeek" private const val KEY_START_OF_DAY_SHIFT = "startOfDayShift" @@ -567,6 +594,7 @@ class PrefsRepoImpl @Inject constructor( private const val KEY_STATISTICS_WIDGET_FILTERED_TAGS = "statistics_widget_filtered_tags_" private const val KEY_STATISTICS_WIDGET_FILTER_TYPE = "statistics_widget_filter_type_" private const val KEY_STATISTICS_WIDGET_RANGE = "statistics_widget_range_" + private const val KEY_STATISTICS_WIDGET_RANGE_LAST_DAYS = "statistics_widget_range_last_days_" private const val KEY_QUICK_SETTINGS_WIDGET_TYPE = "quick_settings_widget_type_" private const val KEY_CARD_ORDER_MANUAL = "cardOrderManual" private const val KEY_CATEGORY_ORDER_MANUAL = "categoryOrderManual" diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/GetProcessedLastDaysCountInteractor.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/GetProcessedLastDaysCountInteractor.kt new file mode 100644 index 000000000..9f164c435 --- /dev/null +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/GetProcessedLastDaysCountInteractor.kt @@ -0,0 +1,10 @@ +package com.example.util.simpletimetracker.domain.interactor + +import javax.inject.Inject + +class GetProcessedLastDaysCountInteractor @Inject constructor() { + + fun execute(enteredCount: Long): Int { + return enteredCount.toInt().coerceIn(2..365) + } +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/PrefsInteractor.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/PrefsInteractor.kt index 747df1058..d70fcc95d 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/PrefsInteractor.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/PrefsInteractor.kt @@ -102,6 +102,13 @@ class PrefsInteractor @Inject constructor( prefsRepo.statisticsRangeCustomStart = rangeLength.range.timeStarted prefsRepo.statisticsRangeCustomEnd = rangeLength.range.timeEnded } + if (rangeLength is RangeLength.Last) { + prefsRepo.statisticsRangeLastDays = rangeLength.days + } + } + + suspend fun getStatisticsLastDays(): Int = withContext(Dispatchers.IO) { + prefsRepo.statisticsRangeLastDays } suspend fun getStatisticsDetailRange(): RangeLength = withContext(Dispatchers.IO) { @@ -115,6 +122,13 @@ class PrefsInteractor @Inject constructor( prefsRepo.statisticsDetailRangeCustomStart = rangeLength.range.timeStarted prefsRepo.statisticsDetailRangeCustomEnd = rangeLength.range.timeEnded } + if (rangeLength is RangeLength.Last) { + prefsRepo.statisticsDetailRangeLastDays = rangeLength.days + } + } + + suspend fun getStatisticsDetailLastDays(): Int = withContext(Dispatchers.IO) { + prefsRepo.statisticsDetailRangeLastDays } suspend fun getKeepStatisticsRange(): Boolean = withContext(Dispatchers.IO) { @@ -548,6 +562,10 @@ class PrefsInteractor @Inject constructor( prefsRepo.getStatisticsWidget(widgetId) } + suspend fun getStatisticsWidgetLastDays(widgetId: Int): Int = withContext(Dispatchers.IO) { + prefsRepo.getStatisticsWidgetLastDays(widgetId) + } + suspend fun removeStatisticsWidget(widgetId: Int) = withContext(Dispatchers.IO) { prefsRepo.removeStatisticsWidget(widgetId) } @@ -707,7 +725,13 @@ class PrefsInteractor @Inject constructor( ) }.let(RangeLength::Custom) } - 6 -> RangeLength.Last + 6 -> { + if (forDetail) { + prefsRepo.statisticsDetailRangeLastDays + } else { + prefsRepo.statisticsRangeLastDays + }.let(RangeLength::Last) + } else -> RangeLength.Day } } diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RangeLength.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RangeLength.kt index 320837ecb..ec216ff79 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RangeLength.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RangeLength.kt @@ -7,7 +7,5 @@ sealed class RangeLength { object Year : RangeLength() object All : RangeLength() data class Custom(val range: Range) : RangeLength() - object Last : RangeLength() { - const val DAYS: Int = 7 - } + data class Last(val days: Int) : RangeLength() } \ No newline at end of file diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/repo/PrefsRepo.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/repo/PrefsRepo.kt index 394cdb396..aca8e1c1c 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/repo/PrefsRepo.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/repo/PrefsRepo.kt @@ -20,10 +20,12 @@ interface PrefsRepo { var statisticsRange: Int var statisticsRangeCustomStart: Long var statisticsRangeCustomEnd: Long + var statisticsRangeLastDays: Int var statisticsDetailRange: Int var statisticsDetailRangeCustomStart: Long var statisticsDetailRangeCustomEnd: Long + var statisticsDetailRangeLastDays: Int var keepStatisticsRange: Boolean @@ -145,6 +147,8 @@ interface PrefsRepo { fun getStatisticsWidget(widgetId: Int): StatisticsWidgetData + fun getStatisticsWidgetLastDays(widgetId: Int): Int + fun removeStatisticsWidget(widgetId: Int) fun setQuickSettingsWidget(widgetId: Int, data: QuickSettingsWidgetType) diff --git a/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/view/StatisticsContainerFragment.kt b/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/view/StatisticsContainerFragment.kt index 4c67d20c4..9a6f7f4ed 100644 --- a/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/view/StatisticsContainerFragment.kt +++ b/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/view/StatisticsContainerFragment.kt @@ -9,6 +9,7 @@ import com.example.util.simpletimetracker.core.base.BaseFragment import com.example.util.simpletimetracker.core.di.BaseViewModelFactory import com.example.util.simpletimetracker.core.dialog.CustomRangeSelectionDialogListener import com.example.util.simpletimetracker.core.dialog.DateTimeDialogListener +import com.example.util.simpletimetracker.core.dialog.DurationDialogListener import com.example.util.simpletimetracker.core.view.SafeFragmentStateAdapter import com.example.util.simpletimetracker.core.viewData.RangesViewData import com.example.util.simpletimetracker.domain.model.Range @@ -25,6 +26,7 @@ import javax.inject.Inject class StatisticsContainerFragment : BaseFragment(), DateTimeDialogListener, + DurationDialogListener, CustomRangeSelectionDialogListener { override val inflater: (LayoutInflater, ViewGroup?, Boolean) -> Binding = @@ -65,6 +67,10 @@ class StatisticsContainerFragment : settingsViewModel.onCustomRangeSelected(range) } + override fun onCountSet(count: Long, tag: String?) { + settingsViewModel.onCountSet(count, tag) + } + override fun initViewModel() { with(viewModel) { title.observe(::updateTitle) diff --git a/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsContainerViewModel.kt b/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsContainerViewModel.kt index 19133a065..a3d646678 100644 --- a/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsContainerViewModel.kt +++ b/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsContainerViewModel.kt @@ -9,6 +9,7 @@ import com.example.util.simpletimetracker.core.mapper.RangeViewDataMapper import com.example.util.simpletimetracker.core.mapper.TimeMapper import com.example.util.simpletimetracker.core.viewData.RangesViewData import com.example.util.simpletimetracker.core.viewData.SelectDateViewData +import com.example.util.simpletimetracker.core.viewData.SelectLastDaysViewData import com.example.util.simpletimetracker.core.viewData.SelectRangeViewData import com.example.util.simpletimetracker.domain.extension.orZero import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor @@ -18,6 +19,7 @@ import com.example.util.simpletimetracker.navigation.Router import com.example.util.simpletimetracker.navigation.params.screen.CustomRangeSelectionParams import com.example.util.simpletimetracker.navigation.params.screen.DateTimeDialogParams import com.example.util.simpletimetracker.navigation.params.screen.DateTimeDialogType +import com.example.util.simpletimetracker.navigation.params.screen.DurationDialogParams import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject @@ -83,6 +85,10 @@ class StatisticsContainerViewModel @Inject constructor( onSelectRangeClick() updateRanges() } + is SelectLastDaysViewData -> { + onSelectLastDaysClick() + updateRanges() + } } } @@ -134,6 +140,20 @@ class StatisticsContainerViewModel @Inject constructor( ).let(router::navigate) } + private fun onSelectLastDaysClick() = viewModelScope.launch { + DurationDialogParams( + tag = LAST_DAYS_COUNT_TAG, + value = DurationDialogParams.Value.Count( + getCurrentLastDaysCount().toLong(), + ), + hideDisableButton = true, + ).let(router::navigate) + } + + private suspend fun getCurrentLastDaysCount(): Int { + return prefsInteractor.getStatisticsLastDays() + } + private suspend fun getRangeLength(): RangeLength { return rangeLength ?: prefsInteractor.getStatisticsRange() } @@ -164,7 +184,11 @@ class StatisticsContainerViewModel @Inject constructor( } private suspend fun loadRanges(): RangesViewData { - return rangeViewDataMapper.mapToRanges(getRangeLength()) + return rangeViewDataMapper.mapToRanges( + currentRange = getRangeLength(), + addSelection = true, + lastDaysCount = getCurrentLastDaysCount(), + ) } private fun updateNavButtonsVisibility() = viewModelScope.launch { @@ -179,6 +203,7 @@ class StatisticsContainerViewModel @Inject constructor( } companion object { + const val LAST_DAYS_COUNT_TAG = "statistics_last_days_count_tag" private const val DATE_TAG = "statistics_date_tag" } } diff --git a/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsSettingsViewModel.kt b/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsSettingsViewModel.kt index 72b50fb60..eeda73bbe 100644 --- a/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsSettingsViewModel.kt +++ b/features/feature_statistics/src/main/java/com/example/util/simpletimetracker/feature_statistics/viewModel/StatisticsSettingsViewModel.kt @@ -6,15 +6,18 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.example.util.simpletimetracker.core.extension.set import com.example.util.simpletimetracker.core.viewData.RangeViewData +import com.example.util.simpletimetracker.domain.interactor.GetProcessedLastDaysCountInteractor import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor import com.example.util.simpletimetracker.domain.model.Range import com.example.util.simpletimetracker.domain.model.RangeLength +import com.example.util.simpletimetracker.feature_statistics.viewModel.StatisticsContainerViewModel.Companion.LAST_DAYS_COUNT_TAG import com.example.util.simpletimetracker.feature_views.spinner.CustomSpinner import kotlinx.coroutines.launch import javax.inject.Inject class StatisticsSettingsViewModel @Inject constructor( private val prefsInteractor: PrefsInteractor, + private val getProcessedLastDaysCountInteractor: GetProcessedLastDaysCountInteractor, ) : ViewModel() { val rangeUpdated: LiveData = MutableLiveData() @@ -27,9 +30,17 @@ class StatisticsSettingsViewModel @Inject constructor( } fun onCustomRangeSelected(range: Range) = viewModelScope.launch { - RangeLength.Custom(range).let { - prefsInteractor.setStatisticsRange(it) - rangeUpdated.set(it) - } + val newRange = RangeLength.Custom(range) + prefsInteractor.setStatisticsRange(newRange) + rangeUpdated.set(newRange) + } + + fun onCountSet(count: Long, tag: String?) = viewModelScope.launch { + if (tag != LAST_DAYS_COUNT_TAG) return@launch + + val lastDaysCount = getProcessedLastDaysCountInteractor.execute(count) + val newRange = RangeLength.Last(lastDaysCount) + prefsInteractor.setStatisticsRange(newRange) + rangeUpdated.set(newRange) } } diff --git a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt index 29eaa225b..fb21de86f 100644 --- a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt +++ b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt @@ -257,7 +257,7 @@ class StatisticsDetailChartInteractor @Inject constructor( is RangeLength.Custom -> { customRangeGroupings.first { it.first == appliedChartGrouping }.second } - is RangeLength.Last -> rangeLength.DAYS + is RangeLength.Last -> rangeLength.days } return when (appliedChartGrouping) { diff --git a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailStreaksInteractor.kt b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailStreaksInteractor.kt index ae67d91c1..d4a32dc2d 100644 --- a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailStreaksInteractor.kt +++ b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailStreaksInteractor.kt @@ -615,12 +615,12 @@ class StatisticsDetailStreaksInteractor @Inject constructor( return when (rangeLength) { is RangeLength.Day, is RangeLength.Week, - is RangeLength.Last, -> true is RangeLength.Month, is RangeLength.Year, -> false is RangeLength.All, + is RangeLength.Last, is RangeLength.Custom, -> dataSize <= RANGE_ALL_STREAKS_CALENDAR_CUTOFF } diff --git a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/view/StatisticsDetailFragment.kt b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/view/StatisticsDetailFragment.kt index 3525c96bd..182324a3f 100644 --- a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/view/StatisticsDetailFragment.kt +++ b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/view/StatisticsDetailFragment.kt @@ -7,6 +7,7 @@ import androidx.fragment.app.viewModels import com.example.util.simpletimetracker.core.base.BaseFragment import com.example.util.simpletimetracker.core.dialog.CustomRangeSelectionDialogListener import com.example.util.simpletimetracker.core.dialog.DateTimeDialogListener +import com.example.util.simpletimetracker.core.dialog.DurationDialogListener import com.example.util.simpletimetracker.core.dialog.RecordsFilterListener import com.example.util.simpletimetracker.core.extension.setSharedTransitions import com.example.util.simpletimetracker.core.extension.toViewData @@ -40,6 +41,7 @@ import com.example.util.simpletimetracker.feature_statistics_detail.databinding. class StatisticsDetailFragment : BaseFragment(), DateTimeDialogListener, + DurationDialogListener, CustomRangeSelectionDialogListener, RecordsFilterListener { @@ -106,6 +108,10 @@ class StatisticsDetailFragment : viewModel.onCustomRangeSelected(range) } + override fun onCountSet(count: Long, tag: String?) { + viewModel.onCountSet(count, tag) + } + override fun initViewModel(): Unit = with(viewModel) { initialize(params) diff --git a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/StatisticsDetailViewModel.kt b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/StatisticsDetailViewModel.kt index 402966e7e..0d937acd7 100644 --- a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/StatisticsDetailViewModel.kt +++ b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/StatisticsDetailViewModel.kt @@ -182,6 +182,10 @@ class StatisticsDetailViewModel @Inject constructor( rangeDelegate.onCustomRangeSelected(range) } + fun onCountSet(count: Long, tag: String?) = viewModelScope.launch { + rangeDelegate.onCountSet(count, tag) + } + fun onStreaksCalendarClick( viewData: SeriesCalendarView.ViewData, coordinates: Coordinates, diff --git a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/delegate/StatisticsDetailRangeViewModelDelegate.kt b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/delegate/StatisticsDetailRangeViewModelDelegate.kt index 0383243a0..b2346e519 100644 --- a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/delegate/StatisticsDetailRangeViewModelDelegate.kt +++ b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/viewModel/delegate/StatisticsDetailRangeViewModelDelegate.kt @@ -10,7 +10,9 @@ import com.example.util.simpletimetracker.core.mapper.TimeMapper import com.example.util.simpletimetracker.core.viewData.RangeViewData import com.example.util.simpletimetracker.core.viewData.RangesViewData import com.example.util.simpletimetracker.core.viewData.SelectDateViewData +import com.example.util.simpletimetracker.core.viewData.SelectLastDaysViewData import com.example.util.simpletimetracker.core.viewData.SelectRangeViewData +import com.example.util.simpletimetracker.domain.interactor.GetProcessedLastDaysCountInteractor import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor import com.example.util.simpletimetracker.domain.model.Range import com.example.util.simpletimetracker.domain.model.RangeLength @@ -20,6 +22,7 @@ import com.example.util.simpletimetracker.navigation.Router import com.example.util.simpletimetracker.navigation.params.screen.CustomRangeSelectionParams import com.example.util.simpletimetracker.navigation.params.screen.DateTimeDialogParams import com.example.util.simpletimetracker.navigation.params.screen.DateTimeDialogType +import com.example.util.simpletimetracker.navigation.params.screen.DurationDialogParams import com.example.util.simpletimetracker.navigation.params.screen.StatisticsDetailParams import kotlinx.coroutines.launch import javax.inject.Inject @@ -30,6 +33,7 @@ class StatisticsDetailRangeViewModelDelegate @Inject constructor( private val prefsInteractor: PrefsInteractor, private val timeMapper: TimeMapper, private val recordFilterInteractor: RecordFilterInteractor, + private val getProcessedLastDaysCountInteractor: GetProcessedLastDaysCountInteractor, ) : StatisticsDetailViewModelDelegate, ViewModelDelegate() { val title: LiveData by lazySuspend { loadTitle() } @@ -71,6 +75,10 @@ class StatisticsDetailRangeViewModelDelegate @Inject constructor( onSelectRangeClick() updateRanges() } + is SelectLastDaysViewData -> { + onSelectLastDaysClick() + updateRanges() + } is RangeViewData -> { rangeLength = item.range onRangeChanged() @@ -95,6 +103,14 @@ class StatisticsDetailRangeViewModelDelegate @Inject constructor( onRangeChanged() } + fun onCountSet(count: Long, tag: String?) { + if (tag != LAST_DAYS_COUNT_TAG) return + + val lastDaysCount = getProcessedLastDaysCountInteractor.execute(count) + rangeLength = RangeLength.Last(lastDaysCount) + onRangeChanged() + } + private fun onSelectDateClick() = delegateScope.launch { val useMilitaryTime = prefsInteractor.getUseMilitaryTimeFormat() val firstDayOfWeek = prefsInteractor.getFirstDayOfWeek() @@ -131,7 +147,9 @@ class StatisticsDetailRangeViewModelDelegate @Inject constructor( is StatisticsDetailParams.RangeLengthParams.Custom -> Range( timeStarted = range.start, timeEnded = range.end, ).let(RangeLength::Custom) - is StatisticsDetailParams.RangeLengthParams.Last -> RangeLength.Last + is StatisticsDetailParams.RangeLengthParams.Last -> RangeLength.Last( + days = range.days, + ) } } @@ -152,8 +170,24 @@ class StatisticsDetailRangeViewModelDelegate @Inject constructor( ).let(router::navigate) } - private fun onRangeChanged() { - delegateScope.launch { prefsInteractor.setStatisticsDetailRange(rangeLength) } + // TODO add custom range reopen same as last days + private fun onSelectLastDaysClick() = delegateScope.launch { + DurationDialogParams( + tag = LAST_DAYS_COUNT_TAG, + value = DurationDialogParams.Value.Count( + getCurrentLastDaysCount().toLong(), + ), + hideDisableButton = true, + ).let(router::navigate) + } + + private suspend fun getCurrentLastDaysCount(): Int { + return (rangeLength as? RangeLength.Last)?.days + ?: prefsInteractor.getStatisticsDetailLastDays() + } + + private fun onRangeChanged() = delegateScope.launch { + prefsInteractor.setStatisticsDetailRange(rangeLength) parent?.onRangeChanged() updatePosition(0) } @@ -181,12 +215,16 @@ class StatisticsDetailRangeViewModelDelegate @Inject constructor( ) } - private fun updateRanges() { + private fun updateRanges() = delegateScope.launch { rangeItems.set(loadRanges()) } - private fun loadRanges(): RangesViewData { - return rangeViewDataMapper.mapToRanges(rangeLength) + private suspend fun loadRanges(): RangesViewData { + return rangeViewDataMapper.mapToRanges( + currentRange = rangeLength, + addSelection = true, + lastDaysCount = getCurrentLastDaysCount(), + ) } private fun updateButtonsVisibility() { @@ -204,6 +242,7 @@ class StatisticsDetailRangeViewModelDelegate @Inject constructor( } companion object { - const val DATE_TAG = "statistics_detail_date_tag" + private const val LAST_DAYS_COUNT_TAG = "statistics_detail_last_days_count_tag" + private const val DATE_TAG = "statistics_detail_date_tag" } } \ No newline at end of file diff --git a/features/feature_widget/src/main/AndroidManifest.xml b/features/feature_widget/src/main/AndroidManifest.xml index 1596d075f..dc1da24b8 100644 --- a/features/feature_widget/src/main/AndroidManifest.xml +++ b/features/feature_widget/src/main/AndroidManifest.xml @@ -11,7 +11,7 @@ diff --git a/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsActivity.kt b/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsActivity.kt new file mode 100644 index 000000000..e56c7c26a --- /dev/null +++ b/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsActivity.kt @@ -0,0 +1,47 @@ +package com.example.util.simpletimetracker.feature_widget.statistics.settings + +import android.app.Activity +import android.appwidget.AppWidgetManager +import android.content.Intent +import android.os.Bundle +import com.example.util.simpletimetracker.core.base.BaseActivity +import com.example.util.simpletimetracker.core.manager.ThemeManager +import com.example.util.simpletimetracker.core.provider.ContextProvider +import com.example.util.simpletimetracker.feature_widget.R +import com.example.util.simpletimetracker.navigation.Router +import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject + +@AndroidEntryPoint +class WidgetStatisticsActivity : BaseActivity() { + + @Inject + lateinit var router: Router + + @Inject + lateinit var themeManager: ThemeManager + + @Inject + lateinit var contextProvider: ContextProvider + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + contextProvider.attach(this) + + // Set the result to CANCELED. This will cause the widget host to cancel + // out of the widget placement if they press the back button. + setResult(RESULT_CANCELED) + + themeManager.setTheme(this) + setContentView(R.layout.widget_statistics_activity) + router.bind(this) + } + + fun exit(widgetId: Int) { + val resultValue = Intent().apply { + putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId) + } + setResult(Activity.RESULT_OK, resultValue) + finish() + } +} \ No newline at end of file diff --git a/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsActivity.kt b/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsFragment.kt similarity index 70% rename from features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsActivity.kt rename to features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsFragment.kt index 4a2b71185..029856ef0 100644 --- a/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsActivity.kt +++ b/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsFragment.kt @@ -1,35 +1,36 @@ package com.example.util.simpletimetracker.feature_widget.statistics.settings -import android.app.Activity import android.appwidget.AppWidgetManager -import android.content.Intent -import android.os.Bundle -import androidx.activity.viewModels -import com.example.util.simpletimetracker.core.base.BaseActivity +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.fragment.app.viewModels +import com.example.util.simpletimetracker.core.base.BaseFragment +import com.example.util.simpletimetracker.core.dialog.DurationDialogListener import com.example.util.simpletimetracker.core.manager.ThemeManager -import com.example.util.simpletimetracker.core.provider.ContextProvider import com.example.util.simpletimetracker.feature_base_adapter.BaseRecyclerAdapter import com.example.util.simpletimetracker.feature_base_adapter.category.createCategoryAdapterDelegate import com.example.util.simpletimetracker.feature_base_adapter.empty.createEmptyAdapterDelegate import com.example.util.simpletimetracker.feature_base_adapter.loader.createLoaderAdapterDelegate import com.example.util.simpletimetracker.feature_base_adapter.recordType.createRecordTypeAdapterDelegate import com.example.util.simpletimetracker.feature_views.extension.setOnClick -import com.example.util.simpletimetracker.feature_widget.databinding.WidgetStatisticsSettingsActivityBinding import com.google.android.flexbox.FlexDirection import com.google.android.flexbox.FlexWrap import com.google.android.flexbox.FlexboxLayoutManager import com.google.android.flexbox.JustifyContent import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject +import com.example.util.simpletimetracker.feature_widget.databinding.WidgetStatisticsSettingsFragmentBinding as Binding @AndroidEntryPoint -class WidgetStatisticsSettingsActivity : BaseActivity() { +class WidgetStatisticsSettingsFragment : + BaseFragment(), + DurationDialogListener { - @Inject - lateinit var themeManager: ThemeManager + override val inflater: (LayoutInflater, ViewGroup?, Boolean) -> Binding = + Binding::inflate @Inject - lateinit var contextProvider: ContextProvider + lateinit var themeManager: ThemeManager private val viewModel: WidgetStatisticsSettingsViewModel by viewModels() @@ -42,33 +43,18 @@ class WidgetStatisticsSettingsActivity : BaseActivity() { ) } - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - contextProvider.attach(this) - - // Set the result to CANCELED. This will cause the widget host to cancel - // out of the widget placement if they press the back button. - setResult(RESULT_CANCELED) - - initUi() - } - - private fun initUi() { - themeManager.setTheme(this) - val binding = WidgetStatisticsSettingsActivityBinding.inflate(layoutInflater) - setContentView(binding.root) - - // Ui + override fun initUi() { binding.rvWidgetStatisticsFilterContainer.apply { - layoutManager = FlexboxLayoutManager(this@WidgetStatisticsSettingsActivity).apply { + layoutManager = FlexboxLayoutManager(requireContext()).apply { flexDirection = FlexDirection.ROW justifyContent = JustifyContent.CENTER flexWrap = FlexWrap.WRAP } adapter = recordTypesAdapter } + } - // Ux + override fun initUx() { with(binding) { buttonsWidgetStatisticsSettingsFilterType.listener = viewModel::onFilterTypeClick btnWidgetStatisticsShowAll.setOnClick(viewModel::onShowAllClick) @@ -79,10 +65,11 @@ class WidgetStatisticsSettingsActivity : BaseActivity() { } btnWidgetStatisticsSettingsRange.setOnClick { spinnerWidgetStatisticsSettingsRange.performClick() } } + } - // ViewModel + override fun initViewModel() { with(viewModel) { - val widgetId = intent?.extras + val widgetId = activity?.intent?.extras ?.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID, @@ -98,11 +85,12 @@ class WidgetStatisticsSettingsActivity : BaseActivity() { } } + override fun onCountSet(count: Long, tag: String?) { + viewModel.onCountSet(count, tag) + } + + // TODO refactor to shared viewModel to pass data? private fun exit(widgetId: Int) { - val resultValue = Intent().apply { - putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId) - } - setResult(Activity.RESULT_OK, resultValue) - finish() + (activity as? WidgetStatisticsActivity)?.exit(widgetId) } } \ No newline at end of file diff --git a/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsViewModel.kt b/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsViewModel.kt index 74a0b4cce..a65f48058 100644 --- a/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsViewModel.kt +++ b/features/feature_widget/src/main/java/com/example/util/simpletimetracker/feature_widget/statistics/settings/WidgetStatisticsSettingsViewModel.kt @@ -13,9 +13,11 @@ import com.example.util.simpletimetracker.core.view.buttonsRowView.ButtonsRowVie import com.example.util.simpletimetracker.core.viewData.ChartFilterTypeViewData import com.example.util.simpletimetracker.core.viewData.RangeViewData import com.example.util.simpletimetracker.core.viewData.RangesViewData +import com.example.util.simpletimetracker.core.viewData.SelectLastDaysViewData import com.example.util.simpletimetracker.domain.UNCATEGORIZED_ITEM_ID import com.example.util.simpletimetracker.domain.UNTRACKED_ITEM_ID import com.example.util.simpletimetracker.domain.interactor.CategoryInteractor +import com.example.util.simpletimetracker.domain.interactor.GetProcessedLastDaysCountInteractor import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor import com.example.util.simpletimetracker.domain.interactor.RecordTagInteractor import com.example.util.simpletimetracker.domain.interactor.RecordTypeInteractor @@ -31,12 +33,15 @@ import com.example.util.simpletimetracker.feature_base_adapter.category.Category import com.example.util.simpletimetracker.feature_base_adapter.loader.LoaderViewData import com.example.util.simpletimetracker.feature_base_adapter.recordType.RecordTypeViewData import com.example.util.simpletimetracker.feature_views.spinner.CustomSpinner +import com.example.util.simpletimetracker.navigation.Router +import com.example.util.simpletimetracker.navigation.params.screen.DurationDialogParams import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.launch +import javax.inject.Inject @HiltViewModel class WidgetStatisticsSettingsViewModel @Inject constructor( + private val router: Router, private val prefsInteractor: PrefsInteractor, private val widgetInteractor: WidgetInteractor, private val recordTypeInteractor: RecordTypeInteractor, @@ -45,6 +50,7 @@ class WidgetStatisticsSettingsViewModel @Inject constructor( private val chartFilterViewDataMapper: ChartFilterViewDataMapper, private val rangeViewDataMapper: RangeViewDataMapper, private val chartFilterViewDataInteractor: ChartFilterViewDataInteractor, + private val getProcessedLastDaysCountInteractor: GetProcessedLastDaysCountInteractor, ) : ViewModel() { lateinit var extra: WidgetStatisticsSettingsExtra @@ -199,9 +205,22 @@ class WidgetStatisticsSettingsViewModel @Inject constructor( updateTitle() updateRanges() } + is SelectLastDaysViewData -> { + onSelectLastDaysClick() + } } } + fun onCountSet(count: Long, tag: String?) = viewModelScope.launch { + if (tag != LAST_DAYS_COUNT_TAG) return@launch + + val lastDaysCount = getProcessedLastDaysCountInteractor.execute(count) + val newRange = RangeLength.Last(lastDaysCount) + widgetData = widgetData.copy(rangeLength = newRange) + updateTitle() + updateRanges() + } + fun onSaveClick() { viewModelScope.launch { prefsInteractor.setStatisticsWidget(extra.widgetId, widgetData) @@ -210,6 +229,21 @@ class WidgetStatisticsSettingsViewModel @Inject constructor( } } + private fun onSelectLastDaysClick() = viewModelScope.launch { + DurationDialogParams( + tag = LAST_DAYS_COUNT_TAG, + value = DurationDialogParams.Value.Count( + getCurrentLastDaysCount().toLong(), + ), + hideDisableButton = true, + ).let(router::navigate) + } + + private suspend fun getCurrentLastDaysCount(): Int { + return (widgetData.rangeLength as? RangeLength.Last)?.days + ?: prefsInteractor.getStatisticsWidgetLastDays(extra.widgetId) + } + private suspend fun initializeWidgetData() { widgetData = prefsInteractor.getStatisticsWidget(extra.widgetId) } @@ -319,7 +353,15 @@ class WidgetStatisticsSettingsViewModel @Inject constructor( rangeItems.set(loadRanges()) } - private fun loadRanges(): RangesViewData { - return rangeViewDataMapper.mapToRanges(widgetData.rangeLength, addSelection = false) + private suspend fun loadRanges(): RangesViewData { + return rangeViewDataMapper.mapToRanges( + currentRange = widgetData.rangeLength, + addSelection = false, + lastDaysCount = getCurrentLastDaysCount(), + ) + } + + companion object { + private const val LAST_DAYS_COUNT_TAG = "widget_statistics_last_days_count_tag" } } diff --git a/features/feature_widget/src/main/res/layout/widget_statistics_activity.xml b/features/feature_widget/src/main/res/layout/widget_statistics_activity.xml new file mode 100644 index 000000000..3f04347f1 --- /dev/null +++ b/features/feature_widget/src/main/res/layout/widget_statistics_activity.xml @@ -0,0 +1,9 @@ + + diff --git a/features/feature_widget/src/main/res/layout/widget_statistics_settings_activity.xml b/features/feature_widget/src/main/res/layout/widget_statistics_settings_fragment.xml similarity index 100% rename from features/feature_widget/src/main/res/layout/widget_statistics_settings_activity.xml rename to features/feature_widget/src/main/res/layout/widget_statistics_settings_fragment.xml diff --git a/features/feature_widget/src/main/res/layout/widget_universal_activity.xml b/features/feature_widget/src/main/res/layout/widget_universal_activity.xml index f4fb39937..a843bc428 100644 --- a/features/feature_widget/src/main/res/layout/widget_universal_activity.xml +++ b/features/feature_widget/src/main/res/layout/widget_universal_activity.xml @@ -6,4 +6,4 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="true" - app:navGraph="@navigation/widget_nav_graph" /> + app:navGraph="@navigation/widget_universal_nav_graph" /> diff --git a/features/feature_widget/src/main/res/layout/widget_universal_fragment.xml b/features/feature_widget/src/main/res/layout/widget_universal_fragment.xml index 4f6e11ee3..04bd93dab 100644 --- a/features/feature_widget/src/main/res/layout/widget_universal_fragment.xml +++ b/features/feature_widget/src/main/res/layout/widget_universal_fragment.xml @@ -12,7 +12,7 @@ android:clipToPadding="false" android:paddingVertical="20dp" tools:itemCount="30" - tools:listitem="@layout/item_widget_record_type_layout" /> + tools:listitem="@layout/item_record_type_layout" /> + + + + + + \ No newline at end of file diff --git a/features/feature_widget/src/main/res/navigation/widget_nav_graph.xml b/features/feature_widget/src/main/res/navigation/widget_universal_nav_graph.xml similarity index 100% rename from features/feature_widget/src/main/res/navigation/widget_nav_graph.xml rename to features/feature_widget/src/main/res/navigation/widget_universal_nav_graph.xml diff --git a/features/feature_widget/src/main/res/xml/widget_statistics_chart_info.xml b/features/feature_widget/src/main/res/xml/widget_statistics_chart_info.xml index 2924969c0..225f32408 100644 --- a/features/feature_widget/src/main/res/xml/widget_statistics_chart_info.xml +++ b/features/feature_widget/src/main/res/xml/widget_statistics_chart_info.xml @@ -1,7 +1,7 @@ سنة كامل الفترة الزمنية - آخر ٧ أيام اختر تاريخ اختر أسبوع اختر شهر اختر سنة + + آخر %s أيام + آخر %s أيام + آخر %s أيام + آخر %s أيام + آخر %s أيام + آخر %s أيام + + حسناً إلغاء diff --git a/resources/src/main/res/values-ca/strings.xml b/resources/src/main/res/values-ca/strings.xml index c90a3ef4d..37b96234c 100644 --- a/resources/src/main/res/values-ca/strings.xml +++ b/resources/src/main/res/values-ca/strings.xml @@ -33,12 +33,20 @@ Any Global Rang - Últims 7 dies Seleccioneu una data Seleccioneu una setmana Seleccioneu un mes Seleccioneu un any + + + Últim %s dia + + + Últims %s dies + Últims %s dies + + D\'acord Cancel·la @@ -416,11 +424,11 @@ Exemple:
Top multitasca - + Enregistrament - - - + + + Enregistraments Enregistraments diff --git a/resources/src/main/res/values-de/strings.xml b/resources/src/main/res/values-de/strings.xml index 182686f3d..b86f81737 100644 --- a/resources/src/main/res/values-de/strings.xml +++ b/resources/src/main/res/values-de/strings.xml @@ -33,12 +33,20 @@ Jahr Gesamt Intervall - Letzten 7 Tage Wähle Datum Wähle Woche Wähle Monat Wähle Jahr + + + Letzter %s Tag + + + + Letzten %s Tage + + OK Abbrechen diff --git a/resources/src/main/res/values-es/strings.xml b/resources/src/main/res/values-es/strings.xml index 94f543964..85af234d9 100644 --- a/resources/src/main/res/values-es/strings.xml +++ b/resources/src/main/res/values-es/strings.xml @@ -33,12 +33,20 @@ Año Global Rango - Los últimos 7 días Seleccione una fecha Seleccione una semana Seleccione un mes Seleccione un año + + + Los último %s día + + + Los últimos %s días + Los últimos %s días + + OK Cancelar @@ -416,11 +424,11 @@ Ejemplo:
Principal multitarea - + Registro - - - + + + Registros Registros diff --git a/resources/src/main/res/values-fa/strings.xml b/resources/src/main/res/values-fa/strings.xml index 81970aff9..8e66fc5e3 100644 --- a/resources/src/main/res/values-fa/strings.xml +++ b/resources/src/main/res/values-fa/strings.xml @@ -33,12 +33,20 @@ سال به طور کلی محدوده - 7 روز قبلی انتخاب تاریخ انتخاب هفته انتخاب ماه انتخاب سال + + + %s روز قبلی + + + + + + موافقت لغو @@ -416,11 +424,11 @@ چند کاره برتر - + تاریخچه - - - + + + تاریخچه diff --git a/resources/src/main/res/values-fr/strings.xml b/resources/src/main/res/values-fr/strings.xml index d4753590f..63f1297c0 100644 --- a/resources/src/main/res/values-fr/strings.xml +++ b/resources/src/main/res/values-fr/strings.xml @@ -33,12 +33,20 @@ Année Global Intervalle - Les 7 derniers jours Sélectionner une date Sélectionner une semaine Sélectionner un mois Sélectionner une année + + + Les %s dernier jour + + + Les %s derniers jours + Les %s derniers jours + + OK Annuler @@ -416,10 +424,10 @@ Exemple:
Top multitâche - + Enregistrement - - + + Enregistrements Enregistrements diff --git a/resources/src/main/res/values-hi/strings.xml b/resources/src/main/res/values-hi/strings.xml index 9b4dd4d7d..9c38a23b7 100644 --- a/resources/src/main/res/values-hi/strings.xml +++ b/resources/src/main/res/values-hi/strings.xml @@ -33,12 +33,20 @@ साल कुल मिलाकर सीमा - पिछले 7 दिन तारीख़ चुनें सप्ताह का चयन करें महीना चुनिए वर्ष का चयन करें + + + अंतिम %s दिन + + + + पिछले %s दिन + + ठीक है रद्द करे @@ -416,11 +424,11 @@ csv फ़ाइल में कॉमा से अलग किए गए य शीर्ष मल्टीटास्कड - + रिकॉर्ड - - - + + + अभिलेख diff --git a/resources/src/main/res/values-in/strings.xml b/resources/src/main/res/values-in/strings.xml index 25cb70b6a..a5fde5113 100644 --- a/resources/src/main/res/values-in/strings.xml +++ b/resources/src/main/res/values-in/strings.xml @@ -33,12 +33,20 @@ Tahun Keseluruhan Rentang - 7 hari terakhir Pilih tanggal Pilih minggu Pilih bulan Pilih tahun + + + + + + + %s hari terakhir + + Oke Batal @@ -416,11 +424,11 @@ Contoh:
Multitugas teratas - - - - - + + + + + Rekor diff --git a/resources/src/main/res/values-it/strings.xml b/resources/src/main/res/values-it/strings.xml index 6c41a1d3f..e476c4c05 100644 --- a/resources/src/main/res/values-it/strings.xml +++ b/resources/src/main/res/values-it/strings.xml @@ -33,12 +33,20 @@ Anno Totale Intervallo - Ultimi 7 giorni Seleziona data Seleziona settimana Seleziona mese Seleziona anno + + + Ultimo %s giorno + + + Ultimi %s giorni + Ultimi %s giorni + + OK Annulla @@ -416,11 +424,11 @@ Esempio:
Il massimo del multitasking - + Registrazione - - - + + + Registrazioni Registrazioni diff --git a/resources/src/main/res/values-ja/strings.xml b/resources/src/main/res/values-ja/strings.xml index 17394b71b..8e731d9ce 100644 --- a/resources/src/main/res/values-ja/strings.xml +++ b/resources/src/main/res/values-ja/strings.xml @@ -33,12 +33,20 @@ 全期間 範囲 - 過去 7 日間 日付指定 週指定 月指定 年指定 + + + + + + + 過去 %s 日間 + + OK キャンセル @@ -416,11 +424,11 @@ CSV ファイルには、カンマで区切られた次の列が含まれてい トップのマルチタスク - 記録 - 記録 - 記録 - 記録 - 記録 + + + + + 記録 diff --git a/resources/src/main/res/values-ko/strings.xml b/resources/src/main/res/values-ko/strings.xml index 35afd999a..892be7653 100644 --- a/resources/src/main/res/values-ko/strings.xml +++ b/resources/src/main/res/values-ko/strings.xml @@ -33,12 +33,20 @@ 전 기간 범위 - 지난 7일 날짜 선택 주 선택 월 선택 연 선택 + + + + + + + 지난 %s일 + + 확인 취소 @@ -416,11 +424,11 @@ csv 파일은 다음과 같은 열(column)들을 가져야합니다:
최고의 멀티태스킹 - - - - - + + + + + 기록 diff --git a/resources/src/main/res/values-nl/strings.xml b/resources/src/main/res/values-nl/strings.xml index a878a1567..4e482f17b 100644 --- a/resources/src/main/res/values-nl/strings.xml +++ b/resources/src/main/res/values-nl/strings.xml @@ -33,12 +33,20 @@ Jaar Algemeen Bereik - Laatste 7 dagen Selecteer dag Selecteer week Selecteer maand Selecteer jaar + + + Laatste %s dag + + + + Laatste %s dagen + + OK Annuleren diff --git a/resources/src/main/res/values-pl/strings.xml b/resources/src/main/res/values-pl/strings.xml index 47d316ff2..54fa8c6be 100644 --- a/resources/src/main/res/values-pl/strings.xml +++ b/resources/src/main/res/values-pl/strings.xml @@ -33,12 +33,20 @@ Rok Cały okres Zakres - Ostatnie 7 dni Wybierz dzień Wybierz tydzień Wybierz miesiąc Wybierz rok + + + Ostatni %s dzień + + Ostatnie %s dni + Ostatnie %s dni + Ostatnie %s dni + + OK Cancel @@ -416,9 +424,9 @@ Przykład:
Najczęściej razem z - + rekord - rekordy + rekordów rekordów rekordów diff --git a/resources/src/main/res/values-pt-rPT/strings.xml b/resources/src/main/res/values-pt-rPT/strings.xml index 87c12ee15..98abf0754 100644 --- a/resources/src/main/res/values-pt-rPT/strings.xml +++ b/resources/src/main/res/values-pt-rPT/strings.xml @@ -33,12 +33,20 @@ Ano Total Período - Últimos 7 dias Selecionar data Selecionar semana Selecionar mês Selecionar ano + + + Último %s dia + + + Últimos %s dias + Últimos %s dias + + OK Cancelar @@ -416,11 +424,11 @@ Exemplo:
Principais multitarefas - + Registo - - - + + + Registos @@ -431,7 +439,7 @@ Exemplo:
Definições rápidas Não encontrado - + Notificação de inatividade Não esqueçer de registar o tempo Notificação de atividade diff --git a/resources/src/main/res/values-pt/strings.xml b/resources/src/main/res/values-pt/strings.xml index f0c209319..ea02983c1 100644 --- a/resources/src/main/res/values-pt/strings.xml +++ b/resources/src/main/res/values-pt/strings.xml @@ -33,12 +33,20 @@ Ano Total Período - Últimos 7 dias Selecionar data Selecionar semana Selecionar mês Selecionar ano + + + Último %s dia + + + Últimos %s dias + Últimos %s dias + + OK Cancelar @@ -416,11 +424,11 @@ Exemplo:
Principais multitarefas - + Registro - - - + + + Registros Registros diff --git a/resources/src/main/res/values-ro/strings.xml b/resources/src/main/res/values-ro/strings.xml index 316383b58..052ae3aab 100644 --- a/resources/src/main/res/values-ro/strings.xml +++ b/resources/src/main/res/values-ro/strings.xml @@ -33,12 +33,20 @@ An Toate Interval - Ultimele 7 zile Alege ziua Alege săptămâna Alege luna Alege anul + + + Ultima %s zi + + Ultimele %s zile + + Ultimele %s zile + + OK Anulează @@ -416,11 +424,11 @@ Examplu:
Top multitasked - Înregistrări + Înregistrări - Înregistrări + Înregistrări - Înregistrări + Înregistrări diff --git a/resources/src/main/res/values-ru/strings.xml b/resources/src/main/res/values-ru/strings.xml index c2128f787..640e01630 100644 --- a/resources/src/main/res/values-ru/strings.xml +++ b/resources/src/main/res/values-ru/strings.xml @@ -33,12 +33,20 @@ Год Все время Диапазон - Последние 7 дней Выберите дату Выберите неделю Выберите месяц Выберите год + + + Последний %s день + + Последние %s дня + Последние %s дней + Последние %s дней + + OK Отмена @@ -416,9 +424,9 @@ CSV-файл должен содержать следующие столбцы, Топ многозадачности - Записей + Запись - Записи + Записи Записей Записей diff --git a/resources/src/main/res/values-sv/strings.xml b/resources/src/main/res/values-sv/strings.xml index b80552c9f..9a811e9f1 100644 --- a/resources/src/main/res/values-sv/strings.xml +++ b/resources/src/main/res/values-sv/strings.xml @@ -33,12 +33,20 @@ År Allt Intervall - Senaste 7 dagarna Välj dag Välj vecka Välj månad Välj år + + + Senaste %s dag + + + + Senaste %s dagarna + + Ok Avbryt @@ -416,11 +424,11 @@ Exempel:
Top multitasked - + Händelse - - - + + + Händelser diff --git a/resources/src/main/res/values-tr/strings.xml b/resources/src/main/res/values-tr/strings.xml index be3fa221d..5b699420d 100644 --- a/resources/src/main/res/values-tr/strings.xml +++ b/resources/src/main/res/values-tr/strings.xml @@ -33,12 +33,20 @@ Yıl Tümü Tarih aralığı - Son 7 gün Tarih seçin Hafta seçin Ay seçin Yıl seçin + + + Son %s gün + + + + Son %s gün + + Tamam İptal @@ -416,11 +424,11 @@ CSV dosyası virgülle ayrılmış şu sütunları içermelidir:
En iyi çoklu görev - + Kayıt - - - + + + Kayıt diff --git a/resources/src/main/res/values-uk/strings.xml b/resources/src/main/res/values-uk/strings.xml index 2dc3e4b85..7fdd932b1 100644 --- a/resources/src/main/res/values-uk/strings.xml +++ b/resources/src/main/res/values-uk/strings.xml @@ -33,12 +33,20 @@ Рік Весь час Діапазон - Останні 7 днів Обрати дату Обрати тиждень Обрати місяць Обрати рік + + + Останній %s день + + Останні %s дні + Останні %s днів + Останні %s днів + + OK Скасувати @@ -416,9 +424,9 @@ Топ багатозадачності - Записів + Запис - Записи + Записи Записів Записів diff --git a/resources/src/main/res/values-vi/strings.xml b/resources/src/main/res/values-vi/strings.xml index 15f9307ed..150cf9ff0 100644 --- a/resources/src/main/res/values-vi/strings.xml +++ b/resources/src/main/res/values-vi/strings.xml @@ -33,12 +33,20 @@ Năm Tổng thể Phạm vi - 7 ngày qua Chọn ngày Chọn tuần Chọn tháng Chọn năm + + + + + + + %s ngày qua + + OK Hủy @@ -416,11 +424,11 @@ Ví dụ:
Đa nhiệm hàng đầu - - - - - + + + + + Bản ghi diff --git a/resources/src/main/res/values-zh-rTW/strings.xml b/resources/src/main/res/values-zh-rTW/strings.xml index 06f45aa20..a0d96b5b0 100644 --- a/resources/src/main/res/values-zh-rTW/strings.xml +++ b/resources/src/main/res/values-zh-rTW/strings.xml @@ -33,12 +33,20 @@ 全部 範圍 - 最後 7 天 選擇日 選擇周 選擇月 選擇年 + + + + + + + 最後 %s 天 + + 確定 取消 @@ -416,11 +424,11 @@ csv 文件必須包含以逗號分隔的這些列:
頂級多工處理 - - - - - + + + + + 紀錄 diff --git a/resources/src/main/res/values-zh/strings.xml b/resources/src/main/res/values-zh/strings.xml index 0d45b0cf8..525dde844 100644 --- a/resources/src/main/res/values-zh/strings.xml +++ b/resources/src/main/res/values-zh/strings.xml @@ -33,12 +33,20 @@ 全部 间隔 - 最近 7 天 选择日期 选择星期 选择月份 选择年份 + + + + + + + 最近 %s 天 + + 确认 取消 @@ -121,7 +129,7 @@ 下一个 重叠 记录完全重叠,将被删除 -` 未跟踪时间是指没有跟踪任何活动的时间。可以在设置中禁用它 + 未跟踪时间是指没有跟踪任何活动的时间。可以在设置中禁用它 未找到之前的记录 未找到下一条记录 diff --git a/resources/src/main/res/values/strings.xml b/resources/src/main/res/values/strings.xml index db02bb284..504eb5b91 100644 --- a/resources/src/main/res/values/strings.xml +++ b/resources/src/main/res/values/strings.xml @@ -33,12 +33,20 @@ Year Overall Range - Last 7 days Select date Select week Select month Select year + + Last %s days + Last %s day + Last %s days + Last %s days + Last %s days + Last %s days + + OK Cancel diff --git a/wear/src/main/java/com/example/util/simpletimetracker/presentation/ui/layout/ScrollingColumn.kt b/wear/src/main/java/com/example/util/simpletimetracker/presentation/ui/layout/ScrollingColumn.kt index 4d27ae49e..0b4f2c62c 100644 --- a/wear/src/main/java/com/example/util/simpletimetracker/presentation/ui/layout/ScrollingColumn.kt +++ b/wear/src/main/java/com/example/util/simpletimetracker/presentation/ui/layout/ScrollingColumn.kt @@ -12,7 +12,6 @@ import androidx.compose.foundation.selection.selectableGroup import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp import androidx.wear.compose.material.AutoCenteringParams import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.ScalingLazyColumn