Skip to content

Commit

Permalink
settings: Update nuke settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mikooomich committed Jan 4, 2025
1 parent b177f85 commit ea23a52
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/dd3boh/outertune/db/DatabaseDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,15 +15,21 @@ 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
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
Expand Down Expand Up @@ -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)
Expand All @@ -81,27 +93,17 @@ 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()
}
}
)

if (devSettings) {
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) },
Expand Down Expand Up @@ -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()}")
}
}
)
}
}
}

Expand Down

0 comments on commit ea23a52

Please sign in to comment.