@@ -18,14 +18,19 @@ package com.example.sft.presentation
1818
1919import android.Manifest
2020import android.app.Activity
21+ import android.health.connect.HealthPermissions
22+ import android.os.Build
2123import android.os.Bundle
2224import androidx.activity.ComponentActivity
2325import androidx.activity.compose.setContent
26+ import androidx.activity.compose.rememberLauncherForActivityResult
27+ import androidx.activity.result.contract.ActivityResultContracts
2428import androidx.compose.foundation.layout.Box
2529import androidx.compose.foundation.layout.fillMaxSize
2630import androidx.compose.foundation.layout.fillMaxWidth
2731import androidx.compose.runtime.Composable
2832import androidx.compose.runtime.LaunchedEffect
33+ import androidx.compose.runtime.collectAsState
2934import androidx.compose.runtime.getValue
3035import androidx.compose.runtime.mutableStateOf
3136import androidx.compose.runtime.remember
@@ -35,27 +40,24 @@ import androidx.compose.ui.Modifier
3540import androidx.compose.ui.platform.LocalContext
3641import androidx.compose.ui.res.stringResource
3742import androidx.compose.ui.text.style.TextAlign
43+ import androidx.lifecycle.viewmodel.compose.viewModel
3844import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
3945import androidx.wear.compose.foundation.lazy.items
4046import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState
41- import androidx.wear.compose.material3.Text
4247import androidx.wear.compose.material3.AppScaffold
4348import androidx.wear.compose.material3.Button
4449import androidx.wear.compose.material3.ButtonDefaults
4550import androidx.wear.compose.material3.ListHeader
4651import androidx.wear.compose.material3.MaterialTheme
4752import androidx.wear.compose.material3.ScreenScaffold
53+ import androidx.wear.compose.material3.Text
4854import androidx.wear.compose.navigation.SwipeDismissableNavHost
4955import androidx.wear.compose.navigation.composable
5056import androidx.wear.compose.navigation.rememberSwipeDismissableNavController
5157import com.example.sft.R
5258import com.example.sft.presentation.theme.WearAppTheme
5359import com.google.android.horologist.compose.layout.ColumnItemType
5460import com.google.android.horologist.compose.layout.rememberResponsiveColumnPadding
55- import androidx.activity.compose.rememberLauncherForActivityResult
56- import androidx.activity.result.contract.ActivityResultContracts
57- import androidx.compose.runtime.collectAsState
58- import androidx.lifecycle.viewmodel.compose.viewModel
5961
6062class MainActivity : ComponentActivity () {
6163
@@ -112,12 +114,17 @@ fun ExerciseSelectionScreen(
112114
113115 LaunchedEffect (Unit ) {
114116 exercises = exerciseRepository.exercises
115- val permissions = arrayOf (
117+ val permissions = mutableListOf (
116118 Manifest .permission.BODY_SENSORS ,
117119 Manifest .permission.ACTIVITY_RECOGNITION ,
118120 Manifest .permission.ACCESS_COARSE_LOCATION ,
119- Manifest .permission.ACCESS_FINE_LOCATION
120- )
121+ Manifest .permission.ACCESS_FINE_LOCATION ,
122+ ).apply {
123+ // Granular heart rate permission for Wear 6+
124+ if (Build .VERSION .SDK_INT >= 36 ) {
125+ this .add(HealthPermissions .READ_HEART_RATE )
126+ }
127+ }.toTypedArray()
121128 permissionLauncher.launch(permissions)
122129 }
123130
@@ -144,7 +151,7 @@ fun ExerciseSelectionScreen(
144151 modifier = Modifier .fillMaxSize()
145152 ) {
146153 item {
147- ListHeader () { Text (text = " Workouts" ) }
154+ ListHeader { Text (text = " Workouts" ) }
148155 }
149156 items(exercises) { exercise ->
150157 Button (
0 commit comments