diff --git a/app/src/main/java/com/dd3boh/outertune/db/DatabaseDao.kt b/app/src/main/java/com/dd3boh/outertune/db/DatabaseDao.kt index 4ca0f9606..831ffc1d5 100644 --- a/app/src/main/java/com/dd3boh/outertune/db/DatabaseDao.kt +++ b/app/src/main/java/com/dd3boh/outertune/db/DatabaseDao.kt @@ -270,6 +270,10 @@ interface DatabaseDao : SongsDao, AlbumsDao, ArtistsDao, PlaylistsDao, QueueDao @Query("DELETE FROM genre WHERE isLocal = 1") fun nukeLocalGenre() + @Transaction + @Query("DELETE FROM format") + fun nukeFormatEntities() + @Transaction fun nukeLocalData() { nukeLocalSongs() diff --git a/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt b/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt index 50636b004..9bd4566ec 100644 --- a/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt +++ b/app/src/main/java/com/dd3boh/outertune/ui/screens/settings/ExperimentalSettings.kt @@ -4,6 +4,8 @@ import android.widget.Toast import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState @@ -13,7 +15,9 @@ import androidx.compose.material.icons.automirrored.rounded.ArrowBack import androidx.compose.material.icons.rounded.Backup import androidx.compose.material.icons.rounded.ConfirmationNumber import androidx.compose.material.icons.rounded.DeveloperMode +import androidx.compose.material.icons.rounded.ErrorOutline import androidx.compose.material.icons.rounded.Sync +import androidx.compose.material.icons.rounded.WarningAmber import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -21,7 +25,11 @@ import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource @@ -61,6 +69,10 @@ fun ExperimentalSettings( val (devSettings, onDevSettingsChange) = rememberPreference(DevSettingsKey, defaultValue = false) val (firstSetupPassed, onFirstSetupPassedChange) = rememberPreference(FirstSetupPassed, defaultValue = false) + var nukeEnabled by remember { + mutableStateOf(false) + } + Column( Modifier .windowInsetsPadding(LocalPlayerAwareWindowInsets.current) @@ -81,10 +93,10 @@ fun ExperimentalSettings( icon = { Icon(Icons.Rounded.Sync, null) }, onClick = { Toast.makeText(context, "Syncing with YouTube account...", Toast.LENGTH_SHORT).show() - coroutineScope.launch(Dispatchers.Main) { - syncUtils.syncAll() - Toast.makeText(context, "Sync complete", Toast.LENGTH_SHORT).show() - } + coroutineScope.launch(Dispatchers.Main) { + syncUtils.syncAll() + Toast.makeText(context, "Sync complete", Toast.LENGTH_SHORT).show() + } } ) @@ -92,16 +104,6 @@ fun ExperimentalSettings( PreferenceGroupTitle( title = stringResource(R.string.settings_debug) ) - PreferenceEntry( - title = { Text("DEBUG: Nuke local lib") }, - icon = { Icon(Icons.Rounded.Backup, null) }, - onClick = { - Toast.makeText(context, "Nuking local files from database...", Toast.LENGTH_SHORT).show() - coroutineScope.launch(Dispatchers.IO) { - Timber.tag("Settings").d("Nuke database status: ${database.nukeLocalData()}") - } - } - ) PreferenceEntry( title = { Text("DEBUG: Force local to remote artist migration NOW") }, icon = { Icon(Icons.Rounded.Backup, null) }, @@ -173,6 +175,49 @@ fun ExperimentalSettings( Text("Error Container", color = MaterialTheme.colorScheme.onErrorContainer) } } + + // nukes + Spacer(Modifier.height(100.dp)) + PreferenceEntry( + title = { Text("Tap to show nuke options") }, + icon = { Icon(Icons.Rounded.ErrorOutline, null) }, + onClick = { + nukeEnabled = true + } + ) + + if (nukeEnabled) { + PreferenceEntry( + title = { Text("DEBUG: Nuke local lib") }, + icon = { Icon(Icons.Rounded.ErrorOutline, null) }, + onClick = { + Toast.makeText(context, "Nuking local files from database...", Toast.LENGTH_SHORT).show() + coroutineScope.launch(Dispatchers.IO) { + Timber.tag("Settings").d("Nuke database status: ${database.nukeLocalData()}") + } + } + ) + PreferenceEntry( + title = { Text("DEBUG: Nuke local artists") }, + icon = { Icon(Icons.Rounded.WarningAmber, null) }, + onClick = { + Toast.makeText(context, "Nuking local artists from database...", Toast.LENGTH_SHORT).show() + coroutineScope.launch(Dispatchers.IO) { + Timber.tag("Settings").d("Nuke database status: ${database.nukeLocalArtists()}") + } + } + ) + PreferenceEntry( + title = { Text("DEBUG: Nuke format entities") }, + icon = { Icon(Icons.Rounded.WarningAmber, null) }, + onClick = { + Toast.makeText(context, "Nuking format entities from database...", Toast.LENGTH_SHORT).show() + coroutineScope.launch(Dispatchers.IO) { + Timber.tag("Settings").d("Nuke database status: ${database.nukeFormatEntities()}") + } + } + ) + } } }