various fixes
- Commit
7428af6cccd431db4761ad89831d8b91b886c104- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-07 15:22 UTC (2 months ago)
- Parents
10b97da
Diff
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.ktindex 74bf80c1a0..0fdabc7e98 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -11,6 +11,7 @@ import androidx.lifecycle.viewModelScope import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppDatabase import com.vayunmathur.appstore.data.AppSource+import com.vayunmathur.appstore.data.DefaultRepos import com.vayunmathur.appstore.data.CatalogRepository import com.vayunmathur.appstore.data.InstalledAppsRepository import com.vayunmathur.appstore.data.InstalledInfo
clock/src/main/java/com/vayunmathur/clock/platform/AlarmActivity.kt
diff --git a/clock/src/main/java/com/vayunmathur/clock/platform/AlarmActivity.kt b/clock/src/main/java/com/vayunmathur/clock/platform/AlarmActivity.ktindex a07c3d20a4..b46038acd8 100644--- a/clock/src/main/java/com/vayunmathur/clock/platform/AlarmActivity.kt+++ b/clock/src/main/java/com/vayunmathur/clock/platform/AlarmActivity.kt@@ -22,6 +22,7 @@ import kotlinx.coroutines.withContext class AlarmActivity : ComponentActivity() { private var alarmId: Long = -1L private var snoozeMinutes: Int = 5+ private var gradualSeconds: Int = 0 override fun onCreate(savedInstanceState: Bundle?) { setShowWhenLocked(true); setTurnScreenOn(true); super.onCreate(savedInstanceState)@@ -33,7 +34,12 @@ class AlarmActivity : ComponentActivity() { val alarm by androidx.compose.runtime.produceState<com.vayunmathur.clock.data.Alarm?>(initialValue = null) { value = withContext(Dispatchers.IO) { repository.getAlarm(alarmId) } }- androidx.compose.runtime.LaunchedEffect(alarm) { alarm?.let { snoozeMinutes = it.snoozeMinutes } }+ androidx.compose.runtime.LaunchedEffect(alarm) {+ alarm?.let {+ snoozeMinutes = it.snoozeMinutes+ gradualSeconds = it.gradualVolumeSeconds+ }+ } DynamicTheme { AlarmRingingScreen( alarmTime = alarm?.let { formatAlarmTime(this@AlarmActivity, it.time) } ?: "--:--",@@ -58,7 +64,13 @@ class AlarmActivity : ComponentActivity() { getSystemService(NotificationManager::class.java).cancel(ALARM_RING_NOTIFICATION_ID) val snoozeTime = Clock.System.now().plus(snoozeMinutes.minutes) val triggerMillis = snoozeTime.toEpochMilliseconds()- val intent = Intent(this, AlarmReceiver::class.java).apply { putExtra("ALARM_ID", alarmId); putExtra("IS_SNOOZE", true) }+ val intent = Intent(this, AlarmReceiver::class.java).apply {+ putExtra("ALARM_ID", alarmId)+ putExtra("IS_SNOOZE", true)+ // Snooze builds its own intent rather than going through AlarmScheduler, so it has+ // to carry this itself or the snoozed alarm would ring on the wrong channel.+ putExtra(AlarmScheduler.EXTRA_GRADUAL_SECONDS, gradualSeconds)+ } val pendingIntent = PendingIntent.getBroadcast(this, alarmId.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) val alarmManager = getSystemService(AlarmManager::class.java) alarmManager.setAlarmClock(AlarmManager.AlarmClockInfo(triggerMillis, pendingIntent), pendingIntent); finish()
clock/src/main/java/com/vayunmathur/clock/platform/AlarmReceiver.kt
diff --git a/clock/src/main/java/com/vayunmathur/clock/platform/AlarmReceiver.kt b/clock/src/main/java/com/vayunmathur/clock/platform/AlarmReceiver.ktindex 3ab496a0e7..becbcb786a 100644--- a/clock/src/main/java/com/vayunmathur/clock/platform/AlarmReceiver.kt+++ b/clock/src/main/java/com/vayunmathur/clock/platform/AlarmReceiver.kt@@ -36,10 +36,20 @@ class AlarmReceiver : BroadcastReceiver() { PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) - // 3. Build the Notification. This is what actually rings: FLAG_INSISTENT below repeats- // the ring channel's sound until something cancels it, so the alarm sounds even when- // AlarmSoundService never reaches startForeground.- val builder = NotificationCompat.Builder(context, ALARM_RING_CHANNEL_ID)+ // 3. Build the Notification. For most alarms this is what actually rings: FLAG_INSISTENT+ // below repeats the ring channel's sound until something cancels it, so the alarm sounds+ // even when AlarmSoundService never reaches startForeground.+ //+ // Gradual-volume alarms opt out. The ring channel's sound is fixed and plays at full+ // volume, so they would blast, cut to silence and then fade in from zero - the opposite+ // of the setting. They ring only once the service starts, and give up the safety net.+ // Read from the intent, not the database: putting a read in front of the ring is the+ // latency this whole design exists to avoid.+ val gradual = intent.getIntExtra(AlarmScheduler.EXTRA_GRADUAL_SECONDS, 0) > 0+ val builder = NotificationCompat.Builder(+ context,+ if (gradual) ALARM_CHANNEL_ID else ALARM_RING_CHANNEL_ID,+ ) .setSmallIcon(R.drawable.baseline_access_alarm_24) .setContentTitle(context.getString(R.string.label_alarm)) .setContentText(context.getString(R.string.alarm_notification_wake_up))@@ -81,7 +91,9 @@ class AlarmReceiver : BroadcastReceiver() { } notificationManager.notify( ALARM_RING_NOTIFICATION_ID,- builder.build().apply { flags = flags or Notification.FLAG_INSISTENT },+ builder.build().apply {+ if (!gradual) flags = flags or Notification.FLAG_INSISTENT+ }, ) // 4. Start the Sound Service immediately so we hear it even if Activity doesn't launch
clock/src/main/java/com/vayunmathur/clock/platform/AlarmScheduler.kt
diff --git a/clock/src/main/java/com/vayunmathur/clock/platform/AlarmScheduler.kt b/clock/src/main/java/com/vayunmathur/clock/platform/AlarmScheduler.ktindex 6809ab1919..4760c99cad 100644--- a/clock/src/main/java/com/vayunmathur/clock/platform/AlarmScheduler.kt+++ b/clock/src/main/java/com/vayunmathur/clock/platform/AlarmScheduler.kt@@ -14,12 +14,19 @@ import kotlin.time.Clock import kotlin.time.Duration.Companion.days object AlarmScheduler {+ /**+ * Whether this alarm fades in, carried in the broadcast so AlarmReceiver can pick a channel+ * without a database read. Absent means zero, which is the fail-safe answer: an alarm we+ * know nothing about gets the insistent ring rather than silently losing it.+ */+ const val EXTRA_GRADUAL_SECONDS = "GRADUAL_SECONDS" fun schedule(context: Context, alarm: Alarm) { val alarmManager = context.getSystemService(AlarmManager::class.java) val intent = Intent(context, AlarmReceiver::class.java).apply { putExtra("ALARM_ID", alarm.id)+ putExtra(EXTRA_GRADUAL_SECONDS, alarm.gradualVolumeSeconds) } val pendingIntent = PendingIntent.getBroadcast(
clock/src/main/java/com/vayunmathur/clock/ui/AlarmPage.kt
diff --git a/clock/src/main/java/com/vayunmathur/clock/ui/AlarmPage.kt b/clock/src/main/java/com/vayunmathur/clock/ui/AlarmPage.ktindex 1a41fd7bca..8845110f4e 100644--- a/clock/src/main/java/com/vayunmathur/clock/ui/AlarmPage.kt+++ b/clock/src/main/java/com/vayunmathur/clock/ui/AlarmPage.kt@@ -85,7 +85,10 @@ fun AlarmPage(backStack: NavBackStack<Route>, clockViewModel: ClockViewModel, ne } override fun setGradualVolumeSeconds(alarm: Alarm, seconds: Int) {- clockViewModel.upsert(alarm.copy(gradualVolumeSeconds = seconds))+ // Must reschedule, not just upsert: the pending broadcast carries this value so+ // AlarmReceiver can pick a channel without a database read, and a plain upsert+ // would leave the already-scheduled intent holding the old one.+ save(alarm.copy(gradualVolumeSeconds = seconds)) } } }
version.txt
diff --git a/version.txt b/version.txtindex 33cd50ef2c..64d4acc96b 100644--- a/version.txt+++ b/version.txt@@ -1,2 +1,2 @@-20260825+20260831 v2.6.8