├── .github ├── FUNDING.yml └── workflows │ └── cla.yaml ├── .gitignore ├── .travis.yml ├── README.md ├── android ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.jdt.apt.core.prefs │ └── org.eclipse.jdt.core.prefs ├── LICENSE ├── assets │ └── README.md ├── build.gradle ├── build.properties.example ├── build.xml ├── documentation │ ├── changelog.md │ └── index.md ├── example │ ├── app.js │ ├── application_image.png │ ├── demos │ │ ├── assetsDemo.js │ │ ├── constantsDemo.js │ │ ├── krollCallbacksAndEventsDemo.js │ │ ├── krollMethodsDemo.js │ │ ├── krollParametersDemo.js │ │ ├── krollPropertiesDemo.js │ │ ├── proxyDemo.js │ │ └── viewproxyDemo.js │ └── navigator.js ├── hooks │ ├── README │ ├── add.py │ ├── install.py │ ├── remove.py │ └── uninstall.py ├── lib │ └── .gitkeep ├── manifest ├── platform │ └── android │ │ └── res │ │ └── drawable │ │ └── module_image.png ├── src │ └── ti │ │ └── moddevguide │ │ ├── DemoView.java │ │ ├── DemoViewProxy.java │ │ ├── KrollDemoProxy.java │ │ ├── LifeCycleProxy.java │ │ ├── MethodsDemoProxy.java │ │ ├── ModdevguideModule.java │ │ └── ParametersDemoProxy.java └── timodule.xml └── ios ├── Classes ├── TiModdevguideDemoView.h ├── TiModdevguideDemoView.m ├── TiModdevguideDemoViewProxy.h ├── TiModdevguideDemoViewProxy.m ├── TiModdevguideKrollDemoProxy.h ├── TiModdevguideKrollDemoProxy.m ├── TiModdevguideLifeCycleProxy.h ├── TiModdevguideLifeCycleProxy.m ├── TiModdevguideMethodsDemoProxy.h ├── TiModdevguideMethodsDemoProxy.m ├── TiModdevguideModule.h ├── TiModdevguideModule.m ├── TiModdevguideModuleAssets.h ├── TiModdevguideModuleAssets.m ├── TiModdevguideParametersDemoProxy.h └── TiModdevguideParametersDemoProxy.m ├── LICENSE ├── README ├── TiModdevguide_Prefix.pch ├── assets ├── README └── module_image.png ├── build.py ├── documentation ├── changelog.md └── index.md ├── example ├── app.js ├── application_image.png ├── demos │ ├── assetsDemo.js │ ├── constantsDemo.js │ ├── krollCallbacksAndEventsDemo.js │ ├── krollMethodsDemo.js │ ├── krollParametersDemo.js │ ├── krollPropertiesDemo.js │ ├── proxyDemo.js │ └── viewproxyDemo.js └── navigator.js ├── hooks ├── README ├── add.py ├── install.py ├── remove.py └── uninstall.py ├── manifest ├── moddevguide.xcodeproj └── project.pbxproj ├── module.xcconfig ├── platform └── README ├── timodule.xml └── titanium.xcconfig /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: tidev 2 | liberapay: tidev 3 | -------------------------------------------------------------------------------- /.github/workflows/cla.yaml: -------------------------------------------------------------------------------- 1 | name: Check CLA 2 | on: 3 | - pull_request 4 | 5 | jobs: 6 | check-cla: 7 | runs-on: ubuntu-latest 8 | name: Verify contributor 9 | 10 | steps: 11 | - uses: tidev/tidev-cla-action@v1 12 | with: 13 | repo-token: ${{ secrets.GITHUB_TOKEN }} 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | tmp 3 | bin 4 | build 5 | dist 6 | *.zip 7 | */*/modules 8 | */*/modules* 9 | .apt_generated 10 | build.properties 11 | .gitignore 12 | .svn 13 | *.pyc 14 | *~.nib/ 15 | *.pbxuser 16 | *.perspective 17 | *.perspectivev3 18 | *.xcworkspace/ 19 | xcuserdata 20 | *.xcuserstate 21 | *.xcuserdata* 22 | 23 | .idea/ 24 | libs/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8.2 3 | env: 4 | global: 5 | - "ARTIFACTS_AWS_REGION=us-east-1" 6 | - "ARTIFACTS_S3_BUCKET=builds.appcelerator.com" 7 | - "MODULE_NAME=ti.moddevguide" 8 | - TRAVIS_NODE_VERSION="4" 9 | before_install: 10 | - MODULE_ROOT=$PWD 11 | - brew update 12 | - brew install nvm 13 | - source $(brew --prefix nvm)/nvm.sh 14 | - nvm install 4 15 | - npm config delete prefix 16 | - nvm use --delete-prefix v4.4.7 4 17 | install: 18 | - cd $MODULE_ROOT 19 | - curl -o install.sh https://raw.githubusercontent.com/sgtcoolguy/ci/v8/travis/install.sh #change this to appcelerator-modules once PR has been merged 20 | - source install.sh -s "--branch master" 21 | script: 22 | - curl -o script.sh https://raw.githubusercontent.com/sgtcoolguy/ci/v8/travis/script.sh 23 | - source script.sh 24 | after_success: # and this only on success 25 | - curl -o deploy.sh https://raw.githubusercontent.com/appcelerator-modules/ci/master/travis/deploy.sh 26 | - source deploy.sh 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Titanium Module Developer Guide [![Build Status](https://travis-ci.org/appcelerator-modules/ti.moddevguide.svg)](https://travis-ci.org/appcelerator-modules/ti.moddevguide) 2 | ======= 3 | 4 | This is the Module Developer's Guide for Titanium. It can be used by native module developers to understand the basic and 5 | advanced concepts to build own native modules for Titanium. 6 | 7 | ## Functionality 8 | This sample module provides the following components across iOS and Android: 9 | - [x] Module / app lifecycle 10 | - [x] View / proxy relationship 11 | - [x] Sending and receiving events ( `fireEvent` and `addEventListener`) 12 | - [x] Writing own setter / getter methods 13 | - [x] Validate user-input and provide proper error-handling 14 | - [x] Manage async tasks using callbacks 15 | 16 | ## Questions? 17 | If you have any questions, feel free to join the `#module_development` channel in the [TiSlack community](http://tislack.org) 18 | or ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/titanium). 19 | 20 | ## Contributors 21 | 22 | Interested in contributing? Read the [contributors/committer's](https://wiki.appcelerator.org/display/community/Home) guide. 23 | 24 | ## Legal 25 | 26 | This module is Copyright (c) 2010-present by Axway Appcelerator. All Rights Reserved. 27 | Usage of this module is subject to the Terms of Service agreement with Axway Appcelerator. 28 | -------------------------------------------------------------------------------- /android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 13 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | titanium-moddevguide 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /android/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | #Thu Sep 02 15:18:34 CDT 2010 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.apt.aptEnabled=true 4 | org.eclipse.jdt.apt.genSrcDir=.apt_generated 5 | org.eclipse.jdt.apt.reconcileEnabled=true 6 | 7 | org.eclipse.jdt.apt.processorOptions/kroll.jsonFile=moddevguide.json 8 | -------------------------------------------------------------------------------- /android/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Thu Sep 02 15:18:34 CDT 2010 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.processAnnotations=enabled 4 | -------------------------------------------------------------------------------- /android/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012-present Axway Appcelerator 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /android/assets/README.md: -------------------------------------------------------------------------------- 1 | Place your assets like PNG files in this directory and they will be packaged with your module. 2 | 3 | If you create a file named ti.moddevguide.js in this directory, it will be 4 | compiled and used as your module. This allows you to run pure Javascript 5 | modules that are pre-compiled. 6 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | dependencies { 3 | // Add the module's library dependencies here. 4 | // See: https://developer.android.com/studio/build/dependencies 5 | } 6 | -------------------------------------------------------------------------------- /android/build.properties.example: -------------------------------------------------------------------------------- 1 | titanium.sdk=/Library/Application\ Support/Titanium/ 2 | titanium.os=osx 3 | titanium.version=2.1.3.GA 4 | android.sdk=/usr/android-sdk 5 | 6 | titanium.platform=${titanium.sdk}/mobilesdk/${titanium.os}/${titanium.version}/android 7 | android.platform=${android.sdk}/platforms/android-8 8 | google.apis=${android.sdk}/add-ons/addon_google_apis_google_inc_8 -------------------------------------------------------------------------------- /android/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ant build script for Titanium Android module moddevguide 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/documentation/changelog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 |
 3 | v2.1.1  [TIMODOPEN-211] Removing TiContext because it is deprecated
 4 | 	
 5 | v2.1.0  [MOD-878] Updated to latest TiSDK module api v2
 6 | 	
 7 | v2.0.1  [MOD-637] Re-enabled requestDataWithCallback example functionality
 8 | 
 9 | v2.0	Upgraded to module api version 2 for 1.8.0.1
10 |         [MOD-346] Handle propertyChanged notification for unchanged values
11 | 
12 | v1.0    Initial Release
13 | 


--------------------------------------------------------------------------------
/android/documentation/index.md:
--------------------------------------------------------------------------------
 1 | # Ti.moddevguide Module
 2 | 
 3 | ## Description
 4 | 
 5 | Demonstrates various aspects of Android module development in Titanium.
 6 | 
 7 | This is a companion module to the Titanium [Android Module Development Guide](http://wiki.appcelerator.org/display/guides2/Android+Module+Development+Guide)
 8 | 
 9 | ## Accessing the Ti.moddevguide Module
10 | 
11 | To access this module from JavaScript, you would do the following:
12 | 
13 | 
var DevGuide = require('ti.moddevguide');
14 | 15 | ## Topics Covered 16 | 17 | ### Life Cycle 18 | 19 | Various aspects of the life cycle of module, proxy, and view proxy classes. 20 | 21 | #### Module Loading 22 | 23 | Demonstrates the methods that are called during module loading and unloading. 24 | 25 | #### Proxy Loading 26 | 27 | Demonstrates the methods that are called during proxy loading and unloading. 28 | 29 | #### View Proxy Loading 30 | 31 | Demonstrates the methods that are called during view proxy loading and unloading. Additionally, demonstrates the methods that are called during the creation and destruction of the associated view. 32 | 33 | ### Kroll 34 | 35 | #### Properties 36 | 37 | Demonstrates how to define and access properties. 38 | 39 | #### Methods 40 | 41 | Demonstrates how to define methods and pass arguments to those methods. 42 | 43 | #### Parameters 44 | 45 | Demonstrates how arguments are passed into methods. 46 | 47 | ### Miscellaneous 48 | 49 | #### Assets 50 | 51 | Demonstrates how to access both module and application assets from a module. 52 | 53 | ## Usage 54 | 55 | See example. 56 | 57 | ## Module History 58 | 59 | View the [change log](changelog.html) for this module. 60 | 61 | ## Author 62 | 63 | Jeff English 64 | 65 | ## Feedback and Support 66 | 67 | Please direct all questions, feedback, and concerns to [info@appcelerator.com](mailto:info@appcelerator.com?subject=Android%20moddevguide%20Module). 68 | 69 | ## License 70 | 71 | Copyright(c) 2010-2012 by Appcelerator, Inc. All Rights Reserved. Please see the LICENSE file included in the distribution for further details. 72 | -------------------------------------------------------------------------------- /android/example/app.js: -------------------------------------------------------------------------------- 1 | // Ensure that the module development guide module is loaded 2 | var DevGuide = require('ti.moddevguide'); 3 | 4 | // Open the main category selection page 5 | require('navigator').start(DevGuide); -------------------------------------------------------------------------------- /android/example/application_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidev/ti.moddevguide/dddbf86979952ea2bd7c3dd7acd8e94640d8d938/android/example/application_image.png -------------------------------------------------------------------------------- /android/example/demos/assetsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | var imageView = null; 5 | 6 | function handleLoadModuleImage(e) { 7 | var image = devGuide.loadImageFromModule('module_image.png'); 8 | if (image != null) { 9 | imageView.image = image; 10 | } 11 | } 12 | 13 | function handleLoadAppImage(e) { 14 | var image = devGuide.loadImageFromApplication('application_image.png'); 15 | if (image != null) { 16 | imageView.image = image; 17 | } 18 | } 19 | 20 | // Public implementation details for commonJS module 21 | 22 | exports.initialize = function(modDevGuide) { 23 | // Save the module object -- we'll need it later 24 | devGuide = modDevGuide; 25 | } 26 | 27 | exports.cleanup = function() { 28 | imageView = null; 29 | devGuide = null; 30 | } 31 | 32 | exports.create = function(win) { 33 | win.add(Ti.UI.createLabel({ 34 | text:'This demonstrates the loading of assets from both the module and application. Some messages will be output to the console.', 35 | textAlign:'left', 36 | font:{ fontsize: 12 }, 37 | top:10, 38 | right:10, 39 | left:10, 40 | width:Ti.UI.SIZE || 'auto', 41 | height:Ti.UI.SIZE || 'auto' 42 | })); 43 | 44 | var moduleImageBtn = Ti.UI.createButton({ 45 | title: 'Load Module Image', 46 | top:10, 47 | width: 250, 48 | height:Ti.UI.SIZE || 'auto' 49 | }); 50 | 51 | var appImageBtn = Ti.UI.createButton({ 52 | title: 'Load Application Image', 53 | top:10, 54 | width: 250, 55 | height:Ti.UI.SIZE || 'auto' 56 | }); 57 | 58 | imageView = Ti.UI.createImageView({ 59 | top:10, 60 | width:150, 61 | height:200 62 | }); 63 | 64 | moduleImageBtn.addEventListener('click', handleLoadModuleImage); 65 | appImageBtn.addEventListener('click', handleLoadAppImage); 66 | 67 | win.add(moduleImageBtn); 68 | win.add(appImageBtn); 69 | win.add(imageView); 70 | } 71 | -------------------------------------------------------------------------------- /android/example/demos/constantsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | 5 | // Public implementation details for commonJS module 6 | 7 | exports.initialize = function(modDevGuide) { 8 | // Save the module object -- we'll need it later 9 | devGuide = modDevGuide; 10 | } 11 | 12 | exports.cleanup = function() { 13 | devGuide = null; 14 | } 15 | 16 | exports.create = function(win) { 17 | win.add(Ti.UI.createLabel({ 18 | text:'This demonstrates the accessing of constants defined by a module (or proxy)', 19 | textAlign:'left', 20 | font:{ fontsize: 12 }, 21 | top:10, 22 | right:10, 23 | left:10, 24 | width:Ti.UI.SIZE || 'auto', 25 | height:Ti.UI.SIZE || 'auto' 26 | })); 27 | 28 | // Declare list of values to display. Each item references a constant defined 29 | // by the module. 30 | var constants = [ 31 | { title: 'Integer: ', value: devGuide.DEMO_INTEGER }, 32 | { title: 'String: ', value: devGuide.DEMO_STRING }, 33 | { title: 'Boolean: ', value: devGuide.DEMO_BOOLEAN } 34 | ]; 35 | 36 | var cnt = constants.length; 37 | for (var index = 0; index < cnt; index++) { 38 | var view = Ti.UI.createView({ 39 | layout:'horizontal', 40 | width:'100%', 41 | height:'30', 42 | top:10, 43 | left:10 44 | }); 45 | 46 | view.add(Ti.UI.createLabel({ 47 | text:constants[index].title, 48 | textAlign:'left', 49 | font:{ fontsize: 12, fontWeight: 'bold' }, 50 | width:Ti.UI.SIZE || 'auto', 51 | height:30 52 | })); 53 | 54 | view.add(Ti.UI.createLabel({ 55 | text:constants[index].value, 56 | textAlign:'left', 57 | font:{ fontsize: 12 }, 58 | width:Ti.UI.SIZE || 'auto', 59 | height:30 60 | })); 61 | 62 | win.add(view); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /android/example/demos/krollCallbacksAndEventsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var krollDemo = null; 4 | 5 | function successCallback(e) { 6 | alert("Success: " + e.title + "\nMessage: " + e.message); 7 | } 8 | 9 | function cancelCallback(e) { 10 | alert("Cancel: " + e.title + "\nMessage: " + e.message); 11 | } 12 | 13 | function directCallback(arg1, arg2) { 14 | Ti.API.info('Direct callback\n' + arg1 + '\n' + arg2); 15 | } 16 | 17 | function requestDataCallback(e) { 18 | Ti.API.info('Callback request for data'); 19 | return 100; 20 | } 21 | 22 | function demoEventHandler(e) { 23 | alert('Demo Event\nindex: ' + e.index + '\nvalue: ' + e.value + '\nname: ' + e.name); 24 | } 25 | 26 | function handleSignalSuccess(e) { 27 | // This sets the 'title' property of the module object 28 | krollDemo.title = 'Successful'; 29 | 30 | // This calls the 'signalCallbackWithSuccess' method in the module which fires a success event 31 | // notification to the registered callback method 32 | krollDemo.signalCallbackWithSuccess(true); 33 | } 34 | 35 | function handleSignalCancelled(e) { 36 | // This sets the 'title' property of the module object 37 | krollDemo.title = 'Cancelled'; 38 | 39 | // This calls the 'signalCallbackWithSuccess' method in the module which fires a cancel event 40 | // notification to the registered callback method 41 | krollDemo.signalCallbackWithSuccess(false); 42 | } 43 | 44 | function handleCallbackDirectly(e) { 45 | // This calls the 'callThisCallbackDirectly' method in the module which calls the 46 | // callback immediately, passing 2 arguments to the callback function. 47 | krollDemo.callThisCallbackDirectly({ 48 | callback: directCallback, 49 | data: "Hello World" 50 | }); 51 | 52 | alert('Check console output for results'); 53 | } 54 | 55 | function handleSignalEvent(e) { 56 | // This calls the 'signalEvent' method in the module which posts a 'demoEvent' 57 | // event to all registered listeners 58 | krollDemo.signalEvent(); 59 | } 60 | 61 | function handleRequestData(e) { 62 | // This calls the 'requestDataWithCallback' method in the module which immediately calls 63 | // back to the registered requestDataCallback function to retrieve data 64 | krollDemo.requestDataWithCallback(); 65 | 66 | alert('Check console output for results'); 67 | } 68 | 69 | // Public implementation details for commonJS module 70 | 71 | exports.initialize = function(modDevGuide) { 72 | // Create the proxy 73 | krollDemo = modDevGuide.createKrollDemo(); 74 | 75 | // This calls the 'registerCallbacks' method in the module which retains and stores 76 | // the KrollCallback functions for use later on. 77 | krollDemo.registerCallbacks({ 78 | success: successCallback, 79 | cancel: cancelCallback, 80 | requestData: requestDataCallback 81 | }); 82 | 83 | // Set up an event listener for a module event 84 | krollDemo.addEventListener('demoEvent', demoEventHandler); 85 | } 86 | 87 | exports.cleanup = function() { 88 | // Release the proxy 89 | krollDemo = null; 90 | } 91 | 92 | exports.create = function(win) { 93 | win.add(Ti.UI.createLabel({ 94 | text:'This demonstrates how to use callbacks and events in your module and how to call from your module back into JavaScript. Some callback messages will be output to the console.', 95 | textAlign:'left', 96 | font:{ fontsize: 12 }, 97 | top:10, 98 | right:10, 99 | left:10, 100 | width:Ti.UI.SIZE || 'auto', 101 | height:Ti.UI.SIZE || 'auto' 102 | })); 103 | 104 | var btn1 = Ti.UI.createButton({ 105 | title:'Success Event', 106 | width: 250, 107 | height:Ti.UI.SIZE || 'auto', 108 | top:20 109 | }); 110 | 111 | var btn2 = Ti.UI.createButton({ 112 | title:'Cancel Event', 113 | width: 250, 114 | height:Ti.UI.SIZE || 'auto', 115 | top:20 116 | }); 117 | 118 | var btn3 = Ti.UI.createButton({ 119 | title:'Direct Callback', 120 | width: 250, 121 | height:Ti.UI.SIZE || 'auto', 122 | top:20 123 | }); 124 | 125 | var btn4 = Ti.UI.createButton({ 126 | title:'Demo Event', 127 | width: 250, 128 | height:Ti.UI.SIZE || 'auto', 129 | top:20 130 | }); 131 | 132 | var btn5 = Ti.UI.createButton({ 133 | title:'Request Data', 134 | width: 250, 135 | height:Ti.UI.SIZE || 'auto', 136 | top:20 137 | }); 138 | 139 | btn1.addEventListener('click', handleSignalSuccess); 140 | btn2.addEventListener('click', handleSignalCancelled); 141 | btn3.addEventListener('click', handleCallbackDirectly); 142 | btn4.addEventListener('click', handleSignalEvent); 143 | btn5.addEventListener('click', handleRequestData); 144 | 145 | win.add(btn1); 146 | win.add(btn2); 147 | win.add(btn3); 148 | win.add(btn4); 149 | win.add(btn5); 150 | } 151 | -------------------------------------------------------------------------------- /android/example/demos/krollMethodsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var methodsDemo = null; 4 | 5 | function handlePickerSelection(e) { 6 | var result = null; 7 | try { 8 | switch (e.row.typeid) { 9 | case 'select': 10 | return; 11 | case 'noreturn': 12 | methodsDemo.demoMethodNoReturn(); 13 | break; 14 | case 'integer': 15 | result = methodsDemo.demoMethodNumberInt(5, 17); 16 | break; 17 | case 'float': 18 | result = methodsDemo.demoMethodNumberFloat(2.7, '18.2'); 19 | break; 20 | case 'strings': 21 | result = methodsDemo.demoMethodString('Joe', 'Smith', 25); 22 | break; 23 | case 'dictionary': 24 | result = JSON.stringify(methodsDemo.demoMethodDictionary(['a', 'b', 'c', 'd', 'e', 'f'])); 25 | Ti.API.info('Dictionary Result:'); 26 | Ti.API.info(result); 27 | break; 28 | case 'date': 29 | result = methodsDemo.demoMethodDate({ month: 7, day: 4, year: 1776 }); 30 | break; 31 | case 'rect': 32 | var rect = methodsDemo.demoMethodRect(10,10,100,200); 33 | result = 'x: ' + rect.x + ' y: ' + rect.y + ' width: ' + rect.width + ' height: ' + rect.height; 34 | break; 35 | case 'point': 36 | var point = methodsDemo.demoMethodPoint(25,40); 37 | result = 'x: ' + point.x + ' y: ' + point.y; 38 | break; 39 | case 'range': 40 | var range = methodsDemo.demoMethodRange(10,100); 41 | result = 'Location: ' + range.location + ' Length: ' + range.length; 42 | break; 43 | case 'color': 44 | result = methodsDemo.demoMethodColor('green'); 45 | if (Ti.Platform.name == 'android') { 46 | // Convert to hex string for display 47 | var u = 0xFFFFFFFF + result + 1; 48 | result = "0x" + u.toString(16).toUpperCase(); 49 | } 50 | break; 51 | case 'array': 52 | result = methodsDemo.demoMethodArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 53 | break; 54 | case 'file': 55 | var t = Ti.Filesystem.createTempFile(); 56 | var file = methodsDemo.demoMethodFile(t.nativePath); 57 | if (Ti.Platform.name == 'android') { 58 | result = 'File with path: ' + file.nativePath; 59 | } else { 60 | result = 'File with path: ' + file.path; 61 | } 62 | t.deleteFile(); 63 | break; 64 | case 'blob': 65 | var blob = methodsDemo.demoMethodBlob(); 66 | result = 'Blob with text: ' + blob.text; 67 | break; 68 | case 'null': 69 | result = methodsDemo.demoMethodNull(); 70 | break; 71 | case 'optional': 72 | result = methodsDemo.demoMethodOptionalArgs('Welcome'); 73 | alert('Method returned:\n' + result); 74 | result = methodsDemo.demoMethodOptionalArgs('Hello', 'World'); 75 | break; 76 | } 77 | 78 | alert('Method returned:\n' + result); 79 | } catch (e) { 80 | alert(e); 81 | } 82 | } 83 | 84 | // Public implementation details for commonJS module 85 | 86 | exports.initialize = function(modDevGuide) { 87 | // Create the proxy 88 | methodsDemo = modDevGuide.createMethodsDemo(); 89 | } 90 | 91 | exports.cleanup = function() { 92 | // Release the proxy 93 | methodsDemo = null; 94 | } 95 | 96 | exports.create = function(win) { 97 | win.add(Ti.UI.createLabel({ 98 | text:'This demonstrates how to use methods and return values in your module. Select a method type to call into the module. Some callback messages will be output to the console.', 99 | textAlign:'left', 100 | font:{ fontsize: 12 }, 101 | top:10, 102 | right:10, 103 | left:10, 104 | width:Ti.UI.SIZE || 'auto', 105 | height:Ti.UI.SIZE || 'auto' 106 | })); 107 | 108 | var data = []; 109 | data.push(Ti.UI.createPickerRow({title: 'Select a type', typeid: 'select' })); 110 | data.push(Ti.UI.createPickerRow({title: 'No return', typeid: 'noreturn' })); 111 | data.push(Ti.UI.createPickerRow({title: 'Integer', typeid: 'integer' })); 112 | data.push(Ti.UI.createPickerRow({title: 'Float', typeid: 'float' })); 113 | data.push(Ti.UI.createPickerRow({title: 'Strings', typeid: 'strings' })); 114 | data.push(Ti.UI.createPickerRow({title: 'Date', typeid: 'date' })); 115 | data.push(Ti.UI.createPickerRow({title: 'Rect', typeid: 'rect' })); 116 | data.push(Ti.UI.createPickerRow({title: 'Point', typeid: 'point' })); 117 | data.push(Ti.UI.createPickerRow({title: 'Range', typeid: 'range' })); 118 | data.push(Ti.UI.createPickerRow({title: 'Color', typeid: 'color' })); 119 | data.push(Ti.UI.createPickerRow({title: 'Dictionary', typeid: 'dictionary' })); 120 | data.push(Ti.UI.createPickerRow({title: 'Array', typeid: 'array' })); 121 | data.push(Ti.UI.createPickerRow({title: 'File', typeid: 'file' })); 122 | data.push(Ti.UI.createPickerRow({title: 'Blob', typeid: 'blob' })); 123 | data.push(Ti.UI.createPickerRow({title: 'Null', typeid: 'null' })); 124 | data.push(Ti.UI.createPickerRow({title: 'Optional Args', typeid: 'optional' })); 125 | 126 | var picker = Ti.UI.createPicker({ 127 | top:20, 128 | width:300, 129 | type:Ti.UI.PICKER_TYPE_PLAIN 130 | }); 131 | picker.add(data); 132 | picker.selectionIndicator = true; 133 | 134 | picker.addEventListener('change', handlePickerSelection); 135 | 136 | win.add(picker); 137 | } 138 | -------------------------------------------------------------------------------- /android/example/demos/krollParametersDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var parametersDemo = null; 4 | 5 | function handlePickerSelection(e) { 6 | try { 7 | switch (e.row.typeid) { 8 | case 'select': 9 | return; 10 | case 'string': 11 | parametersDemo.analyzeParameters('Hello World'); 12 | break; 13 | case 'integer': 14 | parametersDemo.analyzeParameters(100); 15 | break; 16 | case 'float': 17 | parametersDemo.analyzeParameters(10.7); 18 | break; 19 | case 'date': 20 | var myDate = new Date(); 21 | myDate.setFullYear(2011); 22 | myDate.setMonth(7); 23 | myDate.setDate(4); 24 | parametersDemo.analyzeParameters(myDate); 25 | break; 26 | case 'null': 27 | parametersDemo.analyzeParameters(null); 28 | break; 29 | case 'dictionary': 30 | parametersDemo.analyzeParameters({ a:1, b:2 }); 31 | break; 32 | case 'nested_dictionary': 33 | var y = { a:1, b:2 }; 34 | parametersDemo.analyzeParameters({ a:1, b:{ z:1 }, c:y }); 35 | break; 36 | case 'number_array': 37 | parametersDemo.analyzeParameters([1,2,3]); 38 | break; 39 | case 'callback': 40 | parametersDemo.analyzeParameters(function() { Ti.API.Info('Test'); }); 41 | break; 42 | case 'mixed': 43 | parametersDemo.analyzeParameters('Test', 10, 4.3, { title: 'Hello', subtitle: 'World' }, [ 'a', 3, 2.1 ] ); 44 | break; 45 | } 46 | 47 | alert('Check console output for results of parameter analysis'); 48 | } catch (e) { 49 | alert(e); 50 | } 51 | } 52 | 53 | // Public implementation details for commonJS module 54 | 55 | exports.initialize = function(modDevGuide) { 56 | // Create the proxy 57 | parametersDemo = modDevGuide.createParametersDemo(); 58 | } 59 | 60 | exports.cleanup = function() { 61 | // Release the proxy 62 | parametersDemo = null; 63 | } 64 | 65 | exports.create = function(win) { 66 | win.add(Ti.UI.createLabel({ 67 | text:'This demonstrates a variety of parameter types and how they are mapped to native types. Select a parameter type to analyze how they are received in the module. Parameter messages will be output to the console.', 68 | textAlign:'left', 69 | font:{ fontsize: 12 }, 70 | top:10, 71 | right:10, 72 | left:10, 73 | width:Ti.UI.SIZE || 'auto', 74 | height:Ti.UI.SIZE || 'auto' 75 | })); 76 | 77 | var data = []; 78 | data.push(Ti.UI.createPickerRow({title: 'Select a type', typeid: 'select' })); 79 | data.push(Ti.UI.createPickerRow({title: 'String', typeid: 'string' })); 80 | data.push(Ti.UI.createPickerRow({title: 'Integer', typeid: 'integer' })); 81 | data.push(Ti.UI.createPickerRow({title: 'Float', typeid: 'float' })); 82 | data.push(Ti.UI.createPickerRow({title: 'Date', typeid: 'date' })); 83 | data.push(Ti.UI.createPickerRow({title: 'Null', typeid: 'null' })); 84 | data.push(Ti.UI.createPickerRow({title: 'Dictionary', typeid: 'dictionary' })); 85 | data.push(Ti.UI.createPickerRow({title: 'Nested Dictionary', typeid: 'nested_dictionary' })); 86 | data.push(Ti.UI.createPickerRow({title: 'Array of Numbers', typeid: 'number_array' })); 87 | data.push(Ti.UI.createPickerRow({title: 'Callback', typeid: 'callback' })); 88 | data.push(Ti.UI.createPickerRow({title: 'Mixed', typeid: 'mixed' })); 89 | 90 | var picker = Ti.UI.createPicker({ 91 | top:20, 92 | width:300, 93 | type:Ti.UI.PICKER_TYPE_PLAIN 94 | }); 95 | picker.add(data); 96 | picker.selectionIndicator = true; 97 | 98 | picker.addEventListener('change', handlePickerSelection); 99 | 100 | win.add(picker); 101 | } 102 | -------------------------------------------------------------------------------- /android/example/demos/krollPropertiesDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var krollDemo = null; 4 | 5 | function handlePropertyChangesSwitch(e) { 6 | krollDemo.watchPropertyChanges = e.value; 7 | } 8 | 9 | function handleSetPropertyValue(e) { 10 | krollDemo.testValue = e.source.value; 11 | } 12 | 13 | function handleGetPropertyValue(e) { 14 | alert('Current property value is ' + krollDemo.testValue); 15 | } 16 | 17 | function handleBatchUpdate(e) { 18 | krollDemo.value1 = (krollDemo.value1 | 0) + 5; 19 | krollDemo.value2 = { name: 'Hello', value: 'World' }; 20 | krollDemo.value3 = !(krollDemo.value3 | false); 21 | krollDemo.value4 = 'This is a test'; 22 | } 23 | 24 | function handlePropertyChangeNotification(e) { 25 | var result = 'Property ' + e.property + ' changed\nOldValue: ' + e.oldValue + '\nNewValue: ' + e.newValue; 26 | alert(result); 27 | } 28 | 29 | // Public implementation details for commonJS module 30 | 31 | exports.initialize = function(modDevGuide) { 32 | // Create the proxy 33 | krollDemo = modDevGuide.createKrollDemo({ arg1: "Hello", arg2: "World" }); 34 | 35 | krollDemo.addEventListener('propertyChange', handlePropertyChangeNotification); 36 | krollDemo.watchPropertyChanges = true; 37 | } 38 | 39 | exports.cleanup = function() { 40 | krollDemo = null; 41 | } 42 | 43 | exports.create = function(win) { 44 | win.add(Ti.UI.createLabel({ 45 | text:'This demonstrates proxy properties and how to get / set their values as well as process property change notifications. Some messages will be output to the console.', 46 | textAlign:'left', 47 | font:{ fontsize: 12 }, 48 | top:10, 49 | right:10, 50 | left:10, 51 | width:Ti.UI.SIZE || 'auto', 52 | height:Ti.UI.SIZE || 'auto' 53 | })); 54 | 55 | var view1 = Ti.UI.createView({ 56 | layout:'horizontal', 57 | width:'100%', 58 | height:Ti.UI.SIZE || 'auto', 59 | top:10, 60 | left:10 61 | }); 62 | 63 | view1.add(Ti.UI.createLabel({ 64 | text:'Property Changes:', 65 | textAlign:'left', 66 | font:{ fontsize: 12 }, 67 | width:Ti.UI.SIZE || 'auto', 68 | height:Ti.UI.SIZE || 'auto' 69 | })); 70 | 71 | var switchPropertyChanges = Ti.UI.createSwitch({ 72 | value:krollDemo.watchPropertyChanges, 73 | left:10, 74 | top:0 75 | }); 76 | view1.add(switchPropertyChanges); 77 | 78 | var view2= Ti.UI.createView({ 79 | layout:'horizontal', 80 | width:'100%', 81 | height:Ti.UI.SIZE || 'auto', 82 | top:20, 83 | left:10 84 | }) 85 | 86 | view2.add(Ti.UI.createLabel({ 87 | text:'Test Value:', 88 | textAlign:'left', 89 | font:{ fontsize: 12 }, 90 | width:Ti.UI.SIZE || 'auto', 91 | height:Ti.UI.SIZE || 'auto' 92 | })); 93 | 94 | var valueField = Ti.UI.createTextField({ 95 | hintText:'Enter a value', 96 | font:{ fontsize: 12 }, 97 | width: 250, 98 | height:Ti.UI.SIZE || 'auto', 99 | left:10, 100 | borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED 101 | }); 102 | view2.add(valueField); 103 | 104 | var valueBtn = Ti.UI.createButton({ 105 | title:'Get Value', 106 | width: 250, 107 | height:Ti.UI.SIZE || 'auto', 108 | top:20 109 | }); 110 | 111 | var batchUpdateBtn = Ti.UI.createButton({ 112 | title:'Update Multiple Properties', 113 | width: 250, 114 | height:Ti.UI.SIZE || 'auto', 115 | top:20 116 | }); 117 | 118 | switchPropertyChanges.addEventListener('change', handlePropertyChangesSwitch); 119 | valueField.addEventListener('return', handleSetPropertyValue); 120 | valueBtn.addEventListener('click', handleGetPropertyValue); 121 | batchUpdateBtn.addEventListener('click', handleBatchUpdate); 122 | 123 | win.add(view1); 124 | win.add(view2); 125 | win.add(valueBtn); 126 | win.add(batchUpdateBtn); 127 | } 128 | -------------------------------------------------------------------------------- /android/example/demos/proxyDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | var proxyList = []; 5 | var proxyCountLbl = null; 6 | var deleteProxyBtn = null; 7 | 8 | function updateProxyCount() { 9 | proxyCountLbl.text = 'Proxy Count: ' + proxyList.length; 10 | deleteProxyBtn.enabled = proxyList.length > 0; 11 | } 12 | 13 | function handleCreateProxy(e) { 14 | var proxy = devGuide.createLifeCycle ({ 15 | a: 'Hello', 16 | b: 'World' 17 | }); 18 | 19 | proxyList.push(proxy); 20 | 21 | updateProxyCount(); 22 | } 23 | 24 | function handleDeleteProxy(e) { 25 | var proxy = proxyList.pop(); 26 | 27 | // Call proxy for any necessary cleanup 28 | proxy.close(); 29 | 30 | updateProxyCount(); 31 | } 32 | 33 | // Public implementation details for commonJS module 34 | 35 | exports.initialize = function(modDevGuide) { 36 | // Save the module object -- we'll need it later 37 | devGuide = modDevGuide; 38 | } 39 | 40 | exports.cleanup = function() { 41 | proxyList = []; 42 | proxyCountLbl = null; 43 | deleteProxyBtn = null; 44 | devGuide = null; 45 | } 46 | 47 | exports.create = function(win) { 48 | win.add(Ti.UI.createLabel({ 49 | text:'This demonstrates the proxy lifecycle. Press the \'Create Proxy\' button to create a new instance of the proxy. Press the \'Delete Proxy\' button to destroy an instance of the proxy. Lifecycle messages will be output to the console.', 50 | textAlign:'left', 51 | font:{ fontsize: 12 }, 52 | top:10, 53 | right:10, 54 | left:10, 55 | width:Ti.UI.SIZE || 'auto', 56 | height:Ti.UI.SIZE || 'auto' 57 | })); 58 | 59 | proxyCountLbl = Ti.UI.createLabel({ 60 | text: '', 61 | top: 10, 62 | height: Ti.UI.SIZE || 'auto', 63 | width: Ti.UI.SIZE || 'auto', 64 | textAlign: 'left', 65 | font: { fontSize: 12 } 66 | }); 67 | 68 | var createProxyBtn = Ti.UI.createButton({ 69 | title: 'Create Proxy', 70 | top:10, 71 | width:150, 72 | height:60 73 | }); 74 | 75 | deleteProxyBtn = Ti.UI.createButton({ 76 | title: 'Delete Proxy', 77 | top:10, 78 | width:150, 79 | height:60 80 | }); 81 | 82 | createProxyBtn.addEventListener('click', handleCreateProxy); 83 | deleteProxyBtn.addEventListener('click', handleDeleteProxy); 84 | 85 | win.add(createProxyBtn); 86 | win.add(deleteProxyBtn); 87 | win.add(proxyCountLbl); 88 | 89 | updateProxyCount(); 90 | } 91 | -------------------------------------------------------------------------------- /android/example/demos/viewproxyDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | var view = null; 5 | var currentColor = ''; 6 | 7 | function handleColorSelection(e) { 8 | view.color = (currentColor == 'green') ? 'red' : 'green'; 9 | } 10 | 11 | function createColorSelector() { 12 | var colorBtn = Ti.UI.createButton({ 13 | title: 'Change Color', 14 | top:10, 15 | width:150, 16 | height:40 17 | }); 18 | 19 | colorBtn.addEventListener('click', handleColorSelection); 20 | 21 | return colorBtn; 22 | } 23 | 24 | function handleColorChange(e) { 25 | if (Ti.Platform.name == 'android') { 26 | currentColor = e.color; 27 | } else { 28 | currentColor = e.color._name; 29 | } 30 | 31 | alert('Color changed to ' + currentColor); 32 | } 33 | 34 | function toggleViewCreate(e) { 35 | if (view == null) { 36 | view = devGuide.createDemoView({ 37 | width: 250, 38 | height:200, 39 | top:10, 40 | color: 'green', 41 | layout:'vertical' 42 | }); 43 | 44 | view.add(createColorSelector()); 45 | 46 | view.addEventListener('colorChange', handleColorChange); 47 | 48 | e.source.parent.add(view); 49 | } else { 50 | e.source.parent.remove(view); 51 | view = null; 52 | } 53 | 54 | // Toggle the button text 55 | e.source.title = (view == null) ? 'Create View' : 'Delete View'; 56 | } 57 | 58 | // Public implementation details for commonJS module 59 | 60 | exports.initialize = function(modDevGuide) { 61 | // Save the module object -- we'll need it later 62 | devGuide = modDevGuide; 63 | } 64 | 65 | exports.cleanup = function() { 66 | view = null; 67 | currentColor = ''; 68 | devGuide = null; 69 | } 70 | 71 | exports.create = function(win) { 72 | win.add(Ti.UI.createLabel({ 73 | text:'This demonstrates the view proxy lifecycle. Press the \'Create View\' button to create a new instance of the view. Press the \'Delete View\' button to destroy the view. Lifecycle messages will be output to the console.', 74 | textAlign:'left', 75 | font:{ fontsize: 12 }, 76 | top:10, 77 | right:10, 78 | left:10, 79 | width:Ti.UI.SIZE || 'auto', 80 | height:Ti.UI.SIZE || 'auto' 81 | })); 82 | 83 | var toggleBtn = Ti.UI.createButton({ 84 | title: 'Create View', 85 | top:10, 86 | width:150, 87 | height:60 88 | }); 89 | 90 | toggleBtn.addEventListener('click', toggleViewCreate); 91 | 92 | win.add(toggleBtn); 93 | } 94 | -------------------------------------------------------------------------------- /android/example/navigator.js: -------------------------------------------------------------------------------- 1 | // Declare the list of demos and their associated commonJS module names 2 | var demos = [ 3 | { mod: null, title: 'Proxy Loading', section: 'Life Cycle', name: 'proxyDemo' }, 4 | { mod: null, title: 'View Proxy Loading', section: 'Life Cycle', name: 'viewproxyDemo' }, 5 | { mod: null, title: 'Properties', section: 'Kroll', name: 'krollPropertiesDemo' }, 6 | { mod: null, title: 'Methods', section: 'Kroll', name: 'krollMethodsDemo' }, 7 | { mod: null, title: 'Parameters', section: 'Kroll', name: 'krollParametersDemo' }, 8 | { mod: null, title: 'Callbacks & Events', section: 'Kroll', name: 'krollCallbacksAndEventsDemo' }, 9 | { mod: null, title: 'Assets', section: 'Miscellaneous', name: 'assetsDemo' }, 10 | { mod: null, title: 'Constants', section: 'Miscellaneous', name: 'constantsDemo' } 11 | ]; 12 | 13 | var devGuide = null; 14 | var tab = null; 15 | var currentDemo = null; 16 | 17 | function createDemoTableView() { 18 | var sections = []; 19 | var cnt = demos.length; 20 | 21 | for (var index = 0; index < cnt; index++) { 22 | if ((index == 0) || (demos[index].section != demos[index-1].section)) { 23 | sections.push(Ti.UI.createTableViewSection({ 24 | headerTitle: demos[index].section 25 | })); 26 | } 27 | 28 | row = Ti.UI.createTableViewRow({ 29 | title: demos[index].title, 30 | hasChild: true 31 | }); 32 | 33 | sections[sections.length - 1].add(row); 34 | } 35 | 36 | var tableView = Ti.UI.createTableView({ 37 | data: sections 38 | }); 39 | 40 | tableView.addEventListener('click', function(e) { 41 | exports.openDemo(demos[e.index]); 42 | }); 43 | 44 | return tableView; 45 | } 46 | 47 | exports.start = function(modDevGuide) { 48 | // Save the module object -- we'll need it later 49 | devGuide = modDevGuide; 50 | 51 | var win = Ti.UI.createWindow({ 52 | title: 'Module Development Guide', 53 | tabBarHidden: true 54 | }); 55 | 56 | win.add(createDemoTableView()); 57 | 58 | if (Ti.Platform.name == 'android') { 59 | win.exitOnClose = true; 60 | } else { 61 | var tabGroup = Ti.UI.createTabGroup(); 62 | win.tabBarHidden = true; 63 | tab = Ti.UI.createTab({ 64 | title: win.title, 65 | window: win 66 | }); 67 | tabGroup.addTab(tab); 68 | tabGroup.open(); 69 | } 70 | 71 | // Open the application window 72 | win.open(); 73 | } 74 | 75 | exports.openDemo = function(demo) { 76 | var win = Ti.UI.createWindow({ 77 | title: demo.title, 78 | layout: 'vertical' 79 | }); 80 | 81 | // Load the commonJS module for the first time 82 | currentDemo = (demo.mod == null) ? require('demos/' + demo.name) : demo.mod; 83 | 84 | // Perform page initialization 85 | currentDemo.initialize(devGuide); 86 | 87 | // Create the controls for the window 88 | currentDemo.create(win); 89 | 90 | // Handle page cleanup 91 | win.addEventListener('close', function() { 92 | currentDemo.cleanup(); 93 | currentDemo = null; 94 | }); 95 | 96 | win.open({ animated: true }); 97 | } 98 | -------------------------------------------------------------------------------- /android/hooks/README: -------------------------------------------------------------------------------- 1 | These files are not yet supported as of 1.4.0 but will be in a near future release. 2 | -------------------------------------------------------------------------------- /android/hooks/add.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module project add hook that will be 4 | # called when your module is added to a project 5 | # 6 | import os, sys 7 | 8 | def dequote(s): 9 | if s[0:1] == '"': 10 | return s[1:-1] 11 | return s 12 | 13 | def main(args,argc): 14 | # You will get the following command line arguments 15 | # in the following order: 16 | # 17 | # project_dir = the full path to the project root directory 18 | # project_type = the type of project (desktop, mobile, ipad) 19 | # project_name = the name of the project 20 | # 21 | project_dir = dequote(os.path.expanduser(args[1])) 22 | project_type = dequote(args[2]) 23 | project_name = dequote(args[3]) 24 | 25 | # TODO: write your add hook here (optional) 26 | 27 | 28 | # exit 29 | sys.exit(0) 30 | 31 | 32 | 33 | if __name__ == '__main__': 34 | main(sys.argv,len(sys.argv)) 35 | 36 | -------------------------------------------------------------------------------- /android/hooks/install.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module install hook that will be 4 | # called when your module is first installed 5 | # 6 | import os, sys 7 | 8 | def main(args,argc): 9 | 10 | # TODO: write your install hook here (optional) 11 | 12 | # exit 13 | sys.exit(0) 14 | 15 | 16 | 17 | if __name__ == '__main__': 18 | main(sys.argv,len(sys.argv)) 19 | 20 | -------------------------------------------------------------------------------- /android/hooks/remove.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module project remove hook that will be 4 | # called when your module is remove from a project 5 | # 6 | import os, sys 7 | 8 | def dequote(s): 9 | if s[0:1] == '"': 10 | return s[1:-1] 11 | return s 12 | 13 | def main(args,argc): 14 | # You will get the following command line arguments 15 | # in the following order: 16 | # 17 | # project_dir = the full path to the project root directory 18 | # project_type = the type of project (desktop, mobile, ipad) 19 | # project_name = the name of the project 20 | # 21 | project_dir = dequote(os.path.expanduser(args[1])) 22 | project_type = dequote(args[2]) 23 | project_name = dequote(args[3]) 24 | 25 | # TODO: write your remove hook here (optional) 26 | 27 | # exit 28 | sys.exit(0) 29 | 30 | 31 | 32 | if __name__ == '__main__': 33 | main(sys.argv,len(sys.argv)) 34 | 35 | -------------------------------------------------------------------------------- /android/hooks/uninstall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module uninstall hook that will be 4 | # called when your module is uninstalled 5 | # 6 | import os, sys 7 | 8 | def main(args,argc): 9 | 10 | # TODO: write your uninstall hook here (optional) 11 | 12 | # exit 13 | sys.exit(0) 14 | 15 | 16 | if __name__ == '__main__': 17 | main(sys.argv,len(sys.argv)) 18 | 19 | -------------------------------------------------------------------------------- /android/lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidev/ti.moddevguide/dddbf86979952ea2bd7c3dd7acd8e94640d8d938/android/lib/.gitkeep -------------------------------------------------------------------------------- /android/manifest: -------------------------------------------------------------------------------- 1 | # 2 | # this is your module manifest and used by Titanium 3 | # during compilation, packaging, distribution, etc. 4 | # 5 | version: 4.0.0 6 | apiversion: 4 7 | architectures: arm64-v8a armeabi-v7a x86 x86_64 8 | description: Titanium Module Development Guide 9 | author: Jeff English & Jon Alter 10 | license: Apache 2.0 11 | copyright: Copyright (c) 2010-present by Appcelerator, Inc. 12 | 13 | # these should not be edited 14 | name: moddevguide 15 | moduleid: ti.moddevguide 16 | guid: 0c7b7522-0e82-4ff2-b456-3ec6ac7948ae 17 | platform: android 18 | minsdk: 10.0.0 19 | -------------------------------------------------------------------------------- /android/platform/android/res/drawable/module_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidev/ti.moddevguide/dddbf86979952ea2bd7c3dd7acd8e94640d8d938/android/platform/android/res/drawable/module_image.png -------------------------------------------------------------------------------- /android/src/ti/moddevguide/DemoView.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | package ti.moddevguide; 9 | 10 | import android.view.View; 11 | 12 | import org.appcelerator.kroll.KrollDict; 13 | import org.appcelerator.kroll.KrollProxy; 14 | import org.appcelerator.kroll.common.Log; 15 | import org.appcelerator.titanium.TiApplication; 16 | import org.appcelerator.titanium.proxy.TiViewProxy; 17 | import org.appcelerator.titanium.util.TiConvert; 18 | import org.appcelerator.titanium.view.TiCompositeLayout; 19 | import org.appcelerator.titanium.view.TiUIView; 20 | 21 | import java.util.HashMap; 22 | 23 | public class DemoView extends TiUIView { 24 | // Standard Debugging variables 25 | private static final String LCAT = "ModdevguideModule"; 26 | 27 | private static final String PROPERTY_COLOR = "color"; 28 | 29 | public DemoView(TiViewProxy proxy) { 30 | super(proxy); 31 | 32 | Log.d(LCAT, "[VIEW LIFECYCLE EVENT] view"); 33 | 34 | // Create the view as a TiCompositeLayout since our demo 35 | // will be adding children to the view. 36 | TiCompositeLayout view = new TiCompositeLayout(proxy.getActivity()); 37 | 38 | // Set the view as the native view. You must set the native view 39 | // for your view to be rendered correctly. 40 | setNativeView(view); 41 | } 42 | 43 | // The view is automatically registered as a model listener when the view 44 | // is realized by the view proxy. That means that the processProperties 45 | // method will be called during creation and that propertiesChanged and 46 | // propertyChanged will be called when properties are changed on the proxy. 47 | 48 | @Override 49 | public void processProperties(KrollDict props) { 50 | super.processProperties(props); 51 | 52 | Log.d(LCAT, "[VIEW LIFECYCLE EVENT] processProperties " + props); 53 | 54 | // Check if the color is specified when the view was created 55 | if (props.containsKey(PROPERTY_COLOR)) { 56 | View square = (View) getNativeView(); 57 | square.setBackgroundColor(TiConvert.toColor(props, PROPERTY_COLOR, TiApplication.getAppCurrentActivity())); 58 | notifyOfColorChange(props.getString(PROPERTY_COLOR)); 59 | square.invalidate(); 60 | } 61 | } 62 | 63 | @Override 64 | public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { 65 | // This method is called whenever a proxy property value is updated. Note that this 66 | // method is only called if the new value is different than the current value. 67 | 68 | super.propertyChanged(key, oldValue, newValue, proxy); 69 | 70 | Log.d(LCAT, "[VIEW LIFECYCLE EVENT] propertyChanged: " + key + ' ' + oldValue + ' ' + newValue); 71 | } 72 | 73 | // Local helper method to fire the colorChange event 74 | private void notifyOfColorChange(String newColor) { 75 | // The event listeners for a view are actually attached to the view proxy. 76 | // You must reference 'proxy' to get the proxy for this view. 77 | 78 | Log.d(LCAT, "[VIEW LIFECYCLE EVENT] notifyOfColorChange"); 79 | 80 | // It is a good idea to check if there are listeners for the event that 81 | // is about to be fired. There could be zero or multiple listeners for the 82 | // specified event. 83 | if (proxy.hasListeners("colorChange")) { 84 | HashMap hm = new HashMap(); 85 | hm.put("color", newColor); 86 | proxy.fireEvent("colorChange", hm); 87 | } 88 | } 89 | 90 | // Setter method called by the proxy when the 'color' property is 91 | // set. This could also be handled in the propertyChanged handler. 92 | public void setColor(String color) { 93 | Log.d(LCAT, "[VIEW LIFECYCLE EVENT] Property Set: setColor"); 94 | 95 | // Use the TiConvert method to get the values from the arguments 96 | int newColor = TiConvert.toColor(color, TiApplication.getAppCurrentActivity()); 97 | View square = (View) getNativeView(); 98 | square.setBackgroundColor(newColor); 99 | 100 | notifyOfColorChange(color); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /android/src/ti/moddevguide/DemoViewProxy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | package ti.moddevguide; 9 | 10 | import android.app.Activity; 11 | import android.os.Handler; 12 | import android.os.Message; 13 | 14 | import org.appcelerator.kroll.KrollDict; 15 | import org.appcelerator.kroll.KrollModule; 16 | import org.appcelerator.kroll.annotations.Kroll; 17 | import org.appcelerator.kroll.common.AsyncResult; 18 | import org.appcelerator.kroll.common.Log; 19 | import org.appcelerator.kroll.common.TiMessenger; 20 | import org.appcelerator.titanium.TiApplication; 21 | import org.appcelerator.titanium.proxy.TiViewProxy; 22 | import org.appcelerator.titanium.view.TiUIView; 23 | 24 | // The proxy is declared with the @Kroll.proxy annotation 25 | 26 | @Kroll.proxy(creatableInModule = ModdevguideModule.class) 27 | public class DemoViewProxy extends TiViewProxy { 28 | // Standard Debugging variables 29 | private static final String LCAT = "ModdevguideModule"; 30 | private static final int MSG_SET_COLOR = 70000; 31 | 32 | public DemoViewProxy() { 33 | super(); 34 | 35 | Log.d(LCAT, "[VIEWPROXY LIFECYCLE EVENT] init"); 36 | } 37 | 38 | @Override 39 | public TiUIView createView(Activity activity) { 40 | // This method is called when the view needs to be created. This is 41 | // a required method for a TiViewProxy subclass. 42 | 43 | DemoView view = new DemoView(this); 44 | view.getLayoutParams().autoFillsHeight = true; 45 | view.getLayoutParams().autoFillsWidth = true; 46 | 47 | return view; 48 | } 49 | 50 | // Handle creation options 51 | @Override 52 | public void handleCreationDict(KrollDict options) { 53 | // This method is called from handleCreationArgs if there is at least 54 | // argument specified for the proxy creation call and the first argument 55 | // is a KrollDict object. 56 | 57 | Log.d(LCAT, "VIEWPROXY LIFECYCLE EVENT] handleCreationDict " + options); 58 | 59 | // Calling the superclass method ensures that the properties specified 60 | // in the dictionary are properly set on the proxy object. 61 | super.handleCreationDict(options); 62 | } 63 | 64 | // Proxy properties are forwarded to the view in the propertyChanged 65 | // notification. If the property update needs to occur on the UI thread 66 | // then create the setProperty method in the proxy and forward to the view. 67 | 68 | public void handleCreationArgs(KrollModule createdInModule, Object[] args) { 69 | // This method is one of the initializers for the proxy class. The arguments 70 | // for the create call are passed as an array of objects. If your proxy 71 | // simply needs to handle a single KrollDict argument, use handleCreationDict. 72 | // The superclass method calls the handleCreationDict if the first argument 73 | // to the create method is a dictionary object. 74 | 75 | Log.d(LCAT, "VIEWPROXY LIFECYCLE EVENT] handleCreationArgs "); 76 | 77 | for (int i = 0; i < args.length; i++) { 78 | Log.d(LCAT, "VIEWPROXY LIFECYCLE EVENT] args[" + i + "] " + args[i]); 79 | } 80 | 81 | super.handleCreationArgs(createdInModule, args); 82 | } 83 | 84 | @Kroll.setProperty(retain = false) 85 | public void setColor(final String color) { 86 | Log.d(LCAT, "[VIEWPROXY LIFECYCLE EVENT] Property Set: setColor"); 87 | 88 | // Get the view object from the proxy and set the color 89 | if (view != null) { 90 | if (!TiApplication.isUIThread()) { 91 | TiMessenger.sendBlockingMainMessage(new Handler(TiMessenger.getMainMessenger().getLooper(), new Handler.Callback() { 92 | public boolean handleMessage(Message msg) { 93 | switch (msg.what) { 94 | case MSG_SET_COLOR: { 95 | AsyncResult result = (AsyncResult) msg.obj; 96 | DemoView demoView = (DemoView) view; 97 | demoView.setColor(color); 98 | result.setResult(null); 99 | return true; 100 | } 101 | } 102 | return false; 103 | } 104 | }).obtainMessage(MSG_SET_COLOR), color); 105 | } else { 106 | DemoView demoView = (DemoView) view; 107 | demoView.setColor(color); 108 | } 109 | } 110 | 111 | // Call setPropertyAndFire if you want the property set on the proxy and 112 | // to signal the propertyChanged notification 113 | setPropertyAndFire("color", color); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /android/src/ti/moddevguide/KrollDemoProxy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | package ti.moddevguide; 9 | 10 | import org.appcelerator.kroll.KrollDict; 11 | import org.appcelerator.kroll.KrollFunction; 12 | import org.appcelerator.kroll.KrollPropertyChange; 13 | import org.appcelerator.kroll.KrollProxy; 14 | import org.appcelerator.kroll.KrollProxyListener; 15 | import org.appcelerator.kroll.annotations.Kroll; 16 | import org.appcelerator.kroll.common.Log; 17 | import org.appcelerator.titanium.util.TiConvert; 18 | 19 | import java.util.HashMap; 20 | import java.util.List; 21 | 22 | // The proxy is declared with the @Kroll.proxy annotation 23 | 24 | @Kroll.proxy(creatableInModule = ModdevguideModule.class, propertyAccessors = {"title", "testValue", "arg1", "arg2", "value1", "value2", "value3", "value4", "value5"}) 25 | public class KrollDemoProxy extends LifeCycleProxy 26 | implements KrollProxyListener { 27 | // Standard Debugging variables 28 | private static final String LCAT = "ModdevguideModule"; 29 | 30 | // The JavaScript callbacks (KrollCallback objects) 31 | private KrollFunction successCallback = null; 32 | private KrollFunction cancelCallback = null; 33 | private KrollFunction requestDataCallback = null; 34 | 35 | public KrollDemoProxy() { 36 | super(); 37 | 38 | // Registering for Event Listeners is automatically done for KrollProxy subclasses. 39 | } 40 | 41 | // Helper Methods 42 | 43 | private void sendSuccessEvent(String message, String title) { 44 | if (successCallback != null) { 45 | HashMap event = new HashMap(); 46 | event.put("message", message); 47 | event.put("title", title); 48 | 49 | // Fire an event directly to the specified listener (callback) 50 | successCallback.call(getKrollObject(), event); 51 | } 52 | } 53 | 54 | private void sendCancelEvent(String message, String title) { 55 | if (cancelCallback != null) { 56 | HashMap event = new HashMap(); 57 | event.put("message", message); 58 | event.put("title", title); 59 | 60 | // Fire an event directly to the specified listener (callback) 61 | cancelCallback.call(getKrollObject(), event); 62 | } 63 | } 64 | 65 | // Public APIs (available in javascript) 66 | 67 | // The methods are exposed to javascript because of the @Kroll.method annotation 68 | 69 | @Kroll.method 70 | public void registerCallbacks(HashMap args) { 71 | Object callback; 72 | 73 | Log.d(LCAT, "[KROLLDEMO] registerCallbacks called"); 74 | 75 | // Save the callback functions, verifying that they are of the correct type 76 | if (args.containsKey("success")) { 77 | callback = args.get("success"); 78 | if (callback instanceof KrollFunction) { 79 | successCallback = (KrollFunction) callback; 80 | } 81 | } 82 | if (args.containsKey("cancel")) { 83 | callback = args.get("cancel"); 84 | if (callback instanceof KrollFunction) { 85 | cancelCallback = (KrollFunction) callback; 86 | } 87 | } 88 | if (args.containsKey("requestData")) { 89 | callback = args.get("requestData"); 90 | if (callback instanceof KrollFunction) { 91 | requestDataCallback = (KrollFunction) callback; 92 | } 93 | } 94 | 95 | Log.d(LCAT, "[KROLLDEMO] Callbacks registered"); 96 | } 97 | 98 | @Kroll.method 99 | public void requestDataWithCallback() { 100 | Log.w(LCAT, "[KROLLDEMO] requestDataWithCallback called"); 101 | 102 | // The 'callSync' method of the KrollCallback object can be used to directly 103 | // call the associated JavaScript function and get a return value. 104 | HashMap event = new HashMap(); 105 | Object result = requestDataCallback.call(getKrollObject(), event); 106 | 107 | Log.d(LCAT, "[KROLLDEMO] requestData callback returned " + result); 108 | } 109 | 110 | @Kroll.method 111 | public void signalCallbackWithSuccess(Boolean success) { 112 | Log.d(LCAT, "[KROLLDEMO] signalCallbackWithSuccess called"); 113 | 114 | // Caller passes in a value indicating if this is a success call or 115 | // a cancel call. 116 | 117 | // Get the title from the properties of the module proxy object 118 | String title = TiConvert.toString(getProperty("title")); 119 | 120 | if (success) { 121 | sendSuccessEvent("Success", title); 122 | } else { 123 | sendCancelEvent("Cancel", title); 124 | } 125 | 126 | Log.d(LCAT, "[KROLLDEMO] Event fired"); 127 | } 128 | 129 | @Kroll.method 130 | public void signalEvent() { 131 | Log.d(LCAT, "[KROLLDEMO] signalEvent called"); 132 | 133 | // It is a good idea to check if there are listeners for the event that 134 | // is about to fired. There could be zero or multiple listeners for the 135 | // specified event. 136 | if (hasListeners("demoEvent")) { 137 | HashMap event = new HashMap(); 138 | event.put("index", 1); 139 | event.put("value", 100); 140 | event.put("name", "userEvent"); 141 | 142 | fireEvent("demoEvent", event); 143 | 144 | Log.d(LCAT, "[KROLLDEMO] demoEvent fired"); 145 | } 146 | } 147 | 148 | @Kroll.method 149 | public void callThisCallbackDirectly(HashMap args) { 150 | // By specifying an explicit argument type in the method declaration (rather 151 | // than a generic Object array), the argument type has already been validated 152 | 153 | Log.d(LCAT, "[KROLLDEMO] callThisCallbackDirectly called"); 154 | 155 | KrollFunction callback = null; 156 | Object object = args.get("callback"); 157 | if (object instanceof KrollFunction) { 158 | callback = (KrollFunction) object; 159 | } 160 | 161 | Object data = args.get("data"); 162 | 163 | // Our callback will be passed 2 arguments: the value of the data property 164 | // from the dictionary passed in and a fixed string 165 | Object[] arrayOfValues = new Object[]{data, "KrollDemo"}; 166 | 167 | if (callback != null) { 168 | // The 'callSync' method of the KrollCallback object can be used to directly 169 | // call the associated JavaScript function and get a return value. In this 170 | // instance there is no return value for the callback. 171 | callback.call(getKrollObject(), arrayOfValues); 172 | 173 | Log.d(LCAT, "[KROLLDEMO] callback was called"); 174 | } 175 | } 176 | 177 | // Kroll Property Management 178 | 179 | @Kroll.setProperty 180 | public void setWatchPropertyChanges(boolean enabled) { 181 | // 182 | // This method is the 'setter' method for the 'watchPropertyChanges' proxy property. 183 | // It is called whenever the JavaScript code sets the value of the 'watchPropertyChanges' 184 | // property. 185 | // 186 | // By setting the modelListener property of the proxy, the 'propertyChanged' method 187 | // will be called whenever a proxy property is updated. This is an alternative technique 188 | // to implementing individual setter methods if you just need to know when a proxy 189 | // property has been updated in the set of properties that the proxy maintains. 190 | // 191 | // NOTE: The model listener is automatically set for a module. This is only required for a proxy 192 | // 193 | if (enabled) { 194 | setModelListener(this); 195 | } else { 196 | setModelListener(null); 197 | } 198 | 199 | // If you implement a setter, you should also manually store the property in 200 | // the properties for the proxy. This is done by calling the 'setProperty' method. 201 | // Otherwise, you can provide a getter by using the @Kroll.getProperty annotation 202 | setProperty("watchPropertyChanges", enabled); 203 | } 204 | 205 | // KrollProxyListener methods 206 | 207 | @Override 208 | public void listenerAdded(String type, int count, KrollProxy proxy) { 209 | Log.d(LCAT, "[KROLLDEMO] listener added for type " + type); 210 | } 211 | 212 | @Override 213 | public void listenerRemoved(String type, int count, KrollProxy proxy) { 214 | Log.d(LCAT, "[KROLLDEMO] listener removed for type " + type); 215 | } 216 | 217 | @Override 218 | public void processProperties(KrollDict dict) { 219 | Log.d(LCAT, "[KROLLDEMO] processProperties " + dict); 220 | } 221 | 222 | @Override 223 | public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { 224 | // If the 'modelListener' property has been set for this proxy then this method is called 225 | // whenever a proxy property value is updated. Note that this method is called whenever the 226 | // setter is called, so it will get called even if the value of the property has not changed. 227 | 228 | if ((oldValue == newValue) || 229 | ((oldValue != null) && oldValue.equals(newValue))) { 230 | return; 231 | } 232 | 233 | Log.d(LCAT, "[KROLLDEMO] Property " + key + " changed from " + oldValue + " to " + newValue); 234 | 235 | // If is a good idea to check if there are listeners for the event that 236 | // is about to fired. There could be zero or multiple listeners for the 237 | // specified event. 238 | if (hasListeners("propertyChange")) { 239 | HashMap event = new HashMap(); 240 | event.put("property", key); 241 | event.put("oldValue", oldValue); 242 | event.put("newValue", newValue); 243 | 244 | fireEvent("propertyChange", event); 245 | } 246 | } 247 | 248 | @Override 249 | public void propertiesChanged(List changes, KrollProxy proxy) { 250 | 251 | Log.d(LCAT, "[KROLLDEMO] propertiesChanged"); 252 | 253 | for (KrollPropertyChange change : changes) { 254 | propertyChanged(change.getName(), change.getOldValue(), change.getNewValue(), proxy); 255 | } 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /android/src/ti/moddevguide/LifeCycleProxy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | package ti.moddevguide; 9 | 10 | import org.appcelerator.kroll.KrollDict; 11 | import org.appcelerator.kroll.KrollModule; 12 | import org.appcelerator.kroll.KrollProxy; 13 | import org.appcelerator.kroll.annotations.Kroll; 14 | import org.appcelerator.kroll.common.Log; 15 | 16 | // The proxy is declared with the @Kroll.proxy annotation 17 | 18 | @Kroll.proxy(creatableInModule = ModdevguideModule.class) 19 | public class LifeCycleProxy extends KrollProxy { 20 | // Standard Debugging variables 21 | private static final String LCAT = "ModdevguideModule"; 22 | 23 | // Unique Identifier variables 24 | private static int nextProxyId = 1; 25 | private int proxyId = 0; 26 | 27 | public LifeCycleProxy() { 28 | super(); 29 | 30 | // Generate a unique identifier so the user can see which proxy 31 | // instance is being created or destroyed (for demonstration purposes only). 32 | proxyId = nextProxyId++; 33 | 34 | // Each KrollProxy object has a unique proxy id 35 | Log.i(LCAT, "[PROXY LIFECYCLE EVENT] init with proxy id of " + proxyId); 36 | } 37 | 38 | // Handle creation options 39 | @Override 40 | public void handleCreationDict(KrollDict options) { 41 | // This method is called from handleCreationArgs if there is at least one 42 | // argument specified for the proxy creation call and the first argument 43 | // is a KrollDict object. 44 | 45 | Log.d(LCAT, "PROXY LIFECYCLE EVENT] handleCreationDict " + options); 46 | 47 | // Calling the superclass method ensures that the properties specified 48 | // in the dictionary are properly set on the proxy object. 49 | super.handleCreationDict(options); 50 | } 51 | 52 | public void handleCreationArgs(KrollModule createdInModule, Object[] args) { 53 | // This method is one of the initializers for the proxy class. The arguments 54 | // for the create call are passed as an array of objects. If your proxy 55 | // simply needs to handle a single KrollDict argument, use handleCreationDict. 56 | // The superclass method calls the handleCreationDict if the first argument 57 | // to the create method is a dictionary object. 58 | 59 | Log.d(LCAT, "PROXY LIFECYCLE EVENT] handleCreationArgs "); 60 | 61 | for (int i = 0; i < args.length; i++) { 62 | Log.d(LCAT, "PROXY LIFECYCLE EVENT] args[" + i + "] " + args[i]); 63 | } 64 | 65 | // Calling the superclass method is required 66 | super.handleCreationArgs(createdInModule, args); 67 | } 68 | 69 | // Public APIs (available in javascript) 70 | 71 | // The methods are exposed to javascript because of the @Kroll.method annotation 72 | 73 | @Kroll.method 74 | public void close() { 75 | Log.d(LCAT, "[PROXY LIFECYCLE EVENT] close called"); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /android/src/ti/moddevguide/MethodsDemoProxy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | package ti.moddevguide; 9 | 10 | import android.graphics.PointF; 11 | import android.graphics.RectF; 12 | 13 | import org.appcelerator.kroll.KrollDict; 14 | import org.appcelerator.kroll.annotations.Kroll; 15 | import org.appcelerator.kroll.common.Log; 16 | import org.appcelerator.titanium.TiApplication; 17 | import org.appcelerator.titanium.TiBlob; 18 | import org.appcelerator.titanium.TiFileProxy; 19 | import org.appcelerator.titanium.io.TiBaseFile; 20 | import org.appcelerator.titanium.io.TiFileFactory; 21 | import org.appcelerator.titanium.util.TiConvert; 22 | 23 | import java.util.Calendar; 24 | import java.util.Date; 25 | import java.util.HashMap; 26 | 27 | // The proxy is declared with the @Kroll.proxy annotation 28 | 29 | @Kroll.proxy(creatableInModule = ModdevguideModule.class) 30 | public class MethodsDemoProxy extends LifeCycleProxy { 31 | // Standard Debugging variables 32 | private static final String LCAT = "ModdevguideModule"; 33 | 34 | public MethodsDemoProxy() { 35 | super(); 36 | } 37 | 38 | // Public APIs (available in javascript) 39 | 40 | // The methods are exposed to javascript because of the @Kroll.method annotation. 41 | // Method signatures can be specified with the following properties: 42 | // 43 | // 1. The arguments can be declared as an Object[]. Specify this in the method 44 | // signature to handle a variable number of arguments or to support manual 45 | // type conversion of arguments. 46 | // public void myMethod(KrollInvocation invocation, Object[] args); 47 | // 2. The arguments can be declared with explicit types. Specify this in the 48 | // method signature to have Kroll attempt to call with an exact match of 49 | // the parameter types. 50 | // public void myMethod(KrollInvocation invocation, int firstArg, KrollDict secondArg); 51 | 52 | @Kroll.method 53 | public void demoMethodNoReturn() { 54 | // This method is an example of exposing a native method to JavaScript. 55 | // The method signature does not declare any parameters. 56 | 57 | Log.d(LCAT, "[METHODSDEMO] demoMethodNoReturn"); 58 | } 59 | 60 | @Kroll.method 61 | public int demoMethodNumberInt(Object[] args) { 62 | // This method is an example of exposing a native method that accepts 2 63 | // integer values as arguments and returns a number. 64 | // The method signature declares an array of objects, so it is necessary 65 | // to validate the number of arguments passed to the method. 66 | 67 | final int kArgOriginal = 0; 68 | final int kArgMultiplier = 1; 69 | final int kArgCount = 2; 70 | 71 | // Validate correct number of arguments 72 | if (args.length < kArgCount) { 73 | throw new IllegalArgumentException("At least 2 arguments required for method: original, multiplier"); 74 | } 75 | 76 | Log.d(LCAT, "[METHODSDEMO] demoMethodNumberInt received " + args.length + " arguments"); 77 | 78 | // Use the TiConvert methods to get the values from the arguments 79 | int original = (args[kArgOriginal] != null) ? TiConvert.toInt(args[kArgOriginal]) : 0; 80 | int multiplier = (args[kArgMultiplier] != null) ? TiConvert.toInt(args[kArgMultiplier]) : 0; 81 | 82 | int result = original * multiplier; 83 | 84 | Log.d(LCAT, "[METHODSDEMO] " + result + " = " + original + " * " + multiplier); 85 | 86 | return result; 87 | } 88 | 89 | @Kroll.method 90 | public float demoMethodNumberFloat(Object[] args) { 91 | // This method is an example of exposing a native method that accepts 2 92 | // floating point values as arguments and returns a number. 93 | // The method signature declares an array of objects, so it is necessary 94 | // to validate the number of arguments passed to the method. 95 | 96 | final int kArgOriginal = 0; 97 | final int kArgMultiplier = 1; 98 | final int kArgCount = 2; 99 | 100 | // Validate correct number of arguments 101 | if (args.length < kArgCount) { 102 | throw new IllegalArgumentException("At least 2 arguments required for method: original, multiplier"); 103 | } 104 | 105 | Log.d(LCAT, "[METHODSDEMO] demoMethodNumberFloat received " + args.length + " arguments"); 106 | 107 | // Use the TiConvert methods to get the values from the arguments 108 | float original = (args[kArgOriginal] != null) ? TiConvert.toFloat(args[kArgOriginal]) : 0; 109 | float multiplier = (args[kArgMultiplier] != null) ? TiConvert.toFloat(args[kArgMultiplier]) : 0; 110 | 111 | float result = original * multiplier; 112 | 113 | Log.d(LCAT, "[METHODSDEMO] " + result + " = " + original + " * " + multiplier); 114 | 115 | return result; 116 | } 117 | 118 | @Kroll.method 119 | public String demoMethodString(Object[] args) { 120 | // This method is an example of exposing a native method that accepts 3 121 | // arguments (2 string values and 1 integer value) and returns a string. 122 | // The method signature declares an array of objects, so it is necessary 123 | // to validate the number of arguments passed to the method. 124 | 125 | final int kArgFirstName = 0; 126 | final int kArgLastName = 1; 127 | final int kArgAge = 2; 128 | final int kArgCount = 3; 129 | 130 | // Validate correct number of arguments 131 | if (args.length < kArgCount) { 132 | throw new IllegalArgumentException("At least 3 arguments required for method: firstname, lastname, age"); 133 | } 134 | 135 | Log.d(LCAT, "[METHODSDEMO] demoMethodString received " + args.length + " arguments"); 136 | 137 | // Use the TiConvert methods to get the values from the arguments 138 | String firstName = TiConvert.toString(args[kArgFirstName]); 139 | String lastName = TiConvert.toString(args[kArgLastName]); 140 | int age = (args[kArgAge] != null) ? TiConvert.toInt(args[kArgAge]) : 0; 141 | 142 | String result = "User " + firstName + " " + lastName + " is " + age + " years old"; 143 | 144 | Log.d(LCAT, "[METHODSDEMO] " + result); 145 | 146 | return result; 147 | } 148 | 149 | @Kroll.method 150 | public HashMap demoMethodDictionary(Object args) { 151 | // This method is an example of exposing a native method that accepts an 152 | // array of values and returns a dictionary of those values. 153 | // Since the method only accepts one argument and the argument is an 154 | // array, it has been declared as an Object (rather than an Object[]). If 155 | // the argument is declared as an Object[] then the single argument (an array) 156 | // would be received as the Object[] argument. This declaration allows for 157 | // local validation of the array argument. 158 | 159 | // Validate type of argument 160 | if (!(args.getClass().isArray())) { 161 | throw new IllegalArgumentException("Argument must be an array"); 162 | } 163 | 164 | Log.d(LCAT, "[METHODSDEMO] demoMethodDictionary received 1 argument of type array"); 165 | 166 | Object[] argArray = (Object[]) args; 167 | HashMap result = new HashMap(argArray.length); 168 | 169 | for (int index = 0; index < argArray.length; index++) { 170 | result.put("Index" + index, argArray[index]); 171 | } 172 | 173 | Log.d(LCAT, "[METHODSDEMO] " + result); 174 | 175 | return result; 176 | } 177 | 178 | @Kroll.method 179 | public Date demoMethodDate(HashMap hm) { 180 | KrollDict args = new KrollDict(hm); 181 | // This method is an example of exposing a native method that accepts a dictionary 182 | // argument and returns an Date object. 183 | 184 | Log.d(LCAT, "[METHODSDEMO] demoMethodDate received 1 argument of type KrollDict"); 185 | 186 | // Use the optInt methods to get the values from the dictionary 187 | int month = args.optInt("month", 1); 188 | int day = args.optInt("day", 1); 189 | int year = args.optInt("year", 2000); 190 | 191 | Calendar calendar = Calendar.getInstance(); 192 | calendar.set(Calendar.YEAR, year); 193 | // Note: Month is zero-based 194 | calendar.set(Calendar.MONTH, month - 1); 195 | calendar.set(Calendar.DAY_OF_MONTH, day); 196 | 197 | Date result = calendar.getTime(); 198 | 199 | Log.d(LCAT, "[METHODSDEMO] " + result); 200 | 201 | return result; 202 | } 203 | 204 | @Kroll.method 205 | public Object[] demoMethodArray(Object[] args) { 206 | // This method is an example of exposing a native method that accepts a 207 | // dynamic list of arguments and returns an NSArray object. 208 | 209 | Log.d(LCAT, "[METHODSDEMO] demoMethodArray received " + args.length + " arguments"); 210 | 211 | // Create a new array from the argument array 212 | Object[] result = new Object[args.length]; 213 | System.arraycopy(args, 0, result, 0, args.length); 214 | 215 | Log.d(LCAT, "[METHODSDEMO] " + result); 216 | 217 | return result; 218 | } 219 | 220 | @Kroll.method 221 | public Object demoMethodNull() { 222 | // This method is an example of exposing a native method that returns an 223 | // NSNull object. 224 | 225 | Log.d(LCAT, "[METHODSDEMO] demoMethodNull called"); 226 | 227 | Object result = null; 228 | 229 | Log.d(LCAT, "[METHODSDEMO] " + result); 230 | 231 | return result; 232 | } 233 | 234 | @Kroll.method 235 | public TiFileProxy demoMethodFile(String arg) { 236 | // This method is an example of exposing a native method that accepts a 237 | // single string argument and returns a TiFile object. 238 | 239 | Log.d(LCAT, "[METHODSDEMO] demoMethodFile received 1 argument of type String"); 240 | 241 | TiBaseFile file = TiFileFactory.createTitaniumFile(arg, false); 242 | TiFileProxy result = new TiFileProxy(file); 243 | 244 | Log.d(LCAT, "[METHODSDEMO] Path: " + result.getNativePath() + " Size: " + result.getSize()); 245 | 246 | return result; 247 | } 248 | 249 | @Kroll.method 250 | public TiBlob demoMethodBlob() { 251 | // This method is an example of exposing a native method that returns a TiBlob 252 | // object containing a predefined blob of text. 253 | 254 | Log.d(LCAT, "[METHODSDEMO] demoMethodBlob called"); 255 | 256 | TiBlob result = TiBlob.blobFromString("Hello World"); 257 | 258 | Log.d(LCAT, "[METHODSDEMO] " + result); 259 | 260 | return result; 261 | } 262 | 263 | @Kroll.method 264 | public HashMap demoMethodRect(Object[] args) { 265 | // This method is an example of exposing a native method that accepts 4 266 | // integer values as arguments and returns an equivalent TiRect object. 267 | // The method signature declares an array of objects, so it is necessary 268 | // to validate the number of arguments passed to the method. 269 | 270 | final int kArgX = 0; 271 | final int kArgY = 1; 272 | final int kArgWidth = 2; 273 | final int kArgHeight = 3; 274 | final int kArgCount = 4; 275 | 276 | // Validate correct number of arguments 277 | if (args.length < kArgCount) { 278 | throw new IllegalArgumentException("At least 4 arguments required for method: x, y, width, height"); 279 | } 280 | 281 | Log.d(LCAT, "[METHODSDEMO] demoMethodRect received " + args.length + " arguments"); 282 | 283 | // Use the TiConvert methods to get the values from the arguments 284 | RectF rect = new RectF(); 285 | rect.left = (args[kArgX] != null) ? TiConvert.toFloat(args[kArgX]) : 0; 286 | rect.top = (args[kArgY] != null) ? TiConvert.toFloat(args[kArgY]) : 0; 287 | rect.right = rect.left + ((args[kArgWidth] != null) ? TiConvert.toFloat(args[kArgWidth]) : 0); 288 | rect.bottom = rect.top + ((args[kArgHeight] != null) ? TiConvert.toFloat(args[kArgHeight]) : 0); 289 | 290 | HashMap result = new HashMap(); 291 | result.put("x", rect.left); 292 | result.put("y", rect.top); 293 | result.put("width", rect.width()); 294 | result.put("height", rect.height()); 295 | 296 | Log.d(LCAT, "[METHODSDEMO] " + result); 297 | 298 | return result; 299 | } 300 | 301 | @Kroll.method 302 | public HashMap demoMethodPoint(Object[] args) { 303 | // This method is an example of exposing a native method that accepts 2 304 | // integer values as arguments and returns an equivalent TiPoint object. 305 | // The method signature declares an array of objects, so it is necessary 306 | // to validate the number of arguments passed to the method. 307 | 308 | final int kArgX = 0; 309 | final int kArgY = 1; 310 | final int kArgCount = 2; 311 | 312 | // Validate correct number of arguments 313 | if (args.length < kArgCount) { 314 | throw new IllegalArgumentException("At least 2 arguments required for method: x, y"); 315 | } 316 | 317 | Log.d(LCAT, "[METHODSDEMO] demoMethodPoint received " + args.length + " arguments"); 318 | 319 | // Use the TiConvert methods to get the values from the arguments 320 | PointF point = new PointF(); 321 | point.x = (args[kArgX] != null) ? TiConvert.toFloat(args[kArgX]) : 0; 322 | point.y = (args[kArgY] != null) ? TiConvert.toFloat(args[kArgY]) : 0; 323 | 324 | HashMap result = new HashMap(); 325 | result.put("x", point.x); 326 | result.put("y", point.y); 327 | 328 | Log.d(LCAT, "[METHODSDEMO] " + result); 329 | 330 | return result; 331 | } 332 | 333 | @Kroll.method 334 | public HashMap demoMethodRange(Object[] args) { 335 | // This method is an example of exposing a native method that accepts 2 336 | // integer values as arguments and returns an equivalent TiRange object. 337 | // The method signature declares an array of objects, so it is necessary 338 | // to validate the number of arguments passed to the method. 339 | 340 | final int kArgLocation = 0; 341 | final int kArgLength = 1; 342 | final int kArgCount = 2; 343 | 344 | // Validate correct number of arguments 345 | if (args.length < kArgCount) { 346 | throw new IllegalArgumentException("At least 2 arguments required for method: location, length"); 347 | } 348 | 349 | Log.d(LCAT, "[METHODSDEMO] demoMethodRange received " + args.length + " arguments"); 350 | 351 | // Use the TiConvert methods to get the values from the arguments 352 | int location = (args[kArgLocation] != null) ? TiConvert.toInt(args[kArgLocation]) : 0; 353 | int length = (args[kArgLength] != null) ? TiConvert.toInt(args[kArgLength]) : 0; 354 | 355 | HashMap result = new HashMap(); 356 | result.put("location", location); 357 | result.put("length", length); 358 | 359 | Log.d(LCAT, "[METHODSDEMO] " + result); 360 | 361 | return result; 362 | } 363 | 364 | @Kroll.method 365 | public int demoMethodColor(String color) { 366 | // This method is an example of exposing a native method that accepts a 367 | // string containing a color value and returns an equivalent TiColor value. 368 | 369 | Log.d(LCAT, "[METHODSDEMO] demoMethodColor received 1 argument of type String"); 370 | 371 | // Use the TiConvert methods to get the values from the arguments 372 | int result = TiConvert.toColor(color, TiApplication.getAppCurrentActivity()); 373 | 374 | Log.d(LCAT, "[METHODSDEMO] " + Integer.toHexString(result)); 375 | 376 | return result; 377 | } 378 | 379 | @Kroll.method 380 | public String demoMethodOptionalArgs(String greeting, @Kroll.argument(optional = true) Object name) { 381 | // This method is an example of exposing a native method that accepts 1 or 2 382 | // arguments (2 string values) and returns a string. 383 | // The 'Kroll.argument(optional=true)' annotation declares that the argument is optional 384 | // yet allows Kroll to match to this method when either 1 or 2 arguments is specified 385 | // in the JavaScript method call. 386 | 387 | Log.d(LCAT, "[METHODSDEMO] demoMethodOptionalArgs received " + ((name == null) ? "1" : "2") + " arguments"); 388 | 389 | String result = null; 390 | if (name == null) { 391 | result = greeting + "!!"; 392 | } else if (name instanceof String) { 393 | result = greeting + ", " + (String) name + "!"; 394 | } 395 | 396 | Log.d(LCAT, "[METHODSDEMO] " + result); 397 | 398 | return result; 399 | } 400 | 401 | } 402 | -------------------------------------------------------------------------------- /android/src/ti/moddevguide/ModdevguideModule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | package ti.moddevguide; 9 | 10 | import android.app.Activity; 11 | import android.graphics.Bitmap; 12 | 13 | import org.appcelerator.kroll.KrollModule; 14 | import org.appcelerator.kroll.annotations.Kroll; 15 | import org.appcelerator.kroll.common.Log; 16 | import org.appcelerator.titanium.TiApplication; 17 | import org.appcelerator.titanium.TiBlob; 18 | import org.appcelerator.titanium.io.TiBaseFile; 19 | import org.appcelerator.titanium.io.TiFileFactory; 20 | import org.appcelerator.titanium.util.TiRHelper; 21 | import org.appcelerator.titanium.util.TiRHelper.ResourceNotFoundException; 22 | import org.appcelerator.titanium.util.TiUIHelper; 23 | 24 | import java.io.IOException; 25 | 26 | // The module is declared with the @Kroll.module annotation 27 | 28 | @Kroll.module(name = "Moddevguide", id = "ti.moddevguide") 29 | public class ModdevguideModule extends KrollModule { 30 | // Constants can be made available to the JavaScript using the following notations 31 | @Kroll.constant 32 | public static final int DEMO_INTEGER = 50; 33 | @Kroll.constant 34 | public static final String DEMO_STRING = "Hello World"; 35 | @Kroll.constant 36 | public static final Boolean DEMO_BOOLEAN = true; 37 | // Standard Debugging variables 38 | private static final String LCAT = "ModdevguideModule"; 39 | 40 | // Module initialization 41 | 42 | public ModdevguideModule() { 43 | super(); 44 | 45 | Log.d(LCAT, "[MODULE LIFECYCLE EVENT] constructor"); 46 | 47 | // Lifecycle event registration is automatically done in the KrollModule constructor, 48 | // so there is no need to register to receive the lifecycle events. 49 | } 50 | 51 | // Use the '@Kroll.onAppCreate' annotation to declare a method to be called 52 | // when the application object is created. This is optional and is only 53 | // required if you have any application specific initialization. 54 | // 55 | @Kroll.onAppCreate 56 | public static void onAppCreate(TiApplication app) { 57 | // This method is called during application startup. It is only called once and 58 | // is called before your module is actually loaded. Use this method to perform 59 | // process specific initialization -- for example, starting a service that is 60 | // required by the module. 61 | 62 | Log.d(LCAT, "[MODULE LIFECYCLE EVENT] onAppCreate notification"); 63 | } 64 | 65 | // Lifecycle 66 | 67 | // NOTES: 68 | // 69 | // 1. Modules are created in the root context 70 | // 2. Using navBarHidden (or fullscreen or modal) causes the window, when opened, to run in a new Android Activity. 71 | // 3. The root context/activity will be stopped when a new activity is launched 72 | // 4. Lifecycle notifications will NOT be received while the root activity is stopped. 73 | 74 | @Override 75 | public void onStart(Activity activity) { 76 | // This method is called when the module is loaded and the root context is started 77 | 78 | Log.d(LCAT, "[MODULE LIFECYCLE EVENT] start"); 79 | 80 | super.onStart(activity); 81 | } 82 | 83 | @Override 84 | public void onStop(Activity activity) { 85 | // This method is called when the root context is stopped 86 | 87 | Log.d(LCAT, "[MODULE LIFECYCLE EVENT] stop"); 88 | 89 | super.onStop(activity); 90 | } 91 | 92 | @Override 93 | public void onPause(Activity activity) { 94 | // This method is called when the root context is being suspended 95 | 96 | Log.d(LCAT, "[MODULE LIFECYCLE EVENT] pause"); 97 | 98 | super.onPause(activity); 99 | } 100 | 101 | @Override 102 | public void onResume(Activity activity) { 103 | // This method is called when the root context is being resumed 104 | 105 | Log.d(LCAT, "[MODULE LIFECYCLE EVENT] resume"); 106 | 107 | super.onResume(activity); 108 | } 109 | 110 | @Override 111 | public void onDestroy(Activity activity) { 112 | // This method is called when the root context is being destroyed 113 | 114 | Log.d(LCAT, "[MODULE LIFECYCLE EVENT] destroy"); 115 | 116 | super.onDestroy(activity); 117 | } 118 | 119 | // Assets Demo Methods 120 | 121 | private int getIdOfModuleAsset(String assetName, String typeWithDot) { 122 | // Use this to locate resources in the R.java file (e.g. platform/android/res/drawable) 123 | // In case the caller passes in the asset name with the extension, strip it off 124 | // Prefix the asset name with type 125 | 126 | int dot = assetName.lastIndexOf("."); 127 | String resourceName = typeWithDot + ((dot > 0) ? assetName.substring(0, dot) : assetName); 128 | 129 | int result = 0; 130 | try { 131 | result = TiRHelper.getApplicationResource(resourceName); 132 | } catch (ResourceNotFoundException e) { 133 | Log.d(LCAT, "[ASSETSDEMO] EXCEPTION -- RESOURCE NOT FOUND"); 134 | } 135 | 136 | return result; 137 | } 138 | 139 | private String getPathToApplicationAsset(String assetName) { 140 | // The url for an application asset can be created by resolving the specified 141 | // path with the proxy context. This locates a resource relative to the 142 | // application resources folder 143 | 144 | String result = resolveUrl(null, assetName); 145 | 146 | return result; 147 | } 148 | 149 | // Public APIs (available in javascript) 150 | 151 | // The methods are exposed to javascript because of the @Kroll.method annotation 152 | 153 | @Kroll.method 154 | public TiBlob loadImageFromModule(String imageName) { 155 | Log.d(LCAT, "[ASSETSDEMO] loadImageFromModule " + imageName); 156 | 157 | TiBlob result = null; 158 | 159 | int bitmapID = getIdOfModuleAsset(imageName, "drawable."); 160 | Bitmap bitmap = TiUIHelper.getResourceBitmap(bitmapID); 161 | 162 | // The bitmap must be converted to a TiBlob before returning 163 | result = TiBlob.blobFromImage(bitmap); 164 | 165 | Log.d(LCAT, "[ASSETSDEMO] " + result); 166 | 167 | return result; 168 | } 169 | 170 | @Kroll.method 171 | public TiBlob loadImageFromApplication(String imageName) { 172 | Log.d(LCAT, "[ASSETSDEMO] loadImageFromApplication " + imageName); 173 | 174 | TiBlob result = null; 175 | try { 176 | // Load the image from the application assets 177 | String url = getPathToApplicationAsset(imageName); 178 | TiBaseFile file = TiFileFactory.createTitaniumFile(new String[]{url}, false); 179 | Bitmap bitmap = TiUIHelper.createBitmap(file.getInputStream()); 180 | 181 | // The bitmap must be converted to a TiBlob before returning 182 | result = TiBlob.blobFromImage(bitmap); 183 | } catch (IOException e) { 184 | Log.e(LCAT, "[ASSETSDEMO] EXCEPTION - IO"); 185 | } 186 | 187 | Log.d(LCAT, "[ASSETSDEMO] " + result); 188 | 189 | return result; 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /android/src/ti/moddevguide/ParametersDemoProxy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | package ti.moddevguide; 9 | 10 | import org.appcelerator.kroll.KrollFunction; 11 | import org.appcelerator.kroll.annotations.Kroll; 12 | import org.appcelerator.kroll.common.Log; 13 | 14 | import java.text.DateFormat; 15 | import java.text.SimpleDateFormat; 16 | import java.util.Date; 17 | import java.util.HashMap; 18 | import java.util.TimeZone; 19 | 20 | // The proxy is declared with the @Kroll.proxy annotation 21 | 22 | @Kroll.proxy(creatableInModule = ModdevguideModule.class) 23 | public class ParametersDemoProxy extends LifeCycleProxy { 24 | // Standard Debugging variables 25 | private static final String LCAT = "ModdevguideModule"; 26 | 27 | public ParametersDemoProxy() { 28 | super(); 29 | } 30 | 31 | private void analyzeArgument(String prefix, Object arg) { 32 | if (arg == null) { 33 | Log.d(LCAT, prefix + "NULL"); 34 | } else if (arg.getClass().isArray()) { 35 | Object[] objArray = (Object[]) arg; 36 | Log.d(LCAT, prefix + "Array with " + objArray.length + " entries"); 37 | int index = 0; 38 | for (Object obj : objArray) { 39 | Log.d(LCAT, prefix + "Index[" + index++ + "]"); 40 | analyzeArgument(prefix + ".", obj); 41 | } 42 | } else if (arg instanceof HashMap) { 43 | HashMap kd = (HashMap) arg; 44 | Log.d(LCAT, prefix + "Dictionary with " + kd.size() + " entries"); 45 | for (Object key : kd.keySet().toArray()) { 46 | Log.d(LCAT, prefix + "Key[" + key.toString() + "]"); 47 | analyzeArgument(prefix + ".", kd.get(key)); 48 | } 49 | } else if (arg instanceof String) { 50 | Log.d(LCAT, prefix + "String = " + (String) arg); 51 | } else if (arg instanceof Number) { 52 | Log.d(LCAT, prefix + "Number = " + (Number) arg); 53 | } else if (arg instanceof Date) { 54 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); 55 | df.setTimeZone(TimeZone.getTimeZone("GMT")); 56 | Log.d(LCAT, prefix + "Date = " + df.format((Date) arg)); 57 | } else if (arg instanceof KrollFunction) { 58 | Log.d(LCAT, prefix + "Callback"); 59 | } else if (arg instanceof Boolean) { 60 | Log.d(LCAT, prefix + "Boolean = " + (Boolean) arg); 61 | } else { 62 | Log.d(LCAT, prefix + "Unknown class " + arg.getClass().getSimpleName()); 63 | } 64 | } 65 | 66 | // Public APIs (available in javascript) 67 | 68 | // The methods are exposed to javascript because of the @Kroll.method annotation 69 | 70 | @Kroll.method 71 | public void analyzeParameters(Object[] args) { 72 | // This method analyzes the arguments that are passed to it and outputs the types and depth of the 73 | // parameters. This is a recursive method that steps into and out of the arguments in order to output 74 | // their types. A dot ('.') character is output as a prefix to indicate the depth of the argument 75 | // from its parent argument. 76 | // 77 | // This analysis is useful to understand how arguments are passed from JavaScript into your native module. 78 | 79 | String prefix = "[PARAMETERSDEMO] "; 80 | 81 | Log.d(LCAT, prefix + "analyzeParameters called with " + args.length + " arguments"); 82 | 83 | for (Object arg : args) { 84 | analyzeArgument(prefix, arg); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /android/timodule.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideDemoView.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiUIView.h" 9 | 10 | @interface TiModdevguideDemoView : TiUIView { 11 | 12 | @private 13 | UIView *square; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideDemoView.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideDemoView.h" 9 | 10 | #import "TiUtils.h" 11 | 12 | @implementation TiModdevguideDemoView 13 | 14 | - (void)willMoveToSuperview:(UIView *)newSuperview 15 | { 16 | NSLog(@"[VIEW LIFECYCLE EVENT] willMoveToSuperview"); 17 | } 18 | 19 | - (void)initializeState 20 | { 21 | // This method is called right after allocating the view and 22 | // is useful for initializing anything specific to the view 23 | 24 | [super initializeState]; 25 | 26 | NSLog(@"[VIEW LIFECYCLE EVENT] initializeState"); 27 | } 28 | 29 | - (void)configurationSet 30 | { 31 | // This method is called right after all view properties have 32 | // been initialized from the view proxy. If the view is dependent 33 | // upon any properties being initialized then this is the method 34 | // to implement the dependent functionality. 35 | 36 | [super configurationSet]; 37 | 38 | NSLog(@"[VIEW LIFECYCLE EVENT] configurationSet"); 39 | } 40 | 41 | - (UIView*)square 42 | { 43 | // Return the square view. If this is the first time then allocate and 44 | // initialize it. 45 | if (square == nil) { 46 | NSLog(@"[VIEW LIFECYCLE EVENT] square"); 47 | 48 | square = [[UIView alloc] initWithFrame:[self frame]]; 49 | [self addSubview:square]; 50 | } 51 | 52 | return square; 53 | } 54 | 55 | - (void)notifyOfColorChange:(TiColor*)newColor 56 | { 57 | NSLog(@"[VIEW LIFECYCLE EVENT] notifyOfColorChange"); 58 | 59 | // The event listeners for a view are actually attached to the view proxy. 60 | // You must reference 'self.proxy' to get the proxy for this view 61 | 62 | // It is a good idea to check if there are listeners for the event that 63 | // is about to fired. There could be zero or multiple listeners for the 64 | // specified event. 65 | if ([self.proxy _hasListeners:@"colorChange"]) { 66 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys: 67 | newColor,@"color", 68 | nil 69 | ]; 70 | 71 | [self.proxy fireEvent:@"colorChange" withObject:event]; 72 | } 73 | } 74 | 75 | - (void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds 76 | { 77 | // You must implement this method for your view to be sized correctly. 78 | // This method is called each time the frame / bounds / center changes 79 | // within Titanium. 80 | 81 | NSLog(@"[VIEW LIFECYCLE EVENT] frameSizeChanged"); 82 | 83 | if (square != nil) { 84 | 85 | // You must call the special method 'setView:positionRect' against 86 | // the TiUtils helper class. This method will correctly layout your 87 | // child view within the correct layout boundaries of the new bounds 88 | // of your view. 89 | 90 | [TiUtils setView:square positionRect:bounds]; 91 | } 92 | } 93 | 94 | - (void)setColor_:(id)color 95 | { 96 | // This method is a property 'setter' for the 'color' property of the 97 | // view. View property methods are named using a special, required 98 | // convention (the underscore suffix). 99 | 100 | NSLog(@"[VIEW LIFECYCLE EVENT] Property Set: setColor_"); 101 | 102 | // Use the TiUtils methods to get the values from the arguments 103 | TiColor *newColor = [TiUtils colorValue:color]; 104 | UIColor *clr = [newColor _color]; 105 | UIView *sq = [self square]; 106 | sq.backgroundColor = clr; 107 | 108 | // Signal a property change notification to demonstrate the use 109 | // of the proxy for the event listeners 110 | [self notifyOfColorChange:newColor]; 111 | } 112 | 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideDemoViewProxy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiViewProxy.h" 9 | 10 | @interface TiModdevguideDemoViewProxy : TiViewProxy { 11 | 12 | @private 13 | 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideDemoViewProxy.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideDemoViewProxy.h" 9 | 10 | #import "TiUtils.h" 11 | 12 | @implementation TiModdevguideDemoViewProxy 13 | 14 | - (id)init 15 | { 16 | // This is the designated initializer method and will always be called 17 | // when the view proxy is created. 18 | 19 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] init"); 20 | 21 | return [super init]; 22 | } 23 | 24 | - (void)_destroy 25 | { 26 | // This method is called from the dealloc method and is good place to 27 | // release any objects and memory that have been allocated for the view proxy. 28 | 29 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] _destroy"); 30 | 31 | [super _destroy]; 32 | } 33 | 34 | - (id)_initWithPageContext:(id)context 35 | { 36 | // This method is one of the initializers for the view proxy class. If the 37 | // proxy is created without arguments then this initializer will be called. 38 | // This method is also called from the other _initWithPageContext method. 39 | // The superclass method calls the init and _configure methods. 40 | 41 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] _initWithPageContext (no arguments)"); 42 | 43 | return [super _initWithPageContext:context]; 44 | } 45 | 46 | - (id)_initWithPageContext:(id)context_ args:(NSArray *)args 47 | { 48 | // This method is one of the initializers for the view proxy class. If the 49 | // proxy is created with arguments then this initializer will be called. 50 | // The superclass method calls the _initWithPageContext method without 51 | // arguments. 52 | 53 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] _initWithPageContext %@", args); 54 | 55 | return [super _initWithPageContext:context_ args:args]; 56 | } 57 | 58 | - (void)_configure 59 | { 60 | // This method is called from _initWithPageContext to allow for 61 | // custom configuration of the module before startup. The superclass 62 | // method calls the startup method. 63 | 64 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] _configure"); 65 | 66 | [super _configure]; 67 | } 68 | 69 | - (void)_initWithProperties:(NSDictionary *)properties 70 | { 71 | // This method is called from _initWithPageContext if arguments have been 72 | // used to create the view proxy. It is called after the initializers have completed 73 | // and is a good point to process arguments that have been passed to the 74 | // view proxy create method since most of the initialization has been completed 75 | // at this point. 76 | 77 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] _initWithProperties %@", properties); 78 | 79 | [super _initWithProperties:properties]; 80 | } 81 | 82 | - (void)viewWillAttach 83 | { 84 | // This method is called right before the view is attached to the proxy 85 | 86 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] viewWillAttach"); 87 | } 88 | 89 | - (void)viewDidAttach 90 | { 91 | // This method is called right after the view has attached to the proxy 92 | 93 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] viewDidAttach"); 94 | } 95 | 96 | - (void)viewDidDetach 97 | { 98 | // This method is called right before the view is detached from the proxy 99 | 100 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] viewDidDetach"); 101 | } 102 | 103 | - (void)viewWillDetach 104 | { 105 | // This method is called right after the view has detached from the proxy 106 | 107 | NSLog(@"[VIEWPROXY LIFECYCLE EVENT] viewWillDetach"); 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideKrollDemoProxy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideLifeCycleProxy.h" 9 | 10 | // NOTE: This proxy subclasses the TiModdevguideLifeCycleProxy to demonstrate the 11 | // lifecycle of a proxy. This would normally subclass TiProxy 12 | 13 | @interface TiModdevguideKrollDemoProxy : TiModdevguideLifeCycleProxy 14 | { 15 | @private 16 | // The JavaScript callbacks (KrollCallback objects) 17 | KrollCallback *successCallback; 18 | KrollCallback *cancelCallback; 19 | KrollCallback *requestDataCallback; 20 | } 21 | 22 | @end 23 | 24 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideKrollDemoProxy.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideKrollDemoProxy.h" 9 | #import "TiUtils.h" 10 | #import 11 | 12 | @implementation TiModdevguideKrollDemoProxy 13 | 14 | #pragma Helper Methods 15 | 16 | - (void)sendSuccessEvent:(id)message withTitle:(NSString *)title 17 | { 18 | if (successCallback != nil){ 19 | NSMutableDictionary *event = [NSMutableDictionary dictionary]; 20 | [event setObject:message forKey:@"message"]; 21 | [event setObject:title forKey:@"title"]; 22 | 23 | // Fire an event directly to the specified listener (callback) 24 | [self _fireEventToListener:@"success" withObject:event listener:successCallback thisObject:nil]; 25 | } 26 | } 27 | 28 | - (void)sendCancelEvent:(id)message withTitle:(NSString *)title 29 | { 30 | if (cancelCallback != nil){ 31 | NSMutableDictionary *event = [NSMutableDictionary dictionary]; 32 | [event setObject:message forKey:@"message"]; 33 | [event setObject:title forKey:@"title"]; 34 | 35 | // Fire an event directly to the specified listener (callback) 36 | [self _fireEventToListener:@"cancel" withObject:event listener:cancelCallback thisObject:nil]; 37 | } 38 | } 39 | 40 | #pragma Public APIs (available in javascript) 41 | 42 | // These methods are exposed to javascript because of their method signatures 43 | 44 | - (void)registerCallbacks:(id)args 45 | { 46 | ENSURE_SINGLE_ARG(args,NSDictionary); 47 | 48 | NSLog(@"[KROLLDEMO] registerCallbacks called"); 49 | 50 | // Save the callback functions and retain them 51 | successCallback = [args objectForKey:@"success"]; 52 | cancelCallback = [args objectForKey:@"cancel"]; 53 | requestDataCallback = [args objectForKey:@"requestData"]; 54 | 55 | NSLog(@"[KROLLDEMO] Callbacks registered"); 56 | } 57 | 58 | - (void)requestDataWithCallback:(id)args 59 | { 60 | NSLog(@"[KROLLDEMO] requestDataWithCallback called"); 61 | 62 | // The 'call' method of the KrollCallback object can be used to directly 63 | // call the associated JavaScript function and get a return value. 64 | id result = [requestDataCallback call:args thisObject:nil]; 65 | 66 | NSLog(@"[KROLLDEMO] requestData callback returned %@", result); 67 | } 68 | 69 | - (void)signalCallbackWithSuccess:(id)args 70 | { 71 | ENSURE_UI_THREAD(signalCallbackWithSuccess,args); 72 | 73 | NSLog(@"[KROLLDEMO] signalCallbackWithSuccess called"); 74 | 75 | // Caller can pass in a value indicating if this is a success call or 76 | // a cancel call. Default is 'NO'. 77 | BOOL success = [TiUtils boolValue:[args objectAtIndex:0] def:NO]; 78 | 79 | // Get the title from the properties of the module proxy object 80 | NSString *title = [self valueForUndefinedKey:@"title"]; 81 | 82 | if (success){ 83 | [self sendSuccessEvent:@"Success" withTitle:title]; 84 | } else { 85 | [self sendCancelEvent:@"Cancel" withTitle:title]; 86 | } 87 | 88 | NSLog(@"[KROLLDEMO] Event fired"); 89 | } 90 | 91 | - (void)signalEvent:(id)args 92 | { 93 | ENSURE_UI_THREAD(signalEvent,args); 94 | 95 | NSLog(@"[KROLLDEMO] signalEvent called"); 96 | 97 | // It is a good idea to check if there are listeners for the event that 98 | // is about to fired. There could be zero or multiple listeners for the 99 | // specified event. 100 | if ([self _hasListeners:@"demoEvent"]) { 101 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys: 102 | NUMINT(1),@"index", 103 | NUMINT(100),@"value", 104 | @"userEvent",@"name", 105 | nil 106 | ]; 107 | [self fireEvent:@"demoEvent" withObject:event]; 108 | 109 | NSLog(@"[KROLLDEMO] demoEvent fired"); 110 | } 111 | } 112 | 113 | - (void)callThisCallbackDirectly:(id)args 114 | { 115 | // This macro ensures that there is only one argument and that the argument 116 | // is of type NSDictionary. It also has the side-effect of re-assigning the 117 | // 'args' variable to the NSDictionary object. 118 | ENSURE_SINGLE_ARG(args,NSDictionary); 119 | 120 | NSLog(@"[KROLLDEMO] callThisCallbackDirectly called"); 121 | 122 | KrollCallback* callback = [args objectForKey:@"callback"]; 123 | id data = [args objectForKey:@"data"]; 124 | 125 | // Our callback will be passed 2 arguments: the value of the data property 126 | // from the dictionary passed in and a fixed string 127 | NSArray* arrayOfValues = [NSArray arrayWithObjects: data, @"KrollDemo", nil]; 128 | 129 | if (callback){ 130 | // The 'call' method of the KrollCallback object can be used to directly 131 | // call the associated JavaScript function and get a return value. In this 132 | // instance there is no return value for the callback. 133 | [callback call:arrayOfValues thisObject:nil]; 134 | 135 | NSLog(@"[KROLLDEMO] callback was called"); 136 | } 137 | } 138 | 139 | #pragma Kroll Property Management 140 | 141 | - (void)setWatchPropertyChanges:(id)value 142 | { 143 | // This method is the 'setter' method for the 'watchPropertyChanges' proxy property. 144 | // It is called whenever the JavaScript code sets the value of the 'watchPropertyChanges' 145 | // property. 146 | // 147 | // By setting the modelDelegate property of the proxy, the 'propertyChanged' method 148 | // will be called whenever a proxy property is updated. This is an alternative technique 149 | // to implementing individual setter methods if you just need to know when a proxy 150 | // property has been updated in the set of properties that the proxy maintains. 151 | 152 | BOOL enabled = [TiUtils boolValue:value]; 153 | if (enabled) { 154 | self.modelDelegate = self; 155 | } else { 156 | self.modelDelegate = nil; 157 | } 158 | 159 | // If you implement a setter, you should also manually store the property yourself in 160 | // the dynprops for the proxy. This is done by calling the 'replaceValue' method. 161 | [self replaceValue:value forKey:@"watchPropertyChanges" notification:NO]; 162 | } 163 | 164 | - (void)propertyChanged:(NSString *)key oldValue:(id)oldValue newValue:(id)newValue proxy:(TiProxy *)proxy 165 | { 166 | // If the 'modelDelegate' property has been set for this proxy then this method is called 167 | // whenever a proxy property value is updated. Note that this method is called whenever the 168 | // setter is called, so it will get called even if the value of the property has not changed. 169 | 170 | if ([oldValue isEqual:newValue]) { 171 | // Value didn't really change 172 | return; 173 | } 174 | 175 | NSLog(@"[KROLLDEMO] Property %@ changed from %@ to %@", key, oldValue, newValue); 176 | 177 | // If is a good idea to check if there are listeners for the event that 178 | // is about to fired. There could be zero or multiple listeners for the 179 | // specified event. 180 | if ([self _hasListeners:@"propertyChange"]) { 181 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys: 182 | key, @"property", 183 | oldValue == nil ? [NSNull null] : oldValue, @"oldValue", 184 | newValue == nil ? [NSNull null] : newValue, @"newValue", 185 | nil 186 | ]; 187 | [self fireEvent:@"propertyChange" withObject:event]; 188 | } 189 | } 190 | 191 | 192 | @end 193 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideLifeCycleProxy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiProxy.h" 9 | 10 | @interface TiModdevguideLifeCycleProxy : TiProxy { 11 | 12 | @private 13 | int proxyId; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideLifeCycleProxy.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideLifeCycleProxy.h" 9 | 10 | #import "TiUtils.h" 11 | 12 | static int nextProxyId = 1; 13 | 14 | @implementation TiModdevguideLifeCycleProxy 15 | 16 | - (id)init 17 | { 18 | // This is the designated initializer method and will always be called 19 | // when the proxy is created. 20 | 21 | // Generate a unique identifier so the user can see which proxy 22 | // instance is being created or destroyed (for demonstration purposes only). 23 | proxyId = nextProxyId++; 24 | 25 | NSLog(@"[PROXY LIFECYCLE EVENT] init with proxy id of %d", proxyId); 26 | 27 | return [super init]; 28 | } 29 | 30 | - (void)_destroy 31 | { 32 | // This method is called from the dealloc method and is good place to 33 | // release any objects and memory that have been allocated for the proxy. 34 | 35 | NSLog(@"[PROXY LIFECYCLE EVENT] _destroy proxy with id %d", proxyId); 36 | 37 | [super _destroy]; 38 | } 39 | 40 | - (id)_initWithPageContext:(id)context 41 | { 42 | // This method is one of the initializers for the proxy class. If the 43 | // proxy is created without arguments then this initializer will be called. 44 | // This method is also called from the other _initWithPageContext method. 45 | // The superclass method calls the init and _configure methods. 46 | 47 | NSLog(@"[PROXY LIFECYCLE EVENT] _initWithPageContext (no arguments)"); 48 | 49 | return [super _initWithPageContext:context]; 50 | } 51 | 52 | - (id)_initWithPageContext:(id)context_ args:(NSArray *)args 53 | { 54 | // This method is one of the initializers for the proxy class. If the 55 | // proxy is created with arguments then this initializer will be called. 56 | // The superclass method calls the _initWithPageContext method without 57 | // arguments. 58 | 59 | NSLog(@"[PROXY LIFECYCLE EVENT] _initWithPageContext %@", args); 60 | 61 | return [super _initWithPageContext:context_ args:args]; 62 | } 63 | 64 | - (void)_configure 65 | { 66 | // This method is called from _initWithPageContext to allow for 67 | // custom configuration of the module before startup. The superclass 68 | // method calls the startup method. 69 | 70 | NSLog(@"[PROXY LIFECYCLE EVENT] _configure"); 71 | 72 | [super _configure]; 73 | } 74 | 75 | - (void)_initWithProperties:(NSDictionary *)properties 76 | { 77 | // This method is called from _initWithPageContext if arguments have been 78 | // used to create the proxy. It is called after the initializers have completed 79 | // and is a good point to process arguments that have been passed to the 80 | // proxy create method since most of the initialization has been completed 81 | // at this point. 82 | 83 | NSLog(@"[PROXY LIFECYCLE EVENT] _initWithProperties %@", properties); 84 | 85 | [super _initWithProperties:properties]; 86 | } 87 | 88 | - (void)close:(id)args 89 | { 90 | // Provide for API parity with Android 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideMethodsDemoProxy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideLifeCycleProxy.h" 9 | 10 | // NOTE: This proxy subclasses the TiModdevguideLifeCycleProxy to demonstrate the 11 | // lifecycle of a proxy. This would normally subclass TiProxy 12 | 13 | @interface TiModdevguideMethodsDemoProxy : TiModdevguideLifeCycleProxy { 14 | 15 | @private 16 | 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideMethodsDemoProxy.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideMethodsDemoProxy.h" 9 | #import "TiUtils.h" 10 | #import "TiRect.h" 11 | #import "TiPoint.h" 12 | #import "TiBlob.h" 13 | 14 | @implementation TiModdevguideMethodsDemoProxy 15 | 16 | // These methods are exposed to javascript because of their method signatures 17 | 18 | - (void)demoMethodNoReturn:(id)args 19 | { 20 | // This method is an example of exposing a native method to JavaScript. Eventhough 21 | // the method signature has an 'args' parameter it is not required to pass 22 | // arguments from JavaScript to the method. 23 | 24 | NSLog(@"[METHODSDEMO] demoMethodNoReturn"); 25 | } 26 | 27 | - (NSNumber *)demoMethodNumberInt:(id)args 28 | { 29 | // This method is an example of exposing a native method that accepts 2 30 | // integer values as arguments and returns a number. 31 | // Arguments from JavaScript are passed to the native methods as an NSArray 32 | 33 | enum Args { 34 | kArgOriginal = 0, 35 | kArgMultiplier, 36 | kArgCount 37 | }; 38 | 39 | // Validate correct number of arguments 40 | ENSURE_ARG_COUNT(args, kArgCount); 41 | 42 | NSLog(@"[METHODSDEMO] demoMethodNumberInt received %d arguments", kArgCount); 43 | 44 | // Use the TiUtils methods to get the values from the arguments 45 | NSInteger original = [TiUtils intValue:[args objectAtIndex:kArgOriginal] def:0]; 46 | NSInteger multiplier = [TiUtils intValue:[args objectAtIndex:kArgMultiplier] def:0]; 47 | 48 | NSInteger result = original * multiplier; 49 | 50 | NSLog(@"[METHODSDEMO] %d = %d * %d", result, original, multiplier); 51 | 52 | return NUMINTEGER(result); 53 | } 54 | 55 | - (NSNumber *)demoMethodNumberFloat:(id)args 56 | { 57 | // This method is an example of exposing a native method that accepts 2 58 | // floating point values as arguments and returns a number. 59 | // Arguments from JavaScript are passed to the native methods as an NSArray 60 | 61 | enum Args { 62 | kArgOriginal = 0, 63 | kArgMultiplier, 64 | kArgCount 65 | }; 66 | 67 | // Validate correct number of arguments 68 | ENSURE_ARG_COUNT(args, kArgCount); 69 | 70 | NSLog(@"[METHODSDEMO] demoMethodNumberInt received %d arguments", kArgCount); 71 | 72 | // Use the TiUtils methods to get the values from the arguments 73 | float original = [TiUtils floatValue:[args objectAtIndex:kArgOriginal] def:0.0]; 74 | float multiplier = [TiUtils floatValue:[args objectAtIndex:kArgMultiplier] def:0.0]; 75 | 76 | float result = original * multiplier; 77 | 78 | NSLog(@"[METHODSDEMO] %f = %f * %f", result, original, multiplier); 79 | 80 | return NUMFLOAT(result); 81 | } 82 | 83 | - (NSString *)demoMethodString:(id)args 84 | { 85 | // This method is an example of exposing a native method that accepts 3 86 | // arguments (2 string values and 1 integer value) and returns a string. 87 | // Arguments from JavaScript are passed to the native methods as an NSArray 88 | 89 | enum Args { 90 | kArgFirstName = 0, 91 | kArgLastName, 92 | kArgAge, 93 | kArgCount 94 | }; 95 | 96 | // Validate correct number of arguments 97 | ENSURE_ARG_COUNT(args, kArgCount); 98 | 99 | NSLog(@"[METHODSDEMO] demoMethodString received %d arguments", kArgCount); 100 | 101 | // Use the TiUtils methods to get the values from the arguments 102 | NSString *firstName = [TiUtils stringValue:[args objectAtIndex:kArgFirstName]]; 103 | NSString *lastName = [TiUtils stringValue:[args objectAtIndex:kArgLastName]]; 104 | NSInteger age = [TiUtils intValue:[args objectAtIndex:kArgAge]]; 105 | 106 | NSString *result = [NSString stringWithFormat:@"User %@ %@ is %ld years old", firstName, lastName, (long)age]; 107 | 108 | NSLog(@"[METHODSDEMO] %@", result); 109 | 110 | return result; 111 | } 112 | 113 | - (NSDictionary *)demoMethodDictionary:(id)args 114 | { 115 | // This method is an example of exposing a native method that accepts an 116 | // array of values and returns a dictionary of those values. 117 | // Arguments from JavaScript are passed to the native methods as an NSArray 118 | 119 | // The ENSURE_SINGLE_ARG macro will confirm that only 1 argument was passed 120 | // to the method and that it is of the specified type, and as a side-effect 121 | // will reassign 'args' to be the value of the first object in the argument array. 122 | ENSURE_SINGLE_ARG(args,NSArray); 123 | 124 | NSLog(@"[METHODSDEMO] demoMethodDictionary received 1 argument of type NSArray"); 125 | 126 | NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:[args count]]; 127 | 128 | NSInteger index = 0; 129 | for (id arg in args) { 130 | [result setValue:arg forKey:[NSString stringWithFormat:@"Index%ld", (long)index++]]; 131 | } 132 | 133 | NSLog(@"[METHODSDEMO] %@", result); 134 | 135 | return result; 136 | } 137 | 138 | - (NSDate *)demoMethodDate:(id)args 139 | { 140 | // This method is an example of exposing a native method that accepts a dictionary 141 | // argument and returns an NSDate object. 142 | // Arguments from JavaScript are passed to the native methods as an NSArray 143 | 144 | // The ENSURE_SINGLE_ARG macro will confirm that only 1 argument was passed 145 | // to the method and that it is of the specified type, and as a side-effect 146 | // will reassign 'args' to be the value of the first object in the argument array. 147 | ENSURE_SINGLE_ARG(args,NSDictionary); 148 | 149 | NSLog(@"[METHODSDEMO] demoMethodDate received 1 argument of type NSDictionary"); 150 | 151 | // Use the TiUtils methods to get the values from the arguments 152 | NSInteger month = [TiUtils intValue:@"month" properties:args def:1]; 153 | NSInteger day = [TiUtils intValue:@"day" properties:args def:1]; 154 | NSInteger year = [TiUtils intValue:@"year" properties:args def:2000]; 155 | 156 | NSDateComponents *comps = [[NSDateComponents alloc] init]; 157 | [comps setMonth:month]; 158 | [comps setDay:day]; 159 | [comps setYear:year]; 160 | NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; 161 | NSDate *result = [gregorian dateFromComponents:comps]; 162 | 163 | NSLog(@"[METHODSDEMO] %@", result); 164 | 165 | return result; 166 | } 167 | 168 | - (NSArray *)demoMethodArray:(id)args 169 | { 170 | // This method is an example of exposing a native method that accepts a 171 | // dynamic list of arguments and returns an NSArray object. 172 | // Arguments from JavaScript are passed to the native methods as an NSArray 173 | 174 | // The ENSURE_TYPE_OR_NILL macro will confirm that if an argument is passed 175 | // it is of the specified type, but it also allows for no arguments to be passed. 176 | ENSURE_TYPE_OR_NIL(args,NSArray); 177 | 178 | NSLog(@"[METHODSDEMO] demoMethodArray received %d arguments", [args count]); 179 | 180 | // Create a new array from the argument array 181 | NSArray *result = [NSArray arrayWithArray:args]; 182 | 183 | NSLog(@"[METHODSDEMO] %@", result); 184 | 185 | return result; 186 | } 187 | 188 | - (NSNull *)demoMethodNull:(id)args 189 | { 190 | // This method is an example of exposing a native method that returns an 191 | // NSNull object. 192 | // Arguments from JavaScript are passed to the native methods as an NSArray 193 | 194 | NSLog(@"[METHODSDEMO] demoMethodNull called"); 195 | 196 | NSNull *result = [NSNull null]; 197 | 198 | NSLog(@"[METHODSDEMO] %@", result); 199 | 200 | return result; 201 | } 202 | 203 | - (TiFile *)demoMethodFile:(id)args 204 | { 205 | // This method is an example of exposing a native method that accepts a 206 | // single string argument and returns a TiFile object. 207 | // Arguments from JavaScript are passed to the native methods as an NSArray 208 | 209 | // The ENSURE_SINGLE_ARG macro will confirm that only 1 argument was passed 210 | // to the method and that it is of the specified type, and as a side-effect 211 | // will reassign 'args' to be the value of the first object in the argument array. 212 | ENSURE_SINGLE_ARG(args,NSString); 213 | 214 | NSLog(@"[METHODSDEMO] demoMethodFile received 1 argument of type NSString"); 215 | 216 | NSString *path = args; 217 | 218 | // NOTE: File paths may contain URL prefix as of release 1.7 of the SDK 219 | if ([path hasPrefix:@"file:/"]) { 220 | NSURL* url = [NSURL URLWithString:path]; 221 | path = [url path]; 222 | } 223 | 224 | TiFile *result = [[TiFile alloc] initWithPath:path]; 225 | 226 | NSLog(@"[METHODSDEMO] Path: %@ Size: %d", result.path, result.size); 227 | 228 | return result; 229 | } 230 | 231 | - (TiBlob *)demoMethodBlob:(id)args 232 | { 233 | // This method is an example of exposing a native method that returns a TiBlob 234 | // object containing a predefined blob of text. 235 | // Arguments from JavaScript are passed to the native methods as an NSArray 236 | 237 | NSLog(@"METHODSDEMO] demoMethodBlob called"); 238 | 239 | const char *utfString = [@"Hello World" UTF8String]; 240 | 241 | NSData *data = [NSData dataWithBytes:utfString length:strlen(utfString)]; 242 | 243 | TiBlob *result = [[TiBlob alloc] initWithData:data mimetype:@"application/octet-stream"]; 244 | 245 | NSLog(@"[METHODSDEMO] %@", result); 246 | 247 | return result; 248 | } 249 | 250 | - (TiRect*)demoMethodRect:(id)args 251 | { 252 | // This method is an example of exposing a native method that accepts 4 253 | // integer values as arguments and returns a TiRect object. 254 | // Arguments from JavaScript are passed to the native methods as an NSArray 255 | 256 | enum Args { 257 | kArgX = 0, 258 | kArgY, 259 | kArgWidth, 260 | kArgHeight, 261 | kArgCount 262 | }; 263 | 264 | // Validate correct number of arguments 265 | ENSURE_ARG_COUNT(args, kArgCount); 266 | 267 | NSLog(@"[METHODSDEMO] demoMethodRect received %d arguments", kArgCount); 268 | 269 | // Use the TiUtils methods to get the values from the arguments 270 | CGRect rect; 271 | rect.origin.x = [TiUtils intValue:[args objectAtIndex:kArgX]]; 272 | rect.origin.y = [TiUtils intValue:[args objectAtIndex:kArgY]]; 273 | rect.size.width = [TiUtils intValue:[args objectAtIndex:kArgWidth]]; 274 | rect.size.height = [TiUtils intValue:[args objectAtIndex:kArgHeight]]; 275 | 276 | TiRect *result = [[TiRect alloc] init]; 277 | [result setRect:rect]; 278 | 279 | NSLog(@"[METHODSDEMO] %@", result); 280 | 281 | return result; 282 | } 283 | 284 | - (TiPoint *)demoMethodPoint:(id)args 285 | { 286 | // This method is an example of exposing a native method that accepts 2 287 | // integer values as arguments and returns a TiPoint object. 288 | // Arguments from JavaScript are passed to the native methods as an NSArray 289 | 290 | enum Args { 291 | kArgX = 0, 292 | kArgY, 293 | kArgCount 294 | }; 295 | 296 | // Validate correct number of arguments 297 | ENSURE_ARG_COUNT(args, kArgCount); 298 | 299 | NSLog(@"[METHODSDEMO] demoMethodPoint received %d arguments", kArgCount); 300 | 301 | // Use the TiUtils methods to get the values from the arguments 302 | CGPoint point; 303 | point.x = [TiUtils intValue:[args objectAtIndex:kArgX]]; 304 | point.y = [TiUtils intValue:[args objectAtIndex:kArgY]]; 305 | 306 | TiPoint *result = [[TiPoint alloc] initWithPoint:point]; 307 | 308 | NSLog(@"[METHODSDEMO] %@", result); 309 | 310 | return result; 311 | } 312 | 313 | - (NSDictionary *)demoMethodRange:(id)args 314 | { 315 | // This method is an example of exposing a native method that accepts 2 316 | // integer values as arguments and returns a TiRange like object. 317 | // Arguments from JavaScript are passed to the native methods as an NSArray 318 | 319 | enum Args { 320 | kArgLocation = 0, 321 | kArgLength, 322 | kArgCount 323 | }; 324 | 325 | // Validate correct number of arguments 326 | ENSURE_ARG_COUNT(args, kArgCount); 327 | 328 | NSLog(@"[METHODSDEMO] demoMethodRange received %d arguments", kArgCount); 329 | 330 | // Use the TiUtils methods to get the values from the arguments 331 | NSRange range; 332 | range.location = [TiUtils intValue:[args objectAtIndex:kArgLocation]]; 333 | range.length = [TiUtils intValue:[args objectAtIndex:kArgLength]]; 334 | 335 | // TiRange has been removed from the sdk as of version 2.1.0 336 | // Instead of using TiRange, this method just returns a TiRange like dictionary. 337 | NSDictionary* result = [NSDictionary dictionaryWithObjectsAndKeys:NUMINTEGER(range.location),@"location", 338 | NUMINTEGER(range.length),@"length", nil]; 339 | 340 | NSLog(@"[METHODSDEMO] %@", result); 341 | 342 | return result; 343 | } 344 | 345 | - (TiColor *)demoMethodColor:(id)args 346 | { 347 | // This method is an example of exposing a native method that accepts a 348 | // string containing a color value and returns a TiColor object. 349 | // Arguments from JavaScript are passed to the native methods as an NSArray 350 | ENSURE_SINGLE_ARG(args,NSString); 351 | 352 | NSLog(@"[METHODSDEMO] demoMethodColor received 1 argument of type NSString"); 353 | 354 | // Use the TiUtils methods to get the values from the arguments 355 | TiColor *result = [TiUtils colorValue:args]; 356 | 357 | NSLog(@"[METHODSDEMO] %@", result); 358 | 359 | return result; 360 | } 361 | 362 | - (NSString *)demoMethodOptionalArgs:(id)args 363 | { 364 | // This method is an example of exposing a native method that accepts 1 or 2 365 | // arguments (2 string values) and returns a string. 366 | // Arguments from JavaScript are passed to the native methods as an NSArray 367 | 368 | enum Args { 369 | kArgGreeting = 0, 370 | kArgCount, 371 | kArgName = kArgCount // Optional 372 | }; 373 | 374 | // The ENSURE_TYPE macro will confirm that if an argument is passed 375 | // it is of the specified type 376 | ENSURE_TYPE(args,NSArray); 377 | 378 | // Validate correct number of arguments 379 | ENSURE_ARG_COUNT(args, kArgCount); 380 | 381 | NSLog(@"[METHODSDEMO] demoMethodOptionalArgs received %d arguments", [args count]); 382 | 383 | // Use the TiUtils methods to get the values from the arguments 384 | NSString *greeting = [TiUtils stringValue:[args objectAtIndex:kArgGreeting]]; 385 | NSString *name = ([args count] > kArgName) ? [TiUtils stringValue:[args objectAtIndex:kArgName]] : nil; 386 | 387 | NSString *result; 388 | if (name == nil) { 389 | result = [NSString stringWithFormat:@"%@!!", greeting]; 390 | } else { 391 | result = [NSString stringWithFormat:@"%@, %@!", greeting, name]; 392 | } 393 | 394 | NSLog(@"[METHODSDEMO] %@", result); 395 | 396 | return result; 397 | } 398 | 399 | @end 400 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModule.h" 9 | 10 | @interface TiModdevguideModule : TiModule 11 | { 12 | } 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideModule.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideModule.h" 9 | #import "TiBase.h" 10 | #import "TiHost.h" 11 | #import "TiUtils.h" 12 | #import "TiBlob.h" 13 | 14 | @implementation TiModdevguideModule 15 | 16 | #pragma mark - Internal 17 | 18 | // this is generated for your module, please do not change it 19 | - (id)moduleGUID 20 | { 21 | return @"6fe96416-b375-4358-ab0e-65510cc1acbe"; 22 | } 23 | 24 | // this is generated for your module, please do not change it 25 | - (NSString *)moduleId 26 | { 27 | return @"ti.moddevguide"; 28 | } 29 | 30 | // Constants can be made available to the JavaScript using the following notations 31 | MAKE_SYSTEM_NUMBER(DEMO_INTEGER,NUMINT(50)); 32 | MAKE_SYSTEM_STR(DEMO_STRING,@"Hello World"); 33 | MAKE_SYSTEM_PROP(DEMO_BOOLEAN,YES); 34 | 35 | #pragma mark - Lifecycle 36 | 37 | - (void)startup 38 | { 39 | // This method is called when the module is first loaded 40 | // you *must* call the superclass 41 | 42 | [super startup]; 43 | 44 | NSLog(@"[MODULE LIFECYCLE EVENT] startup"); 45 | } 46 | 47 | - (void)shutdown:(id)sender 48 | { 49 | // This method is called when the module is being unloaded. 50 | // Typically this is during application shutdown. Make sure you don't do too 51 | // much processing here or the app will be quit forceably 52 | 53 | NSLog(@"[MODULE LIFECYCLE EVENT] shutdown"); 54 | 55 | // You *must* call the superclass 56 | [super shutdown:sender]; 57 | } 58 | 59 | - (id)init 60 | { 61 | // This is the designated initializer method and will always be called 62 | // when the proxy is created. 63 | 64 | NSLog(@"[MODULE LIFECYCLE EVENT] init"); 65 | 66 | return [super init]; 67 | } 68 | 69 | - (void)_destroy 70 | { 71 | // This method is called from the dealloc method and is good place to 72 | // release any objects and memory that have been allocated for the module. 73 | 74 | NSLog(@"[MODULE LIFECYCLE EVENT] _destroy"); 75 | 76 | [super _destroy]; 77 | } 78 | 79 | - (void)suspend:(id)sender 80 | { 81 | // This method is called when the application is being suspended 82 | 83 | NSLog(@"[MODULE LIFECYCLE EVENT] suspend"); 84 | 85 | [super suspend:sender]; 86 | } 87 | 88 | - (void)resume:(id)sender 89 | { 90 | // This method is called when the application is being resumed 91 | 92 | NSLog(@"[MODULE LIFECYCLE EVENT] resume"); 93 | 94 | [super resume:sender]; 95 | } 96 | 97 | - (void)resumed:(id)sender 98 | { 99 | // This method is called when the application has been resumed 100 | 101 | NSLog(@"[MODULE LIFECYCLE EVENT] resumed"); 102 | 103 | [super resumed:sender]; 104 | } 105 | 106 | - (id)_initWithPageContext:(id)context 107 | { 108 | // This method is one of the initializers for the proxy class. If the 109 | // proxy is created without arguments then this initializer will be called. 110 | // This method is also called from the other _initWithPageContext method. 111 | // The superclass method calls the init and _configure methods. 112 | 113 | NSLog(@"[MODULE LIFECYCLE EVENT] _initWithPageContext (no arguments)"); 114 | 115 | return [super _initWithPageContext:context]; 116 | } 117 | 118 | - (id)_initWithPageContext:(id)context_ args:(NSArray *)args 119 | { 120 | // This method is one of the initializers for the proxy class. If the 121 | // proxy is created with arguments then this initializer will be called. 122 | // The superclass method calls the _initWithPageContext method without 123 | // arguments. 124 | 125 | NSLog(@"[MODULE LIFECYCLE EVENT] _initWithPageContext (arguments)"); 126 | 127 | return [super _initWithPageContext:context_ args:args]; 128 | } 129 | 130 | - (void)_configure 131 | { 132 | // This method is called from _initWithPageContext to allow for 133 | // custom configuration of the module before startup. The superclass 134 | // method calls the startup method. 135 | 136 | NSLog(@"[MODULE LIFECYCLE EVENT] _configure"); 137 | 138 | [super _configure]; 139 | } 140 | 141 | - (void)_initWithProperties:(NSDictionary *)properties 142 | { 143 | // This method is called from _initWithPageContext if arguments have been 144 | // used to create the proxy. It is called after the initializers have completed 145 | // and is a good point to process arguments that have been passed to the 146 | // proxy create method since most of the initialization has been completed 147 | // at this point. 148 | 149 | NSLog(@"[MODULE LIFECYCLE EVENT] _initWithProperties"); 150 | 151 | [super _initWithProperties:properties]; 152 | } 153 | 154 | 155 | #pragma mark Internal Memory Management 156 | 157 | - (void)didReceiveMemoryWarning:(NSNotification*)notification 158 | { 159 | // optionally release any resources that can be dynamically 160 | // reloaded once memory is available - such as caches 161 | [super didReceiveMemoryWarning:notification]; 162 | } 163 | 164 | #pragma mark - Assets Demo Methods 165 | 166 | - (NSString *)getPathToModuleAsset:(NSString *) fileName 167 | { 168 | // The module assets are copied to the application bundle into the folder pattern 169 | // "module/". One way to access these assets is to build a path from the 170 | // mainBundle of the application. 171 | 172 | NSString *pathComponent = [NSString stringWithFormat:@"modules/%@/%@", [self moduleId], fileName]; 173 | NSString *result = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:pathComponent]; 174 | 175 | return result; 176 | } 177 | 178 | - (NSString *)getPathToApplicationAsset:(NSString *) fileName 179 | { 180 | // The application assets can be accessed by building a path from the mainBundle of the application. 181 | 182 | NSString *result = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:fileName]; 183 | 184 | return result; 185 | } 186 | 187 | #pragma mark API exposed to Javascript 188 | 189 | - (TiBlob*)loadImageFromModule:(id)args 190 | { 191 | ENSURE_SINGLE_ARG(args,NSString); 192 | 193 | NSLog(@"[ASSETSDEMO] loadImageFromModule %@", args); 194 | 195 | // Load the image from the module assets 196 | NSString *imagePath = [self getPathToModuleAsset:args]; 197 | UIImage *image = [UIImage imageWithContentsOfFile:imagePath]; 198 | if (image == nil) { 199 | return nil; 200 | } 201 | 202 | // The image must be converted to a TiBlob before returning 203 | TiBlob *result = [[TiBlob alloc] initWithImage:image]; 204 | 205 | NSLog(@"[ASSETSDEMO] %@", result); 206 | 207 | return result; 208 | } 209 | 210 | - (TiBlob*)loadImageFromApplication:(id)args 211 | { 212 | ENSURE_SINGLE_ARG(args,NSString); 213 | 214 | NSLog(@"[ASSETSDEMO] loadImageFromApplication %@", args); 215 | 216 | // Load the image from the application assets 217 | NSString *imagePath = [self getPathToApplicationAsset:args]; 218 | UIImage *image = [UIImage imageWithContentsOfFile:imagePath]; 219 | if (image == nil) { 220 | return nil; 221 | } 222 | 223 | // The image must be converted to a TiBlob before returning 224 | TiBlob *result = [[TiBlob alloc] initWithImage:image]; 225 | 226 | NSLog(@"[ASSETSDEMO] %@", result); 227 | 228 | return result; 229 | } 230 | 231 | @end 232 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideModuleAssets.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a generated file. Do not edit or your changes will be lost 3 | */ 4 | 5 | @interface TiModdevguideModuleAssets : NSObject 6 | { 7 | } 8 | - (NSData*) moduleAsset; 9 | @end 10 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideModuleAssets.m: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a generated file. Do not edit or your changes will be lost 3 | */ 4 | #import "TiModdevguideModuleAssets.h" 5 | 6 | extern NSData * dataWithHexString (NSString * hexString); 7 | 8 | @implementation TiModdevguideModuleAssets 9 | 10 | - (NSData*) moduleAsset 11 | { 12 | return nil; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideParametersDemoProxy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideLifeCycleProxy.h" 9 | 10 | // NOTE: This proxy subclasses the TiModdevguideLifeCycleProxy to demonstrate the 11 | // lifecycle of a proxy. This would normally subclass TiProxy 12 | 13 | @interface TiModdevguideParametersDemoProxy : TiModdevguideLifeCycleProxy { 14 | 15 | @private 16 | 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ios/Classes/TiModdevguideParametersDemoProxy.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Appcelerator Titanium Mobile 3 | * Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved. 4 | * Licensed under the terms of the Apache Public License 5 | * Please see the LICENSE included with this distribution for details. 6 | */ 7 | 8 | #import "TiModdevguideParametersDemoProxy.h" 9 | 10 | #import "TiUtils.h" 11 | 12 | @implementation TiModdevguideParametersDemoProxy 13 | 14 | - (id)analyzeParameters:(id)args 15 | { 16 | // This method analyzes the arguments that are passed to it and outputs the types and depth of the 17 | // parameters. This is a recursive method that steps into and out of the arguments in order to output 18 | // their types. A dot ('.') character is output as a prefix to indicate the depth of the argument 19 | // from its parent argument. 20 | // 21 | // This analysis is useful to understand how arguments are passed from JavaScript into your native module. 22 | 23 | static int level = 0; 24 | 25 | NSString* prefix = [@"[PARAMETERSDEMO] " stringByPaddingToLength:level+17 withString:@"." startingAtIndex:0]; 26 | 27 | level++; 28 | 29 | if ([args isKindOfClass:[NSArray class]]) { 30 | NSLog(@"%@Array with %d entries", prefix, [args count]); 31 | int index = 0; 32 | for (id obj in (NSArray *)args) { 33 | NSLog(@"%@Index[%d]", prefix, index++); 34 | [self analyzeParameters:obj]; 35 | } 36 | } else if ([args isKindOfClass:[NSDictionary class]]) { 37 | NSLog(@"%@Dictionary with %d entries", prefix, [args count]); 38 | for (id key in args) { 39 | NSLog(@"%@Key[%@]", prefix, key); 40 | [self analyzeParameters:[args objectForKey:key]]; 41 | } 42 | } else if ([args isKindOfClass:[NSString class]]) { 43 | NSLog(@"%@String = %@", prefix, args); 44 | } else if ([args isKindOfClass:[NSNumber class]]) { 45 | NSLog(@"%@Number = %@", prefix, [args stringValue]); 46 | } else if ([args isKindOfClass:[NSNull class]]) { 47 | NSLog(@"%@NULL", prefix); 48 | } else if ([args isKindOfClass:[NSDate class]]) { 49 | NSLog(@"%@Date = %@", prefix, args); 50 | } else if ([args isKindOfClass:[KrollCallback class]]) { 51 | NSLog(@"%@Callback = %@", prefix, args); 52 | } else { 53 | NSLog(@"%@Unknown class %@", prefix, [args class]); 54 | } 55 | 56 | level--; 57 | 58 | return nil; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /ios/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012-present Axway Appcelerator 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /ios/README: -------------------------------------------------------------------------------- 1 | Appcelerator Titanium iPhone Module Project 2 | =========================================== 3 | 4 | This is a skeleton Titanium Mobile iPhone module project. Modules can be 5 | used to extend the functionality of Titanium by providing additional native 6 | code that is compiled into your application at build time and can expose certain 7 | APIs into JavaScript. 8 | 9 | MODULE NAMING 10 | -------------- 11 | 12 | Choose a unique module id for your module. This ID usually follows a namespace 13 | convention using DNS notation. For example, com.appcelerator.module.test. This 14 | ID can only be used once by all public modules in Titanium. 15 | 16 | 17 | COMPONENTS 18 | ----------- 19 | 20 | Components that are exposed by your module must follow a special naming convention. 21 | A component (widget, proxy, etc) must be named with the pattern: 22 | 23 | TiProxy 24 | 25 | For example, if you component was called Foo, your proxy would be named: 26 | 27 | TiMyfirstFooProxy 28 | 29 | For view proxies or widgets, you must create both a view proxy and a view implementation. 30 | If you widget was named proxy, you would create the following files: 31 | 32 | TiMyfirstFooProxy.h 33 | TiMyfirstFooProxy.m 34 | TiMyfirstFoo.h 35 | TiMyfirstFoo.m 36 | 37 | The view implementation is named the same except it does contain the suffix `Proxy`. 38 | 39 | View implementations extend the Titanium base class `TiUIView`. View Proxies extend the 40 | Titanium base class `TiUIViewProxy` or `TiUIWidgetProxy`. 41 | 42 | For proxies that are simply native objects that can be returned to JavaScript, you can 43 | simply extend `TiProxy` and no view implementation is required. 44 | 45 | 46 | GET STARTED 47 | ------------ 48 | 49 | 1. Edit manifest with the appropriate details about your module. 50 | 2. Edit LICENSE to add your license details. 51 | 3. Place any assets (such as PNG files) that are required in the assets folder. 52 | 4. Edit the titanium.xcconfig and make sure you're building for the right Titanium version. 53 | 5. Code and build. 54 | 55 | BUILD TIME COMPILER CONFIG 56 | -------------------------- 57 | 58 | You can edit the file `module.xcconfig` to include any build time settings that should be 59 | set during application compilation that your module requires. This file will automatically get `#include` in the main application project. 60 | 61 | For more information about this file, please see the Apple documentation at: 62 | 63 | 64 | 65 | 66 | DOCUMENTATION FOR YOUR MODULE 67 | ----------------------------- 68 | 69 | You should provide at least minimal documentation for your module in `documentation` folder using the Markdown syntax. 70 | 71 | For more information on the Markdown syntax, refer to this documentation at: 72 | 73 | 74 | 75 | 76 | TEST HARNESS EXAMPLE FOR YOUR MODULE 77 | ------------------------------------ 78 | 79 | The `example` directory contains a skeleton application test harness that can be 80 | used for testing and providing an example of usage to the users of your module. 81 | 82 | 83 | INSTALL YOUR MODULE 84 | -------------------- 85 | 86 | 1. Run `build.py` which creates your distribution 87 | 2. cd to `/Library/Application Support/Titanium` 88 | 3. copy this zip file into the folder of your Titanium SDK 89 | 90 | REGISTER YOUR MODULE 91 | --------------------- 92 | 93 | Register your module with your application by editing `tiapp.xml` and adding your module. 94 | Example: 95 | 96 | 97 | ti.moddevguide 98 | 99 | 100 | When you run your project, the compiler will know automatically compile in your module 101 | dependencies and copy appropriate image assets into the application. 102 | 103 | USING YOUR MODULE IN CODE 104 | ------------------------- 105 | 106 | To use your module in code, you will need to require it. 107 | 108 | For example, 109 | 110 | var my_module = require('ti.moddevguide'); 111 | my_module.foo(); 112 | 113 | WRITING PURE JS NATIVE MODULES 114 | ------------------------------ 115 | 116 | You can write a pure JavaScript "natively compiled" module. This is nice if you 117 | want to distribute a JS module pre-compiled. 118 | 119 | To create a module, create a file named ti.moddevguide.js under the assets folder. 120 | This file must be in the Common JS format. For example: 121 | 122 | exports.echo = function(s) 123 | { 124 | return s; 125 | }; 126 | 127 | Any functions and properties that are exported will be made available as part of your 128 | module. All other code inside your JS will be private to your module. 129 | 130 | For pure JS module, you don't need to modify any of the Objective-C module code. You 131 | can leave it as-is and build. 132 | 133 | TESTING YOUR MODULE 134 | ------------------- 135 | 136 | Run the `titanium.py` script to test your module or test from within XCode. 137 | To test with the script, execute: 138 | 139 | titanium run --dir=YOURMODULEDIR 140 | 141 | 142 | This will execute the app.js in the example folder as a Titanium application. 143 | 144 | 145 | DISTRIBUTING YOUR MODULE 146 | ------------------------- 147 | 148 | Currently, you will need to manually distribution your module distribution zip file directly. However, in the near future, we will make module distribution and sharing built-in to Titanium Developer and in the Titanium Marketplace! 149 | 150 | 151 | Cheers! 152 | -------------------------------------------------------------------------------- /ios/TiModdevguide_Prefix.pch: -------------------------------------------------------------------------------- 1 | 2 | #ifdef __OBJC__ 3 | #import 4 | #endif 5 | -------------------------------------------------------------------------------- /ios/assets/README: -------------------------------------------------------------------------------- 1 | Place your assets like PNG files in this directory and they will be packaged with your module. 2 | 3 | If you create a file named ti.moddevguide.js in this directory, it will be 4 | compiled and used as your module. This allows you to run pure Javascript 5 | modules that are pre-compiled. 6 | 7 | -------------------------------------------------------------------------------- /ios/assets/module_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidev/ti.moddevguide/dddbf86979952ea2bd7c3dd7acd8e94640d8d938/ios/assets/module_image.png -------------------------------------------------------------------------------- /ios/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Appcelerator Titanium Module Packager 4 | # 5 | # 6 | import os, sys, glob, string 7 | import zipfile 8 | from datetime import date 9 | 10 | cwd = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename)) 11 | os.chdir(cwd) 12 | required_module_keys = ['name','version','moduleid','description','copyright','license','copyright','platform','minsdk'] 13 | module_defaults = { 14 | 'description':'My module', 15 | 'author': 'Your Name', 16 | 'license' : 'Specify your license', 17 | 'copyright' : 'Copyright (c) %s by Your Company' % str(date.today().year), 18 | } 19 | module_license_default = "TODO: place your license here and we'll include it in the module distribution" 20 | 21 | def replace_vars(config,token): 22 | idx = token.find('$(') 23 | while idx != -1: 24 | idx2 = token.find(')',idx+2) 25 | if idx2 == -1: break 26 | key = token[idx+2:idx2] 27 | if not config.has_key(key): break 28 | token = token.replace('$(%s)' % key, config[key]) 29 | idx = token.find('$(') 30 | return token 31 | 32 | 33 | def read_ti_xcconfig(): 34 | contents = open(os.path.join(cwd,'titanium.xcconfig')).read() 35 | config = {} 36 | for line in contents.splitlines(False): 37 | line = line.strip() 38 | if line[0:2]=='//': continue 39 | idx = line.find('=') 40 | if idx > 0: 41 | key = line[0:idx].strip() 42 | value = line[idx+1:].strip() 43 | config[key] = replace_vars(config,value) 44 | return config 45 | 46 | def generate_doc(config): 47 | docdir = os.path.join(cwd,'documentation') 48 | if not os.path.exists(docdir): 49 | print "Couldn't find documentation file at: %s" % docdir 50 | return None 51 | sdk = config['TITANIUM_SDK'] 52 | support_dir = os.path.join(sdk,'module','support') 53 | sys.path.append(support_dir) 54 | try: 55 | import markdown2 as markdown 56 | except ImportError: 57 | import markdown 58 | documentation = [] 59 | for file in os.listdir(docdir): 60 | if file in ignoreFiles or os.path.isdir(os.path.join(docdir, file)): 61 | continue 62 | md = open(os.path.join(docdir,file)).read() 63 | html = markdown.markdown(md) 64 | documentation.append({file:html}); 65 | return documentation 66 | 67 | def compile_js(manifest,config): 68 | js_file = os.path.join(cwd,'assets','ti.moddevguide.js') 69 | if not os.path.exists(js_file): return 70 | 71 | sdk = config['TITANIUM_SDK'] 72 | iphone_dir = os.path.join(sdk,'iphone') 73 | sys.path.insert(0,iphone_dir) 74 | from compiler import Compiler 75 | 76 | path = os.path.basename(js_file) 77 | metadata = Compiler.make_function_from_file(path,js_file) 78 | method = metadata['method'] 79 | eq = path.replace('.','_') 80 | method = ' return %s;' % method 81 | 82 | f = os.path.join(cwd,'Classes','TiModdevguideModuleAssets.m') 83 | c = open(f).read() 84 | idx = c.find('return ') 85 | before = c[0:idx] 86 | after = """ 87 | } 88 | 89 | @end 90 | """ 91 | newc = before + method + after 92 | 93 | if newc!=c: 94 | x = open(f,'w') 95 | x.write(newc) 96 | x.close() 97 | 98 | def die(msg): 99 | print msg 100 | sys.exit(1) 101 | 102 | def warn(msg): 103 | print "[WARN] %s" % msg 104 | 105 | def validate_license(): 106 | c = open(os.path.join(cwd,'LICENSE')).read() 107 | if c.find(module_license_default)!=1: 108 | warn('please update the LICENSE file with your license text before distributing') 109 | 110 | def validate_manifest(): 111 | path = os.path.join(cwd,'manifest') 112 | f = open(path) 113 | if not os.path.exists(path): die("missing %s" % path) 114 | manifest = {} 115 | for line in f.readlines(): 116 | line = line.strip() 117 | if line[0:1]=='#': continue 118 | if line.find(':') < 0: continue 119 | key,value = line.split(':') 120 | manifest[key.strip()]=value.strip() 121 | for key in required_module_keys: 122 | if not manifest.has_key(key): die("missing required manifest key '%s'" % key) 123 | if module_defaults.has_key(key): 124 | defvalue = module_defaults[key] 125 | curvalue = manifest[key] 126 | if curvalue==defvalue: warn("please update the manifest key: '%s' to a non-default value" % key) 127 | return manifest,path 128 | 129 | ignoreFiles = ['.DS_Store','.gitignore','libTitanium.a','titanium.jar','README','ti.moddevguide.js'] 130 | ignoreDirs = ['.DS_Store','.svn','.git','CVSROOT'] 131 | 132 | def zip_dir(zf,dir,basepath,ignore=[]): 133 | for root, dirs, files in os.walk(dir): 134 | for name in ignoreDirs: 135 | if name in dirs: 136 | dirs.remove(name) # don't visit ignored directories 137 | for file in files: 138 | if file in ignoreFiles: continue 139 | e = os.path.splitext(file) 140 | if len(e)==2 and e[1]=='.pyc':continue 141 | from_ = os.path.join(root, file) 142 | to_ = from_.replace(dir, basepath, 1) 143 | zf.write(from_, to_) 144 | 145 | def glob_libfiles(): 146 | files = [] 147 | for libfile in glob.glob('build/**/*.a'): 148 | if libfile.find('Release-')!=-1: 149 | files.append(libfile) 150 | return files 151 | 152 | def build_module(manifest,config): 153 | rc = os.system("xcodebuild -sdk iphoneos -configuration Release") 154 | if rc != 0: 155 | die("xcodebuild failed") 156 | rc = os.system("xcodebuild -sdk iphonesimulator -configuration Release") 157 | if rc != 0: 158 | die("xcodebuild failed") 159 | # build the merged library using lipo 160 | moduleid = manifest['moduleid'] 161 | libpaths = '' 162 | for libfile in glob_libfiles(): 163 | libpaths+='%s ' % libfile 164 | 165 | os.system("lipo %s -create -output build/lib%s.a" %(libpaths,moduleid)) 166 | 167 | def package_module(manifest,mf,config): 168 | name = manifest['name'].lower() 169 | moduleid = manifest['moduleid'].lower() 170 | version = manifest['version'] 171 | modulezip = '%s-iphone-%s.zip' % (moduleid,version) 172 | if os.path.exists(modulezip): os.remove(modulezip) 173 | zf = zipfile.ZipFile(modulezip, 'w', zipfile.ZIP_DEFLATED) 174 | modulepath = 'modules/iphone/%s/%s' % (moduleid,version) 175 | zf.write(mf,'%s/manifest' % modulepath) 176 | libname = 'lib%s.a' % moduleid 177 | zf.write('build/%s' % libname, '%s/%s' % (modulepath,libname)) 178 | docs = generate_doc(config) 179 | if docs!=None: 180 | for doc in docs: 181 | for file, html in doc.iteritems(): 182 | filename = string.replace(file,'.md','.html') 183 | zf.writestr('%s/documentation/%s'%(modulepath,filename),html) 184 | for dn in ('assets','example','platform'): 185 | if os.path.exists(dn): 186 | zip_dir(zf,dn,'%s/%s' % (modulepath,dn),['README']) 187 | zf.write('LICENSE','%s/LICENSE' % modulepath) 188 | zf.write('module.xcconfig','%s/module.xcconfig' % modulepath) 189 | zf.close() 190 | 191 | 192 | if __name__ == '__main__': 193 | manifest,mf = validate_manifest() 194 | validate_license() 195 | config = read_ti_xcconfig() 196 | compile_js(manifest,config) 197 | build_module(manifest,config) 198 | package_module(manifest,mf,config) 199 | sys.exit(0) 200 | 201 | -------------------------------------------------------------------------------- /ios/documentation/changelog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 |
3 | v2.2.0  [TIMOB-18092] Updated to build for 64bit
4 | 
5 | v2.1.0  [MOD-878] Updated to latest TiSDK module api v2
6 | 
7 | v1.1	Adding more examples
8 | 
9 | v1.0    Initial Release


--------------------------------------------------------------------------------
/ios/documentation/index.md:
--------------------------------------------------------------------------------
 1 | # Ti.moddevguide Module
 2 | 
 3 | ## Description
 4 | 
 5 | Demonstrates various aspects of iOS module development in Titanium.
 6 | 
 7 | This is a companion module to the Titanium [iOS Module Development Guide](http://wiki.appcelerator.org/display/guides2/iOS+Module+Development+Guide)
 8 | 
 9 | ## Accessing the Ti.moddevguide Module
10 | 
11 | To access this module from JavaScript, you would do the following:
12 | 
13 | 
var DevGuide = require('ti.moddevguide');
14 | 15 | ## Topics Covered 16 | 17 | ### Life Cycle 18 | 19 | Various aspects of the life cycle of module, proxy, and view proxy classes. 20 | 21 | #### Module Loading 22 | 23 | Demonstrates the methods that are called during module loading and unloading. 24 | 25 | #### Proxy Loading 26 | 27 | Demonstrates the methods that are called during proxy loading and unloading. 28 | 29 | #### View Proxy Loading 30 | 31 | Demonstrates the methods that are called during view proxy loading and unloading. Additionally, demonstrates the methods that are called during the creation and destruction of the associated view. 32 | 33 | ### Kroll 34 | 35 | #### Properties 36 | 37 | Demonstrates how to define and access properties. 38 | 39 | #### Methods 40 | 41 | Demonstrates how to define methods and pass arguments to those methods. 42 | 43 | #### Parameters 44 | 45 | Demonstrates how arguments are passed into methods. 46 | 47 | ### Miscellaneous 48 | 49 | #### Assets 50 | 51 | Demonstrates how to access both module and application assets from a module. 52 | 53 | ## Usage 54 | 55 | See example. 56 | 57 | ## Author 58 | 59 | Jeff English 60 | 61 | ## Feedback and Support 62 | 63 | Please direct all questions, feedback, and concerns to [info@appcelerator.com](mailto:info@appcelerator.com?subject=iOS%20moddevguide%20Module). 64 | 65 | ## License 66 | 67 | Copyright(c) 2010-2012 by Appcelerator, Inc. All Rights Reserved. Please see the LICENSE file included in the distribution for further details. 68 | -------------------------------------------------------------------------------- /ios/example/app.js: -------------------------------------------------------------------------------- 1 | // Ensure that the module development guide module is loaded 2 | var DevGuide = require('ti.moddevguide'); 3 | 4 | // Open the main category selection page 5 | require('navigator').start(DevGuide); -------------------------------------------------------------------------------- /ios/example/application_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidev/ti.moddevguide/dddbf86979952ea2bd7c3dd7acd8e94640d8d938/ios/example/application_image.png -------------------------------------------------------------------------------- /ios/example/demos/assetsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | var imageView = null; 5 | 6 | function handleLoadModuleImage(e) { 7 | var image = devGuide.loadImageFromModule('module_image.png'); 8 | if (image != null) { 9 | imageView.image = image; 10 | } 11 | } 12 | 13 | function handleLoadAppImage(e) { 14 | var image = devGuide.loadImageFromApplication('application_image.png'); 15 | if (image != null) { 16 | imageView.image = image; 17 | } 18 | } 19 | 20 | // Public implementation details for commonJS module 21 | 22 | exports.initialize = function(modDevGuide) { 23 | // Save the module object -- we'll need it later 24 | devGuide = modDevGuide; 25 | } 26 | 27 | exports.cleanup = function() { 28 | imageView = null; 29 | devGuide = null; 30 | } 31 | 32 | exports.create = function(win) { 33 | win.add(Ti.UI.createLabel({ 34 | text:'This demonstrates the loading of assets from both the module and application. Some messages will be output to the console.', 35 | textAlign:'left', 36 | font:{ fontsize: 12 }, 37 | top:10, 38 | right:10, 39 | left:10, 40 | color:'black', 41 | width:Ti.UI.SIZE || 'auto', 42 | height:Ti.UI.SIZE || 'auto' 43 | })); 44 | 45 | var moduleImageBtn = Ti.UI.createButton({ 46 | title: 'Load Module Image', 47 | top:10, 48 | width:200, 49 | height:Ti.UI.SIZE || 'auto' 50 | }); 51 | 52 | var appImageBtn = Ti.UI.createButton({ 53 | title: 'Load Application Image', 54 | top:10, 55 | width:200, 56 | height:Ti.UI.SIZE || 'auto' 57 | }); 58 | 59 | imageView = Ti.UI.createImageView({ 60 | top:10, 61 | width:150, 62 | height:200 63 | }); 64 | 65 | moduleImageBtn.addEventListener('click', handleLoadModuleImage); 66 | appImageBtn.addEventListener('click', handleLoadAppImage); 67 | 68 | win.add(moduleImageBtn); 69 | win.add(appImageBtn); 70 | win.add(imageView); 71 | } 72 | -------------------------------------------------------------------------------- /ios/example/demos/constantsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | 5 | // Public implementation details for commonJS module 6 | 7 | exports.initialize = function(modDevGuide) { 8 | // Save the module object -- we'll need it later 9 | devGuide = modDevGuide; 10 | } 11 | 12 | exports.cleanup = function() { 13 | devGuide = null; 14 | } 15 | 16 | exports.create = function(win) { 17 | win.add(Ti.UI.createLabel({ 18 | text:'This demonstrates the accessing of constants defined by a module (or proxy)', 19 | textAlign:'left', 20 | font:{ fontsize: 12 }, 21 | top:10, 22 | right:10, 23 | left:10, 24 | color:'black', 25 | width:Ti.UI.SIZE || 'auto', 26 | height:Ti.UI.SIZE || 'auto' 27 | })); 28 | 29 | // Declare list of values to display. Each item references a constant defined 30 | // by the module. 31 | var constants = [ 32 | { title: 'Integer: ', value: devGuide.DEMO_INTEGER }, 33 | { title: 'String: ', value: devGuide.DEMO_STRING }, 34 | { title: 'Boolean: ', value: devGuide.DEMO_BOOLEAN } 35 | ]; 36 | 37 | var cnt = constants.length; 38 | for (var index = 0; index < cnt; index++) { 39 | var view = Ti.UI.createView({ 40 | layout:'horizontal', 41 | width:'100%', 42 | height:'30', 43 | top:10, 44 | left:10 45 | }); 46 | 47 | view.add(Ti.UI.createLabel({ 48 | text:constants[index].title, 49 | textAlign:'left', 50 | font:{ fontsize: 12, fontWeight: 'bold' }, 51 | color:'black', 52 | width:Ti.UI.SIZE || 'auto', 53 | height:30 54 | })); 55 | 56 | view.add(Ti.UI.createLabel({ 57 | text:constants[index].value, 58 | textAlign:'left', 59 | font:{ fontsize: 12 }, 60 | color:'black', 61 | width:Ti.UI.SIZE || 'auto', 62 | height:30 63 | })); 64 | 65 | win.add(view); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ios/example/demos/krollCallbacksAndEventsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var krollDemo = null; 4 | 5 | function successCallback(e) { 6 | alert("Success: " + e.title + "\nMessage: " + e.message); 7 | } 8 | 9 | function cancelCallback(e) { 10 | alert("Cancel: " + e.title + "\nMessage: " + e.message); 11 | } 12 | 13 | function directCallback(arg1, arg2) { 14 | Ti.API.info('Direct callback\n' + arg1 + '\n' + arg2); 15 | } 16 | 17 | function requestDataCallback(e) { 18 | Ti.API.info('Callback request for data'); 19 | return 100; 20 | } 21 | 22 | function demoEventHandler(e) { 23 | alert('Demo Event\nindex: ' + e.index + '\nvalue: ' + e.value + '\nname: ' + e.name); 24 | } 25 | 26 | function handleSignalSuccess(e) { 27 | // This sets the 'title' property of the module object 28 | krollDemo.title = 'Successful'; 29 | 30 | // This calls the 'signalCallbackWithSuccess' method in the module which fires a success event 31 | // notification to the registered callback method 32 | krollDemo.signalCallbackWithSuccess(true); 33 | } 34 | 35 | function handleSignalCancelled(e) { 36 | // This sets the 'title' property of the module object 37 | krollDemo.title = 'Cancelled'; 38 | 39 | // This calls the 'signalCallbackWithSuccess' method in the module which fires a cancel event 40 | // notification to the registered callback method 41 | krollDemo.signalCallbackWithSuccess(false); 42 | } 43 | 44 | function handleCallbackDirectly(e) { 45 | // This calls the 'callThisCallbackDirectly' method in the module which calls the 46 | // callback immediately, passing 2 arguments to the callback function. 47 | krollDemo.callThisCallbackDirectly({ 48 | callback: directCallback, 49 | data: "Hello World" 50 | }); 51 | 52 | alert('Check console output for results'); 53 | } 54 | 55 | function handleSignalEvent(e) { 56 | // This calls the 'signalEvent' method in the module which posts a 'demoEvent' 57 | // event to all registered listeners 58 | krollDemo.signalEvent(); 59 | } 60 | 61 | function handleRequestData(e) { 62 | // This calls the 'requestDataWithCallback' method in the module which immediately calls 63 | // back to the registered requestDataCallback function to retrieve data 64 | krollDemo.requestDataWithCallback(); 65 | 66 | alert('Check console output for results'); 67 | } 68 | 69 | // Public implementation details for commonJS module 70 | 71 | exports.initialize = function(modDevGuide) { 72 | // Create the proxy 73 | krollDemo = modDevGuide.createKrollDemo(); 74 | 75 | // This calls the 'registerCallbacks' method in the module which retains and stores 76 | // the KrollCallback functions for use later on. 77 | krollDemo.registerCallbacks({ 78 | success: successCallback, 79 | cancel: cancelCallback, 80 | requestData: requestDataCallback 81 | }); 82 | 83 | // Set up an event listener for a module event 84 | krollDemo.addEventListener('demoEvent', demoEventHandler); 85 | } 86 | 87 | exports.cleanup = function() { 88 | // Release the proxy 89 | krollDemo = null; 90 | } 91 | 92 | exports.create = function(win) { 93 | win.add(Ti.UI.createLabel({ 94 | text:'This demonstrates how to use callbacks and events in your module and how to call from your module back into JavaScript. Some callback messages will be output to the console.', 95 | textAlign:'left', 96 | font:{ fontsize: 12 }, 97 | top:10, 98 | right:10, 99 | left:10, 100 | color:'black', 101 | width:Ti.UI.SIZE || 'auto', 102 | height:Ti.UI.SIZE || 'auto' 103 | })); 104 | 105 | var btn1 = Ti.UI.createButton({ 106 | title:'Success Event', 107 | width:200, 108 | height:Ti.UI.SIZE || 'auto', 109 | top:20 110 | }); 111 | 112 | var btn2 = Ti.UI.createButton({ 113 | title:'Cancel Event', 114 | width:200, 115 | height:Ti.UI.SIZE || 'auto', 116 | top:20 117 | }); 118 | 119 | var btn3 = Ti.UI.createButton({ 120 | title:'Direct Callback', 121 | width:200, 122 | height:Ti.UI.SIZE || 'auto', 123 | top:20 124 | }); 125 | 126 | var btn4 = Ti.UI.createButton({ 127 | title:'Demo Event', 128 | width:200, 129 | height:Ti.UI.SIZE || 'auto', 130 | top:20 131 | }); 132 | 133 | var btn5 = Ti.UI.createButton({ 134 | title:'Request Data', 135 | width:200, 136 | height:Ti.UI.SIZE || 'auto', 137 | top:20 138 | }); 139 | 140 | btn1.addEventListener('click', handleSignalSuccess); 141 | btn2.addEventListener('click', handleSignalCancelled); 142 | btn3.addEventListener('click', handleCallbackDirectly); 143 | btn4.addEventListener('click', handleSignalEvent); 144 | btn5.addEventListener('click', handleRequestData); 145 | 146 | win.add(btn1); 147 | win.add(btn2); 148 | win.add(btn3); 149 | win.add(btn4); 150 | win.add(btn5); 151 | } 152 | -------------------------------------------------------------------------------- /ios/example/demos/krollMethodsDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var methodsDemo = null; 4 | 5 | function handlePickerSelection(e) { 6 | var result = null; 7 | try { 8 | switch (e.row.typeid) { 9 | case 'select': 10 | return; 11 | case 'noreturn': 12 | methodsDemo.demoMethodNoReturn(); 13 | break; 14 | case 'integer': 15 | result = methodsDemo.demoMethodNumberInt(5, 17); 16 | break; 17 | case 'float': 18 | result = methodsDemo.demoMethodNumberFloat(2.7, '18.2'); 19 | break; 20 | case 'strings': 21 | result = methodsDemo.demoMethodString('Joe', 'Smith', 25); 22 | break; 23 | case 'dictionary': 24 | result = methodsDemo.demoMethodDictionary(['a', 'b', 'c', 'd', 'e', 'f']); 25 | Ti.API.info('Dictionary Result:'); 26 | Ti.API.info(result); 27 | break; 28 | case 'date': 29 | result = methodsDemo.demoMethodDate({ month: 7, day: 4, year: 1776 }); 30 | break; 31 | case 'rect': 32 | var rect = methodsDemo.demoMethodRect(10,10,100,200); 33 | result = 'x: ' + rect.x + ' y: ' + rect.y + ' width: ' + rect.width + ' height: ' + rect.height; 34 | break; 35 | case 'point': 36 | var point = methodsDemo.demoMethodPoint(25,40); 37 | result = 'x: ' + point.x + ' y: ' + point.y; 38 | break; 39 | case 'range': 40 | var range = methodsDemo.demoMethodRange(10,100); 41 | result = 'Location: ' + range.location + ' Length: ' + range.length; 42 | break; 43 | case 'color': 44 | result = methodsDemo.demoMethodColor('green'); 45 | if (Ti.Platform.name == 'android') { 46 | // Convert to hex string for display 47 | var u = 0xFFFFFFFF + result + 1; 48 | result = "0x" + u.toString(16).toUpperCase(); 49 | } 50 | break; 51 | case 'array': 52 | result = methodsDemo.demoMethodArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 53 | break; 54 | case 'file': 55 | var t = Ti.Filesystem.createTempFile(); 56 | var file = methodsDemo.demoMethodFile(t.nativePath); 57 | if (Ti.Platform.name == 'android') { 58 | result = 'File with path: ' + file.nativePath; 59 | } else { 60 | result = 'File with path: ' + file.path; 61 | } 62 | t.deleteFile(); 63 | break; 64 | case 'blob': 65 | var blob = methodsDemo.demoMethodBlob(); 66 | result = 'Blob with text: ' + blob.text; 67 | break; 68 | case 'null': 69 | result = methodsDemo.demoMethodNull(); 70 | break; 71 | case 'optional': 72 | result = methodsDemo.demoMethodOptionalArgs('Welcome'); 73 | alert('Method returned:\n' + result); 74 | result = methodsDemo.demoMethodOptionalArgs('Hello', 'World'); 75 | break; 76 | } 77 | 78 | alert('Method returned:\n' + result); 79 | } catch (e) { 80 | alert(e); 81 | } 82 | } 83 | 84 | // Public implementation details for commonJS module 85 | 86 | exports.initialize = function(modDevGuide) { 87 | // Create the proxy 88 | methodsDemo = modDevGuide.createMethodsDemo(); 89 | } 90 | 91 | exports.cleanup = function() { 92 | // Release the proxy 93 | methodsDemo = null; 94 | } 95 | 96 | exports.create = function(win) { 97 | win.add(Ti.UI.createLabel({ 98 | text:'This demonstrates how to use methods and return values in your module. Select a method type to call into the module. Some callback messages will be output to the console.', 99 | textAlign:'left', 100 | font:{ fontsize: 12 }, 101 | top:10, 102 | right:10, 103 | left:10, 104 | color:'black', 105 | width:Ti.UI.SIZE || 'auto', 106 | height:Ti.UI.SIZE || 'auto' 107 | })); 108 | 109 | var data = []; 110 | data.push(Ti.UI.createPickerRow({title: 'Select a type', typeid: 'select' })); 111 | data.push(Ti.UI.createPickerRow({title: 'No return', typeid: 'noreturn' })); 112 | data.push(Ti.UI.createPickerRow({title: 'Integer', typeid: 'integer' })); 113 | data.push(Ti.UI.createPickerRow({title: 'Float', typeid: 'float' })); 114 | data.push(Ti.UI.createPickerRow({title: 'Strings', typeid: 'strings' })); 115 | data.push(Ti.UI.createPickerRow({title: 'Date', typeid: 'date' })); 116 | data.push(Ti.UI.createPickerRow({title: 'Rect', typeid: 'rect' })); 117 | data.push(Ti.UI.createPickerRow({title: 'Point', typeid: 'point' })); 118 | data.push(Ti.UI.createPickerRow({title: 'Range', typeid: 'range' })); 119 | data.push(Ti.UI.createPickerRow({title: 'Color', typeid: 'color' })); 120 | data.push(Ti.UI.createPickerRow({title: 'Dictionary', typeid: 'dictionary' })); 121 | data.push(Ti.UI.createPickerRow({title: 'Array', typeid: 'array' })); 122 | data.push(Ti.UI.createPickerRow({title: 'File', typeid: 'file' })); 123 | data.push(Ti.UI.createPickerRow({title: 'Blob', typeid: 'blob' })); 124 | data.push(Ti.UI.createPickerRow({title: 'Null', typeid: 'null' })); 125 | data.push(Ti.UI.createPickerRow({title: 'Optional Args', typeid: 'optional' })); 126 | 127 | var picker = Ti.UI.createPicker({ 128 | top:20, 129 | width:300, 130 | type:Ti.UI.PICKER_TYPE_PLAIN 131 | }); 132 | picker.add(data); 133 | picker.selectionIndicator = true; 134 | 135 | picker.addEventListener('change', handlePickerSelection); 136 | 137 | win.add(picker); 138 | } 139 | -------------------------------------------------------------------------------- /ios/example/demos/krollParametersDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var parametersDemo = null; 4 | 5 | function handlePickerSelection(e) { 6 | try { 7 | switch (e.row.typeid) { 8 | case 'select': 9 | return; 10 | case 'string': 11 | parametersDemo.analyzeParameters('Hello World'); 12 | break; 13 | case 'integer': 14 | parametersDemo.analyzeParameters(100); 15 | break; 16 | case 'float': 17 | parametersDemo.analyzeParameters(10.7); 18 | break; 19 | case 'date': 20 | var myDate = new Date(); 21 | myDate.setFullYear(2011); 22 | myDate.setMonth(7); 23 | myDate.setDate(4); 24 | parametersDemo.analyzeParameters(myDate); 25 | break; 26 | case 'null': 27 | parametersDemo.analyzeParameters(null); 28 | break; 29 | case 'dictionary': 30 | parametersDemo.analyzeParameters({ a:1, b:2 }); 31 | break; 32 | case 'nested_dictionary': 33 | var y = { a:1, b:2 }; 34 | parametersDemo.analyzeParameters({ a:1, b:{ z:1 }, c:y }); 35 | break; 36 | case 'number_array': 37 | parametersDemo.analyzeParameters([1,2,3]); 38 | break; 39 | case 'callback': 40 | parametersDemo.analyzeParameters(function() { Ti.API.Info('Test'); }); 41 | break; 42 | case 'mixed': 43 | parametersDemo.analyzeParameters('Test', 10, 4.3, { title: 'Hello', subtitle: 'World' }, [ 'a', 3, 2.1 ] ); 44 | break; 45 | } 46 | 47 | alert('Check console output for results of parameter analysis'); 48 | } catch (e) { 49 | alert(e); 50 | } 51 | } 52 | 53 | // Public implementation details for commonJS module 54 | 55 | exports.initialize = function(modDevGuide) { 56 | // Create the proxy 57 | parametersDemo = modDevGuide.createParametersDemo(); 58 | } 59 | 60 | exports.cleanup = function() { 61 | // Release the proxy 62 | parametersDemo = null; 63 | } 64 | 65 | exports.create = function(win) { 66 | win.add(Ti.UI.createLabel({ 67 | text:'This demonstrates a variety of parameter types and how they are mapped to native types. Select a parameter type to analyze how they are received in the module. Parameter messages will be output to the console.', 68 | textAlign:'left', 69 | font:{ fontsize: 12 }, 70 | top:10, 71 | right:10, 72 | left:10, 73 | color:'black', 74 | width:Ti.UI.SIZE || 'auto', 75 | height:Ti.UI.SIZE || 'auto' 76 | })); 77 | 78 | var data = []; 79 | data.push(Ti.UI.createPickerRow({title: 'Select a type', typeid: 'select' })); 80 | data.push(Ti.UI.createPickerRow({title: 'String', typeid: 'string' })); 81 | data.push(Ti.UI.createPickerRow({title: 'Integer', typeid: 'integer' })); 82 | data.push(Ti.UI.createPickerRow({title: 'Float', typeid: 'float' })); 83 | data.push(Ti.UI.createPickerRow({title: 'Date', typeid: 'date' })); 84 | data.push(Ti.UI.createPickerRow({title: 'Null', typeid: 'null' })); 85 | data.push(Ti.UI.createPickerRow({title: 'Dictionary', typeid: 'dictionary' })); 86 | data.push(Ti.UI.createPickerRow({title: 'Nested Dictionary', typeid: 'nested_dictionary' })); 87 | data.push(Ti.UI.createPickerRow({title: 'Array of Numbers', typeid: 'number_array' })); 88 | data.push(Ti.UI.createPickerRow({title: 'Callback', typeid: 'callback' })); 89 | data.push(Ti.UI.createPickerRow({title: 'Mixed', typeid: 'mixed' })); 90 | 91 | var picker = Ti.UI.createPicker({ 92 | top:20, 93 | width:300, 94 | type:Ti.UI.PICKER_TYPE_PLAIN 95 | }); 96 | picker.add(data); 97 | picker.selectionIndicator = true; 98 | 99 | picker.addEventListener('change', handlePickerSelection); 100 | 101 | win.add(picker); 102 | } 103 | -------------------------------------------------------------------------------- /ios/example/demos/krollPropertiesDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var krollDemo = null; 4 | 5 | function handlePropertyChangesSwitch(e) { 6 | krollDemo.watchPropertyChanges = e.value; 7 | } 8 | 9 | function handleSetPropertyValue(e) { 10 | krollDemo.testValue = e.source.value; 11 | } 12 | 13 | function handleGetPropertyValue(e) { 14 | alert('Current property value is ' + krollDemo.testValue); 15 | } 16 | 17 | function handleBatchUpdate(e) { 18 | krollDemo.value1 = (krollDemo.value1 | 0) + 5; 19 | krollDemo.value2 = { name: 'Hello', value: 'World' }; 20 | krollDemo.value3 = !(krollDemo.value3 | false); 21 | krollDemo.value4 = 'This is a test'; 22 | } 23 | 24 | function handlePropertyChangeNotification(e) { 25 | var result = 'Property ' + e.property + ' changed\nOldValue: ' + e.oldValue + '\nNewValue: ' + e.newValue; 26 | alert(result); 27 | } 28 | 29 | // Public implementation details for commonJS module 30 | 31 | exports.initialize = function(modDevGuide) { 32 | // Create the proxy 33 | krollDemo = modDevGuide.createKrollDemo({ arg1: "Hello", arg2: "World" }); 34 | 35 | krollDemo.addEventListener('propertyChange', handlePropertyChangeNotification); 36 | krollDemo.watchPropertyChanges = true; 37 | } 38 | 39 | exports.cleanup = function() { 40 | krollDemo = null; 41 | } 42 | 43 | exports.create = function(win) { 44 | win.add(Ti.UI.createLabel({ 45 | text:'This demonstrates proxy properties and how to get / set their values as well as process property change notifications. Some messages will be output to the console.', 46 | textAlign:'left', 47 | font:{ fontsize: 12 }, 48 | top:10, 49 | right:10, 50 | left:10, 51 | color:'black', 52 | width:Ti.UI.SIZE || 'auto', 53 | height:Ti.UI.SIZE || 'auto' 54 | })); 55 | 56 | var view1 = Ti.UI.createView({ 57 | layout:'horizontal', 58 | width:'100%', 59 | height:Ti.UI.SIZE || 'auto', 60 | top:10, 61 | left:10 62 | }); 63 | 64 | view1.add(Ti.UI.createLabel({ 65 | text:'Property Changes:', 66 | textAlign:'left', 67 | font:{ fontsize: 12 }, 68 | color:'black', 69 | width:Ti.UI.SIZE || 'auto', 70 | height:Ti.UI.SIZE || 'auto' 71 | })); 72 | 73 | var switchPropertyChanges = Ti.UI.createSwitch({ 74 | value:krollDemo.watchPropertyChanges, 75 | left:10, 76 | top:0 77 | }); 78 | view1.add(switchPropertyChanges); 79 | 80 | var view2= Ti.UI.createView({ 81 | layout:'horizontal', 82 | width:'100%', 83 | height:Ti.UI.SIZE || 'auto', 84 | top:20, 85 | left:10 86 | }) 87 | 88 | view2.add(Ti.UI.createLabel({ 89 | text:'Test Value:', 90 | textAlign:'left', 91 | font:{ fontsize: 12 }, 92 | color:'black', 93 | width:Ti.UI.SIZE || 'auto', 94 | height:Ti.UI.SIZE || 'auto' 95 | })); 96 | 97 | var valueField = Ti.UI.createTextField({ 98 | hintText:'Enter a value', 99 | font:{ fontsize: 12 }, 100 | color:'black', 101 | width:200, 102 | height:Ti.UI.SIZE || 'auto', 103 | left:10, 104 | borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED 105 | }); 106 | view2.add(valueField); 107 | 108 | var valueBtn = Ti.UI.createButton({ 109 | title:'Get Value', 110 | width:200, 111 | height:Ti.UI.SIZE || 'auto', 112 | top:20 113 | }); 114 | 115 | var batchUpdateBtn = Ti.UI.createButton({ 116 | title:'Update Multiple Properties', 117 | width:200, 118 | height:Ti.UI.SIZE || 'auto', 119 | top:20 120 | }); 121 | 122 | switchPropertyChanges.addEventListener('change', handlePropertyChangesSwitch); 123 | valueField.addEventListener('return', handleSetPropertyValue); 124 | valueBtn.addEventListener('click', handleGetPropertyValue); 125 | batchUpdateBtn.addEventListener('click', handleBatchUpdate); 126 | 127 | win.add(view1); 128 | win.add(view2); 129 | win.add(valueBtn); 130 | win.add(batchUpdateBtn); 131 | } 132 | -------------------------------------------------------------------------------- /ios/example/demos/proxyDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | var proxyList = []; 5 | var proxyCountLbl = null; 6 | var deleteProxyBtn = null; 7 | 8 | function updateProxyCount() { 9 | proxyCountLbl.text = 'Proxy Count: ' + proxyList.length; 10 | deleteProxyBtn.enabled = proxyList.length > 0; 11 | } 12 | 13 | function handleCreateProxy(e) { 14 | var proxy = devGuide.createLifeCycle ({ 15 | a: 'Hello', 16 | b: 'World' 17 | }); 18 | 19 | proxyList.push(proxy); 20 | 21 | updateProxyCount(); 22 | } 23 | 24 | function handleDeleteProxy(e) { 25 | var proxy = proxyList.pop(); 26 | 27 | // Call proxy for any necessary cleanup 28 | proxy.close(); 29 | 30 | updateProxyCount(); 31 | } 32 | 33 | // Public implementation details for commonJS module 34 | 35 | exports.initialize = function(modDevGuide) { 36 | // Save the module object -- we'll need it later 37 | devGuide = modDevGuide; 38 | } 39 | 40 | exports.cleanup = function() { 41 | proxyList = []; 42 | proxyCountLbl = null; 43 | deleteProxyBtn = null; 44 | devGuide = null; 45 | } 46 | 47 | exports.create = function(win) { 48 | win.add(Ti.UI.createLabel({ 49 | text:'This demonstrates the proxy lifecycle. Press the \'Create Proxy\' button to create a new instance of the proxy. Press the \'Delete Proxy\' button to destroy an instance of the proxy. Lifecycle messages will be output to the console.', 50 | textAlign:'left', 51 | font:{ fontsize: 12 }, 52 | top:10, 53 | right:10, 54 | left:10, 55 | color:'black', 56 | width:Ti.UI.SIZE || 'auto', 57 | height:Ti.UI.SIZE || 'auto' 58 | })); 59 | 60 | proxyCountLbl = Ti.UI.createLabel({ 61 | text: '', 62 | top: 10, 63 | height: Ti.UI.SIZE || 'auto', 64 | width: Ti.UI.SIZE || 'auto', 65 | textAlign: 'left', 66 | color: 'black', 67 | font: { fontSize: 12 } 68 | }); 69 | 70 | var createProxyBtn = Ti.UI.createButton({ 71 | title: 'Create Proxy', 72 | top:10, 73 | width:150, 74 | height:60 75 | }); 76 | 77 | deleteProxyBtn = Ti.UI.createButton({ 78 | title: 'Delete Proxy', 79 | top:10, 80 | width:150, 81 | height:60 82 | }); 83 | 84 | createProxyBtn.addEventListener('click', handleCreateProxy); 85 | deleteProxyBtn.addEventListener('click', handleDeleteProxy); 86 | 87 | win.add(createProxyBtn); 88 | win.add(deleteProxyBtn); 89 | win.add(proxyCountLbl); 90 | 91 | updateProxyCount(); 92 | } 93 | -------------------------------------------------------------------------------- /ios/example/demos/viewproxyDemo.js: -------------------------------------------------------------------------------- 1 | // Private implementation details for commonJS module 2 | 3 | var devGuide = null; 4 | var view = null; 5 | var currentColor = ''; 6 | 7 | function handleColorSelection(e) { 8 | view.color = (currentColor == 'green') ? 'red' : 'green'; 9 | } 10 | 11 | function createColorSelector() { 12 | var colorBtn = Ti.UI.createButton({ 13 | title: 'Change Color', 14 | top:10, 15 | width:150, 16 | height:40 17 | }); 18 | 19 | colorBtn.addEventListener('click', handleColorSelection); 20 | 21 | return colorBtn; 22 | } 23 | 24 | function handleColorChange(e) { 25 | if (Ti.Platform.name == 'android') { 26 | currentColor = e.color; 27 | } else { 28 | currentColor = e.color._name; 29 | } 30 | 31 | alert('Color changed to ' + currentColor); 32 | } 33 | 34 | function toggleViewCreate(e) { 35 | if (view == null) { 36 | view = devGuide.createDemoView({ 37 | width:200, 38 | height:200, 39 | top:10, 40 | color: 'green', 41 | layout:'vertical' 42 | }); 43 | 44 | view.add(createColorSelector()); 45 | 46 | view.addEventListener('colorChange', handleColorChange); 47 | 48 | e.source.parent.add(view); 49 | } else { 50 | e.source.parent.remove(view); 51 | view = null; 52 | } 53 | 54 | // Toggle the button text 55 | e.source.title = (view == null) ? 'Create View' : 'Delete View'; 56 | } 57 | 58 | // Public implementation details for commonJS module 59 | 60 | exports.initialize = function(modDevGuide) { 61 | // Save the module object -- we'll need it later 62 | devGuide = modDevGuide; 63 | } 64 | 65 | exports.cleanup = function() { 66 | view = null; 67 | currentColor = ''; 68 | devGuide = null; 69 | } 70 | 71 | exports.create = function(win) { 72 | win.add(Ti.UI.createLabel({ 73 | text:'This demonstrates the view proxy lifecycle. Press the \'Create View\' button to create a new instance of the view. Press the \'Delete View\' button to destroy the view. Lifecycle messages will be output to the console.', 74 | textAlign:'left', 75 | font:{ fontsize: 12 }, 76 | top:10, 77 | right:10, 78 | left:10, 79 | color:'black', 80 | width:Ti.UI.SIZE || 'auto', 81 | height:Ti.UI.SIZE || 'auto' 82 | })); 83 | 84 | var toggleBtn = Ti.UI.createButton({ 85 | title: 'Create View', 86 | top:10, 87 | width:150, 88 | height:60 89 | }); 90 | 91 | toggleBtn.addEventListener('click', toggleViewCreate); 92 | 93 | win.add(toggleBtn); 94 | } 95 | -------------------------------------------------------------------------------- /ios/example/navigator.js: -------------------------------------------------------------------------------- 1 | // Declare the list of demos and their associated commonJS module names 2 | var demos = [ 3 | { mod: null, title: 'Proxy Loading', section: 'Life Cycle', name: 'proxyDemo' }, 4 | { mod: null, title: 'View Proxy Loading', section: 'Life Cycle', name: 'viewproxyDemo' }, 5 | { mod: null, title: 'Properties', section: 'Kroll', name: 'krollPropertiesDemo' }, 6 | { mod: null, title: 'Methods', section: 'Kroll', name: 'krollMethodsDemo' }, 7 | { mod: null, title: 'Parameters', section: 'Kroll', name: 'krollParametersDemo' }, 8 | { mod: null, title: 'Callbacks & Events', section: 'Kroll', name: 'krollCallbacksAndEventsDemo' }, 9 | { mod: null, title: 'Assets', section: 'Miscellaneous', name: 'assetsDemo' }, 10 | { mod: null, title: 'Constants', section: 'Miscellaneous', name: 'constantsDemo' } 11 | ]; 12 | 13 | var devGuide = null; 14 | var tab = null; 15 | var currentDemo = null; 16 | 17 | function createDemoTableView() { 18 | var sections = []; 19 | var cnt = demos.length; 20 | 21 | for (var index = 0; index < cnt; index++) { 22 | if ((index == 0) || (demos[index].section != demos[index-1].section)) { 23 | sections.push(Ti.UI.createTableViewSection({ 24 | headerTitle: demos[index].section 25 | })); 26 | } 27 | 28 | row = Ti.UI.createTableViewRow({ 29 | title: demos[index].title, 30 | hasChild: true 31 | }); 32 | 33 | sections[sections.length - 1].add(row); 34 | } 35 | 36 | var tableView = Ti.UI.createTableView({ 37 | style:Titanium.UI.iPhone.TableViewStyle.GROUPED, 38 | data: sections 39 | }); 40 | 41 | tableView.addEventListener('click', function(e) { 42 | exports.openDemo(demos[e.index]); 43 | }); 44 | 45 | return tableView; 46 | } 47 | 48 | exports.start = function(modDevGuide) { 49 | // Save the module object -- we'll need it later 50 | devGuide = modDevGuide; 51 | 52 | var win = Ti.UI.createWindow({ 53 | title: 'Module Development Guide', 54 | backgroundColor: 'white', 55 | tabBarHidden: true 56 | }); 57 | 58 | win.add(createDemoTableView()); 59 | 60 | if (Ti.Platform.name == 'android') { 61 | win.exitOnClose = true; 62 | } else { 63 | var tabGroup = Ti.UI.createTabGroup(); 64 | win.tabBarHidden = true; 65 | tab = Ti.UI.createTab({ 66 | title: win.title, 67 | window: win 68 | }); 69 | tabGroup.addTab(tab); 70 | tabGroup.open(); 71 | } 72 | 73 | // Open the application window 74 | win.open(); 75 | } 76 | 77 | exports.openDemo = function(demo) { 78 | var win = Ti.UI.createWindow({ 79 | title: demo.title, 80 | backgroundColor: 'white', 81 | layout: 'vertical' 82 | }); 83 | 84 | // Load the commonJS module for the first time 85 | currentDemo = (demo.mod == null) ? require('demos/' + demo.name) : demo.mod; 86 | 87 | // Perform page initialization 88 | currentDemo.initialize(devGuide); 89 | 90 | // Create the controls for the window 91 | currentDemo.create(win); 92 | 93 | // Handle page cleanup 94 | win.addEventListener('close', function() { 95 | currentDemo.cleanup(); 96 | currentDemo = null; 97 | }); 98 | 99 | if (Ti.Platform.name == 'android') { 100 | win.open({ modal: true, animated: true }); 101 | } else { 102 | tab.open(win, { animated: true }); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /ios/hooks/README: -------------------------------------------------------------------------------- 1 | These files are not yet supported as of 1.4.0 but will be in a near future release. 2 | -------------------------------------------------------------------------------- /ios/hooks/add.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module project add hook that will be 4 | # called when your module is added to a project 5 | # 6 | import os, sys 7 | 8 | def dequote(s): 9 | if s[0:1] == '"': 10 | return s[1:-1] 11 | return s 12 | 13 | def main(args,argc): 14 | # You will get the following command line arguments 15 | # in the following order: 16 | # 17 | # project_dir = the full path to the project root directory 18 | # project_type = the type of project (desktop, mobile, ipad) 19 | # project_name = the name of the project 20 | # 21 | project_dir = dequote(os.path.expanduser(args[1])) 22 | project_type = dequote(args[2]) 23 | project_name = dequote(args[3]) 24 | 25 | # TODO: write your add hook here (optional) 26 | 27 | 28 | # exit 29 | sys.exit(0) 30 | 31 | 32 | 33 | if __name__ == '__main__': 34 | main(sys.argv,len(sys.argv)) 35 | 36 | -------------------------------------------------------------------------------- /ios/hooks/install.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module install hook that will be 4 | # called when your module is first installed 5 | # 6 | import os, sys 7 | 8 | def main(args,argc): 9 | 10 | # TODO: write your install hook here (optional) 11 | 12 | # exit 13 | sys.exit(0) 14 | 15 | 16 | 17 | if __name__ == '__main__': 18 | main(sys.argv,len(sys.argv)) 19 | 20 | -------------------------------------------------------------------------------- /ios/hooks/remove.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module project remove hook that will be 4 | # called when your module is remove from a project 5 | # 6 | import os, sys 7 | 8 | def dequote(s): 9 | if s[0:1] == '"': 10 | return s[1:-1] 11 | return s 12 | 13 | def main(args,argc): 14 | # You will get the following command line arguments 15 | # in the following order: 16 | # 17 | # project_dir = the full path to the project root directory 18 | # project_type = the type of project (desktop, mobile, ipad) 19 | # project_name = the name of the project 20 | # 21 | project_dir = dequote(os.path.expanduser(args[1])) 22 | project_type = dequote(args[2]) 23 | project_name = dequote(args[3]) 24 | 25 | # TODO: write your remove hook here (optional) 26 | 27 | # exit 28 | sys.exit(0) 29 | 30 | 31 | 32 | if __name__ == '__main__': 33 | main(sys.argv,len(sys.argv)) 34 | 35 | -------------------------------------------------------------------------------- /ios/hooks/uninstall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This is the module uninstall hook that will be 4 | # called when your module is uninstalled 5 | # 6 | import os, sys 7 | 8 | def main(args,argc): 9 | 10 | # TODO: write your uninstall hook here (optional) 11 | 12 | # exit 13 | sys.exit(0) 14 | 15 | 16 | if __name__ == '__main__': 17 | main(sys.argv,len(sys.argv)) 18 | 19 | -------------------------------------------------------------------------------- /ios/manifest: -------------------------------------------------------------------------------- 1 | # 2 | # this is your module manifest and used by Titanium 3 | # during compilation, packaging, distribution, etc. 4 | # 5 | version: 2.3.0 6 | apiversion: 2 7 | architectures: armv7 i386 x86_64 arm64 8 | description: Titanium Module Development Guide 9 | author: Jeff English, Jon Alter & Hans Knoechel 10 | license: Apache 2.0 11 | copyright: Copyright (c) 2010-presemt by Appcelerator, Inc. 12 | 13 | 14 | # these should not be edited 15 | name: moddevguide 16 | moduleid: ti.moddevguide 17 | guid: 6fe96416-b375-4358-ab0e-65510cc1acbe 18 | platform: iphone 19 | minsdk: 5.5.0.GA 20 | -------------------------------------------------------------------------------- /ios/moddevguide.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 24416B8111C4CA220047AFDD /* Build & Test */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 24416B8A11C4CA520047AFDD /* Build configuration list for PBXAggregateTarget "Build & Test" */; 13 | buildPhases = ( 14 | 24416B8011C4CA220047AFDD /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | 24416B8511C4CA280047AFDD /* PBXTargetDependency */, 18 | ); 19 | name = "Build & Test"; 20 | productName = "Build & test"; 21 | }; 22 | /* End PBXAggregateTarget section */ 23 | 24 | /* Begin PBXBuildFile section */ 25 | 24DD6CF91134B3F500162E58 /* TiModdevguideModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DD6CF71134B3F500162E58 /* TiModdevguideModule.h */; }; 26 | 24DD6CFA1134B3F500162E58 /* TiModdevguideModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* TiModdevguideModule.m */; }; 27 | 24DE9E1111C5FE74003F90F6 /* TiModdevguideModuleAssets.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DE9E0F11C5FE74003F90F6 /* TiModdevguideModuleAssets.h */; }; 28 | 24DE9E1211C5FE74003F90F6 /* TiModdevguideModuleAssets.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DE9E1011C5FE74003F90F6 /* TiModdevguideModuleAssets.m */; }; 29 | A284015613E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A284014A13E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.h */; }; 30 | A284015713E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A284014B13E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.m */; }; 31 | A284015813E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A284014C13E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.h */; }; 32 | A284015913E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A284014D13E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.m */; }; 33 | A284015A13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A284014E13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.h */; }; 34 | A284015B13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A284014F13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.m */; }; 35 | A284015C13E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A284015013E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.h */; }; 36 | A284015D13E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A284015113E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.m */; }; 37 | A284015E13E82F2300AD7C77 /* TiModdevguideDemoViewProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A284015213E82F2300AD7C77 /* TiModdevguideDemoViewProxy.h */; }; 38 | A284015F13E82F2300AD7C77 /* TiModdevguideDemoView.h in Headers */ = {isa = PBXBuildFile; fileRef = A284015313E82F2300AD7C77 /* TiModdevguideDemoView.h */; }; 39 | A284016013E82F2300AD7C77 /* TiModdevguideDemoView.m in Sources */ = {isa = PBXBuildFile; fileRef = A284015413E82F2300AD7C77 /* TiModdevguideDemoView.m */; }; 40 | A284016113E82F2300AD7C77 /* TiModdevguideDemoViewProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A284015513E82F2300AD7C77 /* TiModdevguideDemoViewProxy.m */; }; 41 | AA747D9F0F9514B9006C5449 /* TiModdevguide_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* TiModdevguide_Prefix.pch */; }; 42 | AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; 43 | /* End PBXBuildFile section */ 44 | 45 | /* Begin PBXContainerItemProxy section */ 46 | 24416B8411C4CA280047AFDD /* PBXContainerItemProxy */ = { 47 | isa = PBXContainerItemProxy; 48 | containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; 49 | proxyType = 1; 50 | remoteGlobalIDString = D2AAC07D0554694100DB518D; 51 | remoteInfo = moddevguide; 52 | }; 53 | /* End PBXContainerItemProxy section */ 54 | 55 | /* Begin PBXFileReference section */ 56 | 24DD6CF71134B3F500162E58 /* TiModdevguideModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideModule.h; path = Classes/TiModdevguideModule.h; sourceTree = ""; }; 57 | 24DD6CF81134B3F500162E58 /* TiModdevguideModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideModule.m; path = Classes/TiModdevguideModule.m; sourceTree = ""; }; 58 | 24DD6D1B1134B66800162E58 /* titanium.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = titanium.xcconfig; sourceTree = ""; }; 59 | 24DE9E0F11C5FE74003F90F6 /* TiModdevguideModuleAssets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideModuleAssets.h; path = Classes/TiModdevguideModuleAssets.h; sourceTree = ""; }; 60 | 24DE9E1011C5FE74003F90F6 /* TiModdevguideModuleAssets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideModuleAssets.m; path = Classes/TiModdevguideModuleAssets.m; sourceTree = ""; }; 61 | A284014A13E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideLifeCycleProxy.h; path = Classes/TiModdevguideLifeCycleProxy.h; sourceTree = ""; }; 62 | A284014B13E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideLifeCycleProxy.m; path = Classes/TiModdevguideLifeCycleProxy.m; sourceTree = ""; }; 63 | A284014C13E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideKrollDemoProxy.h; path = Classes/TiModdevguideKrollDemoProxy.h; sourceTree = ""; }; 64 | A284014D13E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideKrollDemoProxy.m; path = Classes/TiModdevguideKrollDemoProxy.m; sourceTree = ""; }; 65 | A284014E13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideMethodsDemoProxy.h; path = Classes/TiModdevguideMethodsDemoProxy.h; sourceTree = ""; }; 66 | A284014F13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideMethodsDemoProxy.m; path = Classes/TiModdevguideMethodsDemoProxy.m; sourceTree = ""; }; 67 | A284015013E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideParametersDemoProxy.h; path = Classes/TiModdevguideParametersDemoProxy.h; sourceTree = ""; }; 68 | A284015113E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideParametersDemoProxy.m; path = Classes/TiModdevguideParametersDemoProxy.m; sourceTree = ""; }; 69 | A284015213E82F2300AD7C77 /* TiModdevguideDemoViewProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideDemoViewProxy.h; path = Classes/TiModdevguideDemoViewProxy.h; sourceTree = ""; }; 70 | A284015313E82F2300AD7C77 /* TiModdevguideDemoView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiModdevguideDemoView.h; path = Classes/TiModdevguideDemoView.h; sourceTree = ""; }; 71 | A284015413E82F2300AD7C77 /* TiModdevguideDemoView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideDemoView.m; path = Classes/TiModdevguideDemoView.m; sourceTree = ""; }; 72 | A284015513E82F2300AD7C77 /* TiModdevguideDemoViewProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TiModdevguideDemoViewProxy.m; path = Classes/TiModdevguideDemoViewProxy.m; sourceTree = ""; }; 73 | AA747D9E0F9514B9006C5449 /* TiModdevguide_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiModdevguide_Prefix.pch; sourceTree = SOURCE_ROOT; }; 74 | AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 75 | D2AAC07E0554694100DB518D /* libTiModdevguide.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTiModdevguide.a; sourceTree = BUILT_PRODUCTS_DIR; }; 76 | /* End PBXFileReference section */ 77 | 78 | /* Begin PBXFrameworksBuildPhase section */ 79 | D2AAC07C0554694100DB518D /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXFrameworksBuildPhase section */ 88 | 89 | /* Begin PBXGroup section */ 90 | 034768DFFF38A50411DB9C8B /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | D2AAC07E0554694100DB518D /* libTiModdevguide.a */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | 0867D691FE84028FC02AAC07 /* moddevguide */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 08FB77AEFE84172EC02AAC07 /* Classes */, 102 | 32C88DFF0371C24200C91783 /* Other Sources */, 103 | 0867D69AFE84028FC02AAC07 /* Frameworks */, 104 | 034768DFFF38A50411DB9C8B /* Products */, 105 | ); 106 | name = moddevguide; 107 | sourceTree = ""; 108 | }; 109 | 0867D69AFE84028FC02AAC07 /* Frameworks */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | AACBBE490F95108600F1A2B1 /* Foundation.framework */, 113 | ); 114 | name = Frameworks; 115 | sourceTree = ""; 116 | }; 117 | 08FB77AEFE84172EC02AAC07 /* Classes */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 24DD6CF71134B3F500162E58 /* TiModdevguideModule.h */, 121 | 24DD6CF81134B3F500162E58 /* TiModdevguideModule.m */, 122 | 24DE9E0F11C5FE74003F90F6 /* TiModdevguideModuleAssets.h */, 123 | 24DE9E1011C5FE74003F90F6 /* TiModdevguideModuleAssets.m */, 124 | A284014C13E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.h */, 125 | A284014D13E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.m */, 126 | A284014A13E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.h */, 127 | A284014B13E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.m */, 128 | A284014E13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.h */, 129 | A284014F13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.m */, 130 | A284015013E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.h */, 131 | A284015113E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.m */, 132 | A284015313E82F2300AD7C77 /* TiModdevguideDemoView.h */, 133 | A284015413E82F2300AD7C77 /* TiModdevguideDemoView.m */, 134 | A284015213E82F2300AD7C77 /* TiModdevguideDemoViewProxy.h */, 135 | A284015513E82F2300AD7C77 /* TiModdevguideDemoViewProxy.m */, 136 | ); 137 | name = Classes; 138 | sourceTree = ""; 139 | }; 140 | 32C88DFF0371C24200C91783 /* Other Sources */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | AA747D9E0F9514B9006C5449 /* TiModdevguide_Prefix.pch */, 144 | 24DD6D1B1134B66800162E58 /* titanium.xcconfig */, 145 | ); 146 | name = "Other Sources"; 147 | sourceTree = ""; 148 | }; 149 | /* End PBXGroup section */ 150 | 151 | /* Begin PBXHeadersBuildPhase section */ 152 | D2AAC07A0554694100DB518D /* Headers */ = { 153 | isa = PBXHeadersBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | AA747D9F0F9514B9006C5449 /* TiModdevguide_Prefix.pch in Headers */, 157 | 24DD6CF91134B3F500162E58 /* TiModdevguideModule.h in Headers */, 158 | 24DE9E1111C5FE74003F90F6 /* TiModdevguideModuleAssets.h in Headers */, 159 | A284015613E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.h in Headers */, 160 | A284015813E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.h in Headers */, 161 | A284015A13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.h in Headers */, 162 | A284015C13E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.h in Headers */, 163 | A284015E13E82F2300AD7C77 /* TiModdevguideDemoViewProxy.h in Headers */, 164 | A284015F13E82F2300AD7C77 /* TiModdevguideDemoView.h in Headers */, 165 | ); 166 | runOnlyForDeploymentPostprocessing = 0; 167 | }; 168 | /* End PBXHeadersBuildPhase section */ 169 | 170 | /* Begin PBXNativeTarget section */ 171 | D2AAC07D0554694100DB518D /* moddevguide */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "moddevguide" */; 174 | buildPhases = ( 175 | D2AAC07A0554694100DB518D /* Headers */, 176 | D2AAC07B0554694100DB518D /* Sources */, 177 | D2AAC07C0554694100DB518D /* Frameworks */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | ); 183 | name = moddevguide; 184 | productName = moddevguide; 185 | productReference = D2AAC07E0554694100DB518D /* libTiModdevguide.a */; 186 | productType = "com.apple.product-type.library.static"; 187 | }; 188 | /* End PBXNativeTarget section */ 189 | 190 | /* Begin PBXProject section */ 191 | 0867D690FE84028FC02AAC07 /* Project object */ = { 192 | isa = PBXProject; 193 | attributes = { 194 | LastUpgradeCheck = 0900; 195 | }; 196 | buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "moddevguide" */; 197 | compatibilityVersion = "Xcode 3.2"; 198 | developmentRegion = English; 199 | hasScannedForEncodings = 1; 200 | knownRegions = ( 201 | English, 202 | Japanese, 203 | French, 204 | German, 205 | ); 206 | mainGroup = 0867D691FE84028FC02AAC07 /* moddevguide */; 207 | productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; 208 | projectDirPath = ""; 209 | projectRoot = ""; 210 | targets = ( 211 | D2AAC07D0554694100DB518D /* moddevguide */, 212 | 24416B8111C4CA220047AFDD /* Build & Test */, 213 | ); 214 | }; 215 | /* End PBXProject section */ 216 | 217 | /* Begin PBXShellScriptBuildPhase section */ 218 | 24416B8011C4CA220047AFDD /* ShellScript */ = { 219 | isa = PBXShellScriptBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | ); 223 | inputPaths = ( 224 | ); 225 | outputPaths = ( 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | shellPath = /bin/sh; 229 | shellScript = "# shell script goes here\n\npython \"${TITANIUM_SDK}/titanium.py\" run --dir=\"${PROJECT_DIR}\"\nexit $?\n"; 230 | }; 231 | /* End PBXShellScriptBuildPhase section */ 232 | 233 | /* Begin PBXSourcesBuildPhase section */ 234 | D2AAC07B0554694100DB518D /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 24DD6CFA1134B3F500162E58 /* TiModdevguideModule.m in Sources */, 239 | 24DE9E1211C5FE74003F90F6 /* TiModdevguideModuleAssets.m in Sources */, 240 | A284015713E82F2300AD7C77 /* TiModdevguideLifeCycleProxy.m in Sources */, 241 | A284015913E82F2300AD7C77 /* TiModdevguideKrollDemoProxy.m in Sources */, 242 | A284015B13E82F2300AD7C77 /* TiModdevguideMethodsDemoProxy.m in Sources */, 243 | A284015D13E82F2300AD7C77 /* TiModdevguideParametersDemoProxy.m in Sources */, 244 | A284016013E82F2300AD7C77 /* TiModdevguideDemoView.m in Sources */, 245 | A284016113E82F2300AD7C77 /* TiModdevguideDemoViewProxy.m in Sources */, 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | /* End PBXSourcesBuildPhase section */ 250 | 251 | /* Begin PBXTargetDependency section */ 252 | 24416B8511C4CA280047AFDD /* PBXTargetDependency */ = { 253 | isa = PBXTargetDependency; 254 | target = D2AAC07D0554694100DB518D /* moddevguide */; 255 | targetProxy = 24416B8411C4CA280047AFDD /* PBXContainerItemProxy */; 256 | }; 257 | /* End PBXTargetDependency section */ 258 | 259 | /* Begin XCBuildConfiguration section */ 260 | 1DEB921F08733DC00010E9CD /* Debug */ = { 261 | isa = XCBuildConfiguration; 262 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 263 | buildSettings = { 264 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 265 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 266 | CODE_SIGN_IDENTITY = "iPhone Developer"; 267 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 268 | DSTROOT = /tmp/TiModdevguide.dst; 269 | GCC_C_LANGUAGE_STANDARD = c99; 270 | GCC_OPTIMIZATION_LEVEL = 0; 271 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 272 | GCC_PREFIX_HEADER = TiModdevguide_Prefix.pch; 273 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 274 | GCC_THUMB_SUPPORT = NO; 275 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 276 | GCC_VERSION = ""; 277 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 278 | GCC_WARN_MISSING_PARENTHESES = NO; 279 | GCC_WARN_SHADOW = NO; 280 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 281 | GCC_WARN_UNUSED_FUNCTION = YES; 282 | GCC_WARN_UNUSED_PARAMETER = NO; 283 | GCC_WARN_UNUSED_VALUE = NO; 284 | GCC_WARN_UNUSED_VARIABLE = NO; 285 | INSTALL_PATH = /usr/local/lib; 286 | OTHER_CFLAGS = ( 287 | "-DDEBUG", 288 | "-DTI_POST_1_2", 289 | ); 290 | OTHER_LDFLAGS = "-ObjC"; 291 | PRODUCT_NAME = TiModdevguide; 292 | PROVISIONING_PROFILE = ""; 293 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 294 | RUN_CLANG_STATIC_ANALYZER = NO; 295 | SDKROOT = iphoneos; 296 | USER_HEADER_SEARCH_PATHS = ""; 297 | }; 298 | name = Debug; 299 | }; 300 | 1DEB922008733DC00010E9CD /* Release */ = { 301 | isa = XCBuildConfiguration; 302 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 303 | buildSettings = { 304 | ALWAYS_SEARCH_USER_PATHS = NO; 305 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 306 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 307 | DSTROOT = /tmp/TiModdevguide.dst; 308 | GCC_C_LANGUAGE_STANDARD = c99; 309 | GCC_MODEL_TUNING = G5; 310 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 311 | GCC_PREFIX_HEADER = TiModdevguide_Prefix.pch; 312 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 313 | GCC_THUMB_SUPPORT = NO; 314 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 315 | GCC_VERSION = ""; 316 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 317 | GCC_WARN_MISSING_PARENTHESES = NO; 318 | GCC_WARN_SHADOW = NO; 319 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 320 | GCC_WARN_UNUSED_FUNCTION = YES; 321 | GCC_WARN_UNUSED_PARAMETER = NO; 322 | GCC_WARN_UNUSED_VALUE = NO; 323 | GCC_WARN_UNUSED_VARIABLE = NO; 324 | INSTALL_PATH = /usr/local/lib; 325 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 326 | OTHER_CFLAGS = "-DTI_POST_1_2"; 327 | OTHER_LDFLAGS = "-ObjC"; 328 | PRODUCT_NAME = TiModdevguide; 329 | PROVISIONING_PROFILE = ""; 330 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 331 | RUN_CLANG_STATIC_ANALYZER = NO; 332 | SDKROOT = iphoneos; 333 | USER_HEADER_SEARCH_PATHS = ""; 334 | }; 335 | name = Release; 336 | }; 337 | 1DEB922308733DC00010E9CD /* Debug */ = { 338 | isa = XCBuildConfiguration; 339 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 340 | buildSettings = { 341 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 342 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 343 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 344 | CLANG_ENABLE_OBJC_ARC = YES; 345 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 346 | CLANG_WARN_BOOL_CONVERSION = YES; 347 | CLANG_WARN_COMMA = YES; 348 | CLANG_WARN_CONSTANT_CONVERSION = YES; 349 | CLANG_WARN_EMPTY_BODY = YES; 350 | CLANG_WARN_ENUM_CONVERSION = YES; 351 | CLANG_WARN_INFINITE_RECURSION = YES; 352 | CLANG_WARN_INT_CONVERSION = YES; 353 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 354 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 355 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 356 | CLANG_WARN_STRICT_PROTOTYPES = YES; 357 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 358 | CLANG_WARN_UNREACHABLE_CODE = YES; 359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 360 | CODE_SIGN_IDENTITY = "iPhone Developer"; 361 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 362 | DSTROOT = /tmp/TiModdevguide.dst; 363 | ENABLE_STRICT_OBJC_MSGSEND = YES; 364 | ENABLE_TESTABILITY = YES; 365 | GCC_C_LANGUAGE_STANDARD = c99; 366 | GCC_NO_COMMON_BLOCKS = YES; 367 | GCC_OPTIMIZATION_LEVEL = 0; 368 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 369 | GCC_PREFIX_HEADER = TiModdevguide_Prefix.pch; 370 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 371 | GCC_THUMB_SUPPORT = NO; 372 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 373 | GCC_VERSION = ""; 374 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 375 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 376 | GCC_WARN_MISSING_PARENTHESES = NO; 377 | GCC_WARN_SHADOW = NO; 378 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 379 | GCC_WARN_UNDECLARED_SELECTOR = YES; 380 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 381 | GCC_WARN_UNUSED_FUNCTION = YES; 382 | GCC_WARN_UNUSED_PARAMETER = NO; 383 | GCC_WARN_UNUSED_VALUE = NO; 384 | GCC_WARN_UNUSED_VARIABLE = NO; 385 | INSTALL_PATH = /usr/local/lib; 386 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 387 | ONLY_ACTIVE_ARCH = YES; 388 | OTHER_CFLAGS = ( 389 | "-DDEBUG", 390 | "-DTI_POST_1_2", 391 | ); 392 | OTHER_LDFLAGS = "-ObjC"; 393 | PRODUCT_NAME = TiModdevguide; 394 | PROVISIONING_PROFILE = ""; 395 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 396 | RUN_CLANG_STATIC_ANALYZER = NO; 397 | SDKROOT = iphoneos; 398 | USER_HEADER_SEARCH_PATHS = ""; 399 | }; 400 | name = Debug; 401 | }; 402 | 1DEB922408733DC00010E9CD /* Release */ = { 403 | isa = XCBuildConfiguration; 404 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 405 | buildSettings = { 406 | ALWAYS_SEARCH_USER_PATHS = NO; 407 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 408 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 409 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 410 | CLANG_ENABLE_OBJC_ARC = YES; 411 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 412 | CLANG_WARN_BOOL_CONVERSION = YES; 413 | CLANG_WARN_COMMA = YES; 414 | CLANG_WARN_CONSTANT_CONVERSION = YES; 415 | CLANG_WARN_EMPTY_BODY = YES; 416 | CLANG_WARN_ENUM_CONVERSION = YES; 417 | CLANG_WARN_INFINITE_RECURSION = YES; 418 | CLANG_WARN_INT_CONVERSION = YES; 419 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 420 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 421 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 422 | CLANG_WARN_STRICT_PROTOTYPES = YES; 423 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 424 | CLANG_WARN_UNREACHABLE_CODE = YES; 425 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 426 | DSTROOT = /tmp/TiModdevguide.dst; 427 | ENABLE_STRICT_OBJC_MSGSEND = YES; 428 | GCC_C_LANGUAGE_STANDARD = c99; 429 | GCC_MODEL_TUNING = G5; 430 | GCC_NO_COMMON_BLOCKS = YES; 431 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 432 | GCC_PREFIX_HEADER = TiModdevguide_Prefix.pch; 433 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 434 | GCC_THUMB_SUPPORT = NO; 435 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 436 | GCC_VERSION = ""; 437 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 438 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 439 | GCC_WARN_MISSING_PARENTHESES = NO; 440 | GCC_WARN_SHADOW = NO; 441 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 442 | GCC_WARN_UNDECLARED_SELECTOR = YES; 443 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 444 | GCC_WARN_UNUSED_FUNCTION = YES; 445 | GCC_WARN_UNUSED_PARAMETER = NO; 446 | GCC_WARN_UNUSED_VALUE = NO; 447 | GCC_WARN_UNUSED_VARIABLE = NO; 448 | INSTALL_PATH = /usr/local/lib; 449 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 450 | OTHER_CFLAGS = "-DTI_POST_1_2"; 451 | OTHER_LDFLAGS = "-ObjC"; 452 | PRODUCT_NAME = TiModdevguide; 453 | PROVISIONING_PROFILE = ""; 454 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 455 | RUN_CLANG_STATIC_ANALYZER = NO; 456 | SDKROOT = iphoneos; 457 | USER_HEADER_SEARCH_PATHS = ""; 458 | }; 459 | name = Release; 460 | }; 461 | 24416B8211C4CA220047AFDD /* Debug */ = { 462 | isa = XCBuildConfiguration; 463 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 464 | buildSettings = { 465 | COPY_PHASE_STRIP = NO; 466 | GCC_DYNAMIC_NO_PIC = NO; 467 | GCC_OPTIMIZATION_LEVEL = 0; 468 | GCC_THUMB_SUPPORT = NO; 469 | PRODUCT_NAME = "Build & test"; 470 | }; 471 | name = Debug; 472 | }; 473 | 24416B8311C4CA220047AFDD /* Release */ = { 474 | isa = XCBuildConfiguration; 475 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 476 | buildSettings = { 477 | COPY_PHASE_STRIP = YES; 478 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 479 | GCC_ENABLE_FIX_AND_CONTINUE = NO; 480 | GCC_THUMB_SUPPORT = NO; 481 | PRODUCT_NAME = "Build & test"; 482 | ZERO_LINK = NO; 483 | }; 484 | name = Release; 485 | }; 486 | /* End XCBuildConfiguration section */ 487 | 488 | /* Begin XCConfigurationList section */ 489 | 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "moddevguide" */ = { 490 | isa = XCConfigurationList; 491 | buildConfigurations = ( 492 | 1DEB921F08733DC00010E9CD /* Debug */, 493 | 1DEB922008733DC00010E9CD /* Release */, 494 | ); 495 | defaultConfigurationIsVisible = 0; 496 | defaultConfigurationName = Release; 497 | }; 498 | 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "moddevguide" */ = { 499 | isa = XCConfigurationList; 500 | buildConfigurations = ( 501 | 1DEB922308733DC00010E9CD /* Debug */, 502 | 1DEB922408733DC00010E9CD /* Release */, 503 | ); 504 | defaultConfigurationIsVisible = 0; 505 | defaultConfigurationName = Release; 506 | }; 507 | 24416B8A11C4CA520047AFDD /* Build configuration list for PBXAggregateTarget "Build & Test" */ = { 508 | isa = XCConfigurationList; 509 | buildConfigurations = ( 510 | 24416B8211C4CA220047AFDD /* Debug */, 511 | 24416B8311C4CA220047AFDD /* Release */, 512 | ); 513 | defaultConfigurationIsVisible = 0; 514 | defaultConfigurationName = Release; 515 | }; 516 | /* End XCConfigurationList section */ 517 | }; 518 | rootObject = 0867D690FE84028FC02AAC07 /* Project object */; 519 | } 520 | -------------------------------------------------------------------------------- /ios/module.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // PLACE ANY BUILD DEFINITIONS IN THIS FILE AND THEY WILL BE 3 | // PICKED UP DURING THE APP BUILD FOR YOUR MODULE 4 | // 5 | // see the following webpage for instructions on the settings 6 | // for this file: 7 | // http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/400-Build_Configurations/build_configs.html 8 | // 9 | 10 | // 11 | // How to add a Framework (example) 12 | // 13 | // OTHER_LDFLAGS=$(inherited) -framework Foo 14 | // 15 | // Adding a framework for a specific version(s) of iPhone: 16 | // 17 | // OTHER_LDFLAGS[sdk=iphoneos4*]=$(inherited) -framework Foo 18 | // OTHER_LDFLAGS[sdk=iphonesimulator4*]=$(inherited) -framework Foo 19 | // 20 | // 21 | // How to add a compiler define: 22 | // 23 | // OTHER_CFLAGS=$(inherited) -DFOO=1 24 | // 25 | // 26 | // IMPORTANT NOTE: always use $(inherited) in your overrides 27 | // 28 | -------------------------------------------------------------------------------- /ios/platform/README: -------------------------------------------------------------------------------- 1 | You can place platform-specific files here in sub-folders named "android" and/or "iphone", just as you can with normal Titanium Mobile SDK projects. Any folders and files you place here will be merged with the platform-specific files in a Titanium Mobile project that uses this module. 2 | 3 | When a Titanium Mobile project that uses this module is built, the files from this platform/ folder will be treated the same as files (if any) from the Titanium Mobile project's platform/ folder. 4 | -------------------------------------------------------------------------------- /ios/timodule.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ios/titanium.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // CHANGE THESE VALUES TO REFLECT THE VERSION (AND LOCATION IF DIFFERENT) 4 | // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR 5 | // 6 | // 7 | TITANIUM_SDK_VERSION = 6.0.3.GA 8 | 9 | 10 | // 11 | // THESE SHOULD BE OK GENERALLY AS-IS 12 | // 13 | TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION) 14 | TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" 15 | TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" 16 | HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) ~$(TITANIUM_BASE_SDK) ~$(TITANIUM_BASE_SDK2) 17 | 18 | 19 | 20 | --------------------------------------------------------------------------------