Skip to content

Commit c1ec191

Browse files
juliusmarmingeHorusGoulclaudemaria-rcksshivamhwp
authored
[codex] Add Android mobile support (#3579)
Co-authored-by: Horus Lugo <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: maria-rcks <[email protected]> Co-authored-by: Shivam Sharma <[email protected]> Co-authored-by: Ben Davis <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: codex <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
1 parent 619b0ec commit c1ec191

166 files changed

Lines changed: 17354 additions & 686 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.

‎app.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"expo": {}
3+
}

‎apps/mobile/README.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ Build and run the local iOS dev client:
3434
vp run ios:dev
3535
```
3636

37+
If your Xcode account only has a Personal Team, use a bundle identifier you control and opt into the
38+
reduced-capability local build. Personal Team builds omit the widget extension, push entitlement, and
39+
native Sign in with Apple entitlement; builds without this opt-in are unchanged.
40+
41+
```bash
42+
T3CODE_IOS_PERSONAL_TEAM=1 \
43+
T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID=com.example.t3code.dev \
44+
vp run ios:dev
45+
```
46+
47+
Build and install a self-contained Release app that does not need Metro:
48+
49+
```bash
50+
vp run ios:release
51+
```
52+
53+
The Personal Team equivalent also needs a unique bundle identifier:
54+
55+
```bash
56+
T3CODE_IOS_PERSONAL_TEAM=1 \
57+
T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID=com.example.t3code \
58+
vp run ios:release
59+
```
60+
3761
Build and run the local iOS preview app:
3862

3963
```bash

‎apps/mobile/app.config.ts‎

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ const repoEnv = loadRepoEnv();
88
Object.assign(process.env, repoEnv);
99

1010
const APP_VARIANT = resolveAppVariant(repoEnv.APP_VARIANT);
11+
const isIosPersonalTeamBuild = repoEnv.T3CODE_IOS_PERSONAL_TEAM === "1";
12+
13+
const personalTeamBundleIdentifier = repoEnv.T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID?.trim();
14+
const IOS_BUNDLE_IDENTIFIER_PATTERN = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
15+
16+
if (
17+
isIosPersonalTeamBuild &&
18+
(!personalTeamBundleIdentifier ||
19+
!IOS_BUNDLE_IDENTIFIER_PATTERN.test(personalTeamBundleIdentifier))
20+
) {
21+
throw new Error(
22+
"T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID must be a reverse-DNS identifier such as com.example.t3code when T3CODE_IOS_PERSONAL_TEAM=1.",
23+
);
24+
}
1125

1226
const VARIANT_CONFIG: Record<
1327
AppVariant,
@@ -69,6 +83,26 @@ const dmSansFonts = {
6983
bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
7084
} as const;
7185

86+
const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
87+
"expo-widgets",
88+
{
89+
bundleIdentifier: `${variant.iosBundleIdentifier}.widgets`,
90+
groupIdentifier: `group.${variant.iosBundleIdentifier}`,
91+
enablePushNotifications: true,
92+
// Agent activity can update many times an hour; without the
93+
// frequent-updates entitlement iOS throttles the update budget sooner.
94+
frequentUpdates: true,
95+
widgets: [
96+
{
97+
name: "AgentActivity",
98+
displayName: "Agent Activity",
99+
description: "Shows the current state of active T3 Code agents.",
100+
supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
101+
},
102+
],
103+
},
104+
];
105+
72106
// These aliases match the fonts' PostScript names on iOS. Register the same
73107
// names on Android so React Native and the native composer use one set of
74108
// family names without waiting for runtime font loading.
@@ -125,12 +159,16 @@ const config: ExpoConfig = {
125159
backgroundImage: "./assets/android-icon-background.png",
126160
monochromeImage: "./assets/android-icon-monochrome.png",
127161
},
128-
predictiveBackGestureEnabled: false,
162+
// Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
163+
// JS back handling survives it via react-native's Android 16 shim plus
164+
// withAndroidPredictiveBackCompat on Android 13-15.
165+
predictiveBackGestureEnabled: true,
129166
},
130167
web: {
131168
favicon: "./assets/favicon.png",
132169
},
133170
plugins: [
171+
"expo-asset",
134172
[
135173
"expo-font",
136174
{
@@ -157,8 +195,23 @@ const config: ExpoConfig = {
157195
],
158196
"expo-secure-store",
159197
"expo-sqlite",
160-
["@clerk/expo", { theme: "./clerk-theme.json" }],
198+
// appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
199+
// plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
200+
["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
161201
"expo-web-browser",
202+
[
203+
"expo-quick-actions",
204+
{
205+
// Adaptive launcher-shortcut icon; referenced by resource name from
206+
// the shortcut items set in src/features/shortcuts.
207+
androidIcons: {
208+
shortcut_icon: {
209+
foregroundImage: "./assets/android-icon-foreground.png",
210+
backgroundColor: "#E6F4FE",
211+
},
212+
},
213+
},
214+
],
162215
[
163216
"expo-camera",
164217
{
@@ -198,31 +251,18 @@ const config: ExpoConfig = {
198251
// expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
199252
// would delete the asset catalog) and its xcodeproj mod creates the widget
200253
// target (which must exist before the compile phase can be attached).
201-
"./plugins/withWidgetLogoAsset.cjs",
202-
[
203-
"expo-widgets",
204-
{
205-
bundleIdentifier: `${variant.iosBundleIdentifier}.widgets`,
206-
groupIdentifier: `group.${variant.iosBundleIdentifier}`,
207-
enablePushNotifications: true,
208-
// Agent activity can update many times an hour; without the
209-
// frequent-updates entitlement iOS throttles the update budget sooner.
210-
frequentUpdates: true,
211-
widgets: [
212-
{
213-
name: "AgentActivity",
214-
displayName: "Agent Activity",
215-
description: "Shows the current state of active T3 Code agents.",
216-
supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
217-
},
218-
],
219-
},
220-
],
254+
...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
221255
"./plugins/withIosSceneLifecycle.cjs",
222256
"./plugins/withAndroidCleartextTraffic.cjs",
257+
"./plugins/withAndroidGradleHeap.cjs",
258+
"./plugins/withAndroidModernPopupMenu.cjs",
259+
"./plugins/withAndroidModernAlertDialog.cjs",
260+
"./plugins/withAndroidPredictiveBackCompat.cjs",
261+
...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
223262
],
224263
extra: {
225264
appVariant: APP_VARIANT,
265+
iosPersonalTeamBuild: isIosPersonalTeamBuild,
226266
relay: {
227267
url: repoEnv.T3CODE_RELAY_URL ?? null,
228268
},

‎apps/mobile/global.css‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/* Card / surface */
1313
--color-card: #ffffff;
1414
--color-card-alt: #f5f5f5;
15-
--color-card-translucent: rgba(255, 255, 255, 0.94);
15+
--color-card-translucent: rgba(255, 255, 255, 0.8);
1616

1717
/* Text */
1818
--color-foreground: #262626;
@@ -106,7 +106,7 @@
106106
/* Card / surface */
107107
--color-card: #171717;
108108
--color-card-alt: #1c1c1c;
109-
--color-card-translucent: rgba(17, 17, 17, 0.94);
109+
--color-card-translucent: rgba(17, 17, 17, 0.8);
110110

111111
/* Text */
112112
--color-foreground: #f5f5f5;

‎apps/mobile/metro.config.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { withUniwindConfig } = require("uniwind/metro");
66
/** @type {import("expo/metro-config").MetroConfig} */
77
const config = getDefaultConfig(__dirname);
88
const workspaceRoot = path.resolve(__dirname, "../..");
9+
const escapedWorkspaceRoot = workspaceRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
910
const mobileShikiRoot = path.dirname(require.resolve("shiki/package.json", { paths: [__dirname] }));
1011
const resolveShikiDependencyRoot = (packageName) => {
1112
const entryPath = require.resolve(packageName, { paths: [mobileShikiRoot] });
@@ -25,6 +26,14 @@ const resolveShikiDependencyRoot = (packageName) => {
2526
config.watchFolders = [...new Set([...(config.watchFolders ?? []), workspaceRoot])];
2627
config.resolver = {
2728
...config.resolver,
29+
blockList: [
30+
...(Array.isArray(config.resolver?.blockList)
31+
? config.resolver.blockList
32+
: config.resolver?.blockList
33+
? [config.resolver.blockList]
34+
: []),
35+
new RegExp(`${escapedWorkspaceRoot}[/\\\\]\\.t3[/\\\\].*`),
36+
],
2837
extraNodeModules: {
2938
// oxlint-disable-next-line unicorn/no-useless-fallback-in-spread
3039
...(config.resolver?.extraNodeModules ?? {}),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'org.jetbrains.kotlin.android'
3+
4+
group = 'com.t3tools.composereditor'
5+
version = '0.0.0'
6+
7+
android {
8+
namespace 'expo.modules.t3composereditor'
9+
compileSdk rootProject.ext.compileSdkVersion
10+
11+
defaultConfig {
12+
minSdkVersion rootProject.ext.minSdkVersion
13+
targetSdkVersion rootProject.ext.targetSdkVersion
14+
}
15+
}
16+
17+
dependencies {
18+
implementation project(':expo-modules-core')
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package expo.modules.t3composereditor
2+
3+
import expo.modules.kotlin.modules.Module
4+
import expo.modules.kotlin.modules.ModuleDefinition
5+
6+
class T3ComposerEditorModule : Module() {
7+
override fun definition() = ModuleDefinition {
8+
Name("T3ComposerEditor")
9+
10+
View(T3ComposerEditorView::class) {
11+
Prop("controlledDocumentJson") { view: T3ComposerEditorView, documentJson: String ->
12+
view.setControlledDocumentJson(documentJson)
13+
}
14+
Prop("themeJson") { view: T3ComposerEditorView, themeJson: String ->
15+
view.setThemeJson(themeJson)
16+
}
17+
Prop("placeholder") { view: T3ComposerEditorView, placeholder: String ->
18+
view.setPlaceholder(placeholder)
19+
}
20+
Prop("fontFamily") { view: T3ComposerEditorView, fontFamily: String ->
21+
view.setFontFamily(fontFamily)
22+
}
23+
Prop("fontSize") { view: T3ComposerEditorView, fontSize: Double ->
24+
view.setFontSize(fontSize.toFloat())
25+
}
26+
Prop("lineHeight") { view: T3ComposerEditorView, lineHeight: Double ->
27+
view.setLineHeight(lineHeight.toFloat())
28+
}
29+
Prop("contentInsetVertical") { view: T3ComposerEditorView, contentInsetVertical: Double ->
30+
view.setContentInsetVertical(contentInsetVertical.toInt())
31+
}
32+
33+
Prop("singleLineCentered") { view: T3ComposerEditorView, singleLineCentered: Boolean ->
34+
view.setSingleLineCentered(singleLineCentered)
35+
}
36+
Prop("editable") { view: T3ComposerEditorView, editable: Boolean ->
37+
view.setEditable(editable)
38+
}
39+
Prop("scrollEnabled") { view: T3ComposerEditorView, scrollEnabled: Boolean ->
40+
view.setScrollEnabled(scrollEnabled)
41+
}
42+
Prop("autoFocus") { view: T3ComposerEditorView, autoFocus: Boolean ->
43+
view.setAutoFocus(autoFocus)
44+
}
45+
Prop("autoCorrect") { view: T3ComposerEditorView, autoCorrect: Boolean ->
46+
view.setAutoCorrect(autoCorrect)
47+
}
48+
Prop("spellCheck") { view: T3ComposerEditorView, spellCheck: Boolean ->
49+
view.setSpellCheck(spellCheck)
50+
}
51+
52+
Events(
53+
"onComposerChange",
54+
"onComposerSelectionChange",
55+
"onComposerFocus",
56+
"onComposerBlur",
57+
"onComposerPasteImages",
58+
"onComposerContentSizeChange",
59+
)
60+
61+
AsyncFunction("focus") { view: T3ComposerEditorView ->
62+
view.focusEditor()
63+
}
64+
AsyncFunction("blur") { view: T3ComposerEditorView ->
65+
view.blurEditor()
66+
}
67+
AsyncFunction("setSelection") { view: T3ComposerEditorView, start: Int, end: Int ->
68+
view.setSelection(start, end)
69+
}
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)