From a321927cd3d3d5138c734c56cfb5bf3101e73139 Mon Sep 17 00:00:00 2001 From: Mateus Rodrigues Costa Date: Fri, 9 Feb 2024 19:18:58 -0300 Subject: [PATCH] Improve SettingsScreen up arrow logic --- .../mateusrodcosta/apps/share2storage/SettingsActivity.kt | 3 +-- .../apps/share2storage/screens/SettingsScreen.kt | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/SettingsActivity.kt b/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/SettingsActivity.kt index 60595c9..0b23b9a 100644 --- a/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/SettingsActivity.kt +++ b/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/SettingsActivity.kt @@ -23,7 +23,6 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.result.contract.ActivityResultContracts -import androidx.preference.PreferenceManager import com.mateusrodcosta.apps.share2storage.screens.SettingsScreen class SettingsActivity : ComponentActivity() { @@ -56,7 +55,7 @@ class SettingsActivity : ComponentActivity() { updateSkipFileDetails = { value: Boolean -> settingsViewModel.updateSkipFileDetails(value) }, - activity = this + closeActivity = { this.finish() } ) } } diff --git a/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/screens/SettingsScreen.kt b/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/screens/SettingsScreen.kt index 2803ff2..6b5444b 100644 --- a/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/screens/SettingsScreen.kt +++ b/app/src/main/kotlin/com/mateusrodcosta/apps/share2storage/screens/SettingsScreen.kt @@ -17,7 +17,6 @@ package com.mateusrodcosta.apps.share2storage.screens -import android.app.Activity import android.net.Uri import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box @@ -69,7 +68,7 @@ fun SettingsScreenPreview() { launchFilePicker = {}, clearSaveDirectory = {}, updateSkipFileDetails = { _ -> }, - activity = null, + closeActivity = {}, ) } @@ -81,7 +80,7 @@ fun SettingsScreen( launchFilePicker: (() -> Unit), clearSaveDirectory: (() -> Unit), updateSkipFileDetails: ((Boolean) -> Unit), - activity: Activity?, + closeActivity: () -> Unit, ) { val defaultSaveLocation by spDefaultSaveLocation.collectAsState() val skipFileDetails by spSkipFileDetails.collectAsState() @@ -93,7 +92,7 @@ fun SettingsScreen( TopAppBar(title = { Text(stringResource(R.string.settings)) }, colors = appTopAppBarColors(), navigationIcon = { - IconButton(onClick = { activity?.finish() }) { + IconButton(onClick = { closeActivity() }) { Icon( Icons.AutoMirrored.Filled.ArrowBack, stringResource(id = R.string.back_arrow)