@maccesar/titools 2.7.2 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,546 +0,0 @@
1
- #!/usr/bin/env bash
2
- # ti-branding — generate icon and splash assets for Titanium SDK 13.x projects.
3
- # Entry point. Parses args, validates, and delegates to lib/ scripts.
4
-
5
- set -euo pipefail
6
-
7
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
- LIB_DIR="$SCRIPT_DIR/lib"
9
- ASSETS_DIR="$(cd "$SCRIPT_DIR/../assets" && pwd)"
10
-
11
- # shellcheck source=lib/deps.sh
12
- source "$LIB_DIR/deps.sh"
13
- # shellcheck source=lib/validate.sh
14
- source "$LIB_DIR/validate.sh"
15
- # shellcheck source=lib/prepare-master.sh
16
- source "$LIB_DIR/prepare-master.sh"
17
- # shellcheck source=lib/gen-ios.sh
18
- source "$LIB_DIR/gen-ios.sh"
19
- # shellcheck source=lib/gen-android-adaptive.sh
20
- source "$LIB_DIR/gen-android-adaptive.sh"
21
- # shellcheck source=lib/gen-android-legacy.sh
22
- source "$LIB_DIR/gen-android-legacy.sh"
23
- # shellcheck source=lib/gen-marketplace.sh
24
- source "$LIB_DIR/gen-marketplace.sh"
25
- # shellcheck source=lib/cleanup-legacy.sh
26
- source "$LIB_DIR/cleanup-legacy.sh"
27
- # shellcheck source=lib/gen-notification.sh
28
- source "$LIB_DIR/gen-notification.sh"
29
- # shellcheck source=lib/gen-splash-icon.sh
30
- source "$LIB_DIR/gen-splash-icon.sh"
31
-
32
- # -----------------------------------------------------------------------------
33
- # Defaults
34
- # -----------------------------------------------------------------------------
35
-
36
- MASTER=""
37
- MONOCHROME_MASTER=""
38
- BG_COLOR="#FFFFFF"
39
- BG_COLOR_EXPLICIT=0
40
- PADDING=20
41
- IOS_PADDING=4
42
- WITH_NOTIFICATION=0
43
- WITH_SPLASH_ICON=0
44
- CLEANUP_LEGACY=0
45
- AGGRESSIVE=0
46
- OUTPUT=""
47
- OUTPUT_EXPLICIT=0
48
- DRY_RUN=0
49
- IN_PLACE=0
50
- IS_IN_PLACE=0
51
- NOTES=0
52
- PROJECT_ROOT="$(pwd)"
53
-
54
- # -----------------------------------------------------------------------------
55
- # Colored output helpers
56
- # -----------------------------------------------------------------------------
57
-
58
- if [[ -t 1 ]]; then
59
- C_RED=$'\033[31m'; C_GREEN=$'\033[32m'; C_YELLOW=$'\033[33m'
60
- C_BLUE=$'\033[34m'; C_DIM=$'\033[2m'; C_BOLD=$'\033[1m'; C_RESET=$'\033[0m'
61
- else
62
- C_RED=''; C_GREEN=''; C_YELLOW=''; C_BLUE=''; C_DIM=''; C_BOLD=''; C_RESET=''
63
- fi
64
-
65
- log_info() { echo "${C_BLUE}ℹ${C_RESET} $*"; }
66
- log_ok() { echo "${C_GREEN}✓${C_RESET} $*"; }
67
- log_warn() { echo "${C_YELLOW}⚠${C_RESET} $*" >&2; }
68
- log_err() { echo "${C_RED}✗${C_RESET} $*" >&2; }
69
- log_step() { echo; echo "${C_BOLD}==>${C_RESET} $*"; }
70
-
71
- export C_RED C_GREEN C_YELLOW C_BLUE C_DIM C_BOLD C_RESET
72
- export -f log_info log_ok log_warn log_err log_step
73
-
74
- # -----------------------------------------------------------------------------
75
- # Usage
76
- # -----------------------------------------------------------------------------
77
-
78
- usage() {
79
- cat <<'EOF'
80
- ti-branding — generate branding assets for Titanium SDK 13.x projects.
81
-
82
- USAGE:
83
- ti-branding <master> [options]
84
-
85
- ARGUMENTS:
86
- <master> Path to master image (SVG or PNG ≥ 1024×1024).
87
-
88
- OPTIONS:
89
- --bg-color <hex> Background color for adaptive layer + iOS alpha flatten.
90
- Default: #FFFFFF
91
- --padding <pct> Android safe-zone padding per side (0–40). Default: 20
92
- (Material spec floor is 19.44%; default 20 gives a
93
- tiny buffer while keeping the logo visibly prominent.)
94
- --ios-padding <pct> iOS/marketplace aesthetic padding per side (0–40).
95
- Default: 4. iOS icons have no launcher mask — this
96
- is purely breathing room. Production reference apps
97
- (Mail, Safari, La Baraja) use 2-6% per side.
98
- --with-notification Also generate ic_stat_notify.png × 5 densities.
99
- --with-splash-icon Also generate splash_icon.png × 5 densities (Android 12+).
100
- --cleanup-legacy After generating (or standalone), remove legacy branding
101
- artifacts detected via tiapp.xml analysis. Safe by default —
102
- context-aware, always prints a plan before deleting.
103
- --aggressive With --cleanup-legacy, also remove ldpi density folders
104
- (<1% global market in 2026). Off by default.
105
- --output <dir> Staging directory. Default: <project>/.ti-branding
106
- --project <dir> Project root (default: current working directory).
107
- --in-place Skip the staging directory — write files directly into
108
- the project root. OVERWRITES existing icons. --output
109
- takes precedence when both are passed.
110
- --monochrome-master <p> Optional dedicated silhouette master for
111
- ic_launcher_monochrome.png + ic_stat_notify.png.
112
- Use when the colored logo has multi-color detail
113
- that would collapse into a featureless blob when
114
- naively whitened. Falls back to main master if omitted.
115
- --notes Print full tiapp.xml snippets + padding tuning guide
116
- after the run. Default is a compact summary — use this
117
- when you need the config snippets to paste into tiapp.xml.
118
- --dry-run Print what would be generated without writing files.
119
- -h, --help Show this help.
120
-
121
- EXAMPLES:
122
- ti-branding ./logo.svg
123
- ti-branding ./logo.png --bg-color "#0B1326" --padding 22
124
- ti-branding ./docs/snap-logo.svg --bg-color "#0B1326" --with-notification --with-splash-icon
125
- EOF
126
- }
127
-
128
- # -----------------------------------------------------------------------------
129
- # Parse args
130
- # -----------------------------------------------------------------------------
131
-
132
- while [[ $# -gt 0 ]]; do
133
- case "$1" in
134
- -h|--help) usage; exit 0 ;;
135
- --bg-color) BG_COLOR="$2"; BG_COLOR_EXPLICIT=1; shift 2 ;;
136
- --padding) PADDING="$2"; shift 2 ;;
137
- --ios-padding) IOS_PADDING="$2"; shift 2 ;;
138
- --with-notification) WITH_NOTIFICATION=1; shift ;;
139
- --with-splash-icon) WITH_SPLASH_ICON=1; shift ;;
140
- --cleanup-legacy) CLEANUP_LEGACY=1; shift ;;
141
- --aggressive) AGGRESSIVE=1; shift ;;
142
- --output) OUTPUT="$2"; OUTPUT_EXPLICIT=1; shift 2 ;;
143
- --project) PROJECT_ROOT="$2"; shift 2 ;;
144
- --in-place) IN_PLACE=1; shift ;;
145
- --monochrome-master) MONOCHROME_MASTER="$2"; shift 2 ;;
146
- --notes) NOTES=1; shift ;;
147
- --dry-run) DRY_RUN=1; shift ;;
148
- --) shift; break ;;
149
- -*) log_err "Unknown option: $1"; usage >&2; exit 2 ;;
150
- *)
151
- if [[ -z "$MASTER" ]]; then
152
- MASTER="$1"; shift
153
- else
154
- log_err "Unexpected positional argument: $1"; exit 2
155
- fi
156
- ;;
157
- esac
158
- done
159
-
160
- # -----------------------------------------------------------------------------
161
- # Validate args
162
- # -----------------------------------------------------------------------------
163
-
164
- # Cleanup-only mode: master image is optional when --cleanup-legacy is set alone.
165
- if [[ -z "$MASTER" && $CLEANUP_LEGACY -eq 0 ]]; then
166
- log_err "Master image path is required (unless using --cleanup-legacy alone)."
167
- usage >&2
168
- exit 2
169
- fi
170
-
171
- if [[ -n "$MASTER" && ! -f "$MASTER" ]]; then
172
- log_err "Master image not found: $MASTER"
173
- exit 2
174
- fi
175
-
176
- # Resolve to absolute path
177
- if [[ -n "$MASTER" ]]; then
178
- MASTER="$(cd "$(dirname "$MASTER")" && pwd)/$(basename "$MASTER")"
179
- fi
180
- PROJECT_ROOT="$(cd "$PROJECT_ROOT" && pwd)"
181
-
182
- if [[ "$PADDING" -lt 0 || "$PADDING" -gt 40 ]]; then
183
- log_err "Padding must be between 0 and 40 (got: $PADDING)."
184
- exit 2
185
- fi
186
-
187
- if [[ "$IOS_PADDING" -lt 0 || "$IOS_PADDING" -gt 40 ]]; then
188
- log_err "iOS padding must be between 0 and 40 (got: $IOS_PADDING)."
189
- exit 2
190
- fi
191
-
192
- if [[ ! "$BG_COLOR" =~ ^#[0-9A-Fa-f]{6}$ ]]; then
193
- log_err "--bg-color must be a 6-digit hex like #0B1326 (got: $BG_COLOR)."
194
- exit 2
195
- fi
196
-
197
- # Resolve staging dir:
198
- # explicit --output wins over --in-place (avoids ambiguity)
199
- # --in-place (no --output) → write directly into the project root
200
- # neither → default to .ti-branding/ inside the project
201
- if [[ $IN_PLACE -eq 1 && $OUTPUT_EXPLICIT -eq 0 ]]; then
202
- OUTPUT="$PROJECT_ROOT"
203
- IS_IN_PLACE=1
204
- fi
205
- OUTPUT="${OUTPUT:-$PROJECT_ROOT/.ti-branding}"
206
-
207
- # -----------------------------------------------------------------------------
208
- # Detect project layout
209
- # -----------------------------------------------------------------------------
210
-
211
- PROJECT_TYPE="unknown"
212
- if [[ -d "$PROJECT_ROOT/app" ]]; then
213
- PROJECT_TYPE="alloy"
214
- elif [[ -d "$PROJECT_ROOT/Resources" ]]; then
215
- PROJECT_TYPE="classic"
216
- fi
217
-
218
- log_step "ti-branding — Titanium SDK 13.x"
219
- log_info "Project: $PROJECT_ROOT ($PROJECT_TYPE)"
220
- if [[ -n "$MASTER" ]]; then
221
- log_info "Master: $MASTER"
222
- log_info "Background: $BG_COLOR"
223
- log_info "Padding: Android ${PADDING}% / iOS ${IOS_PADDING}% per side"
224
- if [[ $IS_IN_PLACE -eq 1 ]]; then
225
- log_info "Writing IN PLACE to: $PROJECT_ROOT"
226
- else
227
- log_info "Staging: $OUTPUT"
228
- fi
229
- fi
230
- [[ $WITH_NOTIFICATION -eq 1 ]] && log_info "Extras: + notification icons"
231
- [[ $WITH_SPLASH_ICON -eq 1 ]] && log_info "Extras: + Android 12+ splash icon"
232
- [[ $CLEANUP_LEGACY -eq 1 ]] && log_info "Cleanup: --cleanup-legacy$([[ $AGGRESSIVE -eq 1 ]] && echo " --aggressive")"
233
- [[ $IS_IN_PLACE -eq 1 && $DRY_RUN -eq 0 ]] && log_warn "⚠ --in-place mode: files in your project will be OVERWRITTEN. Commit first if you want a rollback."
234
- [[ $DRY_RUN -eq 1 ]] && log_warn "DRY RUN — no files will be written"
235
-
236
- # -----------------------------------------------------------------------------
237
- # Cleanup-only mode — skip all generation steps
238
- # -----------------------------------------------------------------------------
239
-
240
- if [[ -z "$MASTER" && $CLEANUP_LEGACY -eq 1 ]]; then
241
- log_step "Cleanup-only mode"
242
- cleanup_legacy "$PROJECT_ROOT" "$PROJECT_TYPE" "$AGGRESSIVE" "$DRY_RUN"
243
- exit 0
244
- fi
245
-
246
- if [[ "$PROJECT_TYPE" == "unknown" ]]; then
247
- log_warn "Could not detect project layout. Expected 'app/' (Alloy) or 'Resources/' (Classic)."
248
- log_warn "Assets will be generated under '$OUTPUT/standalone/' so you can copy them manually."
249
- fi
250
-
251
- # -----------------------------------------------------------------------------
252
- # Pipeline
253
- # -----------------------------------------------------------------------------
254
-
255
- log_step "1/6 Checking dependencies"
256
- check_deps "$MASTER"
257
-
258
- log_step "2/6 Validating master"
259
- validate_master "$MASTER"
260
-
261
- log_step "3/6 Preparing masters (square for iOS, tight for Android)"
262
- PREPARED_BASE="$OUTPUT/_master"
263
- MASTER_SQUARE="${PREPARED_BASE}_square.png"
264
- MASTER_TIGHT="${PREPARED_BASE}_tight.png"
265
- MONO_TIGHT=""
266
- if [[ $DRY_RUN -eq 0 ]]; then
267
- mkdir -p "$OUTPUT"
268
- prepare_master "$MASTER" "$PREPARED_BASE"
269
- log_ok "Square master: $MASTER_SQUARE"
270
- log_ok "Tight master: $MASTER_TIGHT"
271
-
272
- # Optional: prepare a dedicated monochrome master if provided.
273
- if [[ -n "$MONOCHROME_MASTER" ]]; then
274
- if [[ ! -f "$MONOCHROME_MASTER" ]]; then
275
- log_err "Monochrome master not found: $MONOCHROME_MASTER"
276
- exit 2
277
- fi
278
- local_mono_base="$OUTPUT/_master_mono"
279
- prepare_master "$MONOCHROME_MASTER" "$local_mono_base"
280
- MONO_TIGHT="${local_mono_base}_tight.png"
281
- log_ok "Monochrome master (for ic_launcher_monochrome + ic_stat_notify): $MONO_TIGHT"
282
- fi
283
- else
284
- log_info "[dry-run] would prepare: $MASTER_SQUARE + $MASTER_TIGHT"
285
- [[ -n "$MONOCHROME_MASTER" ]] && log_info "[dry-run] would prepare monochrome master from: $MONOCHROME_MASTER"
286
- fi
287
-
288
- # Resolve target paths based on project layout
289
- case "$PROJECT_TYPE" in
290
- alloy) ANDROID_RES="$OUTPUT/app/platform/android/res" ;;
291
- classic) ANDROID_RES="$OUTPUT/platform/android/res" ;;
292
- *) ANDROID_RES="$OUTPUT/standalone/platform/android/res" ;;
293
- esac
294
- ROOT_STAGING="$OUTPUT"
295
-
296
- log_step "4/6 Generating iOS master + marketplace artwork (square)"
297
- if [[ $DRY_RUN -eq 0 ]]; then
298
- gen_ios "$MASTER_TIGHT" "$BG_COLOR" "$IOS_PADDING" "$ROOT_STAGING"
299
- gen_marketplace "$MASTER_TIGHT" "$BG_COLOR" "$IOS_PADDING" "$ROOT_STAGING" "$BG_COLOR_EXPLICIT"
300
- else
301
- log_info "[dry-run] would emit DefaultIcon.png, DefaultIcon-ios.png, iTunesConnect.png, MarketplaceArtwork.png"
302
- fi
303
-
304
- log_step "5/6 Generating Android adaptive + legacy launcher icons (tight)"
305
- if [[ $DRY_RUN -eq 0 ]]; then
306
- gen_android_adaptive "$MASTER_TIGHT" "$BG_COLOR" "$PADDING" "$ANDROID_RES" "$MONO_TIGHT"
307
- gen_android_legacy "$MASTER_TIGHT" "$BG_COLOR" "$PADDING" "$ANDROID_RES"
308
- cp "$ASSETS_DIR/ic_launcher.xml" "$ANDROID_RES/mipmap-anydpi-v26/ic_launcher.xml"
309
- log_ok "Adaptive icon XML bind: $ANDROID_RES/mipmap-anydpi-v26/ic_launcher.xml"
310
- else
311
- log_info "[dry-run] would emit adaptive + legacy icons × 5 densities"
312
- fi
313
-
314
- if [[ $WITH_NOTIFICATION -eq 1 || $WITH_SPLASH_ICON -eq 1 ]]; then
315
- log_step "6/6 Generating optional extras"
316
- if [[ $WITH_NOTIFICATION -eq 1 && $DRY_RUN -eq 0 ]]; then
317
- # Use monochrome master if provided, else fall back to main (whitened by the generator).
318
- gen_notification "${MONO_TIGHT:-$MASTER_TIGHT}" "$ANDROID_RES"
319
- elif [[ $WITH_NOTIFICATION -eq 1 ]]; then
320
- log_info "[dry-run] would emit ic_stat_notify.png × 5 densities"
321
- fi
322
- if [[ $WITH_SPLASH_ICON -eq 1 && $DRY_RUN -eq 0 ]]; then
323
- gen_splash_icon "$MASTER_TIGHT" "$ANDROID_RES"
324
- elif [[ $WITH_SPLASH_ICON -eq 1 ]]; then
325
- log_info "[dry-run] would emit splash_icon.png × 5 densities"
326
- fi
327
- else
328
- log_step "6/6 (skipped — no optional extras requested)"
329
- fi
330
-
331
- if [[ $CLEANUP_LEGACY -eq 1 ]]; then
332
- log_step "Cleanup legacy artifacts"
333
- cleanup_legacy "$PROJECT_ROOT" "$PROJECT_TYPE" "$AGGRESSIVE" "$DRY_RUN"
334
- fi
335
-
336
- log_step "Done"
337
- if [[ $DRY_RUN -eq 0 ]]; then
338
- # In --in-place mode, intermediate master files (_master_square.png /
339
- # _master_tight.png) land directly in the project root alongside the real
340
- # branded assets. Clean them up so the user is only left with the 4 icons.
341
- if [[ $IS_IN_PLACE -eq 1 ]]; then
342
- rm -f "$OUTPUT/_master_square.png" "$OUTPUT/_master_tight.png"
343
- log_ok "All assets written IN PLACE at: $PROJECT_ROOT"
344
- else
345
- log_ok "All assets staged at: $OUTPUT"
346
- fi
347
-
348
- # ---------------------------------------------------------------------------
349
- # Post-generation output — compact summary by default, full notes with --notes.
350
- # ---------------------------------------------------------------------------
351
-
352
- if [[ $NOTES -eq 0 ]]; then
353
- # Compact summary — only config/destination + 3-line next steps + hint.
354
- echo
355
- echo "${C_BOLD}Summary${C_RESET}"
356
- echo " Background: ${BG_COLOR} Padding: Android ${PADDING}% / iOS ${IOS_PADDING}%"
357
- if [[ $IS_IN_PLACE -eq 1 ]]; then
358
- echo " Written in place to: $PROJECT_ROOT"
359
- else
360
- echo " Staged at: $OUTPUT"
361
- fi
362
- echo
363
- echo "${C_BOLD}Next steps${C_RESET}"
364
- if [[ $IS_IN_PLACE -eq 1 ]]; then
365
- echo " • Preview the new icons in ${C_YELLOW}Preview.app${C_RESET}."
366
- echo " • If something looks wrong: ${C_DIM}git checkout -- .${C_RESET}"
367
- echo " • Rebuild: ${C_DIM}ti clean && ti build -p android -T emulator${C_RESET}"
368
- else
369
- case "$PROJECT_TYPE" in
370
- alloy)
371
- echo " • Preview in ${C_YELLOW}Preview.app${C_RESET}, then copy to project:"
372
- echo " ${C_DIM}cp $OUTPUT/{DefaultIcon,DefaultIcon-ios,iTunesConnect,MarketplaceArtwork}.png $PROJECT_ROOT/${C_RESET}"
373
- echo " ${C_DIM}cp -R $OUTPUT/app/platform/android/res/. $PROJECT_ROOT/app/platform/android/res/${C_RESET}"
374
- ;;
375
- classic)
376
- echo " • Preview in ${C_YELLOW}Preview.app${C_RESET}, then copy to project:"
377
- echo " ${C_DIM}cp $OUTPUT/{DefaultIcon,DefaultIcon-ios,iTunesConnect,MarketplaceArtwork}.png $PROJECT_ROOT/${C_RESET}"
378
- echo " ${C_DIM}cp -R $OUTPUT/platform/android/res/. $PROJECT_ROOT/platform/android/res/${C_RESET}"
379
- ;;
380
- *)
381
- echo " • Review ${C_YELLOW}$OUTPUT/${C_RESET} and copy files to their final paths manually."
382
- ;;
383
- esac
384
- echo " • Cleanup staging: ${C_DIM}rm -rf $OUTPUT${C_RESET}"
385
- fi
386
- echo
387
- log_info "Pass ${C_BOLD}--notes${C_RESET} to print tiapp.xml snippets + padding tuning guide."
388
- echo
389
- exit 0
390
- fi
391
-
392
- # ---------------------------------------------------------------------------
393
- # Full notes (with --notes) — tiapp.xml snippets, padding tuning, etc.
394
- # ---------------------------------------------------------------------------
395
-
396
- echo
397
- echo "${C_BOLD}Notes on what was generated${C_RESET}"
398
- echo
399
- echo " • Brand color ${BG_COLOR} was baked into Android adaptive background layer"
400
- echo " and iOS/marketplace flattened masters (Apple rejects alpha)."
401
- echo " • Android padding: ${PADDING}% (logo fills $((100 - 2 * PADDING))% of each mipmap canvas)"
402
- echo " • iOS padding: ${IOS_PADDING}% (logo fills $((100 - 2 * IOS_PADDING))% of DefaultIcon-ios and marketplace art)"
403
- echo
404
- echo " If the logo looks ${C_DIM}pegado / cramped${C_RESET}: re-run with higher padding"
405
- echo " --padding ${C_YELLOW}25-30${C_RESET} (Android)"
406
- echo " --ios-padding ${C_YELLOW}8-12${C_RESET} (iOS)"
407
- echo
408
- echo " If the logo looks ${C_DIM}too small / lost${C_RESET}: re-run with lower padding"
409
- echo " --padding ${C_YELLOW}19${C_RESET} (Android spec floor)"
410
- echo " --ios-padding ${C_YELLOW}2-3${C_RESET} (matches first-party apps like Mail, Safari)"
411
-
412
- echo
413
- echo "${C_BOLD}Configuration reminders${C_RESET}"
414
- echo " ${C_DIM}The skill does NOT auto-create XML resource files or edit tiapp.xml.${C_RESET}"
415
- echo " ${C_DIM}Every snippet below is optional — paste only what you need, after reviewing.${C_RESET}"
416
- echo
417
- echo " ${C_YELLOW}⚠${C_RESET} ${C_BOLD}tiapp.xml <application> tag may be self-closing${C_RESET}"
418
- echo " If yours looks like:"
419
- echo " ${C_DIM}<application android:icon=\"@mipmap/ic_launcher\" .../>${C_RESET}"
420
- echo " You must expand it BEFORE adding children:"
421
- echo " ${C_DIM}<application android:icon=\"@mipmap/ic_launcher\" ...>${C_RESET}"
422
- echo " ${C_DIM} <meta-data .../>${C_RESET}"
423
- echo " ${C_DIM}</application>${C_RESET}"
424
- echo
425
- echo " ${C_BOLD}1. iOS launch background${C_RESET} — under ${C_YELLOW}<ios>${C_RESET} in tiapp.xml:"
426
- echo " ${C_DIM}Matches your --bg-color to the launch storyboard.${C_RESET}"
427
- cat <<EOF
428
- <ios>
429
- <enable-launch-screen-storyboard>true</enable-launch-screen-storyboard>
430
- <default-background-color>${BG_COLOR}</default-background-color>
431
- </ios>
432
- EOF
433
- echo
434
- echo " ${C_BOLD}2. Android launcher icon${C_RESET} — under ${C_YELLOW}<android><manifest><application>${C_RESET}:"
435
- echo " ${C_DIM}Required for the adaptive icon you just generated to be used.${C_RESET}"
436
- cat <<'EOF'
437
- <application android:icon="@mipmap/ic_launcher"
438
- android:usesCleartextTraffic="false"/>
439
- EOF
440
-
441
- if [[ $WITH_SPLASH_ICON -eq 1 ]]; then
442
- echo
443
- echo " ${C_BOLD}3. Android 12+ splash screen — OPTIONAL, advanced${C_RESET}"
444
- echo
445
- echo " Titanium SDK 13.x shows a system splash automatically using your launcher"
446
- echo " icon. ${C_YELLOW}For most apps THE DEFAULT IS ENOUGH — do nothing.${C_RESET}"
447
- echo
448
- echo " If you experience a visible ${C_BOLD}FLICKER${C_RESET} at the end of the splash (brief"
449
- echo " color flash before index.js renders), that is the system splash background"
450
- echo " mismatching your first Titanium activity background."
451
- echo
452
- echo " Fixing it requires adding a custom theme + wiring it in tiapp.xml. This is"
453
- echo " ${C_BOLD}INVASIVE${C_RESET} — do NOT auto-apply the snippet below without:"
454
- echo " ${C_DIM}(a) verifying the parent theme you pick actually exists in your${C_RESET}"
455
- echo " ${C_DIM} Titanium SDK version (theme names vary across SDK releases)${C_RESET}"
456
- echo " ${C_DIM}(b) checking whether your project already has a custom theme —${C_RESET}"
457
- echo " ${C_DIM} if so, EXTEND it instead of overriding via android:theme${C_RESET}"
458
- echo " ${C_DIM}(c) testing the build succeeds before committing tiapp.xml${C_RESET}"
459
- echo
460
- echo " ${C_DIM}Template (verify parent theme exists in your SDK before using):${C_RESET}"
461
- cat <<EOF
462
- <!-- app/platform/android/res/values/splash_theme.xml -->
463
- <?xml version="1.0" encoding="utf-8"?>
464
- <resources>
465
- <style name="Theme.App.Splash" parent="@style/YOUR_APP_PARENT_THEME">
466
- <item name="android:windowSplashScreenBackground">${BG_COLOR}</item>
467
- <item name="android:windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
468
- </style>
469
- </resources>
470
- EOF
471
- echo
472
- echo " ${C_BOLD}Known-working parent${C_RESET} (confirmed in Titanium SDK 13.2.0):"
473
- echo " ${C_DIM}@style/Theme.Titanium.Light.Fullscreen${C_RESET}"
474
- echo
475
- echo " If your SDK does not expose Theme.Titanium.Light.Fullscreen, check the"
476
- echo " styles.xml shipped with your installed SDK under the android/ folder —"
477
- echo " the available parent themes vary across SDK versions."
478
- echo
479
- echo " ${C_YELLOW}⚠${C_RESET} Do NOT inherit from ${C_DIM}@android:style/Theme.DeviceDefault.NoActionBar${C_RESET}."
480
- echo " That parent strips the ActionBar from every screen in your app."
481
- echo
482
- echo " ${C_DIM}The splash_icon.png × 5 files are generated for advanced use (custom${C_RESET}"
483
- echo " ${C_DIM}splash icon distinct from launcher). Most apps do NOT need them —${C_RESET}"
484
- echo " ${C_DIM}Titanium falls back to the launcher icon for the system splash.${C_RESET}"
485
- fi
486
-
487
- if [[ $WITH_NOTIFICATION -eq 1 ]]; then
488
- case "$PROJECT_TYPE" in
489
- alloy) COLORS_DIR="app/platform/android/res/values" ;;
490
- classic) COLORS_DIR="platform/android/res/values" ;;
491
- *) COLORS_DIR="platform/android/res/values" ;;
492
- esac
493
- echo
494
- echo " ${C_BOLD}4. FCM notification icon + tint${C_RESET}"
495
- echo " ${C_DIM}Only needed if you use firebase.cloudmessaging for push. The white-on-${C_RESET}"
496
- echo " ${C_DIM}transparent icon was generated; you still need to wire it.${C_RESET}"
497
- echo
498
- echo " ${C_DIM}Create ${COLORS_DIR}/colors.xml (if missing) or merge into existing:${C_RESET}"
499
- cat <<EOF
500
- <?xml version="1.0" encoding="utf-8"?>
501
- <resources>
502
- <color name="notification_tint">${BG_COLOR}</color>
503
- </resources>
504
- EOF
505
- echo
506
- echo " ${C_DIM}Then under <android><manifest><application> in tiapp.xml:${C_RESET}"
507
- cat <<'EOF'
508
- <meta-data android:name="com.google.firebase.messaging.default_notification_icon"
509
- android:resource="@drawable/ic_stat_notify"/>
510
- <meta-data android:name="com.google.firebase.messaging.default_notification_color"
511
- android:resource="@color/notification_tint"/>
512
- EOF
513
- fi
514
-
515
- echo
516
- echo "${C_BOLD}Next steps${C_RESET}"
517
- echo
518
- if [[ $IS_IN_PLACE -eq 1 ]]; then
519
- echo " 1. Preview the new icons in ${C_YELLOW}Preview.app${C_RESET} — the files in your project"
520
- echo " were overwritten directly (no staging directory was used)."
521
- echo " 2. If something looks wrong, restore from git: ${C_DIM}git checkout -- .${C_RESET}"
522
- echo " 3. Rebuild: ${C_DIM}ti clean && ti build -p android -T emulator${C_RESET}"
523
- else
524
- echo " 1. Preview in ${C_YELLOW}Preview.app${C_RESET} (never use ${C_DIM}open${C_RESET} without -a — triggers heavy editors)"
525
- case "$PROJECT_TYPE" in
526
- alloy)
527
- echo " 2. If good, copy to project:"
528
- echo " cp $OUTPUT/DefaultIcon.png $OUTPUT/DefaultIcon-ios.png $OUTPUT/iTunesConnect.png $OUTPUT/MarketplaceArtwork.png $PROJECT_ROOT/"
529
- echo " cp -R $OUTPUT/app/platform/android/res/. $PROJECT_ROOT/app/platform/android/res/"
530
- ;;
531
- classic)
532
- echo " 2. If good, copy to project:"
533
- echo " cp $OUTPUT/DefaultIcon.png $OUTPUT/DefaultIcon-ios.png $OUTPUT/iTunesConnect.png $OUTPUT/MarketplaceArtwork.png $PROJECT_ROOT/"
534
- echo " cp -R $OUTPUT/platform/android/res/. $PROJECT_ROOT/platform/android/res/"
535
- ;;
536
- *)
537
- echo " 2. Review staging dir and copy files to their final paths manually."
538
- ;;
539
- esac
540
- echo " 3. Cleanup staging: rm -rf $OUTPUT"
541
- echo " 4. Rebuild: ${C_DIM}ti clean && ti build -p android -T emulator${C_RESET}"
542
- fi
543
- echo
544
- else
545
- log_info "Dry-run complete. Re-run without --dry-run to write files."
546
- fi