Skip to content

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

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

Core app review & feedback API (#3665)#5268
shai-almog wants to merge 9 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 136 screenshots: 135 matched, 1 updated.

  • AppReviewDialog — updated screenshot. Screenshot differs (320x640 px, bit depth 8).

    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.43% (8832/61196 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 11.71% (43549/371875), branch 5.16% (1803/34959), complexity 6.18% (2072/33504), method 10.70% (1676/15661), class 17.49% (388/2218)
    • 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 192ms / native 102ms = 1.8x speedup
SIMD float-mul (64K x300) java 182ms / native 111ms = 1.6x 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 314.000 ms
Base64 CN1 decode 294.000 ms
Base64 native encode 871.000 ms
Base64 encode ratio (CN1/native) 0.361x (63.9% faster)
Base64 native decode 1559.000 ms
Base64 decode ratio (CN1/native) 0.189x (81.1% 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

Compared 134 screenshots: 134 matched.
Native Linux port (x64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub x64 runner. Baseline: scripts/linux/screenshots.

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 134 screenshots: 134 matched.
Native Linux port (arm64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub arm64 runner. Baseline: scripts/linux/screenshots-arm.

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 132 screenshots: 132 matched.
Native Windows port, REAL shipping pipeline: the hellocodenameone screenshot suite rendered by a binary CROSS-COMPILED on Linux (clang-cl + xwin, WebView2 linked) and RUN on a Windows x64 runner. Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 65ms / native 4ms = 16.2x speedup
SIMD float-mul (64K x300) java 66ms / native 3ms = 22.0x 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 342.000 ms
Base64 CN1 decode 229.000 ms
Base64 SIMD encode 197.000 ms
Base64 encode ratio (SIMD/CN1) 0.576x (42.4% faster)
Base64 SIMD decode 140.000 ms
Base64 decode ratio (SIMD/CN1) 0.611x (38.9% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 54.000 ms
Image createMask (SIMD on) 40.000 ms
Image createMask ratio (SIMD on/off) 0.741x (25.9% faster)
Image applyMask (SIMD off) 56.000 ms
Image applyMask (SIMDcaptureWindowToPngBytes window target is not WIC-backed

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

JavaScript port screenshot updates

Compared 128 screenshots: 127 matched, 1 updated.

  • AppReviewDialog — updated screenshot. Screenshot differs (375x667 px, bit depth 8).

    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

Compared 134 screenshots: 134 matched.
✅ Native Mac screenshot tests passed.

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 53ms / native 3ms = 17.6x speedup
SIMD float-mul (64K x300) java 53ms / native 3ms = 17.6x 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 282.000 ms
Base64 CN1 decode 208.000 ms
Base64 native encode 954.000 ms
Base64 encode ratio (CN1/native) 0.296x (70.4% faster)
Base64 native decode 632.000 ms
Base64 decode ratio (CN1/native) 0.329x (67.1% faster)
Base64 SIMD encode 58.000 ms
Base64 encode ratio (SIMD/CN1) 0.206x (79.4% faster)
Base64 SIMD decode 47.000 ms
Base64 decode ratio (SIMD/CN1) 0.226x (77.4% faster)
Base64 encode ratio (SIMD/native) 0.061x (93.9% faster)
Base64 decode ratio (SIMD/native) 0.074x (92.6% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 23.000 ms
Image createMask (SIMD on) 14.000 ms
Image createMask ratio (SIMD on/off) 0.609x (39.1% faster)
Image applyMask (SIMD off) 184.000 ms
Image applyMask (SIMD on) 165.000 ms
Image applyMask ratio (SIMD on/off) 0.897x (10.3% faster)
Image modifyAlpha (SIMD off) 200.000 ms
Image modifyAlpha (SIMD on) 150.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.750x (25.0% faster)
Image modifyAlpha removeColor (SIMD off) 166.000 ms
Image modifyAlpha removeColor (SIMD on) 168.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.012x (1.2% slower)

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

Apple Watch (watchOS / Core Graphics)

Compared 211 screenshots: 210 matched, 1 updated.

  • AppReviewDialog — updated screenshot. Screenshot differs (416x496 px, bit depth 8).

    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

iOS screenshot updates

Compared 131 screenshots: 129 matched, 2 updated.

  • AppReviewDialog — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

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

  • landscape — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 73000 ms
Simulator Boot (Run) 2000 ms
App Install 19000 ms
App Launch 1000 ms
Test Execution 462000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 54ms / native 4ms = 13.5x speedup
SIMD float-mul (64K x300) java 54ms / native 2ms = 27.0x 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 548.000 ms
Base64 CN1 decode 229.000 ms
Base64 native encode 741.000 ms
Base64 encode ratio (CN1/native) 0.740x (26.0% faster)
Base64 native decode 750.000 ms
Base64 decode ratio (CN1/native) 0.305x (69.5% faster)
Base64 SIMD encode 63.000 ms
Base64 encode ratio (SIMD/CN1) 0.115x (88.5% faster)
Base64 SIMD decode 84.000 ms
Base64 decode ratio (SIMD/CN1) 0.367x (63.3% faster)
Base64 encode ratio (SIMD/native) 0.085x (91.5% faster)
Base64 decode ratio (SIMD/native) 0.112x (88.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 43.000 ms
Image createMask (SIMD on) 45.000 ms
Image createMask ratio (SIMD on/off) 1.047x (4.7% slower)
Image applyMask (SIMD off) 359.000 ms
Image applyMask (SIMD on) 126.000 ms
Image applyMask ratio (SIMD on/off) 0.351x (64.9% faster)
Image modifyAlpha (SIMD off) 89.000 ms
Image modifyAlpha (SIMD on) 151.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.697x (69.7% slower)
Image modifyAlpha removeColor (SIMD off) 153.000 ms
Image modifyAlpha removeColor (SIMD on) 85.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.556x (44.4% faster)

@shai-almog

shai-almog commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator Author

iOS Metal screenshot updates

Compared 135 screenshots: 134 matched, 1 updated.

  • AppReviewDialog — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

    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: 221 seconds

Build and Run Timing

Metric Duration
Simulator Boot 66000 ms
Simulator Boot (Run) 0 ms
App Install 12000 ms
App Launch 4000 ms
Test Execution 285000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 57ms / native 3ms = 19.0x speedup
SIMD float-mul (64K x300) java 74ms / native 3ms = 24.6x 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 413.000 ms
Base64 CN1 decode 579.000 ms
Base64 native encode 586.000 ms
Base64 encode ratio (CN1/native) 0.705x (29.5% faster)
Base64 native decode 1210.000 ms
Base64 decode ratio (CN1/native) 0.479x (52.1% faster)
Base64 SIMD encode 102.000 ms
Base64 encode ratio (SIMD/CN1) 0.247x (75.3% faster)
Base64 SIMD decode 109.000 ms
Base64 decode ratio (SIMD/CN1) 0.188x (81.2% faster)
Base64 encode ratio (SIMD/native) 0.174x (82.6% faster)
Base64 decode ratio (SIMD/native) 0.090x (91.0% 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) 65.000 ms
Image applyMask (SIMD on) 37.000 ms
Image applyMask ratio (SIMD on/off) 0.569x (43.1% faster)
Image modifyAlpha (SIMD off) 70.000 ms
Image modifyAlpha (SIMD on) 47.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.671x (32.9% faster)
Image modifyAlpha removeColor (SIMD off) 67.000 ms
Image modifyAlpha removeColor (SIMD on) 63.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.940x (6.0% faster)

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 6 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>
Captures the real fallback-Sheet render from each platform's screenshot
run (Android, iOS, iOS-metal, JavaScript, Linux x64, Linux arm64,
mac-native, Windows; watch already committed) so the screenshot bot no
longer reports the test as a new/missing golden on every pipeline. Each
golden is the platform's own render so the comparison is exact.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the GridLayout star strip (which spread the five stars across the
full width) with a horizontal BoxLayout so they sit together at the
leading edge -- left-aligned, or right-aligned under RTL -- on a single
row without wrapping. Mirrored in the screenshot test; goldens to follow.

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