Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Compani
import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Companion.KEY_ACTIVITY_REMINDER_RECURRENT
import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Companion.KEY_ALLOW_MULTIPLE_ACTIVITY_FILTERS
import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Companion.KEY_ALLOW_MULTITASKING
import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Companion.KEY_ALWAYS_SHOW_WIDGET_ACTIVITY_COLORS
import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Companion.KEY_AUTOMATED_TRACKING_RECEIVE_QUERIES
import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Companion.KEY_AUTOMATED_TRACKING_SEND_EVENTS
import com.example.util.simpletimetracker.data_local.prefs.PrefsRepoImpl.Companion.KEY_AUTOSTART_POMODORO_ACTIVITIES
Expand Down Expand Up @@ -252,6 +253,7 @@ class BackupPrefsRepo @Inject constructor(
PrefsProcessor(KEY_AUTOMATED_TRACKING_RECEIVE_QUERIES, ::automatedTrackingReceiveQueries),
PrefsProcessor(KEY_REPEAT_BUTTON_TYPE, ::repeatButtonType),
PrefsProcessor(KEY_WIDGET_TRANSPARENCY_PERCENT, ::widgetBackgroundTransparencyPercent),
PrefsProcessor(KEY_ALWAYS_SHOW_WIDGET_ACTIVITY_COLORS, ::alwaysShowWidgetActivityColors),
PrefsProcessor(KEY_DEFAULT_TYPES_HIDDEN, ::defaultTypesHidden),
PrefsProcessor(KEY_IS_NAV_BAR_AT_THE_BOTTOM, ::isNavBarAtTheBottom),
PrefsProcessor(KEY_IS_CATEGORIES_SEARCH_ENABLED, ::isCategoriesSearchEnabled),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ class PrefsRepoImpl @Inject constructor(
KEY_WIDGET_TRANSPARENCY_PERCENT, 60,
)

override var alwaysShowWidgetActivityColors: Boolean by prefs.delegate(
KEY_ALWAYS_SHOW_WIDGET_ACTIVITY_COLORS, false,
)

override var defaultTypesHidden: Boolean by prefs.delegate(
KEY_DEFAULT_TYPES_HIDDEN, false,
)
Expand Down Expand Up @@ -831,6 +835,7 @@ class PrefsRepoImpl @Inject constructor(
const val KEY_AUTOMATED_TRACKING_RECEIVE_QUERIES = "automatedTrackingReceiveQueries"
const val KEY_REPEAT_BUTTON_TYPE = "repeatButtonType"
const val KEY_WIDGET_TRANSPARENCY_PERCENT = "widgetTransparencyPercent"
const val KEY_ALWAYS_SHOW_WIDGET_ACTIVITY_COLORS = "alwaysShowWidgetActivityColors"
const val KEY_DEFAULT_TYPES_HIDDEN = "defaultTypesHidden"
const val KEY_IS_NAV_BAR_AT_THE_BOTTOM = "isNavBarAtTheBottom"
const val KEY_IS_CATEGORIES_SEARCH_ENABLED = "isCategoriesSearchEnabled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ class UpdateExternalViewsInteractor @Inject constructor(
)
}

suspend fun onWidgetActivityColorsChange() {
runUpdates(
Update.WidgetSingleTypes,
Update.WidgetGrid,
)
}

