summaryrefslogtreecommitdiff
path: root/app/src/main/java/org/terst/feedreader/data/Settings.kt
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-08-31 15:43:02 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-08-31 15:43:02 +0000
commit0cd94d0821661fef3fc34b51011be95034e51a5b (patch)
treeea91f813be8bbe0e5aac506744fcfbb22ce3ad41 /app/src/main/java/org/terst/feedreader/data/Settings.kt
parente42bfbd6a65eefd0f24677aebb74993ae56490cf (diff)
Add reader font size setting, rewrite paywall-avoidance settings copy
Font size was hardcoded at 18px in ReaderWebView's injected CSS. Added a DataStore-backed setting (Settings.readerFontSizePx, 14-28px range) with a slider in Settings, threaded through ReaderScreen/ReaderContent into wrapReaderHtml. The reload-tracking key in ReaderContent's AndroidView now includes font size alongside content, so changing it and returning to an already-open article picks up the new size without reloading on every unrelated recomposition (matches the existing comment there about avoiding scroll-position jank). Rewrote the Settings screen's paywall note -- it read as defensive throat-clearing about what the app won't do. Restated as what it's actually for: avoiding tracking, manipulation, and junk fees, with reader mode pulling up anything findable by search anyway. Regenerated the detekt baseline: ReaderContent's pre-existing LongMethod/LongParameterList/CyclomaticComplexMethod findings are keyed by exact function signature text, and adding the fontSizePx parameter changed that text, invalidating the old baseline entries. The underlying debt (a 300+ line, 9-now-10-parameter composable) predates this change and isn't what this commit is about. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AwnALZL6bD4VBtATDVv3B
Diffstat (limited to 'app/src/main/java/org/terst/feedreader/data/Settings.kt')
-rw-r--r--app/src/main/java/org/terst/feedreader/data/Settings.kt19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/src/main/java/org/terst/feedreader/data/Settings.kt b/app/src/main/java/org/terst/feedreader/data/Settings.kt
index 2e7eaae..be3e809 100644
--- a/app/src/main/java/org/terst/feedreader/data/Settings.kt
+++ b/app/src/main/java/org/terst/feedreader/data/Settings.kt
@@ -28,8 +28,16 @@ private object SettingsKeys {
val LAST_FETCH_AT = longPreferencesKey("last_fetch_at")
val LAST_FETCH_NEW_ARTICLES = intPreferencesKey("last_fetch_new_articles")
val LAST_ACKNOWLEDGED_FETCH_AT = longPreferencesKey("last_acknowledged_fetch_at")
+ val READER_FONT_SIZE_PX = intPreferencesKey("reader_font_size_px")
}
+// Matches the size ReaderWebView hardcoded before this setting existed, so an upgrading
+// user's reader looks exactly the same until they deliberately change it.
+const val DEFAULT_READER_FONT_SIZE_PX = 18
+private const val READER_FONT_SIZE_MIN_PX = 14
+private const val READER_FONT_SIZE_MAX_PX = 28
+val READER_FONT_SIZE_RANGE_PX = READER_FONT_SIZE_MIN_PX..READER_FONT_SIZE_MAX_PX
+
/** Stash connection settings, configured on the Settings screen. Both blank until set. */
class Settings(private val context: Context) {
val stashBaseUrl: Flow<String> =
@@ -109,4 +117,15 @@ class Settings(private val context: Context) {
suspend fun acknowledgeFetch(at: Long) {
context.settingsDataStore.edit { prefs -> prefs[SettingsKeys.LAST_ACKNOWLEDGED_FETCH_AT] = at }
}
+
+ val readerFontSizePx: Flow<Int> =
+ context.settingsDataStore.data.map { it[SettingsKeys.READER_FONT_SIZE_PX] ?: DEFAULT_READER_FONT_SIZE_PX }
+
+ suspend fun readerFontSizePxNow(): Int = readerFontSizePx.first()
+
+ suspend fun setReaderFontSizePx(px: Int) {
+ context.settingsDataStore.edit { prefs ->
+ prefs[SettingsKeys.READER_FONT_SIZE_PX] = px.coerceIn(READER_FONT_SIZE_RANGE_PX.first, READER_FONT_SIZE_RANGE_PX.last)
+ }
+ }
}