Skip to content
Browse files

iOS5以上に対応

  • Loading branch information...
1 parent d3ad088 commit 9e04d8a937ad92a402966010b7ea1f31ab8f7d24 @ojimac committed Oct 2, 2012
View
2 Classes/ELCAlbumPickerController.h
@@ -6,6 +6,7 @@
//
#import <UIKit/UIKit.h>
+#import <AssetsLibrary/AssetsLibrary.h>
typedef enum ELCAlbumPickerFilter {
kELCAlbumAllAssets = 0,
@@ -21,6 +22,7 @@ typedef enum ELCAlbumPickerFilter {
ELCAlbumPickerFilter assetFilter;
CGFloat cellHeight;
NSString *titleForSelection;
+ ALAssetsLibrary *library_;
}
@property (nonatomic, assign) id parent;
View
5 Classes/ELCAlbumPickerController.m
@@ -79,13 +79,12 @@ - (void)viewDidLoad {
};
// Enumerate Albums
- ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
- [library enumerateGroupsWithTypes:ALAssetsGroupAll
+ library_ = [[ALAssetsLibrary alloc] init];
+ [library_ enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:assetGroupEnumberatorFailure];
- [library release];
[pool release];
});
}
View
2 Classes/JpKrayTiELCImagePickerModule.h
@@ -6,11 +6,13 @@
*/
#import "TiModule.h"
#import "KrollCallback.h"
+#import "ELCAlbumPickerController.h"
@interface JpKrayTiELCImagePickerModule : TiModule {
KrollCallback *pickerSuccessCallback;
KrollCallback *pickerErrorCallback;
KrollCallback *pickerCancelCallback;
+ ELCAlbumPickerController *_albumController;
}
@end
View
13 Classes/JpKrayTiELCImagePickerModule.m
@@ -109,19 +109,18 @@ - (void)loadImagePicker:(id)args {
}
}
- ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] init];
- ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
- [albumController setParent:elcPicker];
- albumController.assetFilter = kELCAlbumAllAssets;
- albumController.cellHeight = 75;
- albumController.titleForSelection = NSLocalizedString(@"Pick Something", @"Title for picking items");
+ _albumController = [[ELCAlbumPickerController alloc] init];
+ ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:_albumController];
+ [_albumController setParent:elcPicker];
+ _albumController.assetFilter = kELCAlbumAllAssets;
+ _albumController.cellHeight = 75;
+ _albumController.titleForSelection = NSLocalizedString(@"Pick Something", @"Title for picking items");
[elcPicker setDelegate:self];
TiApp *tiApp = [TiApp app];
[tiApp showModalController:elcPicker animated:YES];
[elcPicker release];
- [albumController release];
}
#pragma mark ELCImagePickerControllerDelegate Methods
View
59 build.py
@@ -3,8 +3,9 @@
# Appcelerator Titanium Module Packager
#
#
-import os, sys, glob, string
+import os, subprocess, sys, glob, string
import zipfile
+from datetime import date
cwd = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
os.chdir(cwd)
@@ -17,6 +18,10 @@
}
module_license_default = "TODO: place your license here and we'll include it in the module distribution"
+def find_sdk(config):
+ sdk = config['TITANIUM_SDK']
+ return os.path.expandvars(os.path.expanduser(sdk))
+
def replace_vars(config,token):
idx = token.find('$(')
while idx != -1:
@@ -47,35 +52,44 @@ def generate_doc(config):
if not os.path.exists(docdir):
print "Couldn't find documentation file at: %s" % docdir
return None
- sdk = config['TITANIUM_SDK']
- support_dir = os.path.join(sdk,'module','support')
- sys.path.append(support_dir)
- import markdown2
+
+ try:
+ import markdown2 as markdown
+ except ImportError:
+ import markdown
documentation = []
for file in os.listdir(docdir):
+ if file in ignoreFiles or os.path.isdir(os.path.join(docdir, file)):
+ continue
md = open(os.path.join(docdir,file)).read()
- html = markdown2.markdown(md)
+ html = markdown.markdown(md)
documentation.append({file:html});
return documentation
def compile_js(manifest,config):
js_file = os.path.join(cwd,'assets','jp.kray.ti.ELCImagePicker.js')
if not os.path.exists(js_file): return
-
- sdk = config['TITANIUM_SDK']
- iphone_dir = os.path.join(sdk,'iphone')
- sys.path.insert(0,iphone_dir)
+
from compiler import Compiler
+ try:
+ import json
+ except:
+ import simplejson as json
path = os.path.basename(js_file)
- metadata = Compiler.make_function_from_file(path,js_file)
- method = metadata['method']
- eq = path.replace('.','_')
- method = ' return %s;' % method
+ compiler = Compiler(cwd, manifest['moduleid'], manifest['name'], 'commonjs')
+ method = compiler.compile_commonjs_file(path,js_file)
+
+ exports = open('metadata.json','w')
+ json.dump({'exports':compiler.exports }, exports)
+ exports.close()
+
+ method += '\treturn filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[0]);'
f = os.path.join(cwd,'Classes','JpKrayTiELCImagePickerModuleAssets.m')
c = open(f).read()
- idx = c.find('return ')
+ templ_search = ' moduleAsset\n{\n'
+ idx = c.find(templ_search) + len(templ_search)
before = c[0:idx]
after = """
}
@@ -98,7 +112,7 @@ def warn(msg):
def validate_license():
c = open(os.path.join(cwd,'LICENSE')).read()
- if c.find(module_license_default)!=1:
+ if c.find(module_license_default)!=-1:
warn('please update the LICENSE file with your license text before distributing')
def validate_manifest():
@@ -144,6 +158,9 @@ def glob_libfiles():
return files
def build_module(manifest,config):
+ from tools import ensure_dev_path
+ ensure_dev_path()
+
rc = os.system("xcodebuild -sdk iphoneos -configuration Release")
if rc != 0:
die("xcodebuild failed")
@@ -175,18 +192,26 @@ def package_module(manifest,mf,config):
for file, html in doc.iteritems():
filename = string.replace(file,'.md','.html')
zf.writestr('%s/documentation/%s'%(modulepath,filename),html)
- for dn in ('assets','example'):
+ for dn in ('assets','example','platform'):
if os.path.exists(dn):
zip_dir(zf,dn,'%s/%s' % (modulepath,dn),['README'])
zf.write('LICENSE','%s/LICENSE' % modulepath)
zf.write('module.xcconfig','%s/module.xcconfig' % modulepath)
+ exports_file = 'metadata.json'
+ if os.path.exists(exports_file):
+ zf.write(exports_file, '%s/%s' % (modulepath, exports_file))
zf.close()
if __name__ == '__main__':
manifest,mf = validate_manifest()
validate_license()
config = read_ti_xcconfig()
+
+ sdk = find_sdk(config)
+ sys.path.insert(0,os.path.join(sdk,'iphone'))
+ sys.path.append(os.path.join(sdk, "common"))
+
compile_js(manifest,config)
build_module(manifest,config)
package_module(manifest,mf,config)
View
4 titanium.xcconfig
@@ -4,13 +4,13 @@
// OF YOUR TITANIUM SDK YOU'RE BUILDING FOR
//
//
-TITANIUM_SDK_VERSION = 1.6.2
+TITANIUM_SDK_VERSION = 2.1.3.v20120927181611
//
// THESE SHOULD BE OK GENERALLY AS-IS
//
-TITANIUM_SDK = /Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)
+TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)
TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include"
TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore"
HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2)

0 comments on commit 9e04d8a

Please sign in to comment.
Something went wrong with that request. Please try again.