Skip to content

Standardize native-theme build hints; fix simulator menu bugs#4855

Merged
shai-almog merged 1 commit intomasterfrom
fix-native-theme-build-hints
May 3, 2026
Merged

Standardize native-theme build hints; fix simulator menu bugs#4855
shai-almog merged 1 commit intomasterfrom
fix-native-theme-build-hints

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Build-hint rename (with back-compat). nativeTheme (global), ios.themeMode / and.themeMode (platform-specific). The previous cn1.nativeTheme / cn1.androidTheme keys stay accepted everywhere as deprecated aliases - simulator schema, runtime ports (Android, HTML5, iOS), Maven plugin, and the BuildDaemon's IPhoneBuilder / AndroidGradleBuilder.
  • Simulator Native Theme menu now actually reloads. The menu used window.dispose() (unreliable field) instead of the frm.dispose() + deinitializeSync() pattern the skin selector already uses - selecting a theme had no effect. Fixed.
  • "Auto" defers to build hints. When the menu is on "Auto", the simulator now resolves the theme from ios.themeMode / and.themeMode / nativeTheme in codenameone_settings.properties (with the deprecated aliases as fallback). A project with ios.themeMode=modern previews iOS Modern; flipping the same project to ios.themeMode=ios7 previews iOS 7. Without the fix, "Auto" hard-coded the modern theme.
  • "Rotate" menu item restored for non-single-window mode. It was removed wholesale when the toolbar buttons landed in 2022; the sibling Zoom item was correctly gated behind appFrame == null but Rotate was just deleted, leaving non-single-window users with no way to rotate. Now gated the same way.
  • initializr / Playground default to modern themes with the new key names. The bundled common.zip template, the source codenameone_settings.properties files, and PlaygroundProjectExporter.codenameOneSettings() all emit nativeTheme=modern + ios.themeMode=modern + and.themeMode=modern.
  • Playground samples no longer require a trailing form; / root; line - removed from the 11 bundled samples; the runner's existing first-created-Form / first-created-Component fallback covers the implicit return. The exporter also strips form; / root; defensively when synthesizing Lifecycle source.
  • Docs updated. docs/developer-guide/Native-Themes.asciidoc, docs/developer-guide/Advanced-Topics-Under-The-Hood.asciidoc, and the liquid-glass-material-3-modern-native-themes blog post describe the new naming with the deprecated aliases noted.

Test plan

  • Simulator: open with iOS skin, default codenameone_settings.properties (no theme hints) — Auto previews iOS Modern.
  • Set ios.themeMode=ios7 in codenameone_settings.properties — Auto now previews iOS 7 after reload.
  • Pick "iOS 7 (Flat)" explicitly from Native Theme menu — simulator reloads and previews iOS 7.
  • Pick "iOS Modern" explicitly from Native Theme menu — simulator reloads and previews iOS Modern.
  • Toggle Single Window mode off — verify Simulator menu shows both Rotate and Zoom items.
  • Toggle Single Window mode on — verify menu hides them and the toolbar Portrait/Landscape/Zoom buttons appear instead.
  • Click Rotate in non-single-window mode — verify the simulator window flips orientation and resizes.
  • Generate a project from the initializr — verify common/codenameone_settings.properties contains nativeTheme=modern / ios.themeMode=modern / and.themeMode=modern.
  • Download a project from cn1playground — verify the same three keys are present in the generated codenameone_settings.properties.
  • Open each bundled cn1playground sample (Welcome, Hello World, Date Picker, Profile Form, Menu List, UI Showcase, Tabs, BrowserComponent, Network Fetch, REST Request, Camera Capture) — preview should still render despite missing trailing form; / root; line.
  • Build a device app with cn1.androidTheme=material (legacy alias) — Android runtime still loads AndroidMaterialTheme.res.
  • Build a device app with nativeTheme=modern only (no platform-specific hints) — iOS builder picks modern, Android runtime picks material.

🤖 Generated with Claude Code

Build hints rename: nativeTheme (global), ios.themeMode and
and.themeMode (platform-specific). The old keys cn1.nativeTheme
and cn1.androidTheme stay accepted as deprecated aliases on every
runtime, builder (maven plugin + BuildDaemon), and the simulator's
schema editor.

Simulator fixes:
- Native Theme menu reload now uses frm.dispose() + deinitializeSync()
  (matching the working skin selector) instead of the unreliable
  window field, so selecting a theme actually triggers a reload.
- "Auto" in the Native Theme menu defers to the project's build hints
  (ios.themeMode / and.themeMode / nativeTheme), so a project that
  set ios.themeMode=modern previews iOS Modern instead of being
  hard-coded to one default.
- Restored the "Rotate" menu item for non-single-window mode. It was
  removed wholesale when the toolbar Portrait/Landscape buttons
  landed; now gated behind appFrame == null like the sibling Zoom
  item so single-window users still see only the toolbar buttons.

Defaults:
- initializr / Playground codenameone_settings.properties (and the
  bundled common.zip template) ship the renamed keys: nativeTheme,
  ios.themeMode, and.themeMode all set to modern.
- PlaygroundProjectExporter now writes the same defaults into
  generated project zips downloaded from cn1playground.

Playground samples:
- Removed trailing form;/root; lines from the bundled samples - the
  runner already falls back to the first created Form/Component.
  The exporter also strips form; / root; lines defensively when
  generating Lifecycle source from a snippet.

Docs:
- Native-Themes.asciidoc, Advanced-Topics-Under-The-Hood.asciidoc,
  and the liquid-glass blog post all describe the new naming with
  the deprecated aliases noted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

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

Developer Guide quality checks:

  • AsciiDoc linter: No issues found (report)
  • Vale: Vale failed (exit code 2) (report)
  • Image references: No unused images detected (report)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 3, 2026

Compared 7 screenshots: 7 matched.
✅ JavaSE simulator integration screenshots matched stored baselines.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

Cloudflare Preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

✅ 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
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 3, 2026

Compared 86 screenshots: 86 matched.

Native Android coverage

  • 📊 Line coverage: 9.89% (5376/54372 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 7.76% (26351/339651), branch 3.59% (1172/32602), complexity 4.54% (1418/31210), method 7.97% (1162/14574), class 13.02% (254/1951)
    • 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)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 9.89% (5376/54372 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 7.76% (26351/339651), branch 3.59% (1172/32602), complexity 4.54% (1418/31210), method 7.97% (1162/14574), class 13.02% (254/1951)
    • 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
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 953.000 ms
Base64 CN1 encode 245.000 ms
Base64 encode ratio (CN1/native) 0.257x (74.3% faster)
Base64 native decode 931.000 ms
Base64 CN1 decode 186.000 ms
Base64 decode ratio (CN1/native) 0.200x (80.0% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 3, 2026

Compared 86 screenshots: 86 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 110000 ms
Simulator Boot (Run) 1000 ms
App Install 15000 ms
App Launch 14000 ms
Test Execution 280000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1775.000 ms
Base64 CN1 encode 1811.000 ms
Base64 encode ratio (CN1/native) 1.020x (2.0% slower)
Base64 native decode 1161.000 ms
Base64 CN1 decode 1763.000 ms
Base64 decode ratio (CN1/native) 1.519x (51.9% slower)
Base64 SIMD encode 613.000 ms
Base64 encode ratio (SIMD/native) 0.345x (65.5% faster)
Base64 encode ratio (SIMD/CN1) 0.338x (66.2% faster)
Base64 SIMD decode 539.000 ms
Base64 decode ratio (SIMD/native) 0.464x (53.6% faster)
Base64 decode ratio (SIMD/CN1) 0.306x (69.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 59.000 ms
Image createMask (SIMD on) 10.000 ms
Image createMask ratio (SIMD on/off) 0.169x (83.1% faster)
Image applyMask (SIMD off) 247.000 ms
Image applyMask (SIMD on) 164.000 ms
Image applyMask ratio (SIMD on/off) 0.664x (33.6% faster)
Image modifyAlpha (SIMD off) 206.000 ms
Image modifyAlpha (SIMD on) 96.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.466x (53.4% faster)
Image modifyAlpha removeColor (SIMD off) 140.000 ms
Image modifyAlpha removeColor (SIMD on) 71.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.507x (49.3% faster)
Image PNG encode (SIMD off) 1096.000 ms
Image PNG encode (SIMD on) 855.000 ms
Image PNG encode ratio (SIMD on/off) 0.780x (22.0% faster)
Image JPEG encode 708.000 ms

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 644 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 10562 ms

  • Hotspots (Top 20 sampled methods):

    • 22.33% java.lang.String.indexOf (410 samples)
    • 19.66% com.codename1.tools.translator.Parser.isMethodUsed (361 samples)
    • 13.62% java.util.ArrayList.indexOf (250 samples)
    • 5.17% java.lang.Object.hashCode (95 samples)
    • 4.36% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (80 samples)
    • 2.89% java.lang.System.identityHashCode (53 samples)
    • 2.83% com.codename1.tools.translator.Parser.addToConstantPool (52 samples)
    • 1.69% com.codename1.tools.translator.Parser.getClassByName (31 samples)
    • 1.58% com.codename1.tools.translator.ByteCodeClass.updateAllDependencies (29 samples)
    • 1.58% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (29 samples)
    • 1.53% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (28 samples)
    • 1.42% com.codename1.tools.translator.ByteCodeClass.markDependent (26 samples)
    • 1.14% com.codename1.tools.translator.BytecodeMethod.optimize (21 samples)
    • 1.09% java.lang.StringBuilder.append (20 samples)
    • 1.03% com.codename1.tools.translator.BytecodeMethod.equals (19 samples)
    • 0.93% java.lang.StringCoding.encode (17 samples)
    • 0.87% com.codename1.tools.translator.Parser.cullMethods (16 samples)
    • 0.76% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (14 samples)
    • 0.65% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (12 samples)
    • 0.65% sun.nio.ch.FileDispatcherImpl.write0 (12 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

Generated automatically by the PR CI workflow.

@shai-almog shai-almog merged commit a3effb5 into master May 3, 2026
28 of 30 checks passed
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.

1 participant