-
Notifications
You must be signed in to change notification settings - Fork 0
Add CastManager singleton, settings toggle, and set proprietary flavor default
#14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideIntroduces a singleton CastManager service wired via Hilt, exposes a user-facing toggle to enable/disable casting through settings, and changes the Android build configuration to use the Sequence diagram for toggling casting and reading CastManager statesequenceDiagram
actor User
participant SettingsUI
participant SettingsViewModel
participant AppPreferences
participant SharedPreferences
participant SomePlayerComponent
participant CastManager
User->>SettingsUI: Toggle cast switch
SettingsUI->>SettingsViewModel: onCastToggle(enabled)
SettingsViewModel->>AppPreferences: setValue(playerCastEnabled, enabled)
AppPreferences->>SharedPreferences: putBoolean(pref_player_cast_enabled, enabled)
SharedPreferences-->>AppPreferences: persist_success
AppPreferences-->>SettingsViewModel: completion
SettingsViewModel-->>SettingsUI: update_switch_state
SomePlayerComponent->>CastManager: isCastingEnabled
CastManager-->>SomePlayerComponent: Boolean
Class diagram for CastManager singleton and preferences integrationclassDiagram
class CastManager {
<<interface>>
+Boolean isCastingEnabled
+setCastingEnabled(enabled Boolean)
}
class DefaultCastManager {
+DefaultCastManager(appPreferences AppPreferences)
+Boolean isCastingEnabled
+setCastingEnabled(enabled Boolean)
-appPreferences AppPreferences
}
class AppPreferences {
+SharedPreferences sharedPreferences
+Preference playerPipGesture
+Preference playerCastEnabled
+Preference downloadOverMobileData
+Preference downloadWhenRoaming
+getValue(preference Preference) Boolean
+setValue(preference Preference, value Boolean)
}
class Preference {
+String key
+Boolean defaultValue
}
class CastModule {
<<HiltModule>>
+bindCastManager(impl DefaultCastManager) CastManager
}
CastManager <|.. DefaultCastManager
AppPreferences "1" --> "*" Preference : uses
DefaultCastManager --> AppPreferences : depends_on
CastModule ..> CastManager : binds
CastModule ..> DefaultCastManager : implementation
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- Consider exposing
CastManagerstate as a reactive stream (e.g., Flow/State) rather than a simple boolean getter so that UI or services depending on casting can observe changes without pollingSharedPreferenceson each access. - In
SettingsViewModel, you’re wiring the casting toggle directly toAppPreferences.playerCastEnabled; ifCastManageris intended as the central abstraction, you may want to route writes/reads through it to avoid future duplication of casting logic across modules.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider exposing `CastManager` state as a reactive stream (e.g., Flow/State) rather than a simple boolean getter so that UI or services depending on casting can observe changes without polling `SharedPreferences` on each access.
- In `SettingsViewModel`, you’re wiring the casting toggle directly to `AppPreferences.playerCastEnabled`; if `CastManager` is intended as the central abstraction, you may want to route writes/reads through it to avoid future duplication of casting logic across modules.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Motivation
proprietaryproduct flavor as the default build variant while keeping thelibreflavor available.Description
proprietaryas the default variant inapp/phone/build.gradle.ktsand keeplibreas a second flavor.playerCastEnabledinsettings/src/main/java/.../AppPreferences.ktdefaulting totrue.settings/src/main/res/values/strings.xmland wire aPreferenceSwitchinto the player settings inSettingsViewModel.ktto surface the toggle.CastManagerinterface inplayer/coreand provide an application singleton implementationDefaultCastManagerinapp/phonethat reads/writesplayerCastEnabled, plus a HiltCastModuleto bind the singleton.Testing
Codex Task
Summary by Sourcery
Introduce a global cast management service controlled by a new user setting and switch the Android phone app to use the proprietary build flavor by default.
New Features:
Enhancements:
Build: