@maccesar/titools 2.0.7 → 2.2.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.
- package/{AGENTS-TEMPLATE.md → AGENTS-VERCEL-RESEARCH.md} +16 -18
- package/README.md +250 -168
- package/agents/{ti-researcher.md → ti-pro.md} +10 -10
- package/bin/titools.js +16 -12
- package/lib/cleanup.js +95 -0
- package/lib/commands/agents.js +146 -70
- package/lib/commands/skills.js +349 -0
- package/lib/commands/uninstall.js +189 -154
- package/lib/commands/update.js +104 -21
- package/lib/config.js +26 -20
- package/lib/downloader.js +1 -1
- package/lib/installer.js +37 -97
- package/lib/platform.js +9 -5
- package/lib/prompts/checkboxCancel.js +264 -0
- package/lib/prompts/selectCancel.js +204 -0
- package/lib/symlink.js +19 -7
- package/lib/utils.js +17 -17
- package/package.json +10 -10
- package/skills/alloy-guides/SKILL.md +8 -30
- package/skills/alloy-guides/references/CLI_TASKS.md +14 -24
- package/skills/alloy-guides/references/CONCEPTS.md +5 -25
- package/skills/alloy-guides/references/CONTROLLERS.md +2 -19
- package/skills/alloy-guides/references/MODELS.md +40 -10
- package/skills/alloy-guides/references/PURGETSS.md +1 -11
- package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +8 -14
- package/skills/alloy-guides/references/VIEWS_STYLES.md +14 -25
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +2 -8
- package/skills/alloy-guides/references/VIEWS_XML.md +29 -40
- package/skills/alloy-guides/references/WIDGETS.md +1 -17
- package/skills/alloy-howtos/SKILL.md +1 -22
- package/skills/alloy-howtos/references/best_practices.md +0 -17
- package/skills/alloy-howtos/references/cli_reference.md +1 -23
- package/skills/alloy-howtos/references/config_files.md +86 -15
- package/skills/alloy-howtos/references/custom_tags.md +14 -13
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +3 -22
- package/skills/alloy-howtos/references/samples.md +4 -14
- package/skills/purgetss/SKILL.md +11 -37
- package/skills/purgetss/references/EXAMPLES.md +106 -17
- package/skills/purgetss/references/animation-system.md +0 -67
- package/skills/purgetss/references/apply-directive.md +0 -18
- package/skills/purgetss/references/arbitrary-values.md +0 -25
- package/skills/purgetss/references/class-index.md +0 -46
- package/skills/purgetss/references/cli-commands.md +0 -41
- package/skills/purgetss/references/configurable-properties.md +0 -55
- package/skills/purgetss/references/custom-rules.md +0 -14
- package/skills/purgetss/references/customization-deep-dive.md +0 -49
- package/skills/purgetss/references/dynamic-component-creation.md +56 -37
- package/skills/purgetss/references/grid-layout.md +0 -32
- package/skills/purgetss/references/icon-fonts.md +0 -50
- package/skills/purgetss/references/installation-setup.md +61 -32
- package/skills/purgetss/references/migration-guide.md +127 -0
- package/skills/purgetss/references/opacity-modifier.md +0 -34
- package/skills/purgetss/references/performance-tips.md +261 -0
- package/skills/purgetss/references/platform-modifiers.md +0 -46
- package/skills/purgetss/references/smart-mappings.md +0 -12
- package/skills/purgetss/references/tikit-components.md +393 -0
- package/skills/purgetss/references/titanium-resets.md +1 -27
- package/skills/purgetss/references/ui-ux-design.md +467 -117
- package/skills/{alloy-expert → ti-expert}/SKILL.md +45 -54
- package/skills/ti-expert/references/alloy-builtins.md +387 -0
- package/skills/{alloy-expert → ti-expert}/references/alloy-structure.md +147 -40
- package/skills/ti-expert/references/anti-patterns.md +90 -0
- package/skills/ti-expert/references/cli-expert.md +109 -0
- package/skills/{alloy-expert → ti-expert}/references/code-conventions.md +182 -49
- package/skills/{alloy-expert → ti-expert}/references/controller-patterns.md +103 -93
- package/skills/{alloy-expert → ti-expert}/references/error-handling.md +12 -12
- package/skills/{alloy-expert → ti-expert}/references/examples.md +144 -85
- package/skills/{alloy-expert → ti-expert}/references/migration-patterns.md +38 -36
- package/skills/{alloy-expert → ti-expert}/references/patterns.md +8 -8
- package/skills/ti-expert/references/performance-listview.md +251 -0
- package/skills/{alloy-expert/references/performance-patterns.md → ti-expert/references/performance-optimization.md} +67 -283
- package/skills/{alloy-expert/references/security-patterns.md → ti-expert/references/security-device.md} +12 -295
- package/skills/ti-expert/references/security-fundamentals.md +284 -0
- package/skills/{alloy-expert → ti-expert}/references/state-management.md +10 -10
- package/skills/ti-expert/references/testing-e2e-ci.md +432 -0
- package/skills/ti-expert/references/testing-unit.md +433 -0
- package/skills/ti-expert/references/theming.md +394 -0
- package/skills/ti-guides/SKILL.md +1 -14
- package/skills/ti-guides/references/advanced-data-and-images.md +126 -10
- package/skills/ti-guides/references/app-distribution.md +48 -10
- package/skills/ti-guides/references/application-frameworks.md +9 -2
- package/skills/ti-guides/references/cli-reference.md +338 -82
- package/skills/ti-guides/references/coding-best-practices.md +14 -4
- package/skills/ti-guides/references/commonjs-advanced.md +103 -6
- package/skills/ti-guides/references/hello-world.md +5 -2
- package/skills/ti-guides/references/hyperloop-native-access.md +439 -46
- package/skills/ti-guides/references/javascript-primer.md +4 -3
- package/skills/ti-guides/references/resources.md +0 -1
- package/skills/ti-guides/references/style-and-conventions.md +57 -9
- package/skills/ti-guides/references/tiapp-config.md +48 -6
- package/skills/ti-howtos/SKILL.md +2 -27
- package/skills/ti-howtos/references/android-platform-deep-dives.md +41 -90
- package/skills/ti-howtos/references/automation-fastlane-appium.md +15 -14
- package/skills/ti-howtos/references/buffer-codec-streams.md +22 -22
- package/skills/ti-howtos/references/cross-platform-development.md +68 -37
- package/skills/ti-howtos/references/debugging-profiling.md +8 -53
- package/skills/ti-howtos/references/extending-titanium.md +12 -51
- package/skills/ti-howtos/references/google-maps-v2.md +30 -29
- package/skills/ti-howtos/references/ios-map-kit.md +19 -25
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +95 -283
- package/skills/ti-howtos/references/local-data-sources.md +45 -37
- package/skills/ti-howtos/references/location-and-maps.md +47 -28
- package/skills/ti-howtos/references/media-apis.md +84 -27
- package/skills/ti-howtos/references/notification-services.md +40 -89
- package/skills/ti-howtos/references/remote-data-sources.md +21 -36
- package/skills/ti-howtos/references/tutorials.md +79 -39
- package/skills/ti-howtos/references/using-modules.md +4 -30
- package/skills/ti-howtos/references/web-content-integration.md +28 -45
- package/skills/ti-howtos/references/webpack-build-pipeline.md +54 -18
- package/skills/ti-ui/SKILL.md +1 -21
- package/skills/ti-ui/references/accessibility-deep-dive.md +71 -25
- package/skills/ti-ui/references/animation-and-matrices.md +0 -47
- package/skills/ti-ui/references/application-structures.md +0 -46
- package/skills/ti-ui/references/custom-fonts-styling.md +9 -57
- package/skills/ti-ui/references/event-handling.md +32 -40
- package/skills/ti-ui/references/gestures.md +0 -40
- package/skills/ti-ui/references/icons-and-splash-screens.md +21 -44
- package/skills/ti-ui/references/layouts-and-positioning.md +47 -39
- package/skills/ti-ui/references/listviews-and-performance.md +187 -73
- package/skills/ti-ui/references/orientation.md +57 -71
- package/skills/ti-ui/references/platform-ui-android.md +114 -48
- package/skills/ti-ui/references/platform-ui-ios.md +63 -38
- package/skills/ti-ui/references/scrolling-views.md +14 -23
- package/skills/ti-ui/references/tableviews.md +6 -56
- package/lib/commands/install.js +0 -188
- package/skills/alloy-expert/references/anti-patterns.md +0 -133
- package/skills/alloy-expert/references/testing.md +0 -872
- package/skills/ti-guides/references/alloy-cli-advanced.md +0 -84
- package/skills/ti-guides/references/alloy-data-mastery.md +0 -29
- package/skills/ti-guides/references/alloy-widgets-and-themes.md +0 -19
- /package/skills/{alloy-expert → ti-expert}/assets/ControllerAutoCleanup.js +0 -0
- /package/skills/{alloy-expert → ti-expert}/references/contracts.md +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Essential JavaScript concepts, resources, and best practices for Titanium development.
|
|
4
4
|
|
|
5
|
-
## Table of Contents
|
|
6
5
|
1. [JavaScript Overview](#javascript-overview)
|
|
7
6
|
2. [Learning Resources](#learning-resources)
|
|
8
7
|
3. [Best Practices](#best-practices)
|
|
@@ -45,7 +44,7 @@ JavaScript is the language of Titanium. It's a powerful, lightweight, dynamic ob
|
|
|
45
44
|
- **[MDN JavaScript Guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide)** - Comprehensive JavaScript documentation
|
|
46
45
|
- **[Douglas Crockford's Resources](http://javascript.crockford.com/)** - From the creator of JSON and JSLint
|
|
47
46
|
- **[JavaScript in 10 Minutes](https://github.com/spencertipping/js-in-ten-minutes)** - Dense advanced guide
|
|
48
|
-
- **[Google JavaScript Style Guide](
|
|
47
|
+
- **[Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)** - Code style guidelines
|
|
49
48
|
- **[Learning Advanced JavaScript](http://ejohn.org/apps/learn/)** - By John Resig (jQuery creator)
|
|
50
49
|
|
|
51
50
|
### Print Books (Recommended)
|
|
@@ -137,6 +136,8 @@ for (let i = 0, j = names.length; i < j; i++) {
|
|
|
137
136
|
}
|
|
138
137
|
```
|
|
139
138
|
|
|
139
|
+
This is especially important when working with Titanium proxy objects (representing native OS structures), where checking length on each iteration has additional overhead.
|
|
140
|
+
|
|
140
141
|
**Even better:** ES6 `for...of`
|
|
141
142
|
```javascript
|
|
142
143
|
for (const name of names) {
|
|
@@ -161,7 +162,7 @@ const z = 30; // Cannot be reassigned
|
|
|
161
162
|
|
|
162
163
|
### Ternary Operator
|
|
163
164
|
|
|
164
|
-
Compact conditional assignment
|
|
165
|
+
Compact conditional assignment. Value after `?` is assigned if the condition is true; value after `:` if false.
|
|
165
166
|
|
|
166
167
|
```javascript
|
|
167
168
|
// Instead of this:
|
|
@@ -6,10 +6,38 @@
|
|
|
6
6
|
- **Classes/Constructors**: `PascalCase` (e.g., `User`, `NetClient`).
|
|
7
7
|
- **Factories**: Prefix with `create` (e.g., `createWidget`).
|
|
8
8
|
- **Namespaces**: Use capitalized words (e.g., `App.UI.Widget`, `App.Network.Request`). Avoid lowercase for major namespaces (e.g., use `App.UI` instead of `app.ui`).
|
|
9
|
+
- **Hungarian Notation**: Titanium SDK does not support the use of Hungarian Notation.
|
|
9
10
|
|
|
10
|
-
## 2.
|
|
11
|
-
- **Semicolons**:
|
|
12
|
-
-
|
|
11
|
+
## 2. Language Rules
|
|
12
|
+
- **Semicolons**: Always use semicolons to terminate statements. This is mandatory in official SDK guides, but **omitted** in the `ti-expert` standard (let ASI handle it).
|
|
13
|
+
- **`this` keyword**: Use `this` with extreme care, as it sometimes doesn't refer to the object you expect.
|
|
14
|
+
|
|
15
|
+
## 3. Formatting
|
|
16
|
+
- **Indentation**: Both K&R/1TBS and Allman styles are acceptable. Consistency is most important — never mix styles in the same project.
|
|
17
|
+
```javascript
|
|
18
|
+
// K&R/1TBS Style
|
|
19
|
+
if (x < 10) {
|
|
20
|
+
if (y > 10) {
|
|
21
|
+
// do this
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
// do this
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
```javascript
|
|
28
|
+
// Allman Style
|
|
29
|
+
if (x < 10)
|
|
30
|
+
{
|
|
31
|
+
if (y > 10)
|
|
32
|
+
{
|
|
33
|
+
// do this
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
{
|
|
38
|
+
// do this
|
|
39
|
+
}
|
|
40
|
+
```
|
|
13
41
|
- **Operators**: Add a single space around operators.
|
|
14
42
|
```javascript
|
|
15
43
|
const fullName = firstName + ' ' + lastName
|
|
@@ -30,19 +58,39 @@ return {
|
|
|
30
58
|
}
|
|
31
59
|
```
|
|
32
60
|
|
|
33
|
-
##
|
|
61
|
+
## 4. Control Statements
|
|
62
|
+
- Switch statements should have a single space before the opening parenthesis and a single space after the closing parenthesis. Switch content is indented with one tab; content in each case is indented one tab as well.
|
|
63
|
+
```javascript
|
|
64
|
+
switch (someTest) {
|
|
65
|
+
case 1:
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
case 2:
|
|
69
|
+
break;
|
|
70
|
+
|
|
71
|
+
default:
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 5. Primitive Types
|
|
34
77
|
- Avoid using primitive type object constructors (e.g., `new String()`).
|
|
35
78
|
- Use template literals or single space concatenation.
|
|
36
79
|
|
|
37
|
-
##
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
## 5. Comments and Documentation
|
|
41
|
-
- **Single-line comments**: Preferred for short explanations.
|
|
80
|
+
## 6. Comments and Documentation
|
|
81
|
+
- **Single-line comments**: Required to reduce programmer error. Inline statement comments should be used at a minimum or not at all.
|
|
42
82
|
- **JSDoc/Block comments**: Required for documenting functions and classes.
|
|
43
83
|
```javascript
|
|
84
|
+
// Calculate position using initial
|
|
85
|
+
// and offset x coordinates.
|
|
86
|
+
const finalPos = initPosX + offsetPosX;
|
|
87
|
+
|
|
44
88
|
/**
|
|
45
89
|
* @param {String} customerName Customer's full name.
|
|
46
90
|
*/
|
|
47
91
|
function getCustomer(customerName) {}
|
|
48
92
|
```
|
|
93
|
+
|
|
94
|
+
## 7. References
|
|
95
|
+
- Douglas Crockford's JavaScript Code Conventions
|
|
96
|
+
- Google's JavaScript Style Guide (https://google.github.io/styleguide/jsguide.html)
|
|
@@ -19,14 +19,14 @@ Complete reference for Titanium app configuration files. `tiapp.xml` is the main
|
|
|
19
19
|
<dict>
|
|
20
20
|
<key>UISupportedInterfaceOrientations~iphone</key>
|
|
21
21
|
<array>
|
|
22
|
-
<string>
|
|
22
|
+
<string>UIInterfaceOrientationPortrait</string>
|
|
23
23
|
</array>
|
|
24
24
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
|
25
25
|
<array>
|
|
26
|
-
<string>
|
|
27
|
-
<string>
|
|
28
|
-
<string>
|
|
29
|
-
<string>
|
|
26
|
+
<string>UIInterfaceOrientationPortrait</string>
|
|
27
|
+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
|
28
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
29
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
30
30
|
</array>
|
|
31
31
|
</dict>
|
|
32
32
|
</plist>
|
|
@@ -71,6 +71,13 @@ Complete reference for Titanium app configuration files. `tiapp.xml` is the main
|
|
|
71
71
|
|
|
72
72
|
### Optional Elements
|
|
73
73
|
|
|
74
|
+
#### `<defaultLang>`
|
|
75
|
+
Sets the default language for Android i18n `strings.xml`. Android defaults to `en`. If you only use a single non-English i18n file, set this to that language.
|
|
76
|
+
|
|
77
|
+
```xml
|
|
78
|
+
<defaultLang>de</defaultLang>
|
|
79
|
+
```
|
|
80
|
+
|
|
74
81
|
#### `<copyright>`
|
|
75
82
|
Application copyright.
|
|
76
83
|
|
|
@@ -202,6 +209,20 @@ Default unit for sizes/positions.
|
|
|
202
209
|
|
|
203
210
|
**Values:** `system`, `cm`, `dip`/`dp`, `in`, `mm`, `px`
|
|
204
211
|
|
|
212
|
+
#### `run-on-main-thread`
|
|
213
|
+
**Since 5.1.0.** Run all JavaScript on the main thread instead of a secondary thread. Disabled by default in existing projects, enabled in new projects. Enabled automatically in SDK 7.0.0+.
|
|
214
|
+
|
|
215
|
+
```xml
|
|
216
|
+
<property name="run-on-main-thread" type="bool">true</property>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### `allow-custom-keyboards`
|
|
220
|
+
**Since 6.1.0.** Allow or disallow custom iOS 8+ keyboard extensions. Custom keyboards are allowed by default. Set to `false` to disallow them.
|
|
221
|
+
|
|
222
|
+
```xml
|
|
223
|
+
<property name="allow-custom-keyboards" type="bool">false</property>
|
|
224
|
+
```
|
|
225
|
+
|
|
205
226
|
#### `appc-sourcecode-encryption-policy`
|
|
206
227
|
Encryption policy for app assets.
|
|
207
228
|
|
|
@@ -467,6 +488,10 @@ Settings for generated `Info.plist`. Uses key/value pairs.
|
|
|
467
488
|
<string>audio</string>
|
|
468
489
|
<string>location</string>
|
|
469
490
|
<string>voip</string>
|
|
491
|
+
<string>newsstand-content</string>
|
|
492
|
+
<string>external-accessory</string>
|
|
493
|
+
<string>bluetooth-central</string>
|
|
494
|
+
<string>bluetooth-peripheral</string>
|
|
470
495
|
</array>
|
|
471
496
|
</dict>
|
|
472
497
|
</plist>
|
|
@@ -480,8 +505,25 @@ Settings for generated `Info.plist`. Uses key/value pairs.
|
|
|
480
505
|
<array>
|
|
481
506
|
<string>telephony</string>
|
|
482
507
|
<string>wifi</string>
|
|
483
|
-
<string>
|
|
508
|
+
<string>sms</string>
|
|
509
|
+
<string>still-camera</string>
|
|
510
|
+
<string>auto-focus-camera</string>
|
|
511
|
+
<string>front-facing-camera</string>
|
|
512
|
+
<string>camera-flash</string>
|
|
513
|
+
<string>video-camera</string>
|
|
484
514
|
<string>accelerometer</string>
|
|
515
|
+
<string>gyroscope</string>
|
|
516
|
+
<string>location-services</string>
|
|
517
|
+
<string>gps</string>
|
|
518
|
+
<string>magnetometer</string>
|
|
519
|
+
<string>gamekit</string>
|
|
520
|
+
<string>microphone</string>
|
|
521
|
+
<string>opengles-1</string>
|
|
522
|
+
<string>opengles-2</string>
|
|
523
|
+
<string>armv6</string>
|
|
524
|
+
<string>armv7</string>
|
|
525
|
+
<string>peer-peer</string>
|
|
526
|
+
<string>bluetooth-le</string>
|
|
485
527
|
</array>
|
|
486
528
|
</dict>
|
|
487
529
|
</plist>
|
|
@@ -28,31 +28,6 @@ This skill automatically detects Titanium projects when invoked and provides nat
|
|
|
28
28
|
- **Not detected** → Indicates this is for Titanium projects only
|
|
29
29
|
:::
|
|
30
30
|
|
|
31
|
-
## Table of Contents
|
|
32
|
-
|
|
33
|
-
- [Titanium SDK How-tos Expert](#titanium-sdk-how-tos-expert)
|
|
34
|
-
- [Project Detection](#project-detection)
|
|
35
|
-
- [Table of Contents](#table-of-contents)
|
|
36
|
-
- [Integration Workflow](#integration-workflow)
|
|
37
|
-
- [Native Integration Rules (Low Freedom)](#native-integration-rules-low-freedom)
|
|
38
|
-
- [iOS Permissions](#ios-permissions)
|
|
39
|
-
- [Android Resource Management](#android-resource-management)
|
|
40
|
-
- [Data \& Networking](#data--networking)
|
|
41
|
-
- [Media \& Memory](#media--memory)
|
|
42
|
-
- [Platform-Specific Properties](#platform-specific-properties)
|
|
43
|
-
- [Reference Guides (Progressive Disclosure)](#reference-guides-progressive-disclosure)
|
|
44
|
-
- [Core Features](#core-features)
|
|
45
|
-
- [Data Handling](#data-handling)
|
|
46
|
-
- [Media \& Content](#media--content)
|
|
47
|
-
- [Web Integration](#web-integration)
|
|
48
|
-
- [Platform-Specific (Android)](#platform-specific-android)
|
|
49
|
-
- [Platform-Specific (iOS)](#platform-specific-ios)
|
|
50
|
-
- [Advanced \& DevOps](#advanced--devops)
|
|
51
|
-
- [Related Skills](#related-skills)
|
|
52
|
-
- [Response Format](#response-format)
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
31
|
## Integration Workflow
|
|
57
32
|
|
|
58
33
|
1. **Requirement Check**: Identify needed permissions, `tiapp.xml` configurations, and module dependencies.
|
|
@@ -121,7 +96,7 @@ if (OS_IOS) {
|
|
|
121
96
|
- iOS: `statusBarStyle`, `modalStyle`, `modalTransitionStyle`, any `Ti.UI.iOS.*`
|
|
122
97
|
- Android: `actionBar` config, any `Ti.UI.Android.*` constant
|
|
123
98
|
|
|
124
|
-
**For platform-specific modifier syntax, see** [
|
|
99
|
+
**For platform-specific modifier syntax in TSS, see** [Code Conventions (ti-expert)](skills/ti-expert/references/code-conventions.md#platform--device-modifiers) or [Platform UI guides](references/ios-platform-deep-dives.md).
|
|
125
100
|
:::
|
|
126
101
|
|
|
127
102
|
## Reference Guides (Progressive Disclosure)
|
|
@@ -161,7 +136,7 @@ For tasks beyond native feature integration, use these complementary skills:
|
|
|
161
136
|
|
|
162
137
|
| Task | Use This Skill |
|
|
163
138
|
| ---------------------------------------------- | -------------- |
|
|
164
|
-
| Project architecture, services, memory cleanup | `
|
|
139
|
+
| Project architecture, services, memory cleanup | `ti-expert` |
|
|
165
140
|
| UI layouts, ListViews, gestures, animations | `ti-ui` |
|
|
166
141
|
| Hyperloop, app distribution, tiapp.xml config | `ti-guides` |
|
|
167
142
|
| Alloy MVC, models, data binding | `alloy-guides` |
|
|
@@ -1,63 +1,5 @@
|
|
|
1
1
|
# Android Platform Deep Dives
|
|
2
2
|
|
|
3
|
-
## Table of Contents
|
|
4
|
-
|
|
5
|
-
- [Android Platform Deep Dives](#android-platform-deep-dives)
|
|
6
|
-
- [Table of Contents](#table-of-contents)
|
|
7
|
-
- [1. Android Intent Filters (Advanced)](#1-android-intent-filters-advanced)
|
|
8
|
-
- [Critical Step: Copy Root Activity](#critical-step-copy-root-activity)
|
|
9
|
-
- [Retrieving Intent Data](#retrieving-intent-data)
|
|
10
|
-
- [2. Broadcast Intents with Permissions](#2-broadcast-intents-with-permissions)
|
|
11
|
-
- [Sending with Permission](#sending-with-permission)
|
|
12
|
-
- [Declaring Permission in tiapp.xml](#declaring-permission-in-tiappxml)
|
|
13
|
-
- [3. FusedLocationProvider (TiSDK 7.1.0+)](#3-fusedlocationprovider-tisdk-710)
|
|
14
|
-
- [4. Android Intents](#4-android-intents)
|
|
15
|
-
- [Overview](#overview)
|
|
16
|
-
- [Intent Structure](#intent-structure)
|
|
17
|
-
- [Creating Intents](#creating-intents)
|
|
18
|
-
- [Simple Intent (Action only)](#simple-intent-action-only)
|
|
19
|
-
- [Intent with Action and Data](#intent-with-action-and-data)
|
|
20
|
-
- [Intent with Extras](#intent-with-extras)
|
|
21
|
-
- [Common Use Cases](#common-use-cases)
|
|
22
|
-
- [Open URL in Browser](#open-url-in-browser)
|
|
23
|
-
- [Dial Phone Number](#dial-phone-number)
|
|
24
|
-
- [Send Email](#send-email)
|
|
25
|
-
- [Share Content](#share-content)
|
|
26
|
-
- [Open PDF File](#open-pdf-file)
|
|
27
|
-
- [Starting Other Apps](#starting-other-apps)
|
|
28
|
-
- [2. Intent Filters](#2-intent-filters)
|
|
29
|
-
- [Overview](#overview-1)
|
|
30
|
-
- [Configuring in tiapp.xml](#configuring-in-tiappxml)
|
|
31
|
-
- [Handling Incoming Intents](#handling-incoming-intents)
|
|
32
|
-
- [Get Intent Data on Startup](#get-intent-data-on-startup)
|
|
33
|
-
- [Listen for New Intents (Activity Restart)](#listen-for-new-intents-activity-restart)
|
|
34
|
-
- [Deep Linking Example](#deep-linking-example)
|
|
35
|
-
- [3. Broadcast Intents and Receivers](#3-broadcast-intents-and-receivers)
|
|
36
|
-
- [Overview](#overview-2)
|
|
37
|
-
- [System Broadcasts](#system-broadcasts)
|
|
38
|
-
- [Registering Broadcast Receivers](#registering-broadcast-receivers)
|
|
39
|
-
- [Dynamic Registration (in code)](#dynamic-registration-in-code)
|
|
40
|
-
- [Network Change Listener](#network-change-listener)
|
|
41
|
-
- [Sending Custom Broadcasts](#sending-custom-broadcasts)
|
|
42
|
-
- [Receiver for Custom Broadcast](#receiver-for-custom-broadcast)
|
|
43
|
-
- [Boot Receiver](#boot-receiver)
|
|
44
|
-
- [4. Android Services](#4-android-services)
|
|
45
|
-
- [Overview](#overview-3)
|
|
46
|
-
- [Service Types](#service-types)
|
|
47
|
-
- [Creating a Service](#creating-a-service)
|
|
48
|
-
- [IntentService](#intentservice)
|
|
49
|
-
- [Foreground Service](#foreground-service)
|
|
50
|
-
- [Service Lifecycle Management](#service-lifecycle-management)
|
|
51
|
-
- [Inter-Service Communication](#inter-service-communication)
|
|
52
|
-
- [5. Android Permissions](#5-android-permissions)
|
|
53
|
-
- [Runtime Permissions (Android 6.0+)](#runtime-permissions-android-60)
|
|
54
|
-
- [Common Dangerous Permissions](#common-dangerous-permissions)
|
|
55
|
-
- [Best Practices](#best-practices)
|
|
56
|
-
- [Common Dangerous Permissions](#common-dangerous-permissions-1)
|
|
57
|
-
- [Best Practices](#best-practices-1)
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
3
|
## 1. Android Intent Filters (Advanced)
|
|
62
4
|
|
|
63
5
|
To allow your app to receive implicit intents (e.g., opening a PDF file or a web link), you must register the filter in the manifest.
|
|
@@ -165,8 +107,8 @@ const intent = Ti.Android.createIntent({
|
|
|
165
107
|
action: 'com.example.MY_ACTION',
|
|
166
108
|
type: 'text/plain'
|
|
167
109
|
});
|
|
168
|
-
intent.
|
|
169
|
-
intent.
|
|
110
|
+
intent.putExtra('message', 'Hello from Titanium');
|
|
111
|
+
intent.putExtra('count', 42);
|
|
170
112
|
```
|
|
171
113
|
|
|
172
114
|
### Common Use Cases
|
|
@@ -195,8 +137,8 @@ const intent = Ti.Android.createIntent({
|
|
|
195
137
|
action: Ti.Android.ACTION_SENDTO,
|
|
196
138
|
data: 'mailto:user@example.com'
|
|
197
139
|
});
|
|
198
|
-
intent.
|
|
199
|
-
intent.
|
|
140
|
+
intent.putExtra(Ti.Android.EXTRA_SUBJECT, 'Hello');
|
|
141
|
+
intent.putExtra(Ti.Android.EXTRA_TEXT, 'Email body');
|
|
200
142
|
Ti.Android.currentActivity.startActivity(intent);
|
|
201
143
|
```
|
|
202
144
|
|
|
@@ -206,7 +148,7 @@ const intent = Ti.Android.createIntent({
|
|
|
206
148
|
action: Ti.Android.ACTION_SEND,
|
|
207
149
|
type: 'text/plain'
|
|
208
150
|
});
|
|
209
|
-
intent.
|
|
151
|
+
intent.putExtra(Ti.Android.EXTRA_TEXT, 'Check this out!');
|
|
210
152
|
Ti.Android.currentActivity.startActivity(intent);
|
|
211
153
|
```
|
|
212
154
|
|
|
@@ -236,7 +178,37 @@ try {
|
|
|
236
178
|
}
|
|
237
179
|
```
|
|
238
180
|
|
|
239
|
-
|
|
181
|
+
### Intent Chooser
|
|
182
|
+
Force the system to show an app chooser dialog (even if a default is set):
|
|
183
|
+
```javascript
|
|
184
|
+
const intent = Ti.Android.createIntent({
|
|
185
|
+
action: Ti.Android.ACTION_SEND,
|
|
186
|
+
type: 'text/plain'
|
|
187
|
+
});
|
|
188
|
+
intent.putExtra(Ti.Android.EXTRA_TEXT, 'Share this text');
|
|
189
|
+
|
|
190
|
+
Ti.Android.currentActivity.startActivity(
|
|
191
|
+
Ti.Android.createIntentChooser(intent, 'Share via...')
|
|
192
|
+
);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Getting Results from Activities
|
|
196
|
+
```javascript
|
|
197
|
+
const intent = Ti.Android.createIntent({
|
|
198
|
+
action: 'android.media.action.IMAGE_CAPTURE'
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
Ti.Android.currentActivity.startActivityForResult(intent, (e) => {
|
|
202
|
+
if (e.resultCode === Ti.Android.RESULT_OK) {
|
|
203
|
+
const imageUri = e.intent.data;
|
|
204
|
+
Ti.API.info(`Captured image: ${imageUri}`);
|
|
205
|
+
} else if (e.resultCode === Ti.Android.RESULT_CANCELED) {
|
|
206
|
+
Ti.API.info('User canceled');
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## 5. Intent Filters
|
|
240
212
|
|
|
241
213
|
### Overview
|
|
242
214
|
Intent Filters advertise your app's capability to handle certain actions and data types. Enable deep linking, file handling, and inter-app communication.
|
|
@@ -338,7 +310,7 @@ if (intent && intent.getData()) {
|
|
|
338
310
|
}
|
|
339
311
|
```
|
|
340
312
|
|
|
341
|
-
##
|
|
313
|
+
## 6. Broadcast Intents and Receivers
|
|
342
314
|
|
|
343
315
|
### Overview
|
|
344
316
|
Broadcast Intents allow system-wide or app-wide messaging. Apps can send broadcasts and register receivers to listen for them.
|
|
@@ -413,7 +385,7 @@ Ti.Android.registerBroadcastReceiver(networkReceiver, [
|
|
|
413
385
|
const intent = Ti.Android.createIntent({
|
|
414
386
|
action: 'com.myapp.CUSTOM_EVENT'
|
|
415
387
|
});
|
|
416
|
-
intent.
|
|
388
|
+
intent.putExtra('data', 'Custom data here');
|
|
417
389
|
Ti.Android.currentActivity.sendBroadcast(intent);
|
|
418
390
|
```
|
|
419
391
|
|
|
@@ -452,7 +424,7 @@ Ti.Android.registerBroadcastReceiver(customReceiver, [
|
|
|
452
424
|
</android>
|
|
453
425
|
```
|
|
454
426
|
|
|
455
|
-
##
|
|
427
|
+
## 7. Android Services
|
|
456
428
|
|
|
457
429
|
### Overview
|
|
458
430
|
Services are background components that run independently of the UI. Useful for long-running operations like music playback, location tracking, or network polling.
|
|
@@ -573,7 +545,7 @@ Ti.Android.currentActivity.addEventListener('destroy', () => {
|
|
|
573
545
|
const intent = Ti.Android.createServiceIntent({
|
|
574
546
|
url: 'myservice.js'
|
|
575
547
|
});
|
|
576
|
-
intent.
|
|
548
|
+
intent.putExtra('command', 'pause');
|
|
577
549
|
Ti.Android.startService(intent);
|
|
578
550
|
|
|
579
551
|
// In service
|
|
@@ -583,7 +555,7 @@ if (command === 'pause') {
|
|
|
583
555
|
}
|
|
584
556
|
```
|
|
585
557
|
|
|
586
|
-
##
|
|
558
|
+
## 8. Android Permissions
|
|
587
559
|
|
|
588
560
|
### Runtime Permissions (Android 6.0+)
|
|
589
561
|
|
|
@@ -635,24 +607,3 @@ checkPermission();
|
|
|
635
607
|
6. **Validate intent data** before processing
|
|
636
608
|
7. **Use proper Intent Flags** for navigation behavior
|
|
637
609
|
8. **Test intent filters** with ADB: `adb shell am start -W -a android.intent.action.VIEW -d "myapp://path"`
|
|
638
|
-
|
|
639
|
-
### Common Dangerous Permissions
|
|
640
|
-
- `ACCESS_FINE_LOCATION` - GPS location
|
|
641
|
-
- `ACCESS_COARSE_LOCATION` - Network location
|
|
642
|
-
- `CAMERA` - Camera access
|
|
643
|
-
- `READ_EXTERNAL_STORAGE` - Read files
|
|
644
|
-
- `WRITE_EXTERNAL_STORAGE` - Write files
|
|
645
|
-
- `RECORD_AUDIO` - Microphone
|
|
646
|
-
- `CALL_PHONE` - Make phone calls
|
|
647
|
-
- `SEND_SMS` / `READ_SMS` - SMS access
|
|
648
|
-
|
|
649
|
-
## Best Practices
|
|
650
|
-
|
|
651
|
-
1. **Always unregister** broadcast receivers when no longer needed
|
|
652
|
-
2. **Stop services** explicitly to conserve battery
|
|
653
|
-
3. **Use IntentService** for one-off background tasks
|
|
654
|
-
4. **Use foreground services** for user-visible long operations
|
|
655
|
-
5. **Handle runtime permissions** gracefully on Android 6.0+
|
|
656
|
-
6. **Validate intent data** before processing
|
|
657
|
-
7. **Use proper Intent Flags** for navigation behavior
|
|
658
|
-
8. **Test intent filters** with ADB: `adb shell am start -W -a android.intent.action.VIEW -d "myapp://path"`
|
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Guide for setting up continuous integration pipelines, automatic testing, and deployment in Titanium.
|
|
4
4
|
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Automation with Fastlane and Appium](#automation-with-fastlane-and-appium)
|
|
8
|
-
- [Table of Contents](#table-of-contents)
|
|
9
|
-
- [1. UI Testing with Appium](#1-ui-testing-with-appium)
|
|
10
|
-
- [Prerequisites](#prerequisites)
|
|
11
|
-
- [Test Example (Mocha + WebdriverIO)](#test-example-mocha--webdriverio)
|
|
12
|
-
- [2. Automation with Fastlane](#2-automation-with-fastlane)
|
|
13
|
-
- [Titanium Plugins](#titanium-plugins)
|
|
14
|
-
- [Fastfile Configuration](#fastfile-configuration)
|
|
15
|
-
- [3. CI/CD Best Practices](#3-cicd-best-practices)
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
5
|
## 1. UI Testing with Appium
|
|
20
6
|
|
|
21
7
|
Appium allows for automated functional testing on real devices and simulators.
|
|
@@ -93,3 +79,18 @@ end
|
|
|
93
79
|
2. **Environment Lanes**: Define separate lanes for `beta`, `production`, and `test`.
|
|
94
80
|
3. **Profile Management**: Use Fastlane Match to sync certificates and provisioning profiles across the team.
|
|
95
81
|
4. **Snapshots**: Use Fastlane's `snapshot` action to automate App Store screenshot generation.
|
|
82
|
+
|
|
83
|
+
## 4. Unit Testing with TiUnit
|
|
84
|
+
|
|
85
|
+
For unit tests (non-UI), consider **TiUnit**, a Jasmine-based testing framework for Titanium:
|
|
86
|
+
- Runs tests inside the app context
|
|
87
|
+
- Supports standard Jasmine `describe`/`it`/`expect` syntax
|
|
88
|
+
- Can be integrated into CI pipelines
|
|
89
|
+
|
|
90
|
+
## 5. Broader CI/CD Options
|
|
91
|
+
|
|
92
|
+
Beyond Fastlane and Appium, Titanium apps can integrate with:
|
|
93
|
+
- **Jenkins** — for build orchestration and pipeline management
|
|
94
|
+
- **SonarQube** — for code quality analysis
|
|
95
|
+
- **AWS Device Farm** — for testing on real devices in the cloud
|
|
96
|
+
- **Nexus/Artifactory** — for build artifact archiving and versioning
|
|
@@ -2,25 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Guide for advanced binary data manipulation and data flows in Titanium SDK.
|
|
4
4
|
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Buffer, Codec, and Streams](#buffer-codec-and-streams)
|
|
8
|
-
- [Table of Contents](#table-of-contents)
|
|
9
|
-
- [1. Titanium.Buffer](#1-titaniumbuffer)
|
|
10
|
-
- [Creating Buffers](#creating-buffers)
|
|
11
|
-
- [Common Operations](#common-operations)
|
|
12
|
-
- [2. Titanium.Codec](#2-titaniumcodec)
|
|
13
|
-
- [Encoding Numbers](#encoding-numbers)
|
|
14
|
-
- [Decoding Strings](#decoding-strings)
|
|
15
|
-
- [3. Streams](#3-streams)
|
|
16
|
-
- [Stream Types](#stream-types)
|
|
17
|
-
- [Example: BufferStream](#example-bufferstream)
|
|
18
|
-
- [Example: FileStream (Chunk-based reading)](#example-filestream-chunk-based-reading)
|
|
19
|
-
- [Example: BlobStream (Camera to File)](#example-blobstream-camera-to-file)
|
|
20
|
-
- [4. Best Practices](#4-best-practices)
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
5
|
## 1. Titanium.Buffer
|
|
25
6
|
|
|
26
7
|
Buffers are mutable and resizable containers for bytes (byte arrays).
|
|
@@ -75,6 +56,23 @@ const text = Ti.Codec.decodeString({
|
|
|
75
56
|
});
|
|
76
57
|
```
|
|
77
58
|
|
|
59
|
+
### Supported Types and Charsets
|
|
60
|
+
|
|
61
|
+
**Numeric types**: `TYPE_BYTE`, `TYPE_SHORT`, `TYPE_INT`, `TYPE_LONG`, `TYPE_FLOAT`, `TYPE_DOUBLE`
|
|
62
|
+
|
|
63
|
+
**String charsets**: `CHARSET_UTF8`, `CHARSET_UTF16`, `CHARSET_UTF16BE`, `CHARSET_UTF16LE`, `CHARSET_ISO_LATIN1`
|
|
64
|
+
|
|
65
|
+
### Position Parameter
|
|
66
|
+
The `position` parameter controls where encoding/decoding starts in the buffer:
|
|
67
|
+
```javascript
|
|
68
|
+
Ti.Codec.encodeNumber({
|
|
69
|
+
source: 42,
|
|
70
|
+
dest: buffer,
|
|
71
|
+
position: 4, // start writing at byte 4
|
|
72
|
+
type: Ti.Codec.TYPE_INT
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
78
76
|
## 3. Streams
|
|
79
77
|
|
|
80
78
|
Streams allow reading and writing data in a serialized and memory-efficient way.
|
|
@@ -84,6 +82,8 @@ Streams allow reading and writing data in a serialized and memory-efficient way.
|
|
|
84
82
|
2. **FileStream**: For file operations (more efficient than `file.read()`).
|
|
85
83
|
3. **BlobStream**: Read-only for Blob objects (images, camera).
|
|
86
84
|
|
|
85
|
+
**Stream modes**: `Ti.Filesystem.MODE_READ`, `Ti.Filesystem.MODE_WRITE`, `Ti.Filesystem.MODE_APPEND`
|
|
86
|
+
|
|
87
87
|
### Example: BufferStream
|
|
88
88
|
```javascript
|
|
89
89
|
const buffer = Ti.createBuffer({ length: 1024 });
|
|
@@ -118,16 +118,16 @@ Ti.Media.showCamera({
|
|
|
118
118
|
source: e.media,
|
|
119
119
|
mode: Ti.Stream.MODE_READ
|
|
120
120
|
});
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
const outfile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'photo.jpg');
|
|
123
123
|
const outstream = outfile.open(Ti.Filesystem.MODE_WRITE);
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
const buffer = Ti.createBuffer({ length: 4096 });
|
|
126
126
|
let readBytes = 0;
|
|
127
127
|
while ((readBytes = instream.read(buffer)) > 0) {
|
|
128
128
|
outstream.write(buffer, 0, readBytes);
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
instream.close();
|
|
132
132
|
outstream.close();
|
|
133
133
|
}
|