Skip to content

Commit f173efe

Browse files
shai-almogclaude
andcommitted
cn1-ai-*: drop win modules, auto-set plist hints in sim, theme ChatView
Three review-driven fixes: 1. Remove the win/ module from every cn1-ai-* lib. UWP is not a runtime target -- the C# stubs were dead weight inside every .cn1lib. Drop the module from the root pom, the lib pom, the generator, and delete the existing win/ trees. .cn1lib archives now ship 6 entries (was 7). 2. Replace `codename1.arg.ios.plistInject` build hints with implicit simulator-side injection. Each JavaSE NativeXxxImpl constructor calls a one-shot `ensureSimulatorHints()` that: - reads `getProjectBuildHints()` (returns null off-simulator, so this is a no-op on real devices) - sets the default value ONLY when the hint is absent -- never overwrites a developer-customised string This way the developer never has to copy a Camera/Microphone usage description out of docs into their properties file, but stays in full control of the wording. Only mlkit-text, barcode, and face declared `NSCameraUsageDescription` in the previous plistInject form; same coverage, now via the helper. 3. Style ChatView in the modern themes. The earlier ChatView screenshot rendered without bubble fills because the default themes had no ChatBubble*/ChatInput*/ChatTypingIndicator UIIDs. iOSModern now uses iMessage-style accent fills for user bubbles + neutral fills for assistant bubbles + a centred muted row for system; AndroidMaterial mirrors with Material 3 primary container / surface variant tokens. ChatView itself now wraps each bubble in a FlowLayout row (USER -> RIGHT, ASSISTANT -> LEFT, SYSTEM -> CENTER) so the bubble's visible width tracks its content rather than spanning the chat surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 12ff8fa commit f173efe

64 files changed

Lines changed: 254 additions & 1020 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CodenameOne/src/com/codename1/components/ChatView.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.codename1.ui.events.ActionListener;
3333
import com.codename1.ui.layouts.BorderLayout;
3434
import com.codename1.ui.layouts.BoxLayout;
35+
import com.codename1.ui.layouts.FlowLayout;
3536

3637
import java.util.ArrayList;
3738
import java.util.Arrays;
@@ -107,15 +108,25 @@ public ChatView() {
107108

108109
/// Renders `message` as a new [ChatBubble] at the bottom of the
109110
/// list and scrolls into view. Safe to call from any thread.
111+
///
112+
/// The bubble itself is laid out inside a single-row FlowLayout
113+
/// container whose alignment is driven by the message role:
114+
/// USER -> right, ASSISTANT -> left, SYSTEM -> centre. That keeps
115+
/// the bubble's *visible width* anchored to its text content
116+
/// rather than stretching across the full chat surface, which is
117+
/// what makes a chat bubble actually look like a bubble.
110118
public ChatBubble addMessage(final ChatMessage message) {
111119
final ChatBubble[] out = new ChatBubble[1];
112120
Runnable r = new Runnable() {
113121
@Override
114122
public void run() {
115123
ChatBubble b = createBubble(message);
124+
Container row = new Container(new FlowLayout(alignmentFor(message.getRole())));
125+
row.setUIID("ChatBubbleRow");
126+
row.add(b);
116127
history.add(message);
117128
bubbles.add(b);
118-
messages.add(b);
129+
messages.add(row);
119130
messages.revalidateLater();
120131
messages.scrollComponentToVisible(b);
121132
out[0] = b;
@@ -193,4 +204,14 @@ public List<ChatMessage> getHistory() {
193204
protected ChatBubble createBubble(ChatMessage message) {
194205
return new ChatBubble(message);
195206
}
207+
208+
private static int alignmentFor(Role role) {
209+
if (role == Role.USER) {
210+
return com.codename1.ui.Component.RIGHT;
211+
}
212+
if (role == Role.SYSTEM) {
213+
return com.codename1.ui.Component.CENTER;
214+
}
215+
return com.codename1.ui.Component.LEFT;
216+
}
196217
}

Themes/AndroidMaterialTheme.res

24.8 KB
Binary file not shown.

Themes/iOSModernTheme.res

25.3 KB
Binary file not shown.

maven/cn1-ai-mlkit-barcode/common/codenameone_library_required.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
# further per-class entries as needed.
55
codename1.arg.ios.pods=GoogleMLKit/BarcodeScanning
66
codename1.arg.android.gradleDep=implementation 'com.google.mlkit:barcode-scanning:17.2.0'
7-
codename1.arg.ios.plistInject=<key>NSCameraUsageDescription</key><string>This app uses the camera to scan barcodes.</string>
87
codename1.arg.android.xpermissions=<uses-permission android:name="android.permission.CAMERA"/>

maven/cn1-ai-mlkit-barcode/javase/src/main/java/com/codename1/ai/mlkit/barcode/NativeBarcodeScannerImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
package com.codename1.ai.mlkit.barcode;
22

33
public class NativeBarcodeScannerImpl implements NativeBarcodeScanner {
4+
5+
private static boolean hintsEnsured;
6+
private static synchronized void ensureSimulatorHints() {
7+
if (hintsEnsured) return;
8+
hintsEnsured = true;
9+
java.util.Map<String, String> hints =
10+
com.codename1.ui.Display.getInstance().getProjectBuildHints();
11+
if (hints == null) return; // not running in the simulator
12+
if (!hints.containsKey("ios.NSCameraUsageDescription")) {
13+
com.codename1.ui.Display.getInstance()
14+
.setProjectBuildHint("ios.NSCameraUsageDescription", "This app uses the camera to scan barcodes.");
15+
}
16+
}
17+
18+
public NativeBarcodeScannerImpl() {
19+
ensureSimulatorHints();
20+
}
421
public String[] scan(byte[] imageBytes) {
522
if (imageBytes == null || imageBytes.length == 0) return new String[0];
623
// Deterministic stub for simulator runs.

maven/cn1-ai-mlkit-barcode/lib/pom.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,5 @@
7474
</dependency>
7575
</dependencies>
7676
</profile>
77-
<profile>
78-
<id>win</id>
79-
<activation>
80-
<property><name>codename1.platform</name><value>win</value></property>
81-
</activation>
82-
<dependencies>
83-
<dependency>
84-
<groupId>com.codenameone</groupId>
85-
<artifactId>cn1-ai-mlkit-barcode-win</artifactId>
86-
<version>${project.version}</version>
87-
</dependency>
88-
</dependencies>
89-
</profile>
9077
</profiles>
9178
</project>

maven/cn1-ai-mlkit-barcode/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<module>android</module>
2929
<module>javase</module>
3030
<module>javascript</module>
31-
<module>win</module>
3231
<module>lib</module>
3332
</modules>
3433
</project>

maven/cn1-ai-mlkit-barcode/win/pom.xml

Lines changed: 0 additions & 52 deletions
This file was deleted.

maven/cn1-ai-mlkit-barcode/win/src/main/csharp/com/codename1/ai/mlkit/barcode/NativeBarcodeScannerImpl.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

maven/cn1-ai-mlkit-docscan/lib/pom.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,5 @@
7474
</dependency>
7575
</dependencies>
7676
</profile>
77-
<profile>
78-
<id>win</id>
79-
<activation>
80-
<property><name>codename1.platform</name><value>win</value></property>
81-
</activation>
82-
<dependencies>
83-
<dependency>
84-
<groupId>com.codenameone</groupId>
85-
<artifactId>cn1-ai-mlkit-docscan-win</artifactId>
86-
<version>${project.version}</version>
87-
</dependency>
88-
</dependencies>
89-
</profile>
9077
</profiles>
9178
</project>

0 commit comments

Comments
 (0)