diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 1b5337a..35e9e77 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -105,6 +105,10 @@ dependencies {
implementation(libs.hilt.android)
implementation(libs.androidx.hilt.navigation.compose)
kapt(libs.hilt.compiler)
+ // Hilt Worker
+ implementation(libs.androidx.hilt.work)
+ // When using Kotlin.
+ kapt(libs.androidx.hilt.compiler)
// Unit Test
testImplementation(libs.mockito.core)
@@ -126,4 +130,10 @@ dependencies {
// Data Store
implementation(libs.androidx.datastore.preferences)
+
+ // Work Manager
+ // Kotlin + coroutines
+ implementation(libs.androidx.work.runtime.ktx)
+ // optional - Test helpers
+ androidTestImplementation(libs.androidx.work.testing)
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 76276a9..b3ea7f9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,6 +2,8 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rememberme/MainActivity.kt b/app/src/main/java/com/example/rememberme/MainActivity.kt
index 625d7ba..a020ff2 100644
--- a/app/src/main/java/com/example/rememberme/MainActivity.kt
+++ b/app/src/main/java/com/example/rememberme/MainActivity.kt
@@ -1,16 +1,39 @@
package com.example.rememberme
+import android.Manifest.permission.POST_NOTIFICATIONS
+import android.content.pm.PackageManager
+import android.os.Build
import android.os.Bundle
+import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.core.content.ContextCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
+import androidx.work.PeriodicWorkRequestBuilder
+import androidx.work.WorkManager
+import com.example.rememberme.data.manager.NotificationWorker
import dagger.hilt.android.AndroidEntryPoint
+import java.util.concurrent.TimeUnit
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
// @Inject
// lateinit var peopleDao: PeopleDao
+
+ private val requestPermissionLauncher = registerForActivityResult(
+ ActivityResultContracts.RequestPermission()
+ ) { isGranted: Boolean ->
+ if (isGranted) {
+ // Permission is granted. Schedule the notification work.
+ Log.i(TAG, "Permission granted")
+ scheduleNotificationWork()
+ } else {
+ Log.i(TAG, "Permission denied")
+ // Permission is denied. Handle the case.
+ }
+ }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
@@ -24,5 +47,44 @@ class MainActivity : ComponentActivity() {
setContent {
RememberMeApp()
}
+
+ // Check for notification permission only if the SDK version is 33 or higher
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ if (ContextCompat.checkSelfPermission(
+ this,
+ POST_NOTIFICATIONS
+ ) == PackageManager.PERMISSION_GRANTED
+ ) {
+ // Permission is already granted
+ scheduleNotificationWork()
+ } else {
+ // Request permission
+ requestPermissionLauncher.launch(POST_NOTIFICATIONS)
+ }
+ } else {
+ // SDK version is lower than 33, no need to request POST_NOTIFICATIONS permission
+ scheduleNotificationWork()
+ }
}
+ private fun scheduleNotificationWork() {
+ Log.i(TAG, "Scheduling notification work")
+ val workManager = WorkManager.getInstance(this)
+ val existingWork = workManager.getWorkInfosByTag("notificationWork").get()
+
+ if (existingWork.isEmpty()) {
+ Log.i(TAG, "No existing work found, scheduling new work")
+ val notificationWorkRequest =
+ PeriodicWorkRequestBuilder(1, TimeUnit.MINUTES)
+ .addTag("notificationWork")
+ .setInitialDelay(5, TimeUnit.SECONDS)
+ .build()
+ workManager.enqueue(notificationWorkRequest)
+ }else{
+ Log.i(TAG, "Existing work found, not scheduling new work")
+ }
+ }
+ companion object {
+ private const val TAG = "MainActivity"
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rememberme/RememberMeApplication.kt b/app/src/main/java/com/example/rememberme/RememberMeApplication.kt
index f402c70..78208fe 100644
--- a/app/src/main/java/com/example/rememberme/RememberMeApplication.kt
+++ b/app/src/main/java/com/example/rememberme/RememberMeApplication.kt
@@ -1,8 +1,21 @@
package com.example.rememberme
import android.app.Application
+import androidx.hilt.work.HiltWorkerFactory
+import androidx.work.Configuration
import dagger.hilt.android.HiltAndroidApp
+import javax.inject.Inject
@HiltAndroidApp
-class RememberMeApplication: Application() {
+class RememberMeApplication : Application(), Configuration.Provider {
+
+ @Inject
+ lateinit var workerFactory: HiltWorkerFactory
+
+ override val workManagerConfiguration: Configuration
+ get() = Configuration.Builder()
+ .setWorkerFactory(workerFactory)
+ .build()
+
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rememberme/data/manager/NotificationService.kt b/app/src/main/java/com/example/rememberme/data/manager/NotificationService.kt
new file mode 100644
index 0000000..bde4290
--- /dev/null
+++ b/app/src/main/java/com/example/rememberme/data/manager/NotificationService.kt
@@ -0,0 +1,78 @@
+package com.example.rememberme.data.manager
+
+import android.Manifest
+import android.app.NotificationChannel
+import android.app.NotificationManager
+import android.app.PendingIntent
+import android.content.Context
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.net.Uri
+import android.os.Build
+import androidx.core.app.ActivityCompat
+import androidx.core.app.NotificationCompat
+import androidx.core.app.NotificationManagerCompat
+import com.example.rememberme.R
+import com.example.rememberme.domain.model.People
+import javax.inject.Inject
+
+class NotificationService @Inject constructor(private val context: Context) {
+
+ private val CHANNEL_ID = "people_notification_channel"
+ private val NOTIFICATION_ID = 0
+
+
+ init {
+ createNotificationChannel()
+ }
+
+ private fun createNotificationChannel() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ val name = "People Notification"
+ val descriptionText = "Reminders about the people you have met"
+ val importance = NotificationManager.IMPORTANCE_HIGH
+ val channel = NotificationChannel(CHANNEL_ID, name, importance).apply {
+ description = descriptionText
+ }
+ val notificationManager: NotificationManager =
+ context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
+ notificationManager.createNotificationChannel(channel)
+ }
+ }
+
+ fun showNotification(person: People) {
+ val deepLinkIntent = Intent(
+ Intent.ACTION_VIEW,
+ Uri.parse("app://people/${person.id}")
+ ).apply {
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
+ }
+
+ val pendingIntent: PendingIntent = PendingIntent.getActivity(
+ context,
+ 0,
+ deepLinkIntent,
+ PendingIntent.FLAG_IMMUTABLE
+ )
+
+ val builder = NotificationCompat.Builder(context, CHANNEL_ID)
+ .setSmallIcon(R.drawable.ic_m2)
+ .setContentTitle("Do you remember ${person.firstName}?")
+ .setContentText("You met at ${person.place}")
+ .setPriority(NotificationCompat.PRIORITY_MAX)
+ .setChannelId(CHANNEL_ID)
+ .setContentIntent(pendingIntent)
+ .setAutoCancel(true)
+
+ with(NotificationManagerCompat.from(context)) {
+ if (ActivityCompat.checkSelfPermission(
+ context,
+ Manifest.permission.POST_NOTIFICATIONS
+ ) != PackageManager.PERMISSION_GRANTED
+ ) {
+ return
+ }
+ notify(NOTIFICATION_ID, builder.build())
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/rememberme/data/manager/NotificationWorker.kt b/app/src/main/java/com/example/rememberme/data/manager/NotificationWorker.kt
new file mode 100644
index 0000000..722545e
--- /dev/null
+++ b/app/src/main/java/com/example/rememberme/data/manager/NotificationWorker.kt
@@ -0,0 +1,43 @@
+package com.example.rememberme.data.manager
+
+
+import android.content.Context
+import android.util.Log
+import androidx.hilt.work.HiltWorker
+import androidx.work.Worker
+import androidx.work.WorkerParameters
+import com.example.rememberme.domain.usecases.people.GetAllPeople
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedInject
+import kotlinx.coroutines.runBlocking
+import kotlin.random.Random
+
+@HiltWorker
+class NotificationWorker
+ @AssistedInject constructor(
+ @Assisted context: Context,
+ @Assisted workerParams: WorkerParameters,
+ private val getAllPeople: GetAllPeople,
+ private val notificationService: NotificationService
+ ) : Worker(context, workerParams) {
+
+ override fun doWork(): Result {
+ Log.d(TAG, "Performing long running task in scheduled job")
+ return runBlocking {
+ getAllPeople().collect { people ->
+ if (people.isNotEmpty()) {
+ Log.d(TAG, "People: $people")
+ val randomPerson = people[Random.nextInt(people.size)]
+ notificationService.showNotification(randomPerson)
+ } else {
+ Log.d(TAG, "No people found")
+ }
+ }
+ Log.d(TAG, "Work finished")
+ Result.success()
+ }
+ }
+ companion object {
+ private const val TAG = "NotificationWorker"
+ }
+}
diff --git a/app/src/main/java/com/example/rememberme/di/AppModule.kt b/app/src/main/java/com/example/rememberme/di/AppModule.kt
index 03516c6..11fd6aa 100644
--- a/app/src/main/java/com/example/rememberme/di/AppModule.kt
+++ b/app/src/main/java/com/example/rememberme/di/AppModule.kt
@@ -5,6 +5,7 @@ import android.content.Context
import androidx.room.Room
import com.example.rememberme.data.PeopleRepositoryImpl
import com.example.rememberme.data.local.PeopleDatabase
+import com.example.rememberme.data.manager.NotificationService
import com.example.rememberme.data.manager.SettingsManagerImpl
import com.example.rememberme.domain.manager.SettingsManager
import com.example.rememberme.domain.repository.PeopleRepository
@@ -121,4 +122,10 @@ object AppModule {
setSchedule = SetSchedule(settingsManager)
)
}
+
+ @Provides
+ @Singleton
+ fun provideNotificationService(@ApplicationContext context: Context): NotificationService {
+ return NotificationService(context)
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rememberme/domain/model/RemindersRepetition.kt b/app/src/main/java/com/example/rememberme/domain/model/RemindersRepetition.kt
index 300abb7..9273af2 100644
--- a/app/src/main/java/com/example/rememberme/domain/model/RemindersRepetition.kt
+++ b/app/src/main/java/com/example/rememberme/domain/model/RemindersRepetition.kt
@@ -1,7 +1,7 @@
package com.example.rememberme.domain.model
enum class RemindersRepetition {
- OnceADay,
- ThreeADay,
- FiveADay
+ OnceADay { override fun toString(): String ="Once a day" },
+ ThreeADay { override fun toString(): String = "Three a day" },
+ FiveADay { override fun toString(): String = "Five a day" }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rememberme/domain/usecases/people/DeletePersonById.kt b/app/src/main/java/com/example/rememberme/domain/usecases/people/DeletePersonById.kt
index ab93c85..1293994 100644
--- a/app/src/main/java/com/example/rememberme/domain/usecases/people/DeletePersonById.kt
+++ b/app/src/main/java/com/example/rememberme/domain/usecases/people/DeletePersonById.kt
@@ -4,8 +4,9 @@ import com.example.rememberme.domain.repository.PeopleRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
+import javax.inject.Inject
-class DeletePersonById(
+class DeletePersonById @Inject constructor(
private val peopleRepository: PeopleRepository,
private val dispatcher: CoroutineDispatcher = Dispatchers.IO
) {
diff --git a/app/src/main/java/com/example/rememberme/domain/usecases/people/GetAllPeople.kt b/app/src/main/java/com/example/rememberme/domain/usecases/people/GetAllPeople.kt
index 8f3317e..1152fcf 100644
--- a/app/src/main/java/com/example/rememberme/domain/usecases/people/GetAllPeople.kt
+++ b/app/src/main/java/com/example/rememberme/domain/usecases/people/GetAllPeople.kt
@@ -3,8 +3,9 @@ package com.example.rememberme.domain.usecases.people
import com.example.rememberme.domain.model.People
import com.example.rememberme.domain.repository.PeopleRepository
import kotlinx.coroutines.flow.Flow
+import javax.inject.Inject
-class GetAllPeople(
+class GetAllPeople @Inject constructor(
private val peopleRepository: PeopleRepository
) {
operator fun invoke(): Flow> {
diff --git a/app/src/main/java/com/example/rememberme/domain/usecases/people/GetPersonById.kt b/app/src/main/java/com/example/rememberme/domain/usecases/people/GetPersonById.kt
index 03f9d19..08dbc67 100644
--- a/app/src/main/java/com/example/rememberme/domain/usecases/people/GetPersonById.kt
+++ b/app/src/main/java/com/example/rememberme/domain/usecases/people/GetPersonById.kt
@@ -3,8 +3,9 @@ package com.example.rememberme.domain.usecases.people
import com.example.rememberme.domain.model.People
import com.example.rememberme.domain.repository.PeopleRepository
import kotlinx.coroutines.flow.Flow
+import javax.inject.Inject
-class GetPersonById(
+class GetPersonById @Inject constructor(
private val peopleRepository: PeopleRepository
) {
suspend operator fun invoke(id: Long): Flow {
diff --git a/app/src/main/java/com/example/rememberme/domain/usecases/people/InsertNewPerson.kt b/app/src/main/java/com/example/rememberme/domain/usecases/people/InsertNewPerson.kt
index 29d05a3..e0ddcca 100644
--- a/app/src/main/java/com/example/rememberme/domain/usecases/people/InsertNewPerson.kt
+++ b/app/src/main/java/com/example/rememberme/domain/usecases/people/InsertNewPerson.kt
@@ -5,8 +5,9 @@ import com.example.rememberme.domain.repository.PeopleRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
+import javax.inject.Inject
-class InsertNewPerson(
+class InsertNewPerson @Inject constructor(
private val peopleRepository: PeopleRepository,
private val dispatcher: CoroutineDispatcher = Dispatchers.IO
) {
diff --git a/app/src/main/java/com/example/rememberme/domain/usecases/people/PeopleUseCases.kt b/app/src/main/java/com/example/rememberme/domain/usecases/people/PeopleUseCases.kt
index 466f9f2..1b93a33 100644
--- a/app/src/main/java/com/example/rememberme/domain/usecases/people/PeopleUseCases.kt
+++ b/app/src/main/java/com/example/rememberme/domain/usecases/people/PeopleUseCases.kt
@@ -1,6 +1,8 @@
package com.example.rememberme.domain.usecases.people
- data class PeopleUseCases(
+ import javax.inject.Inject
+
+ data class PeopleUseCases @Inject constructor(
val getAllPeople: GetAllPeople,
val getPersonById: GetPersonById,
val insertPerson: InsertNewPerson,
diff --git a/app/src/main/java/com/example/rememberme/domain/usecases/people/UpdatePerson.kt b/app/src/main/java/com/example/rememberme/domain/usecases/people/UpdatePerson.kt
index 21f74cc..c933fd7 100644
--- a/app/src/main/java/com/example/rememberme/domain/usecases/people/UpdatePerson.kt
+++ b/app/src/main/java/com/example/rememberme/domain/usecases/people/UpdatePerson.kt
@@ -6,8 +6,9 @@ import com.example.rememberme.domain.repository.PeopleRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
+import javax.inject.Inject
-class UpdatePerson(
+class UpdatePerson @Inject constructor(
private val peopleRepository: PeopleRepository,
private val dispatcher: CoroutineDispatcher = Dispatchers.IO
) {
diff --git a/app/src/main/java/com/example/rememberme/presentation/details/PersonDetails.kt b/app/src/main/java/com/example/rememberme/presentation/details/PersonDetails.kt
index 5f11038..687da7a 100644
--- a/app/src/main/java/com/example/rememberme/presentation/details/PersonDetails.kt
+++ b/app/src/main/java/com/example/rememberme/presentation/details/PersonDetails.kt
@@ -1,7 +1,5 @@
package com.example.rememberme.presentation.details
-
import android.content.res.Configuration.UI_MODE_NIGHT_YES
-import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@@ -23,6 +21,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Edit
+import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
@@ -69,23 +68,20 @@ fun PersonDetailsScreen(
when {
uiState.value.isLoading -> {
LoadingStateScreen()
- Log.d(TAG, "PersonDetailsScreen: Loading")
}
uiState.value.error != null -> {
- Log.e(TAG, "PersonDetailsScreen: Error - ${uiState.value.error}")
ErrorContent(uiState.value.error!!)
}
uiState.value.person != null -> {
- Log.d(TAG, "PersonDetailsScreen: ${uiState.value.person}")
PersonDetailsContent(
uiState.value.person!!,
navigateUp,
navigateToEditScreen,
- onDeletePerson = {viewModel.onEvent(PersonDetailsEvent.DeletePerson)}
+ onDeletePerson = {viewModel.onEvent(PersonDetailsEvent.DeletePerson)},
+ onSendNotification = {viewModel.sendNotification()}
)
}
else -> {
- Log.e(TAG, "PersonDetailsScreen: Person not found")
// Optionally, you can add a UI to show "Person not found"
}
}
@@ -113,7 +109,8 @@ fun PersonDetailsContent(
navigateUp: () -> Unit,
navigateToEditScreen: (Long?) -> Unit,
onDeletePerson: () -> Unit,
- modifier: Modifier = Modifier
+ modifier: Modifier = Modifier,
+ onSendNotification: () -> Unit,
) {
val scrollState = rememberScrollState()
Column(
@@ -148,7 +145,6 @@ fun PersonDetailsContent(
) {
IconButton(
onClick = {
- Log.d(TAG, "PersonDetailsContent: Back arrow Clicked!")
navigateUp()
}) {
Icon(
@@ -158,10 +154,11 @@ fun PersonDetailsContent(
)
}
Row {
- IconButton(onClick = {
- Log.d(TAG, "PersonDetailsContent: Edit Person Clicked, navigating to edit screen with personId: ${person.id}")
+ IconButton(
+ onClick = {
navigateToEditScreen(person.id)
- }) {
+ }
+ ) {
Icon(
imageVector = Icons.Default.Edit,
contentDescription = null,
@@ -169,7 +166,6 @@ fun PersonDetailsContent(
)
}
IconButton(onClick = {
- Log.d(TAG, "PersonDetailsContent: Delete Person Clicked, Deleting person with personId: ${person.id}")
onDeletePerson()
navigateUp()
}) {
@@ -179,6 +175,15 @@ fun PersonDetailsContent(
tint = MaterialTheme.colorScheme.onPrimary
)
}
+ IconButton(onClick = {
+ onSendNotification()
+ }){
+ Icon(
+ imageVector = Icons.Default.Notifications,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.onPrimary
+ )
+ }
}
}
@@ -271,10 +276,10 @@ fun PersonDetailsContentPreview() {
avatar = R.drawable.ic_m4
),
navigateUp = {
- Log.d(TAG, "PersonDetailsContentPreview: Clicked")
},
navigateToEditScreen = {},
- onDeletePerson = {}
+ onDeletePerson = {},
+ onSendNotification = {}
)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/rememberme/presentation/details/PersonDetailsViewModel.kt b/app/src/main/java/com/example/rememberme/presentation/details/PersonDetailsViewModel.kt
index 4557f36..92d88d6 100644
--- a/app/src/main/java/com/example/rememberme/presentation/details/PersonDetailsViewModel.kt
+++ b/app/src/main/java/com/example/rememberme/presentation/details/PersonDetailsViewModel.kt
@@ -3,6 +3,7 @@ package com.example.rememberme.presentation.details
import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import com.example.rememberme.data.manager.NotificationService
import com.example.rememberme.domain.usecases.people.PeopleUseCases
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
@@ -13,7 +14,8 @@ import javax.inject.Inject
@HiltViewModel
class PersonDetailsViewModel @Inject constructor(
- private val peopleUseCases: PeopleUseCases
+ private val peopleUseCases: PeopleUseCases,
+ private val notificationManager: NotificationService
) : ViewModel() {
private val _uiState = MutableStateFlow(PersonDetailsUiState())
val uiState: StateFlow = _uiState
@@ -65,6 +67,10 @@ class PersonDetailsViewModel @Inject constructor(
}
}
+ fun sendNotification(){
+ notificationManager.showNotification(_uiState.value.person!!)
+ }
+
companion object {
private const val TAG = "PersonDetailsViewModel"
}
diff --git a/app/src/main/java/com/example/rememberme/presentation/navgraph/NavGraph.kt b/app/src/main/java/com/example/rememberme/presentation/navgraph/NavGraph.kt
index 8ff3338..b88df3c 100644
--- a/app/src/main/java/com/example/rememberme/presentation/navgraph/NavGraph.kt
+++ b/app/src/main/java/com/example/rememberme/presentation/navgraph/NavGraph.kt
@@ -11,6 +11,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
+import androidx.navigation.navDeepLink
import androidx.navigation.navigation
import com.example.rememberme.presentation.addperson.AddPersonScreen
import com.example.rememberme.presentation.details.PersonDetailsScreen
@@ -90,7 +91,8 @@ fun NavGraph(
}
composable(
route = "${Routes.PersonDetailsScreen.route}/{personId}",
- arguments = listOf(navArgument("personId") { type = NavType.StringType })
+ arguments = listOf(navArgument("personId") { type = NavType.StringType }),
+ deepLinks = listOf(navDeepLink { uriPattern = "app://people/{personId}" })
) { it ->
val personId = it.arguments?.getString("personId")?.toLong()
if (personId != null) {
diff --git a/app/src/main/java/com/example/rememberme/presentation/settings/SettingsScreen.kt b/app/src/main/java/com/example/rememberme/presentation/settings/SettingsScreen.kt
index 8520188..1d0cdfd 100644
--- a/app/src/main/java/com/example/rememberme/presentation/settings/SettingsScreen.kt
+++ b/app/src/main/java/com/example/rememberme/presentation/settings/SettingsScreen.kt
@@ -169,19 +169,16 @@ fun RemindersRepetitionDialog(
text = {
Column {
ReminderOptionRow(
- "Once a day",
RemindersRepetition.OnceADay,
selectedOption,
onRepetitionSelected
)
ReminderOptionRow(
- "Three a day",
RemindersRepetition.ThreeADay,
selectedOption,
onRepetitionSelected
)
ReminderOptionRow(
- "Five a day",
RemindersRepetition.FiveADay,
selectedOption,
onRepetitionSelected
@@ -215,19 +212,16 @@ fun ThemeSelectionDialog(
text = {
Column {
ThemeOptionRow(
- "Light",
ThemeMode.LIGHT,
selectedOption,
onThemeSelected
)
ThemeOptionRow(
- "Dark",
ThemeMode.DARK,
selectedOption,
onThemeSelected
)
ThemeOptionRow(
- "System Default",
ThemeMode.SYSTEM,
selectedOption,
onThemeSelected
@@ -245,7 +239,6 @@ fun ThemeSelectionDialog(
@Composable
fun ThemeOptionRow(
- label: String,
themeMode: ThemeMode,
selectedOption: ThemeMode,
onOptionSelected: (ThemeMode) -> Unit
@@ -262,13 +255,12 @@ fun ThemeOptionRow(
onClick = { onOptionSelected(themeMode) }
)
Spacer(modifier = Modifier.width(8.dp))
- Text(text = label)
+ Text(text = themeMode.toString())
}
}
@Composable
fun ReminderOptionRow(
- label: String,
repetition: RemindersRepetition,
selectedOption: RemindersRepetition,
onOptionSelected: (RemindersRepetition) -> Unit
@@ -284,7 +276,7 @@ fun ReminderOptionRow(
onClick = { onOptionSelected(repetition) }
)
Spacer(modifier = Modifier.width(8.dp))
- Text(text = label)
+ Text(text = repetition.toString())
}
}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 128dfac..5d088ec 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -30,6 +30,7 @@ truth = "1.4.2"
uiTextGoogleFonts = "1.6.8"
junitKtx = "1.2.1"
lifecycleRuntimeComposeAndroid = "2.8.4"
+workRuntimeKtx = "2.9.1"
@@ -40,6 +41,8 @@ androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref =
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" }
androidx-core-testing = { module = "androidx.arch.core:core-testing", version.ref = "coreTesting" }
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
+androidx-hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltNavigationCompose" }
+androidx-hilt-work = { module = "androidx.hilt:hilt-work", version.ref = "hiltNavigationCompose" }
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtx" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
androidx-navigation-testing = { module = "androidx.navigation:navigation-testing", version.ref = "navigationCompose" }
@@ -47,6 +50,8 @@ androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref =
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "roomRuntime" }
androidx-room-room-testing = { module = "androidx.room:room-testing", version.ref = "roomRuntime" }
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "roomRuntime" }
+androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "workRuntimeKtx" }
+androidx-work-testing = { module = "androidx.work:work-testing", version.ref = "workRuntimeKtx" }
core-testing = { module = "android.arch.core:core-testing", version.ref = "coreTestingVersion" }
firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebaseBom" }
gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }