Skip to content

Commit 13bbef4

Browse files
Fix: Remove top banner by using a Scaffold with an empty topBar
1 parent efd8d7e commit 13bbef4

File tree

1 file changed

+87
-54
lines changed

1 file changed

+87
-54
lines changed

app/src/main/kotlin/com/google/ai/sample/MainActivity.kt

Lines changed: 87 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import androidx.compose.material3.Button
5050
import androidx.compose.material3.Card
5151
import androidx.compose.material3.CircularProgressIndicator
5252
import androidx.compose.material3.MaterialTheme
53+
import androidx.compose.material3.Scaffold
5354
import androidx.compose.material3.Surface
5455
import androidx.compose.material3.Text
5556
import androidx.compose.material3.TextButton
@@ -511,61 +512,93 @@ class MainActivity : ComponentActivity() {
511512
Log.d(TAG, "setContent: Composable content rendering. Current trial state: $currentTrialState")
512513
navController = rememberNavController()
513514
GenerativeAISample {
514-
Surface(
515-
modifier = Modifier.fillMaxSize(),
516-
color = MaterialTheme.colorScheme.background
517-
) {
518-
Log.d(TAG, "setContent: Rendering AppNavigation.")
519-
AppNavigation(navController)
520-
521-
// if (showPermissionRationaleDialog) { ... } // Deleted block
522-
if (showFirstLaunchInfoDialog) {
523-
Log.d(TAG, "setContent: Rendering FirstLaunchInfoDialog.")
524-
FirstLaunchInfoDialog(
525-
onDismiss = {
526-
showFirstLaunchInfoDialog = false
527-
prefs.edit().putBoolean(PREF_KEY_FIRST_LAUNCH_INFO_SHOWN, true).apply()
528-
Log.d(TAG, "FirstLaunchInfoDialog dismissed and preference set.")
529-
}
530-
)
531-
} else if (showApiKeyDialog && currentTrialState != TrialManager.TrialState.EXPIRED_INTERNET_TIME_CONFIRMED) {
532-
Log.d(TAG, "setContent: Rendering ApiKeyDialog. showApiKeyDialog=$showApiKeyDialog, currentTrialState=$currentTrialState")
533-
ApiKeyDialog(
534-
apiKeyManager = apiKeyManager,
535-
isFirstLaunch = apiKeyManager.getApiKeys().isEmpty(),
536-
onDismiss = {
537-
Log.d(TAG, "ApiKeyDialog onDismiss called.")
538-
showApiKeyDialog = false
539-
}
540-
)
541-
} else {
542-
Log.d(TAG, "setContent: Handling Trial State Dialogs. Current state: $currentTrialState, showTrialInfoDialog: $showTrialInfoDialog")
543-
when (currentTrialState) {
544-
TrialManager.TrialState.EXPIRED_INTERNET_TIME_CONFIRMED -> {
545-
Log.d(TAG, "setContent: Rendering TrialExpiredDialog.")
546-
TrialExpiredDialog(
547-
onPurchaseClick = {
548-
Log.d(TAG, "TrialExpiredDialog onPurchaseClick called.")
549-
initiateDonationPurchase()
550-
},
551-
onDismiss = { Log.d(TAG, "TrialExpiredDialog onDismiss called (should be persistent).") }
552-
)
553-
}
554-
TrialManager.TrialState.NOT_YET_STARTED_AWAITING_INTERNET,
555-
TrialManager.TrialState.INTERNET_UNAVAILABLE_CANNOT_VERIFY -> {
556-
if (showTrialInfoDialog) {
557-
Log.d(TAG, "setContent: Rendering InfoDialog for AWAITING/UNAVAILABLE. Message: $trialInfoMessage")
558-
InfoDialog(message = trialInfoMessage, onDismiss = {
559-
Log.d(TAG, "InfoDialog onDismiss called.")
560-
showTrialInfoDialog = false
561-
})
562-
} else {
563-
Log.d(TAG, "setContent: Not rendering InfoDialog for AWAITING/UNAVAILABLE because showTrialInfoDialog is false.")
515+
Scaffold(
516+
topBar = { }
517+
) { innerPadding ->
518+
Surface(
519+
modifier = Modifier
520+
.fillMaxSize()
521+
.padding(innerPadding),
522+
color = MaterialTheme.colorScheme.background
523+
) {
524+
Log.d(TAG, "setContent: Rendering AppNavigation.")
525+
AppNavigation(navController)
526+
527+
// if (showPermissionRationaleDialog) { ... } // Deleted block
528+
if (showFirstLaunchInfoDialog) {
529+
Log.d(TAG, "setContent: Rendering FirstLaunchInfoDialog.")
530+
FirstLaunchInfoDialog(
531+
onDismiss = {
532+
showFirstLaunchInfoDialog = false
533+
prefs.edit()
534+
.putBoolean(PREF_KEY_FIRST_LAUNCH_INFO_SHOWN, true).apply()
535+
Log.d(
536+
TAG,
537+
"FirstLaunchInfoDialog dismissed and preference set."
538+
)
539+
}
540+
)
541+
} else if (showApiKeyDialog && currentTrialState != TrialManager.TrialState.EXPIRED_INTERNET_TIME_CONFIRMED) {
542+
Log.d(
543+
TAG,
544+
"setContent: Rendering ApiKeyDialog. showApiKeyDialog=$showApiKeyDialog, currentTrialState=$currentTrialState"
545+
)
546+
ApiKeyDialog(
547+
apiKeyManager = apiKeyManager,
548+
isFirstLaunch = apiKeyManager.getApiKeys().isEmpty(),
549+
onDismiss = {
550+
Log.d(TAG, "ApiKeyDialog onDismiss called.")
551+
showApiKeyDialog = false
552+
}
553+
)
554+
} else {
555+
Log.d(
556+
TAG,
557+
"setContent: Handling Trial State Dialogs. Current state: $currentTrialState, showTrialInfoDialog: $showTrialInfoDialog"
558+
)
559+
when (currentTrialState) {
560+
TrialManager.TrialState.EXPIRED_INTERNET_TIME_CONFIRMED -> {
561+
Log.d(TAG, "setContent: Rendering TrialExpiredDialog.")
562+
TrialExpiredDialog(
563+
onPurchaseClick = {
564+
Log.d(TAG, "TrialExpiredDialog onPurchaseClick called.")
565+
initiateDonationPurchase()
566+
},
567+
onDismiss = {
568+
Log.d(
569+
TAG,
570+
"TrialExpiredDialog onDismiss called (should be persistent)."
571+
)
572+
}
573+
)
574+
}
575+
576+
TrialManager.TrialState.NOT_YET_STARTED_AWAITING_INTERNET,
577+
TrialManager.TrialState.INTERNET_UNAVAILABLE_CANNOT_VERIFY -> {
578+
if (showTrialInfoDialog) {
579+
Log.d(
580+
TAG,
581+
"setContent: Rendering InfoDialog for AWAITING/UNAVAILABLE. Message: $trialInfoMessage"
582+
)
583+
InfoDialog(message = trialInfoMessage, onDismiss = {
584+
Log.d(TAG, "InfoDialog onDismiss called.")
585+
showTrialInfoDialog = false
586+
})
587+
} else {
588+
Log.d(
589+
TAG,
590+
"setContent: Not rendering InfoDialog for AWAITING/UNAVAILABLE because showTrialInfoDialog is false."
591+
)
592+
}
593+
}
594+
595+
TrialManager.TrialState.ACTIVE_INTERNET_TIME_CONFIRMED,
596+
TrialManager.TrialState.PURCHASED -> {
597+
Log.d(
598+
TAG,
599+
"setContent: No specific dialog for ACTIVE/PURCHASED states."
600+
)
564601
}
565-
}
566-
TrialManager.TrialState.ACTIVE_INTERNET_TIME_CONFIRMED,
567-
TrialManager.TrialState.PURCHASED -> {
568-
Log.d(TAG, "setContent: No specific dialog for ACTIVE/PURCHASED states.")
569602
}
570603
}
571604
}

0 commit comments

Comments
 (0)