Skip to content

Commit a278413

Browse files
authored
Merge pull request #169 from HereLiesAz/claude/persistent-ad-settings-compartments
Persistent bottom ad across in-app screens + compartmentalized Settings
2 parents 2cfcbef + 8c8545b commit a278413

4 files changed

Lines changed: 350 additions & 326 deletions

File tree

app/src/main/kotlin/com/hereliesaz/logkitty/MainActivity.kt

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import com.google.android.play.core.install.model.UpdateAvailability
3636
import com.hereliesaz.aznavrail.AzButton
3737
import com.hereliesaz.aznavrail.model.AzButtonShape
3838
import com.hereliesaz.logkitty.services.LogKittyOverlayService
39+
import com.hereliesaz.logkitty.ui.AdBannerSlot
3940
import com.hereliesaz.logkitty.ui.GitHubScreen
4041
import com.hereliesaz.logkitty.ui.SettingsScreen
4142
import com.hereliesaz.logkitty.ui.theme.LogKittyTheme
@@ -128,39 +129,47 @@ class MainActivity : ComponentActivity() {
128129

129130
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
130131
val viewModel = (application as MainApplication).mainViewModel
131-
when {
132-
showSettings ->
133-
// Show the Settings Screen (Full Page).
134-
SettingsScreen(
135-
onBack = { showSettings = false },
136-
viewModel = viewModel
137-
)
138-
showGitHub ->
139-
// Full-screen GitHub Actions (same panel the overlay tab hosts).
140-
GitHubScreen(
141-
viewModel = viewModel,
142-
onBack = { showGitHub = false },
143-
// Keep showGitHub=true: the when checks showSettings first, so Settings
144-
// shows on top and backing out of it returns here, not the dashboard.
145-
onConfigure = { showSettings = true },
146-
)
147-
else -> {
148-
// Show the Main Dashboard / Permission Wizard.
149-
val isRootEnabled by viewModel.isRootEnabled.collectAsState()
150-
151-
MainScreenContent(
152-
isOverlayGranted = isOverlayGranted,
153-
isReadLogsGranted = isReadLogsGranted,
154-
isRootEnabled = isRootEnabled,
155-
isServiceRunning = isServiceRunning,
156-
updateReadyToInstall = updateReadyToInstall,
157-
onCompleteUpdate = { appUpdateManager.completeUpdate() },
158-
onGrantOverlay = { requestOverlayPermission() },
159-
onToggleService = { toggleOverlayService() },
160-
onOpenSettings = { showSettings = true },
161-
onOpenGitHub = { showGitHub = true }
162-
)
132+
// One persistent banner anchored to the bottom of every in-app screen. Composed
133+
// once here, outside the navigation `when`, so the same AdView instance survives
134+
// dashboard <-> Settings <-> GitHub navigation instead of reloading per screen.
135+
Column(modifier = Modifier.fillMaxSize()) {
136+
Box(modifier = Modifier.weight(1f)) {
137+
when {
138+
showSettings ->
139+
// Show the Settings Screen (Full Page).
140+
SettingsScreen(
141+
onBack = { showSettings = false },
142+
viewModel = viewModel
143+
)
144+
showGitHub ->
145+
// Full-screen GitHub Actions (same panel the overlay tab hosts).
146+
GitHubScreen(
147+
viewModel = viewModel,
148+
onBack = { showGitHub = false },
149+
// Keep showGitHub=true: the when checks showSettings first, so Settings
150+
// shows on top and backing out of it returns here, not the dashboard.
151+
onConfigure = { showSettings = true },
152+
)
153+
else -> {
154+
// Show the Main Dashboard / Permission Wizard.
155+
val isRootEnabled by viewModel.isRootEnabled.collectAsState()
156+
157+
MainScreenContent(
158+
isOverlayGranted = isOverlayGranted,
159+
isReadLogsGranted = isReadLogsGranted,
160+
isRootEnabled = isRootEnabled,
161+
isServiceRunning = isServiceRunning,
162+
updateReadyToInstall = updateReadyToInstall,
163+
onCompleteUpdate = { appUpdateManager.completeUpdate() },
164+
onGrantOverlay = { requestOverlayPermission() },
165+
onToggleService = { toggleOverlayService() },
166+
onOpenSettings = { showSettings = true },
167+
onOpenGitHub = { showGitHub = true }
168+
)
169+
}
170+
}
163171
}
172+
AdBannerSlot(modifier = Modifier.fillMaxWidth(), showTopDivider = true)
164173
}
165174
}
166175
}

app/src/main/kotlin/com/hereliesaz/logkitty/ui/LogBottomSheet.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,9 @@ private fun ExpandedView(
522522

523523
// --- Banner ad, pinned to the bottom of the expanded sheet (HALF / FULL only). ---
524524
// Takes no space (and shows no divider) until the on-demand :feature:ads module is installed
525-
// and the ad loads, so it never leaves an empty gap below the log. Suppressed on the GitHub
526-
// tab, whose panel manages its own full-height layout.
527-
if (selectedTab.type != TabType.GITHUB) {
528-
AdBannerSlot(modifier = Modifier.fillMaxWidth(), showTopDivider = true)
529-
}
525+
// and the ad loads, so it never leaves an empty gap below the log. Shown on every tab,
526+
// including GitHub, so the banner stays consistently anchored at the bottom.
527+
AdBannerSlot(modifier = Modifier.fillMaxWidth(), showTopDivider = true)
530528
}
531529
}
532530

0 commit comments

Comments
 (0)