Skip to content

Core app review & feedback API (#3665)#5268

Open
shai-almog wants to merge 7 commits into
masterfrom
app-review-api
Open

Core app review & feedback API (#3665)#5268
shai-almog wants to merge 7 commits into
masterfrom
app-review-api

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Resolves #3665.

Adds a core app-review & feedback API (com.codename1.appreview) instead of a cn1lib. It uses the platform's native store-review prompt when available and falls back to a built-in Codename One widget everywhere else, while giving the app full control over when feedback is requested.

What's included

Public API — com.codename1.appreview

  • AppReview — singleton facade with two usage styles:
    • Manual: AppReview.getInstance().requestReview() — ask whenever it makes sense.
    • Scheduled: configure thresholds (minimumLaunches / minimumDaysInstalled / daysBetweenPrompts) and call registerSession() each launch; state is persisted in Preferences and the user is never re-prompted after rating or opting out.
  • Smart feedback split — the fallback widget routes high ratings (≥ highRatingThreshold) to the store and low ratings to a pluggable FeedbackListener (e-mail helper provided), so unhappy users reach you privately instead of leaving a 1-star public review.
  • RatingDialog — the built-in fallback widget (stars + feedback), package-private.

Native plumbing (mirrors share() / dial())

  • CodenameOneImplementation.isNativeInAppReviewSupported() / requestNativeInAppReview(SuccessCallback<Boolean>), exposed via Display and CN.
  • iOS: IOSNative.requestAppStoreReview()SKStoreReviewController.requestReview (iOS ≥ 10.3), guarded by a new CN1_USE_APPREVIEW macro (symbol always emitted so ParparVM links; StoreKit body compiled only when used).
  • Android: AppReviewSupport drives the Play In-App Review flow via reflection, so the port compiles without the extra dependency; isNativeInAppReviewSupported() returns false when the lib wasn't bundled.

Implicit dependency inclusion (no build hint)

The Android/iOS builders already scan the app's classes to auto-enable native deps. This PR extends that scan so referencing com.codename1.appreview (or the CN/Display review methods) automatically injects com.google.android.play:review on Android and links StoreKit.framework + flips CN1_USE_APPREVIEW on iOS. Apps that never ask for a review carry no extra weight.

Tests & docs

  • Unit tests: maven/core-unittests/.../appreview/AppReviewTest.java — 8 JUnit5 tests covering the scheduler decision logic (run: mvn -DunitTests -pl core-unittests test -Dtest=AppReviewTest, all green).
  • Developer guide: new docs/developer-guide/App-Review.asciidoc, registered in the master document.
  • Screenshot test: AppReviewDialogScreenshotTest in scripts/hellocodenameone, registered in Cn1ssDeviceRunner. It is a brand-new golden, so each platform's screenshot job reports it as missing_expected (non-gating) until the baselines are recorded via the usual flow.

Verified

  • Core + new package + unit tests compile and the 8 unit tests pass.
  • mvn compile of the maven-plugin module (both builders) → BUILD SUCCESS.
  • AppReviewSupport compiles against android.jar; the screenshot test compiles against core.

Note for maintainers

The same implicit-detection edits were applied to the out-of-repo cloud build server copies (~/dev/CodenameOne/BuildDaemon, -analytics, -winpkg) since those aren't part of this repo — they need to be deployed separately for the native dep to be injected on cloud builds.

🤖 Generated with Claude Code

Introduces com.codename1.appreview.AppReview: requests the platform's
native store-review prompt (SKStoreReviewController on iOS, Play In-App
Review on Android) when available and falls back to a Codename One drawn
rating widget elsewhere. Adds an opt-in engagement scheduler (launch /
days-installed / cool-down thresholds persisted via Preferences) plus a
manual requestReview() trigger, and a smart feedback split that routes
high ratings to the store and low ratings to a pluggable FeedbackListener
(e-mail helper provided).

Plumbing follows the existing share()/dial() pattern:
- CodenameOneImplementation.isNativeInAppReviewSupported() /
  requestNativeInAppReview(), exposed via Display and CN.
- iOS: IOSNative.requestAppStoreReview() bridges to SKStoreReviewController
  guarded by a new CN1_USE_APPREVIEW macro (symbol always emitted, StoreKit
  body compiled only when used).
- Android: AppReviewSupport drives the Play review flow via reflection so the
  port compiles without the extra dependency.

Native dependencies are added implicitly (no build hint): the Android/iOS
builders detect com.codename1.appreview usage during their class scan and
only then inject com.google.android.play:review / link StoreKit.framework.

Tests & docs:
- maven/core-unittests: AppReviewTest covers the scheduler decision logic.
- docs/developer-guide: new App-Review chapter.
- scripts/hellocodenameone: AppReviewDialogScreenshotTest for the widget.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Developer Guide build artifacts are available for download from this workflow run:

Developer Guide quality checks:

  • AsciiDoc linter: No issues found (report)
  • Vale: No alerts found (report)
  • Paragraph capitalization: No paragraph capitalization issues (report)
  • LanguageTool: No grammar matches (report)
  • Image references: No unused images detected (report)

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Android screenshot updates

Compared 130 screenshots: 129 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /home/runner/work/CodenameOne/CodenameOne/scripts/android/screenshots/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

Native Android coverage

  • 📊 Line coverage: 14.28% (8719/61050 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 11.56% (42916/371191), branch 5.11% (1783/34925), complexity 6.11% (2045/33465), method 10.58% (1654/15639), class 17.20% (380/2209)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend scalar fallback (no native SIMD)
SIMD int-add (64K x300) java 142ms / native 212ms = 0.6x speedup
SIMD float-mul (64K x300) java 150ms / native 169ms = 0.8x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 274.000 ms
Base64 CN1 decode 300.000 ms
Base64 native encode 1624.000 ms
Base64 encode ratio (CN1/native) 0.169x (83.1% faster)
Base64 native decode 782.000 ms
Base64 decode ratio (CN1/native) 0.384x (61.6% faster)
Image encode benchmark status skipped (SIMD unsupported)

@github-actions

Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Native Linux port (x64)

Compared 129 screenshots: 128 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /home/runner/work/CodenameOne/CodenameOne/scripts/linux/screenshots/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Native Linux port (arm64)

Compared 129 screenshots: 128 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /home/runner/work/CodenameOne/CodenameOne/scripts/linux/screenshots-arm/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Native Windows port (cross-compiled)

Compared 127 screenshots: 126 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /home/runner/work/CodenameOne/CodenameOne/scripts/windows/screenshots/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 70ms / native 4ms = 17.5x speedup
SIMD float-mul (64K x300) java 70ms / native 4ms = 17.5x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 288.000 ms
Base64 CN1 decode 173.000 ms
Base64 SIMD encode 134.000 ms
Base64 encode ratio (SIMD/CN1) 0.465x (53.5% faster)
Base64 SIMD decode 132.000 ms
Base64 decode ratio (SIMD/CN1) 0.763x (23.7% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 35.000 ms
Image createMask (SIMD on) 12.000 ms
Image createMask ratio (SIMD on/off) 0.343x (65.7% faster)
Image applyMask (SIMD off) 53.000 ms
Image applyMask (SIMD on) 28.000 ms
Image applyMask ratio (SIMD on/off) 0.528x (47.2% faster)
Image modifyAlpha (SIMD off) 60.000 ms
Image modifyAlpha (SIMD on) 25.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.417x (58.3% faster)
Image modifyAlpha removeColor (SIMD off) 65.000 ms
Image modifyAlpha removeColor (SIMD on) 22.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.338x (66.2% faster)

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

JavaScript port screenshot updates

Compared 123 screenshots: 122 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /home/runner/work/CodenameOne/CodenameOne/scripts/javascript/screenshots/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Mac native screenshot updates

Compared 130 screenshots: 129 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /Users/runner/work/CodenameOne/CodenameOne/scripts/mac-native/screenshots/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 151 seconds

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 54ms / native 9ms = 6.0x speedup
SIMD float-mul (64K x300) java 53ms / native 2ms = 26.5x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 276.000 ms
Base64 CN1 decode 214.000 ms
Base64 native encode 736.000 ms
Base64 encode ratio (CN1/native) 0.375x (62.5% faster)
Base64 native decode 447.000 ms
Base64 decode ratio (CN1/native) 0.479x (52.1% faster)
Base64 SIMD encode 54.000 ms
Base64 encode ratio (SIMD/CN1) 0.196x (80.4% faster)
Base64 SIMD decode 57.000 ms
Base64 decode ratio (SIMD/CN1) 0.266x (73.4% faster)
Base64 encode ratio (SIMD/native) 0.073x (92.7% faster)
Base64 decode ratio (SIMD/native) 0.128x (87.2% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 25.000 ms
Image createMask (SIMD on) 3.000 ms
Image createMask ratio (SIMD on/off) 0.120x (88.0% faster)
Image applyMask (SIMD off) 106.000 ms
Image applyMask (SIMD on) 133.000 ms
Image applyMask ratio (SIMD on/off) 1.255x (25.5% slower)
Image modifyAlpha (SIMD off) 112.000 ms
Image modifyAlpha (SIMD on) 122.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.089x (8.9% slower)
Image modifyAlpha removeColor (SIMD off) 93.000 ms
Image modifyAlpha removeColor (SIMD on) 56.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.602x (39.8% faster)

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 211 screenshots: 211 matched.
✅ Native Apple Watch (watchOS, Core Graphics) screenshot tests passed.

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

iOS screenshot updates

Compared 126 screenshots: 125 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /Users/runner/work/CodenameOne/CodenameOne/scripts/ios/screenshots/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 60; JPEG preview quality 60; downscaled to 825x1789.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 223 seconds

Build and Run Timing

Metric Duration
Simulator Boot 87000 ms
Simulator Boot (Run) 0 ms
App Install 12000 ms
App Launch 15000 ms
Test Execution 318000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 129ms / native 6ms = 21.5x speedup
SIMD float-mul (64K x300) java 133ms / native 3ms = 44.3x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 696.000 ms
Base64 CN1 decode 421.000 ms
Base64 native encode 1140.000 ms
Base64 encode ratio (CN1/native) 0.611x (38.9% faster)
Base64 native decode 569.000 ms
Base64 decode ratio (CN1/native) 0.740x (26.0% faster)
Base64 SIMD encode 74.000 ms
Base64 encode ratio (SIMD/CN1) 0.106x (89.4% faster)
Base64 SIMD decode 86.000 ms
Base64 decode ratio (SIMD/CN1) 0.204x (79.6% faster)
Base64 encode ratio (SIMD/native) 0.065x (93.5% faster)
Base64 decode ratio (SIMD/native) 0.151x (84.9% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 25.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.080x (92.0% faster)
Image applyMask (SIMD off) 118.000 ms
Image applyMask (SIMD on) 107.000 ms
Image applyMask ratio (SIMD on/off) 0.907x (9.3% faster)
Image modifyAlpha (SIMD off) 262.000 ms
Image modifyAlpha (SIMD on) 103.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.393x (60.7% faster)
Image modifyAlpha removeColor (SIMD off) 180.000 ms
Image modifyAlpha removeColor (SIMD on) 167.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.928x (7.2% faster)

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

iOS Metal screenshot updates

Compared 130 screenshots: 129 matched, 1 missing reference.

  • AppReviewDialog — missing reference. Reference screenshot missing at /Users/runner/work/CodenameOne/CodenameOne/scripts/ios/screenshots-metal/AppReviewDialog.png.

    AppReviewDialog
    Preview info: JPEG preview quality 60; JPEG preview quality 60; downscaled to 825x1789.
    Full-resolution PNG saved as AppReviewDialog.png in workflow artifacts.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 349 seconds

Build and Run Timing

Metric Duration
Simulator Boot 79000 ms
Simulator Boot (Run) 1000 ms
App Install 14000 ms
App Launch 10000 ms
Test Execution 250000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 64ms / native 4ms = 16.0x speedup
SIMD float-mul (64K x300) java 58ms / native 3ms = 19.3x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 442.000 ms
Base64 CN1 decode 209.000 ms
Base64 native encode 984.000 ms
Base64 encode ratio (CN1/native) 0.449x (55.1% faster)
Base64 native decode 346.000 ms
Base64 decode ratio (CN1/native) 0.604x (39.6% faster)
Base64 SIMD encode 55.000 ms
Base64 encode ratio (SIMD/CN1) 0.124x (87.6% faster)
Base64 SIMD decode 48.000 ms
Base64 decode ratio (SIMD/CN1) 0.230x (77.0% faster)
Base64 encode ratio (SIMD/native) 0.056x (94.4% faster)
Base64 decode ratio (SIMD/native) 0.139x (86.1% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 17.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.118x (88.2% faster)
Image applyMask (SIMD off) 56.000 ms
Image applyMask (SIMD on) 36.000 ms
Image applyMask ratio (SIMD on/off) 0.643x (35.7% faster)
Image modifyAlpha (SIMD off) 60.000 ms
Image modifyAlpha (SIMD on) 37.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.617x (38.3% faster)
Image modifyAlpha removeColor (SIMD off) 87.000 ms
Image modifyAlpha removeColor (SIMD on) 172.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.977x (97.7% slower)

shai-almog and others added 2 commits June 21, 2026 17:33
- RatingDialog now presents as a bottom Sheet (swipe to dismiss) instead of
  a blocking modal Dialog, addressing the "too intrusive" feedback.
- Stars use a single-row GridLayout so they no longer wrap on narrow
  displays (the Android screenshot showed the flow-layout wrap).
- Fix SpotBugs LI_LAZY_INIT_STATIC by eager-initializing the AppReview
  singleton.
- Rewrite the developer-guide chapter to satisfy the Vale prose gate
  (contractions, adverbs, quote punctuation) and describe the Sheet UI.
- Screenshot test mirrors the single-row star grid.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Make RatingDialog final (ClassWithOnlyPrivateConstructorsShouldBeFinal).
- Simplify shouldPrompt() boolean return (SimplifyBooleanReturns).
- Add @OverRide to anonymous Runnable/SuccessCallback/ActionListener
  implementations (MissingOverride).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

shai-almog and others added 4 commits June 21, 2026 18:21
Seeds scripts/ios/screenshots-watch/AppReviewDialog.png from the watch
suite's streamed render of the rating sheet. The watch runner gates on
missing_expected (CN1SS_ALLOWED_MISSING=0); the other platforms treat a
new golden as non-gating, and build-ios-metal is intentionally left
without a baseline since that job is flaky.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The test previously rendered an inline Dialog-styled container; it now
builds the same content as RatingDialog and calls Sheet.show() (following
the SheetScreenshotTest pattern) so the capture shows the actual sheet
chrome. The native store review widgets are OS-drawn, throttled overlays
outside Display.screenshot(), so they can't be captured by the harness;
this covers the Codename One fallback sheet that renders elsewhere.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The committed watch golden was the old inline-Dialog render; the test now
shows the real Sheet, so the golden must be regenerated. Removing it both
avoids a false "different" and (being a screenshots-watch change) re-runs
the full screenshot suite against the new test so the fresh render can be
captured.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Regenerate scripts/ios/screenshots-watch/AppReviewDialog.png from the
  real-Sheet render of the updated test.
- Developer guide: embed the fallback rating Sheet screenshot (a cropped
  desktop render showing the bottom sheet with the single-row star strip)
  and describe the native iOS/Android prompts in prose, since those OS-drawn
  widgets are outside Display.screenshot() and can't be captured.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide app review Library (cn1lib)

1 participant