Repository navigation
App open ads while deploying data. - #253
Conversation
Qodana for JVMIt seems all right 👌 No new problems were found according to the checks applied ☁️ View the detailed Qodana report Contact Qodana teamContact us at [email protected]
|
…mtransit-for-android into mm/app_open_ad_deploy_data
There was a problem hiding this comment.
Code Review
This pull request introduces App Open Ads and a data deployment mechanism during the splash screen, ensuring required agency data is initialized before proceeding to the main activity. Key changes include the addition of AppOpenAdManager, a database migration to track agency setup status, and a refactor of LiveData event observation using a new observeEvent extension. Feedback from the reviewer identifies a recurring typo in the google_ads_app_open_ad_unit_id resource name across multiple files and an incorrect method reference in a log message within the AppOpenAdFullScreenContentCallback class.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces App Open ads and a data deployment mechanism during the splash screen. Key changes include the implementation of AppOpenAdManager, the addition of a setup_required field to AgencyProperties, and updates to the SplashScreenActivity and ViewModel to coordinate data initialization with ad display. The codebase was also refactored to use a new observeEvent extension for LiveData. Review feedback focuses on ensuring thread safety by applying @mainthread annotations, correcting threading violations in the splash screen logic, and improving the transition logic to prevent UI flickering. Additionally, suggestions were made to rename methods for clarity and optimize variable initialization during the deployment process.
There was a problem hiding this comment.
Pull request overview
Adds app-open ad support during splash-screen data deployment, including setup-required tracking for agency modules and reusable event-observation helpers.
Changes:
- Adds app-open ad loading/showing infrastructure and integrates it into the splash flow.
- Tracks agency
setupRequiredstate in Room and queries providers during startup/deployment. - Refactors event observer call sites to use
observeEvent()helper extensions.
Reviewed changes
Copilot reviewed 38 out of 40 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
app-android/src/main/res/values/strings.xml |
Adds English splash deployment status strings. |
app-android/src/main/res/values-fr/strings.xml |
Adds French splash deployment status strings. |
app-android/src/main/res/values/keys.xml |
Adds release app-open ad unit key placeholder. |
app-android/src/debug/res/values/keys.xml |
Adds debug app-open test ad unit. |
app-android/src/main/java/org/mtransit/android/ui/view/common/Event.kt |
Adds observeEvent() LiveData helper overloads. |
app-android/src/main/java/org/mtransit/android/ui/splash/SplashScreenViewModel.kt |
Adds deployment polling, splash retention, and app-open ad trigger state. |
app-android/src/main/java/org/mtransit/android/ui/splash/SplashScreenActivity.kt |
Wires splash retention, deployment toasts, and app-open ad display. |
app-android/src/main/java/org/mtransit/android/ad/AdManager.kt |
Adds app-open ad manager delegation and banner-specific init. |
app-android/src/main/java/org/mtransit/android/ad/IAdManager.kt |
Extends ad manager API for app-open ads and cached ad state. |
app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt |
Refactors ad initialization callbacks and cached subscription handling. |
app-android/src/main/java/org/mtransit/android/ad/AdsConsentManager.kt |
Adds no-UI consent update mode for splash initialization. |
app-android/src/main/java/org/mtransit/android/ad/appopen/AppOpenAdManager.kt |
Introduces app-open ad load/show manager. |
app-android/src/main/java/org/mtransit/android/ad/appopen/AppOpenAdFullScreenContentCallback.kt |
Handles app-open full-screen ad lifecycle callbacks. |
app-android/src/main/java/org/mtransit/android/datasource/DataSourcesDatabase.kt |
Bumps database version and adds setup_required migration. |
app-android/schemas/org.mtransit.android.datasource.DataSourcesDatabase/7.json |
Adds Room schema for database version 7. |
app-android/src/main/java/org/mtransit/android/data/AgencyProperties.kt |
Adds setupRequired agency property. |
app-android/src/main/java/org/mtransit/android/data/DataSourceManager.java |
Adds provider query for agency setup-required state. |
app-android/src/main/java/org/mtransit/android/datasource/DataSourceRequestManager.kt |
Exposes ping and setup-required provider requests. |
app-android/src/main/java/org/mtransit/android/datasource/DataSourcesReader.kt |
Refreshes and persists setup-required state. |
app-android/src/main/java/org/mtransit/android/datasource/DataSourcesRepository.kt |
Exposes setup-required refresh through repository. |
app-android/src/main/java/org/mtransit/android/billing/IBillingManager.kt |
Adds cached subscription lookup API. |
app-android/src/main/java/org/mtransit/android/billing/MTBillingManager.kt |
Implements cached subscription lookup. |
app-android/src/main/java/org/mtransit/android/ui/MainActivity.kt |
Switches main ad init to banner-specific init. |
app-android/src/main/java/org/mtransit/android/ui/main/NextMainActivity.kt |
Switches next main ad init to banner-specific init. |
app-android/src/main/java/org/mtransit/android/ui/MTApplication.kt |
Qualifies main scope reference. |
app-android/src/main/java/org/mtransit/android/di/NetworkModule.kt |
Renames injected context parameter. |
app-android/src/main/java/org/mtransit/android/ui/home/HomeFragment.kt |
Refactors event observers to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/favorites/FavoritesFragment.kt |
Refactors event observers to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/news/NewsListDetailFragment.kt |
Refactors event observers to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/news/details/NewsDetailsFragment.kt |
Refactors event observers to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/pick/PickPOIDialogFragment.kt |
Refactors event observers to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/purchase/PurchaseActivity.kt |
Refactors event observer to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/rds/route/RDSRouteFragment.kt |
Refactors event observers to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/rds/route/direction/RDSDirectionStopsFragment.kt |
Refactors event observer to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/schedule/ScheduleFragment.kt |
Refactors event observer to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ui/type/rds/RDSAgencyRoutesFragment.kt |
Refactors event observer to observeEvent(). |
app-android/src/main/java/org/mtransit/android/ad/rewarded/RewardedAdManager.kt |
Formatting-only rewarded ad preference read cleanup. |
app-android/src/main/java/org/mtransit/android/ad/rewarded/RewardedUserManager.kt |
Formatting-only rewarded user preference read cleanup. |
Comments suppressed due to low confidence (2)
app-android/src/main/java/org/mtransit/android/ui/splash/SplashScreenViewModel.kt:143
loadAdTriggeredis set as soon as the load request is enqueued, but it is never reset if the app-open ad load fails. BecausetriggerLoadAd()returns early once this flag is true, a transient load failure means the splash deployment window will not retry even thoughAppOpenAdManagerclears its own loading state on failure.
app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt:131- When initialization is already in progress, this drops the new
onInitCompleteListenerinstead of running it after the existing initialization completes. With the splash screen now starting ad initialization,MainActivity.initForBanner()can hit this branch while MobileAds is still initializing and its banner refresh callback will never run.
if (initializing.getAndSet(true)) {
logAdsD(this, "initWithConsent() > SKIP (initializing: ${this.initializing.get()})")
return // SKIP
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 42 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt:131
- When an initialization is already in progress, this returns without retaining or invoking the new
onInitCompleteListener. With the splash screen now starting ad initialization beforeMainActivity/NextMainActivitycallinitForBanner(), the banner refresh callback can be dropped if those calls happen whileinitializingis true, leaving banners unrefreshed after initialization completes.
if (initializing.getAndSet(true)) {
logAdsD(this, "initWithConsent() > SKIP (initializing: ${this.initializing.get()})")
return // SKIP
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements "App Open" ads and a data deployment process during the splash screen. It introduces AppOpenAdManager, updates the database schema to include a setupRequired field for agencies, and refactors DataSourcesCache to DataSourcesStorage. The splash screen logic now manages ad display and pings agencies needing setup. Feedback identifies a threading issue in SplashScreenViewModel.deployIfNecessary where database I/O occurs on the main thread, a potential bug regarding the agency.isEnabled(pm) call, and an optimization to prevent redundant event posting in the checkState loop.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces App Open Ads integration and a data deployment mechanism during the splash screen. Key changes include the addition of AppOpenAdManager, updates to the database schema to version 7 with a new setup_required field for agencies, and logic in SplashScreenViewModel to manage ad loading and data synchronization. The AdsConsentManager and GlobalAdManager were also updated to support initialization with consent-only modes. Feedback focuses on correcting a latent logic bug in the splash screen visibility state, removing unused imports and variables, and adopting more idiomatic LiveData initialization. Additionally, it is suggested to implement ad pre-loading to improve availability.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 46 out of 48 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (3)
app-android/src/main/java/org/mtransit/android/ui/splash/SplashScreenViewModel.kt:203
- This early exit bypasses the
_deployingData.postValue(false.toEvent())cleanup at the end of the method. If the ad completes at this point, the progress toast is never canceled or transitioned to the done state before leaving the splash screen.
app-android/src/main/java/org/mtransit/android/ui/splash/SplashScreenViewModel.kt:207 - This early exit bypasses the
_deployingData.postValue(false.toEvent())cleanup at the end of the method. If the ad completes during the polling loop, the progress toast can remain active after navigation because the false event is never posted.
app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt:131 - When a second caller initializes ads while the first initialization is still running, its completion callback is dropped. In the new splash flow,
SplashScreenActivitystarts initialization andMainActivity/NextMainActivitycan callinitForBanner()before it finishes, so the banner refresh callback may never run after MobileAds finishes initializing; queue or invoke pending listeners when initialization completes.
if (initializing.getAndSet(true)) {
logAdsD(this, "initWithConsent() > SKIP (initializing: ${this.initializing.get()})")
return // SKIP
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 46 out of 48 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt:130
- When another screen calls
initForBanner()while the splash screen's ad initialization is still in progress, this method returns from theinitializingbranch without retaining or invoking that caller's completion listener. The banner refresh callback passed byinitForBanner()can therefore be dropped, leaving banners uninitialized until some later unrelated refresh. Queue the completion callbacks or invoke the new listener once the in-flight initialization completes.
onInitCompleteListener()
return // SKIP
}
if (initializing.getAndSet(true)) {
logAdsD(this, "initWithConsent() > SKIP (initializing: ${this.initializing.get()})")
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements Google AdMob App Open ads and introduces a data deployment phase during the splash screen. Key technical changes include a database migration to version 7 to track agency setup requirements, the introduction of AppOpenAdManager, and significant updates to the splash screen logic to handle concurrent data deployment and ad loading. Review feedback highlights a potential issue where paying users might be unnecessarily delayed by the deployment process, the need for a safer default for ad visibility when the billing cache is empty, and a request to optimize the splash screen timeout behavior if an ad fails to load.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces 'App Open' ads and a data deployment mechanism during the splash screen, supported by a database migration to track agency setup requirements. Ad initialization is refactored to improve consent handling and subscription checks. Feedback focuses on ensuring thread safety for ad objects, resolving race conditions during the splash screen's startup sequence, and correcting the logic for displaying data deployment status to the user.
…penAdManager.kt Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 46 out of 48 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
app-android/src/main/java/org/mtransit/android/ad/GlobalAdManager.kt:131
- When initialization is already in progress, this returns without preserving the caller's
onInitCompleteListener. Because the splash screen can start MobileAds initialization and then MainActivity/NextMainActivity can callinitForBanner()before it finishes, the banner refresh callback is dropped; the splash callback is the only one invoked when initialization completes, so the first main screen may never load its banner until another ad-refresh event occurs. Queue the listener or invoke banner refresh once the in-flight initialization completes.
if (initializing.getAndSet(true)) {
logAdsD(this, "initWithConsent() > SKIP (initializing: ${this.initializing.get()})")
return // SKIP
…mtransit-for-android into mm/app_open_ad_deploy_data
While agency local data is deployed (can take up to 10 seconds for biggest agency), try to load and show app open ads.
Related:
A/B testing:
Part of: