Every comment is reduced to its first sentence plus @param, @return and @throws tags. Comment lines: 20040 to 8526. ktlint 1.8 applied with its default (official Kotlin) style across all modules; 262 files reformatted. The 264 remaining ktlint findings are naming and filename rules, which are code changes, and are left alone. Comments and formatting only. 1208 tests pass, counted from the XML. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
92 lines
3.1 KiB
Kotlin
92 lines
3.1 KiB
Kotlin
package io.flamenet.messenger.app
|
|
|
|
import androidx.compose.foundation.layout.ColumnScope
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.Spacer
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.foundation.layout.height
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.Switch
|
|
import androidx.compose.material3.Text
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.setValue
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.platform.testTag
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
/**
|
|
* What this phone's notifications are allowed to say.
|
|
*/
|
|
@Composable
|
|
fun ColumnScope.NotificationSection() {
|
|
val context = LocalContext.current
|
|
val settings = remember { NotificationSettings(context) }
|
|
var enabled by remember { mutableStateOf(settings.enabled) }
|
|
var newMessages by remember { mutableStateOf(settings.newMessages) }
|
|
var previews by remember { mutableStateOf(settings.showPreviews) }
|
|
var sounds by remember { mutableStateOf(settings.inAppSounds) }
|
|
|
|
Text("Notifications", style = MaterialTheme.typography.titleMedium)
|
|
|
|
@Composable
|
|
fun row(
|
|
label: String,
|
|
tag: String,
|
|
value: Boolean,
|
|
onChange: (Boolean) -> Unit,
|
|
) {
|
|
Row(
|
|
modifier = Modifier.fillMaxWidth().padding(vertical = Space.sm),
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
) {
|
|
Text(label, fontSize = 16.sp, modifier = Modifier.weight(1f))
|
|
Switch(
|
|
checked = value,
|
|
onCheckedChange = onChange,
|
|
modifier = Modifier.testTag(tag),
|
|
)
|
|
}
|
|
}
|
|
|
|
row("Notify me", "notify-enabled", enabled) { on ->
|
|
settings.enabled = on
|
|
enabled = on
|
|
}
|
|
if (enabled) {
|
|
row("New messages", "notify-messages", newMessages) { on ->
|
|
settings.newMessages = on
|
|
newMessages = on
|
|
}
|
|
row("Show who it is from", "notify-previews", previews) { on ->
|
|
settings.showPreviews = on
|
|
previews = on
|
|
}
|
|
row("Sound while the app is open", "notify-sounds", sounds) { on ->
|
|
settings.inAppSounds = on
|
|
sounds = on
|
|
}
|
|
}
|
|
|
|
Spacer(Modifier.height(Space.xs))
|
|
|
|
// Says what turning it on costs, and does not pretend the default is merely
|
|
// cautious.
|
|
Text(
|
|
if (previews) {
|
|
"Your lock screen will name whoever wrote to you. Anyone who can see your " +
|
|
"phone can see that, which is sometimes more revealing than the message."
|
|
} else {
|
|
"Notifications say how many messages arrived and nothing else, no name, no " +
|
|
"words. Calls still ring."
|
|
},
|
|
fontSize = 12.sp,
|
|
color = Palette.SecondaryText,
|
|
)
|
|
}
|