|
|
@ -7,46 +7,66 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
|
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import eu.kanade.presentation.more.settings.screen.SettingsDataScreen
|
|
|
|
import eu.kanade.presentation.more.settings.screen.SettingsDataScreen
|
|
|
|
import eu.kanade.tachiyomi.util.system.toast
|
|
|
|
import eu.kanade.tachiyomi.util.system.toast
|
|
|
|
import tachiyomi.core.preference.Preference
|
|
|
|
import kotlinx.coroutines.flow.collectLatest
|
|
|
|
|
|
|
|
import tachiyomi.domain.storage.service.StoragePreferences
|
|
|
|
import tachiyomi.i18n.MR
|
|
|
|
import tachiyomi.i18n.MR
|
|
|
|
import tachiyomi.presentation.core.components.material.Button
|
|
|
|
import tachiyomi.presentation.core.components.material.Button
|
|
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
|
|
|
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
|
|
|
|
|
import uy.kohesive.injekt.api.get
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
internal class StorageStep : OnboardingStep {
|
|
|
|
internal fun StorageStep(
|
|
|
|
|
|
|
|
storagePref: Preference<String>,
|
|
|
|
private val storagePref = Injekt.get<StoragePreferences>().baseStorageDirectory()
|
|
|
|
) {
|
|
|
|
|
|
|
|
val context = LocalContext.current
|
|
|
|
private var _isComplete by mutableStateOf(false)
|
|
|
|
val pickStorageLocation = SettingsDataScreen.storageLocationPicker(storagePref)
|
|
|
|
|
|
|
|
|
|
|
|
override val isComplete: Boolean
|
|
|
|
Column(
|
|
|
|
get() = _isComplete
|
|
|
|
modifier = Modifier.padding(16.dp),
|
|
|
|
|
|
|
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
|
|
|
@Composable
|
|
|
|
) {
|
|
|
|
override fun Content() {
|
|
|
|
Text(
|
|
|
|
val context = LocalContext.current
|
|
|
|
stringResource(
|
|
|
|
val pickStorageLocation = SettingsDataScreen.storageLocationPicker(storagePref)
|
|
|
|
MR.strings.onboarding_storage_info,
|
|
|
|
|
|
|
|
stringResource(MR.strings.app_name),
|
|
|
|
Column(
|
|
|
|
SettingsDataScreen.storageLocationText(storagePref),
|
|
|
|
modifier = Modifier.padding(16.dp),
|
|
|
|
),
|
|
|
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Button(
|
|
|
|
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
|
|
|
|
onClick = {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
pickStorageLocation.launch(null)
|
|
|
|
|
|
|
|
} catch (e: ActivityNotFoundException) {
|
|
|
|
|
|
|
|
context.toast(MR.strings.file_picker_error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Text(stringResource(MR.strings.onboarding_storage_action_select))
|
|
|
|
Text(
|
|
|
|
|
|
|
|
stringResource(
|
|
|
|
|
|
|
|
MR.strings.onboarding_storage_info,
|
|
|
|
|
|
|
|
stringResource(MR.strings.app_name),
|
|
|
|
|
|
|
|
SettingsDataScreen.storageLocationText(storagePref),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Button(
|
|
|
|
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
|
|
|
|
onClick = {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
pickStorageLocation.launch(null)
|
|
|
|
|
|
|
|
} catch (e: ActivityNotFoundException) {
|
|
|
|
|
|
|
|
context.toast(MR.strings.file_picker_error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
Text(stringResource(MR.strings.onboarding_storage_action_select))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LaunchedEffect(Unit) {
|
|
|
|
|
|
|
|
storagePref.changes()
|
|
|
|
|
|
|
|
.collectLatest { _isComplete = storagePref.isSet() }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|