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
4 changes: 2 additions & 2 deletions app/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ app/
and are cancelled, since a failed replacement may leave the previous alarm in place.
Receivers await `AlarmScheduler.syncUpcomingAlarms` (capped at 8 s, within their `goAsync()` budget) before finishing:
a process started for a broadcast may be killed or frozen as soon as it's over.
`MainActivity` requests the `POST_NOTIFICATIONS` runtime permission (Android 13+) on each fresh start (skipped on
recreation). Exact alarms need no request: `USE_EXACT_ALARM` on API 33+, `SCHEDULE_EXACT_ALARM` on API 31–32 (falls
The `POST_NOTIFICATIONS` runtime permission (Android 13+) is only requested by the onboarding's notifications step;
`AlarmReceiver` skips posting while notifications are disabled. Exact alarms need no request: `USE_EXACT_ALARM` on API 33+, `SCHEDULE_EXACT_ALARM` on API 31–32 (falls
back to inexact alarms while the user revokes it; exactness is part of `AlarmRegistration`, so they're all registered
again as exact ones once it's granted back).
Notification small icons use ESDS vectors rendered by `ImageVector.toBitmap` into white-on-transparent bitmaps,
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/java/com/infomaniak/calendar/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
*/
package com.infomaniak.calendar

import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.Surface
Expand Down Expand Up @@ -59,7 +57,6 @@ import com.infomaniak.calendar.ui.navigation.state.rememberCustomSnackbarHostSta
import com.infomaniak.calendar.ui.navigation.state.rememberToolbarScrollableState
import com.infomaniak.calendar.ui.state.LocalVisibleDayState
import com.infomaniak.calendar.ui.theme.CalendarTheme
import com.infomaniak.core.common.extensions.hasPermission
import com.infomaniak.multiplatform_calendar.core.domain.model.event.OccurrenceId
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.serialization.json.Json
Expand All @@ -68,7 +65,6 @@ class MainActivity : ComponentActivity() {

private val mainViewModel: MainViewModel by viewModels()
private val pendingOccurrenceId = mutableStateOf<OccurrenceId?>(null)
private val notificationPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) {}

override val defaultViewModelProviderFactory: ViewModelProvider.Factory
get() = appGraph.metroViewModelFactory
Expand All @@ -78,8 +74,6 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
handleEventIntent(intent)
// Only on a fresh start, so a configuration change right after a refusal doesn't ask again
requestNotificationPermissionIfNeeded()
} else {
// On recreation, the already handled intent comes back: only restore a destination not navigated to yet
pendingOccurrenceId.value = savedInstanceState.getString(KEY_PENDING_OCCURRENCE_ID)?.toOccurrenceIdOrNull()
Expand Down Expand Up @@ -132,12 +126,6 @@ class MainActivity : ComponentActivity() {
return runCatching { Json.decodeFromString(OccurrenceId.serializer(), this) }.getOrNull()
}

private fun requestNotificationPermissionIfNeeded() {
if (SDK_INT >= 33 && !hasPermission(Manifest.permission.POST_NOTIFICATIONS)) {
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}

companion object {
private const val KEY_PENDING_OCCURRENCE_ID = "pendingOccurrenceId"
}
Expand Down
Loading