suspend fun onShowUntrackedInStatisticsChange() {
runUpdates(
Update.WidgetStatistics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,14 @@ class PrefsInteractor @Inject constructor(
prefsRepo.widgetBackgroundTransparencyPercent
}

suspend fun setAlwaysShowWidgetActivityColors(value: Boolean) = withContext(Dispatchers.IO) {
prefsRepo.alwaysShowWidgetActivityColors = value
}

suspend fun getAlwaysShowWidgetActivityColors(): Boolean = withContext(Dispatchers.IO) {
prefsRepo.alwaysShowWidgetActivityColors
}

suspend fun getDefaultTypesHidden(): Boolean = withContext(Dispatchers.IO) {
prefsRepo.defaultTypesHidden
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ interface PrefsRepo {

var widgetBackgroundTransparencyPercent: Long

var alwaysShowWidgetActivityColors: Boolean

var defaultTypesHidden: Boolean

var isNavBarAtTheBottom: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ enum class SettingsBlock {
DisplayGoalsOnSeparateTabs,
DisplayNavBarAtTheBottom,
DisplayWidgetBackground,
DisplayWidgetActivityColors,
DisplayMilitaryFormat,
DisplayMonthDayFormat,
DisplayDurationFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ class SettingsDisplayViewDataInteractor @Inject constructor(
selectedPosition = widgetTransparencyViewData.selectedPosition,
processSameItemSelected = false,
)
result += SettingsCheckboxViewData(
block = SettingsBlock.DisplayWidgetActivityColors,
title = resourceRepo.getString(R.string.settings_always_show_widget_activity_colors),
subtitle = resourceRepo.getString(R.string.settings_always_show_widget_activity_colors_hint),
isChecked = prefsInteractor.getAlwaysShowWidgetActivityColors(),
)
result += SettingsCheckboxViewData(
block = SettingsBlock.DisplayMilitaryFormat,
title = resourceRepo.getString(R.string.settings_use_military_time),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class SettingsDisplayViewModelDelegate @Inject constructor(
SettingsBlock.DisplayMilitaryFormat -> onUseMilitaryTimeClicked()
SettingsBlock.DisplayMonthDayFormat -> onUseMonthDayTimeClicked()
SettingsBlock.DisplayShowSeconds -> onShowSecondsClicked()
SettingsBlock.DisplayWidgetActivityColors -> onWidgetActivityColorsClicked()
else -> {
// Do nothing
}
Expand Down Expand Up @@ -182,6 +183,15 @@ class SettingsDisplayViewModelDelegate @Inject constructor(
}
}

private fun onWidgetActivityColorsClicked() {
delegateScope.launch {
val newValue = !prefsInteractor.getAlwaysShowWidgetActivityColors()
prefsInteractor.setAlwaysShowWidgetActivityColors(newValue)
parent?.updateContent()
externalViewsInteractor.onWidgetActivityColorsChange()
}
}

private fun onRecordTypeOrderSelected(position: Int) {
onOrderSelected(
type = CardOrderDialogParams.Type.RecordType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class WidgetGridRemoveViewsFactory @Inject constructor(
val runningRecords = runningRecordInteractor.getAll()
val isDarkTheme = prefsInteractor.getDarkMode()
val backgroundTransparency = prefsInteractor.getWidgetBackgroundTransparencyPercent()
val alwaysShowActivityColors = prefsInteractor.getAlwaysShowWidgetActivityColors()
val prevRecords = if (prefsInteractor.getRetroactiveTrackingMode()) {
recordInteractor.getAllPrev(timeStarted = System.currentTimeMillis())
} else {
Expand Down Expand Up @@ -156,6 +157,7 @@ class WidgetGridRemoveViewsFactory @Inject constructor(
allDailyCurrents = allDailyCurrents,
isDarkTheme = isDarkTheme,
backgroundTransparency = backgroundTransparency,
alwaysShowActivityColors = alwaysShowActivityColors,
)
}
val row = getRow(context, items, gridSize)
Expand Down Expand Up @@ -216,8 +218,10 @@ class WidgetGridRemoveViewsFactory @Inject constructor(
allDailyCurrents: Map<Long, GetCurrentRecordsDurationInteractor.Result>,
isDarkTheme: Boolean,
backgroundTransparency: Long,
alwaysShowActivityColors: Boolean,
): RemoteViews {
val isColored = when {
alwaysShowActivityColors -> true
runningRecord != null -> true
prevRecord != null -> true
else -> false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class WidgetSingleProvider : AppWidgetProvider() {
val view: View
val recordTypeId = prefsInteractor.getWidget(appWidgetId)
val backgroundTransparency = prefsInteractor.getWidgetBackgroundTransparencyPercent()
val alwaysShowActivityColors = prefsInteractor.getAlwaysShowWidgetActivityColors()
val retroactiveTrackingModeEnabled = prefsInteractor.getRetroactiveTrackingMode()
val typeIds = typeIdsToUpdate
if (typeIds.isNotEmpty() && recordTypeId !in typeIds) return@launch
Expand Down Expand Up @@ -192,6 +193,7 @@ class WidgetSingleProvider : AppWidgetProvider() {
emptyList()
}
val isColored = when {
alwaysShowActivityColors && recordType != null -> true
runningRecord != null -> recordType != null
prevRecord != null -> true
else -> false
Expand Down
2 changes: 2 additions & 0 deletions resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ This allows you to see how much time you\'re spending on productive versus unpro
<string name="settings_reverse_order_in_calendar">Reverse order of records</string>
<string name="settings_days_in_calendar">Days in calendar</string>
<string name="settings_widget_transparency">Widget background transparency</string>
<string name="settings_always_show_widget_activity_colors">Always show activity colors in widgets</string>
<string name="settings_always_show_widget_activity_colors_hint">Show activity colors even when inactive in the Grid and Single Activity widgets. Running activities display a timer.</string>
<string name="settings_show_activity_filters">Show activity filters on main screen</string>
<string name="settings_allow_multiple_activity_filters">Allow multiple activity filters</string>
<string name="settings_allow_multiple_activity_filters_hint">If disabled, selecting a filter will disable other activity filters.</string>
Expand Down