Skip to content

Conversation

@HatakeKakashri
Copy link
Contributor

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Added all the preference items of Debug screen.
  • Implemented all actions / callbacks for the debug preferences, including checking for new streams, intentionally crashing the app, and displaying error notifications and snackbars.
  • Refactored the SettingsViewModel to use a BooleanPreference helper class to reuse and reducing boilerplate for state management.
  • Created a shared TextBase composable to remove duplicated UI logic between SwitchPreference and TextPreference.
  • Move the build-variant-dependent logic for LeakCanary and reused it in Compose and Fragment, this logic is used for ensuring the leak canary fields are only enabled in debug variants.
  • Fixed a layout bug in SwitchPreference where long summary text could misalign the switch component and also adjusted the paddings for consistency.

Before/After Screenshots/Screen Record (The toolbar colors are to be handled in a seperate PR #12654)

Screenshot_20251115_112209

Fixes the following issue(s)

Relies on the following changes

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions bot added the size/large PRs with less than 750 changed lines label Nov 15, 2025
@TobiGr TobiGr added this to Rewrite Nov 15, 2025
@github-project-automation github-project-automation bot moved this to In Progress in Rewrite Nov 15, 2025
@TobiGr TobiGr added the rewrite Issues and PRs related to rewrite label Nov 15, 2025
@github-actions github-actions bot added size/giant PRs with more than 750 changed lines and removed size/large PRs with less than 750 changed lines labels Jan 13, 2026
@HatakeKakashri
Copy link
Contributor Author

Updated the PR with nav3 as requested here

cc: @theimpulson @TobiGr

Copy link
Member

@theimpulson theimpulson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add SPDX copyright header to all files which are being modified/added as done in recent merged PRs for Kotlin migration.

import androidx.navigation3.runtime.NavKey
import kotlinx.serialization.Serializable

sealed interface SettingsKey : NavKey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a common sealed class such as Screen and put a Settings class inside it. This one should be a Sealed class as well but as ExtraScreen or something as all of this screens are extra used by Settings only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you meant. Don't think there is much advantage to keeping all screens keys in one place. I'm fine either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Sealed class so that everyone who adds a new Screen is forced to keep it inside there and not able to put logic at any package. Then you should keep all screens which are child to Settings in its own package so that it can handle its own children and they don't take space in global screens.

Comment on lines 13 to 15
@StringRes title: Int,
@StringRes summary: Int?,
enabled: Boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pass actual string resources here and set a default boolean as well. Additionally, please add a preview and doc-comment on what this composable is used for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% aligned on passing strings instead of @StringRes. Did you have any specific reasoning for this change?

My preference for @StringRes is:

  • Compile-time safety with resource IDs
  • Automatic localization handling
  • Android standard patterns

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to write all compose logic as multi-platform so that when everything is ready NewPipe can be used on OS other than Android. Second thing is testing. We should be able to test composable without being dependent upon resources.

TextPreference(
title = R.string.settings_category_player_title,
icon = R.drawable.ic_play_arrow,
onClick = { backStack.add(PlayerSettings) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider making the onClick logic a bit more general and avoid interacting with backstack directly. An example would be that the screen forwards this to the class with NavDisplay so all navigation logic is in one place making it easy for refactor.

- Completed the UI and logic for pending items of Debug screen using Jetpack Compose.
- Implemented a new navigation system for settings using the navigation3
  lib as it is now stable.
- Reuses the `ScaffoldWithToolbar` composable and removed the previous
  `Toolbar` composable to avoid redundancy in code.
- Refactored the `SettingsViewModel` to use a `BooleanPreference` helper
  class to reuse and reducing boilerplate for state management.
- Created a shared `TextBase` composable to remove duplicated UI logic
  between `SwitchPreference` and `TextPreference`.
- Move the build-variant-dependent logic for LeakCanary and reused it in
  Compose and Fragment, this logic is used for ensuring the leak canary
  fields are only enabled in debug variants.
- Fixed a layout bug in `SwitchPreference` where long summary text could
  misalign the switch component and also adjusted the paddings for consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rewrite Issues and PRs related to rewrite size/giant PRs with more than 750 changed lines

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants