feat: add oss/playstore flavors and feature flags#1007
Conversation
📝 WalkthroughWalkthroughAdds a new product-flavor dimension ( Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as LibraryScreen / TabBar
participant VM as LibraryViewModel
participant Enum as LibraryTab
User->>UI: select tab / press Add Custom Game
UI->>UI: check BuildConfig.ENABLE_CUSTOM_GAMES
alt ENABLE_CUSTOM_GAMES = false
UI-->>User: no-op or switch to ALL
UI->>VM: setTab(LibraryTab.sanitize(selected))
VM->>Enum: LibraryTab.availableTabs()
Enum-->>VM: available list (LOCAL excluded)
VM-->>UI: updated state (custom-game flows disabled)
else ENABLE_CUSTOM_GAMES = true
UI->>VM: open folder picker / set LOCAL
VM->>Enum: LibraryTab.availableTabs()
Enum-->>VM: available list (LOCAL included)
VM-->>UI: allow custom-game actions
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Any reason why custom games feature is required to be Disabled for playstore? |
|
can we keep this one as draft for now? |
91aadb8 to
377828b
Compare
|
@utkarshdalal bringing out of draft as 0.9.0 release is up, as discussed I think we should get this in as groundwork toward play store release and unblock feature works |
d74058b to
67deef7
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
app/src/main/java/app/gamenative/ui/screen/library/LibraryScreen.kt (1)
435-438: Consider reusingLibraryTab.sanitize()for tab correction.Line 437 hardcodes
LibraryTab.ALL. UsingLibraryTab.sanitize(state.currentTab)here would keep policy centralized if valid fallback behavior ever changes.Suggested patch
LaunchedEffect(customGamesEnabled, state.currentTab) { - if (!customGamesEnabled && state.currentTab == LibraryTab.LOCAL) { - onTabChanged(LibraryTab.ALL) - } + if (!customGamesEnabled) { + val sanitizedTab = LibraryTab.sanitize(state.currentTab) + if (sanitizedTab != state.currentTab) { + onTabChanged(sanitizedTab) + } + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/app/gamenative/ui/screen/library/LibraryScreen.kt` around lines 435 - 438, The LaunchedEffect block that currently forces a hardcoded fallback to LibraryTab.ALL should instead call LibraryTab.sanitize(state.currentTab) and pass that result to onTabChanged so fallback logic is centralized; update the LaunchedEffect in LibraryScreen (the block referencing customGamesEnabled and state.currentTab) to compute val corrected = LibraryTab.sanitize(state.currentTab) and call onTabChanged(corrected) rather than onTabChanged(LibraryTab.ALL).app/src/main/java/app/gamenative/ui/enums/LibraryTab.kt (1)
82-93: Add a defensive empty-list guard in tab navigation helpers.Line 85 and Line 92 assume
availableTabsis non-empty. If a caller passesemptyList(), this can crash (% 0or invalid index). A small guard makes these helpers resilient.Suggested patch
fun LibraryTab.next(availableTabs: List<LibraryTab> = LibraryTab.availableTabs()): LibraryTab { + if (availableTabs.isEmpty()) return ALL val currentIndex = availableTabs.indexOf(this) if (currentIndex == -1) return ALL val nextIndex = (currentIndex + 1) % availableTabs.size return availableTabs[nextIndex] } fun LibraryTab.previous(availableTabs: List<LibraryTab> = LibraryTab.availableTabs()): LibraryTab { + if (availableTabs.isEmpty()) return ALL val currentIndex = availableTabs.indexOf(this) if (currentIndex == -1) return ALL val prevIndex = if (currentIndex == 0) availableTabs.size - 1 else currentIndex - 1 return availableTabs[prevIndex] }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/app/gamenative/ui/enums/LibraryTab.kt` around lines 82 - 93, The next and previous helpers (LibraryTab.next and LibraryTab.previous) assume availableTabs is non-empty and can crash on emptyList() (mod by zero or invalid index); add a defensive guard at the start of both functions that returns a safe default (e.g., LibraryTab.ALL) when availableTabs.isEmpty() to avoid division by zero/invalid indexing, then continue with the existing logic for non-empty lists.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@app/src/main/java/app/gamenative/ui/enums/LibraryTab.kt`:
- Around line 82-93: The next and previous helpers (LibraryTab.next and
LibraryTab.previous) assume availableTabs is non-empty and can crash on
emptyList() (mod by zero or invalid index); add a defensive guard at the start
of both functions that returns a safe default (e.g., LibraryTab.ALL) when
availableTabs.isEmpty() to avoid division by zero/invalid indexing, then
continue with the existing logic for non-empty lists.
In `@app/src/main/java/app/gamenative/ui/screen/library/LibraryScreen.kt`:
- Around line 435-438: The LaunchedEffect block that currently forces a
hardcoded fallback to LibraryTab.ALL should instead call
LibraryTab.sanitize(state.currentTab) and pass that result to onTabChanged so
fallback logic is centralized; update the LaunchedEffect in LibraryScreen (the
block referencing customGamesEnabled and state.currentTab) to compute val
corrected = LibraryTab.sanitize(state.currentTab) and call
onTabChanged(corrected) rather than onTabChanged(LibraryTab.ALL).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 74e42258-2484-4618-ad56-783efcbb7ce1
📒 Files selected for processing (7)
.github/workflows/pluvia-pr-check.ymlapp/build.gradle.ktsapp/src/main/java/app/gamenative/ui/enums/LibraryTab.ktapp/src/main/java/app/gamenative/ui/model/LibraryViewModel.ktapp/src/main/java/app/gamenative/ui/screen/library/LibraryScreen.ktapp/src/main/java/app/gamenative/ui/screen/library/components/LibraryTabBar.ktubuntufs/build.gradle.kts
✅ Files skipped from review due to trivial changes (2)
- .github/workflows/pluvia-pr-check.yml
- app/src/main/java/app/gamenative/ui/screen/library/components/LibraryTabBar.kt
🚧 Files skipped from review as they are similar to previous changes (3)
- ubuntufs/build.gradle.kts
- app/build.gradle.kts
- app/src/main/java/app/gamenative/ui/model/LibraryViewModel.kt
Starting groundwork to feat flag between playstore focused releases vs "oss" which would be releases in GitHub.
First and most obvious thing we want to flag I think is hiding custom games creation, and accessing of them. so here we have one new bool for
ENABLE_CUSTOM_GAMESwhere if false:Summary by CodeRabbit