Skip to content

Commit d33ba8a

Browse files
committed
refactor settings screen, debug, viewmodels, etc
1 parent fbfa1fd commit d33ba8a

14 files changed

Lines changed: 382 additions & 342 deletions

File tree

app/src/main/java/org/schabi/newpipe/settings/DebugScreen.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/settings/SettingsV2Activity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import android.os.Bundle
1010
import androidx.activity.ComponentActivity
1111
import androidx.activity.compose.setContent
1212
import dagger.hilt.android.AndroidEntryPoint
13-
import org.schabi.newpipe.settings.navigation.SettingsNavigation
13+
import org.schabi.newpipe.ui.screens.settings.navigation.SettingsNavigation
1414
import org.schabi.newpipe.ui.theme.AppTheme
1515

1616
@AndroidEntryPoint
@@ -22,7 +22,7 @@ class SettingsV2Activity : ComponentActivity() {
2222
setContent {
2323
AppTheme {
2424
SettingsNavigation(
25-
onExitSettings = { finish() },
25+
onExitSettings = { finish() }
2626
)
2727
}
2828
}

app/src/main/java/org/schabi/newpipe/ui/SwitchPreference.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
package org.schabi.newpipe.ui
88

9-
import androidx.annotation.StringRes
109
import androidx.compose.foundation.layout.Column
1110
import androidx.compose.foundation.layout.Row
1211
import androidx.compose.foundation.layout.Spacer
@@ -22,10 +21,10 @@ import org.schabi.newpipe.ui.theme.SizeTokens
2221
@Composable
2322
fun SwitchPreference(
2423
modifier: Modifier = Modifier,
25-
@StringRes title: Int,
24+
title: String,
2625
isChecked: Boolean,
2726
onCheckedChange: (Boolean) -> Unit,
28-
@StringRes summary: Int? = null,
27+
summary: String? = null,
2928
enabled: Boolean = true
3029
) {
3130
Row(

app/src/main/java/org/schabi/newpipe/ui/TextBase.kt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,38 @@
55

66
package org.schabi.newpipe.ui
77

8-
import androidx.annotation.StringRes
98
import androidx.compose.foundation.layout.Column
109
import androidx.compose.material3.MaterialTheme
1110
import androidx.compose.material3.Text
1211
import androidx.compose.runtime.Composable
1312
import androidx.compose.ui.graphics.Color
14-
import androidx.compose.ui.res.stringResource
1513
import androidx.compose.ui.text.style.TextAlign
1614
import androidx.compose.ui.tooling.preview.Preview
17-
import org.schabi.newpipe.R
1815

1916
/**
2017
* A base composable that displays a title and an optional summary text. Used in settings preference
21-
* items such as TextPreference and SwitchPreference
18+
* items such as TextPreference and SwitchPreference.
2219
*
23-
* @param title the resource ID of the string to be used as the title
24-
* @param summary the optional resource ID of the string to be used as the summary
20+
* @param title the title text to display
21+
* @param summary the optional summary text to display below the title
2522
* @param enabled whether the text should be displayed in an enabled or disabled state
2623
*/
2724
@Composable
2825
internal fun TextBase(
29-
@StringRes title: Int,
30-
@StringRes summary: Int?,
26+
title: String,
27+
summary: String?,
3128
enabled: Boolean = true
3229
) {
3330
Column {
3431
Text(
35-
text = stringResource(id = title),
32+
text = title,
3633
style = MaterialTheme.typography.titleSmall,
3734
textAlign = TextAlign.Start,
3835
color = if (enabled) Color.Unspecified else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
3936
)
4037
summary?.let {
4138
Text(
42-
text = stringResource(id = summary),
39+
text = it,
4340
style = MaterialTheme.typography.bodySmall,
4441
textAlign = TextAlign.Start,
4542
color = if (enabled) Color.Unspecified else MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.38f)
@@ -50,6 +47,6 @@ internal fun TextBase(
5047

5148
@Preview(showBackground = true, backgroundColor = 0xFFFFFFFF)
5249
@Composable
53-
fun TextBasePreview() {
54-
TextBase(R.string.settings_category_debug_title, R.string.settings_category_debug_title)
50+
private fun TextBasePreview() {
51+
TextBase("Debug", "Debug settings summary")
5552
}

app/src/main/java/org/schabi/newpipe/ui/TextPreference.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package org.schabi.newpipe.ui
88

99
import androidx.annotation.DrawableRes
10-
import androidx.annotation.StringRes
1110
import androidx.compose.foundation.clickable
1211
import androidx.compose.foundation.layout.Arrangement
1312
import androidx.compose.foundation.layout.Column
@@ -29,9 +28,9 @@ import org.schabi.newpipe.ui.theme.SizeTokens
2928
@Composable
3029
fun TextPreference(
3130
modifier: Modifier = Modifier,
32-
@StringRes title: Int,
31+
title: String,
3332
@DrawableRes icon: Int? = null,
34-
@StringRes summary: Int? = null,
33+
summary: String? = null,
3534
onClick: () -> Unit,
3635
enabled: Boolean = true
3736
) {
@@ -47,7 +46,7 @@ fun TextPreference(
4746
icon?.let {
4847
Icon(
4948
painter = painterResource(id = icon),
50-
contentDescription = "icon for $title preference",
49+
contentDescription = null,
5150
tint = if (enabled) Color.Unspecified else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
5251
)
5352
Spacer(modifier = Modifier.width(SizeTokens.SpacingSmall))

app/src/main/java/org/schabi/newpipe/ui/components/common/ScaffoldWithToolbar.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fun ScaffoldWithToolbar(
8686
)
8787
},
8888
expanded = true,
89-
onExpandedChange = { isSearchActive = it },
89+
onExpandedChange = { isSearchActive = it }
9090
) {
9191
val suggestions = onSearchQueryChange?.invoke(query) ?: emptyList()
9292
if (suggestions.isNotEmpty()) {
@@ -96,7 +96,7 @@ fun ScaffoldWithToolbar(
9696
}
9797
}
9898
} else {
99-
DefaultSearchNoResults()
99+
DefaultSearchNoResults()
100100
}
101101
}
102102
} else {
@@ -107,7 +107,7 @@ fun ScaffoldWithToolbar(
107107
scrolledContainerColor = MaterialTheme.colorScheme.primaryContainer,
108108
navigationIconContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
109109
titleContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
110-
actionIconContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
110+
actionIconContentColor = MaterialTheme.colorScheme.onPrimaryContainer
111111
),
112112
navigationIcon = {
113113
IconButton(onClick = onBackClick) {

app/src/main/java/org/schabi/newpipe/ui/screens/DebugScreen.kt

Lines changed: 0 additions & 194 deletions
This file was deleted.

0 commit comments

Comments
 (0)