Skip to content

ProviderContract.Filter > shared filter params#164

Merged
mmathieum merged 12 commits into
masterfrom
mm/shared_filter_params
Jun 26, 2026
Merged

ProviderContract.Filter > shared filter params#164
mmathieum merged 12 commits into
masterfrom
mm/shared_filter_params

Conversation

@mmathieum

@mmathieum mmathieum commented Jun 25, 2026

Copy link
Copy Markdown
Member

@mmathieum

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Filter classes across multiple provider contracts (News, POI, Service Update, Status, and Vehicle Location) to inherit from a new common base class ProviderContract.Filter, reducing code duplication for shared properties like cache settings and encryption keys. The review feedback highlights three critical issues: a logic bug in NewsProviderContract.java where getNewTargetUUIDsFilter incorrectly returns an article UUID filter, and two compilation errors in VehicleLocationProviderContract.kt where the static Java superclass methods fromJSON and toJSON are called without proper qualification.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@mmathieum

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors several provider contract Filter classes to inherit from a new common base class, ProviderContract.Filter, consolidating shared properties (like cacheOnly, cacheValidityInMs, and inFocus) and their JSON serialization logic. The review feedback suggests refactoring the setter methods in the new base class to return the Filter instance to support fluent API chaining and preserve backward compatibility. Additionally, it is recommended to prevent null values in setProvidedKeys and to fully qualify the fromJSON and toJSON calls in VehicleLocationProviderContract to avoid resolution ambiguity.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main/java/org/mtransit/android/commons/provider/common/ProviderContract.java Outdated
Comment thread src/main/java/org/mtransit/android/commons/provider/common/ProviderContract.java Outdated
Comment thread src/main/java/org/mtransit/android/commons/provider/common/ProviderContract.java Outdated
Comment thread src/main/java/org/mtransit/android/commons/provider/common/ProviderContract.java Outdated
Comment thread src/main/java/org/mtransit/android/commons/provider/common/ProviderContract.java Outdated
@mmathieum mmathieum marked this pull request as ready for review June 25, 2026 14:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors various Filter classes across provider contracts to inherit from a new common base class, ProviderContract.Filter, centralizing shared properties like cache settings and encryption keys to reduce code duplication. The review feedback highlights formatting issues in the toString() implementations of StatusProviderContract and ServiceUpdateProviderContract where missing separators can lead to poorly formatted string outputs. Additionally, the reviewer recommends adding braces to single-line if statements in POIProviderContract to comply with standard Java style guidelines.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main/java/org/mtransit/android/commons/provider/poi/POIProviderContract.java Outdated
@mmathieum mmathieum added the L ◼️◻️Large size label Jun 26, 2026
@mmathieum

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors several core provider contracts and status filters from Java to Kotlin, extracting nested filter classes (such as ScheduleStatusFilter, AvailabilityPercentStatusFilter, and AppStatusFilter) into standalone Kotlin files and updating references across various transit providers. The review feedback highlights a few critical issues in the new Kotlin code: a bug in JSONExt.kt where optional getters do not safely handle JSON nulls, a string template syntax error in POIProviderContract.kt, an incorrect annotation message in NewsProviderContract.kt, and multiple instances in StatusProviderContract.kt where using this inside a companion object for logging results in an unhelpful log tag.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main/java/org/mtransit/android/commons/JSONExt.kt Outdated
Comment thread src/main/java/org/mtransit/android/commons/provider/poi/POIProviderContract.kt Outdated
Comment thread src/main/java/org/mtransit/android/commons/provider/news/NewsProviderContract.kt Outdated
@mmathieum

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates several status, news, POI, and service update provider contracts and filters from Java to Kotlin, updating their references across various transit providers. The review feedback highlights a bug in POIProviderContract.kt where searchKeyword.isEmpty() is incorrectly checked instead of keyword.isEmpty(), alongside suggestions to simplify the search selection logic using Kotlin idioms. Additionally, feedback recommends using optJSONArray for parsing extras to prevent potential JSONExceptions, and falling back to poi.authority in ServiceUpdateProviderContract.kt if the authority key is missing.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main/java/org/mtransit/android/commons/provider/poi/POIProviderContract.kt Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors provider contracts to share common filter parameters via ProviderContract.Filter, migrates several provider contracts from Java to Kotlin, and updates providers/call-sites to use the new Kotlin-first APIs (properties, @JvmStatic accessors, and new filter types).

Changes:

  • Introduces ProviderContract.kt with a shared Filter base class and JSON (de)serialization helpers for shared filter params.
  • Migrates provider contracts (News, POI, ServiceUpdate, Status) from Java to Kotlin and updates Java/Kotlin providers to use the new access patterns.
  • Extracts status filter types (e.g., ScheduleStatusFilter, AvailabilityPercentStatusFilter, AppStatusFilter) into dedicated Kotlin classes and updates usages/casts across providers.

Reviewed changes

Copilot reviewed 51 out of 51 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/java/org/mtransit/android/commons/provider/YouTubeNewsProvider.kt Adapts to Kotlin ProviderContract/NewsProviderContract property-based API.
src/main/java/org/mtransit/android/commons/provider/WinnipegTransitProvider.java Updates status filter cast + uses Kotlin static accessors for constants/projections.
src/main/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProviderContract.kt Moves shared filter params into ProviderContract.Filter + JSON handling updates.
src/main/java/org/mtransit/android/commons/provider/vehiclelocations/VehicleLocationProvider.kt Switches to property-based contract access (URI_MATCHER, writeDB, filter flags).
src/main/java/org/mtransit/android/commons/provider/vehiclelocations/NextBusVehicleLocationsProvider.kt Uses shared inFocus default + new rds accessor.
src/main/java/org/mtransit/android/commons/provider/vehiclelocations/GTFSRealTimeVehiclePositionsProvider.kt Uses shared inFocus default flag accessor.
src/main/java/org/mtransit/android/commons/provider/TwitterNewsProvider.kt Adapts to Kotlin contract properties + shared constants access.
src/main/java/org/mtransit/android/commons/provider/StmInfoApiProvider.java Updates status filter type to extracted ScheduleStatusFilter + signature tweaks.
src/main/java/org/mtransit/android/commons/provider/status/StatusProviderContract.kt Kotlin replacement contract for status providers + shared filter base integration.
src/main/java/org/mtransit/android/commons/provider/status/StatusProviderContract.java Removed Java contract in favor of Kotlin version.
src/main/java/org/mtransit/android/commons/provider/status/StatusProvider.java Updates to new filter types + Kotlin static projection accessor.
src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProvider.kt Updates casts/params to ScheduleStatusFilter.
src/main/java/org/mtransit/android/commons/provider/serviceupdate/ServiceUpdateProviderExt.kt Uses readDB property access in query helper.
src/main/java/org/mtransit/android/commons/provider/serviceupdate/ServiceUpdateProviderContract.kt Kotlin replacement contract for service updates + shared filter base integration.
src/main/java/org/mtransit/android/commons/provider/serviceupdate/ServiceUpdateProviderContract.java Removed Java contract in favor of Kotlin version.
src/main/java/org/mtransit/android/commons/provider/serviceupdate/ServiceUpdateProvider.java Updates cache validity getter + Kotlin static projection accessor.
src/main/java/org/mtransit/android/commons/provider/RTCQuebecProvider.java Updates status filter type + service update deletion signature.
src/main/java/org/mtransit/android/commons/provider/RSSNewsProvider.java Uses Kotlin static accessor for max cache validity constant.
src/main/java/org/mtransit/android/commons/provider/ReginaTransitProvider.java Updates status filter type to extracted ScheduleStatusFilter.
src/main/java/org/mtransit/android/commons/provider/poi/POIProviderContract.kt Kotlin replacement POI contract + shared filter base integration.
src/main/java/org/mtransit/android/commons/provider/poi/POIProviderContract.java Removed Java contract in favor of Kotlin version.
src/main/java/org/mtransit/android/commons/provider/poi/POIProvider.java Updates to Kotlin contract naming/accessors + exposes PROJECTION_POI_ALL_COLUMNS.
src/main/java/org/mtransit/android/commons/provider/OneBusAwayProvider.java Updates status filter type to extracted ScheduleStatusFilter.
src/main/java/org/mtransit/android/commons/provider/NextBusProvider.java Updates status filter type + service update deletion signature; formatting cleanup.
src/main/java/org/mtransit/android/commons/provider/news/NewsProviderContract.kt Kotlin replacement news contract + shared filter base integration.
src/main/java/org/mtransit/android/commons/provider/news/NewsProviderContract.java Removed Java contract in favor of Kotlin version.
src/main/java/org/mtransit/android/commons/provider/news/NewsProvider.java Updates filter API usage + Kotlin static projection accessor + nullability tweaks.
src/main/java/org/mtransit/android/commons/provider/InstagramNewsProvider.kt Adapts to Kotlin ProviderContract/NewsProviderContract property-based API.
src/main/java/org/mtransit/android/commons/provider/GTFSRealTimeProvider.java Updates service update deletion signature.
src/main/java/org/mtransit/android/commons/provider/GTFSProviderContract.java Uses POIProviderContract projection instead of POIProvider constant.
src/main/java/org/mtransit/android/commons/provider/GTFSProvider.java Updates POI contract method names (getPoi*) and projection map accessors.
src/main/java/org/mtransit/android/commons/provider/gtfs/GTFSStringsUtils.kt Adds suppression for constant boolean simplification.
src/main/java/org/mtransit/android/commons/provider/gtfs/GtfsStatusProviderExt.kt Builds selection using new ScheduleStatusFilter JSON helpers.
src/main/java/org/mtransit/android/commons/provider/gtfs/GTFSStatusProvider.java Updates status filter type to extracted ScheduleStatusFilter.
src/main/java/org/mtransit/android/commons/provider/gtfs/GTFSPOIProvider.java Updates POI projection map/projection accessor method names + max validity accessor.
src/main/java/org/mtransit/android/commons/provider/GBFSProvider.java Updates availability-percent status filter type + POI validity method names.
src/main/java/org/mtransit/android/commons/provider/common/ProviderContract.kt Kotlin replacement base provider contract + shared Filter/JSON helpers.
src/main/java/org/mtransit/android/commons/provider/common/ProviderContract.java Removed Java base contract in favor of Kotlin version.
src/main/java/org/mtransit/android/commons/provider/common/ContentProviderConstants.java Adds Kotlin Regex constant for shared splitting behavior in Kotlin call sites.
src/main/java/org/mtransit/android/commons/provider/CleverDevicesProvider.java Updates status filter type to extracted ScheduleStatusFilter.
src/main/java/org/mtransit/android/commons/provider/bike/BikeStationProvider.java Updates availability-percent status filter type + POI validity/projection accessor method names.
src/main/java/org/mtransit/android/commons/provider/agency/AgencyProviderContract.java Re-exports PING_PATH from ProviderContract.
src/main/java/org/mtransit/android/commons/JSONExt.kt Adds Kotlin JSONObject.opt* helpers with nullable fallbacks.
src/main/java/org/mtransit/android/commons/data/ServiceUpdateKtx.kt Updates to use property accessors for service-update contract fields.
src/main/java/org/mtransit/android/commons/data/ScheduleStatusFilter.kt New extracted schedule status filter with JSON (de)serialization.
src/main/java/org/mtransit/android/commons/data/Schedule.java Removes nested ScheduleStatusFilter in favor of extracted Kotlin class.
src/main/java/org/mtransit/android/commons/data/POIStatus.java Uses Kotlin static accessor for status projection.
src/main/java/org/mtransit/android/commons/data/AvailabilityPercentStatusFilter.kt New extracted availability-percent status filter with JSON (de)serialization.
src/main/java/org/mtransit/android/commons/data/AvailabilityPercent.java Removes nested AvailabilityPercentStatusFilter in favor of extracted Kotlin class.
src/main/java/org/mtransit/android/commons/data/AppStatusFilter.kt New extracted app status filter with JSON (de)serialization.
src/main/java/org/mtransit/android/commons/data/AppStatus.java Removes nested AppStatusFilter in favor of extracted Kotlin class.

Comment thread src/main/java/org/mtransit/android/commons/provider/poi/POIProviderContract.kt Outdated
@mmathieum

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates several core provider contracts and filter classes (including ProviderContract, NewsProviderContract, POIProviderContract, ServiceUpdateProviderContract, and StatusProviderContract) from Java to Kotlin, updating referencing providers to use Kotlin properties. The review feedback identifies critical compilation errors across the migrated files due to incorrect usage of the @Discouraged annotation, which requires explicitly naming the message parameter, and a missing import in VehicleLocationProviderContract.kt.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@mmathieum mmathieum merged commit 1f6489b into master Jun 26, 2026
4 checks passed
@mmathieum mmathieum deleted the mm/shared_filter_params branch June 26, 2026 18:52
montransit added a commit to mtransitapps/mtransit-for-android that referenced this pull request Jun 26, 2026
- commons-android: `ProviderContract.Filter` > shared filter params mtransitapps/commons-android#164
- commons-java: `ProviderContract.Filter` > shared filter params mtransitapps/commons-java#42
montransit added a commit to mtransitapps/ca-st-hyacinthe-transport-collectif-bus-android that referenced this pull request Jun 27, 2026
- commons-android: `ProviderContract.Filter` > shared filter params mtransitapps/commons-android#164
- commons-java: `ProviderContract.Filter` > shared filter params mtransitapps/commons-java#42
montransit added a commit to mtransitapps/ca-mrc-nicolet-yamaska-bili-bus-android that referenced this pull request Jun 27, 2026
- commons-android: `ProviderContract.Filter` > shared filter params mtransitapps/commons-android#164
- commons-java: `ProviderContract.Filter` > shared filter params mtransitapps/commons-java#42
montransit added a commit to mtransitapps/ca-ottawa-oc-transpo-bus-android that referenced this pull request Jun 28, 2026
- commons-android: `ProviderContract.Filter` > shared filter params mtransitapps/commons-android#164
- commons-java: `ProviderContract.Filter` > shared filter params mtransitapps/commons-java#42
montransit added a commit to mtransitapps/ca-ottawa-oc-transpo-train-android that referenced this pull request Jun 28, 2026
- commons-android: `ProviderContract.Filter` > shared filter params mtransitapps/commons-android#164
- commons-java: `ProviderContract.Filter` > shared filter params mtransitapps/commons-java#42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L ◼️◻️Large size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants