Skip to content

Commit 25c12ef

Browse files
Merge pull request #12803 from HatakeKakashri/debug_screen_migration
Complete the debug screen migration to Compose
2 parents 5fafccb + d33ba8a commit 25c12ef

22 files changed

Lines changed: 949 additions & 263 deletions

app/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,14 @@ dependencies {
271271
implementation(libs.androidx.compose.ui.text) // Needed for parsing HTML to AnnotatedString
272272
implementation(libs.androidx.compose.material.icons.extended)
273273

274+
// Jetpack navigatio3
275+
implementation(libs.androidx.navigation3.ui)
276+
implementation(libs.androidx.navigation3.runtime)
277+
implementation(libs.androidx.navigation3.viewmodel)
278+
274279
// Jetpack Compose related dependencies
275280
implementation(libs.androidx.paging.compose)
276-
implementation(libs.androidx.navigation.compose)
281+
implementation(libs.androidx.hilt.navigation.compose)
277282

278283
// Coroutines interop
279284
implementation(libs.kotlinx.coroutines.rx3)

app/src/debug/java/org/schabi/newpipe/settings/DebugSettingsBVDLeakCanary.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.settings
7+
8+
import android.content.Intent
9+
import leakcanary.LeakCanary.newLeakDisplayActivityIntent
10+
11+
/**
12+
* Build variant dependent (BVD) leak canary API implementation for the debug settings fragment.
13+
* This class is loaded via reflection by
14+
* [DebugSettingsBVDLeakCanaryAPI].
15+
*/
16+
@Suppress("unused") // Class is used but loaded via reflection
17+
class DebugSettingsBVDLeakCanary :
18+
19+
DebugSettingsBVDLeakCanaryAPI {
20+
override fun getNewLeakDisplayActivityIntent(): Intent {
21+
return newLeakDisplayActivityIntent()
22+
}
23+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2017-2026 NewPipe contributors <https://newpipe.net>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.navigation
7+
8+
import androidx.navigation3.runtime.NavKey
9+
import kotlinx.serialization.Serializable
10+
11+
@Serializable
12+
sealed interface Screen : NavKey {
13+
14+
sealed interface Settings : Screen {
15+
@Serializable
16+
data object Home : Settings
17+
18+
@Serializable
19+
data object Player : Settings
20+
21+
@Serializable
22+
data object Behaviour : Settings
23+
24+
@Serializable
25+
data object Download : Settings
26+
27+
@Serializable
28+
data object LookFeel : Settings
29+
30+
@Serializable
31+
data object HistoryCache : Settings
32+
33+
@Serializable
34+
data object Content : Settings
35+
36+
@Serializable
37+
data object Feed : Settings
38+
39+
@Serializable
40+
data object Services : Settings
41+
42+
@Serializable
43+
data object Language : Settings
44+
45+
@Serializable
46+
data object BackupRestore : Settings
47+
48+
@Serializable
49+
data object Updates : Settings
50+
51+
@Serializable
52+
data object Debug : Settings
53+
}
54+
}

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

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.settings
7+
8+
import android.content.Intent
9+
10+
/**
11+
* Build variant dependent (BVD) leak canary API.
12+
* Why is LeakCanary not used directly? Because it can't be assured to be available.
13+
*/
14+
interface DebugSettingsBVDLeakCanaryAPI {
15+
fun getNewLeakDisplayActivityIntent(): Intent
16+
17+
companion object {
18+
const val IMPL_CLASS = "org.schabi.newpipe.settings.DebugSettingsBVDLeakCanary"
19+
}
20+
}

app/src/main/java/org/schabi/newpipe/settings/DebugSettingsFragment.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2017-2025 NewPipe contributors <https://newpipe.net>
3+
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
4+
* SPDX-License-Identifier: GPL-3.0-or-later
5+
*/
6+
17
package org.schabi.newpipe.settings;
28

3-
import android.content.Intent;
49
import android.os.Bundle;
510

611
import androidx.preference.Preference;
@@ -88,15 +93,4 @@ private Optional<DebugSettingsBVDLeakCanaryAPI> getBVDLeakCanary() {
8893
return Optional.empty();
8994
}
9095
}
91-
92-
/**
93-
* Build variant dependent (BVD) leak canary API for this fragment.
94-
* Why is LeakCanary not used directly? Because it can't be assured
95-
*/
96-
public interface DebugSettingsBVDLeakCanaryAPI {
97-
String IMPL_CLASS =
98-
"org.schabi.newpipe.settings.DebugSettingsBVDLeakCanary";
99-
100-
Intent getNewLeakDisplayActivityIntent();
101-
}
10296
}

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

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,30 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2017-2025 NewPipe contributors <https://newpipe.net>
3+
* SPDX-FileCopyrightText: 2025-2026 NewPipe e.V. <https://newpipe-ev.de>
4+
* SPDX-License-Identifier: GPL-3.0-or-later
5+
*/
6+
17
package org.schabi.newpipe.settings
28

39
import android.os.Bundle
410
import androidx.activity.ComponentActivity
511
import androidx.activity.compose.setContent
6-
import androidx.activity.viewModels
7-
import androidx.annotation.StringRes
8-
import androidx.compose.foundation.layout.padding
9-
import androidx.compose.material3.Scaffold
10-
import androidx.compose.runtime.getValue
11-
import androidx.compose.runtime.mutableIntStateOf
12-
import androidx.compose.runtime.remember
13-
import androidx.compose.runtime.setValue
14-
import androidx.compose.ui.Modifier
15-
import androidx.compose.ui.res.stringResource
16-
import androidx.navigation.compose.NavHost
17-
import androidx.navigation.compose.composable
18-
import androidx.navigation.compose.rememberNavController
19-
import androidx.navigation.navArgument
2012
import dagger.hilt.android.AndroidEntryPoint
21-
import org.schabi.newpipe.R
22-
import org.schabi.newpipe.settings.viewmodel.SettingsViewModel
23-
import org.schabi.newpipe.ui.Toolbar
13+
import org.schabi.newpipe.ui.screens.settings.navigation.SettingsNavigation
2414
import org.schabi.newpipe.ui.theme.AppTheme
2515

26-
const val SCREEN_TITLE_KEY = "SCREEN_TITLE_KEY"
27-
2816
@AndroidEntryPoint
2917
class SettingsV2Activity : ComponentActivity() {
3018

31-
private val settingsViewModel: SettingsViewModel by viewModels()
32-
3319
override fun onCreate(savedInstanceState: Bundle?) {
3420
super.onCreate(savedInstanceState)
3521

3622
setContent {
37-
val navController = rememberNavController()
38-
var screenTitle by remember { mutableIntStateOf(SettingsScreenKey.ROOT.screenTitle) }
39-
navController.addOnDestinationChangedListener { _, _, arguments ->
40-
screenTitle =
41-
arguments?.getInt(SCREEN_TITLE_KEY) ?: SettingsScreenKey.ROOT.screenTitle
42-
}
43-
4423
AppTheme {
45-
Scaffold(topBar = {
46-
Toolbar(
47-
title = stringResource(id = screenTitle),
48-
hasSearch = true,
49-
onSearchQueryChange = null // TODO: Add suggestions logic
50-
)
51-
}) { padding ->
52-
NavHost(
53-
navController = navController,
54-
startDestination = SettingsScreenKey.ROOT.name,
55-
modifier = Modifier.padding(padding)
56-
) {
57-
composable(
58-
SettingsScreenKey.ROOT.name,
59-
listOf(createScreenTitleArg(SettingsScreenKey.ROOT.screenTitle))
60-
) {
61-
SettingsScreen(onSelectSettingOption = { screen ->
62-
navController.navigate(screen.name)
63-
})
64-
}
65-
composable(
66-
SettingsScreenKey.DEBUG.name,
67-
listOf(createScreenTitleArg(SettingsScreenKey.DEBUG.screenTitle))
68-
) {
69-
DebugScreen(settingsViewModel)
70-
}
71-
}
72-
}
24+
SettingsNavigation(
25+
onExitSettings = { finish() }
26+
)
7327
}
7428
}
7529
}
7630
}
77-
78-
fun createScreenTitleArg(@StringRes screenTitle: Int) = navArgument(SCREEN_TITLE_KEY) {
79-
defaultValue = screenTitle
80-
}
81-
82-
enum class SettingsScreenKey(@StringRes val screenTitle: Int) {
83-
ROOT(R.string.settings),
84-
DEBUG(R.string.settings_category_debug_title)
85-
}

app/src/main/java/org/schabi/newpipe/settings/viewmodel/SettingsViewModel.kt

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

0 commit comments

Comments
 (0)