diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e7ffeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/iphone/build +/iphone/*.zip \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dd95850 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright 2017-Present Cesar Cavazos + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8caa8ad --- /dev/null +++ b/README.md @@ -0,0 +1,106 @@ +## Alternate App Icon Ti Module (iOS 10.3+) + +### Summary + +Leverage the ability to change the app icon in iOS 10.3+ + +WhiteIconBlackIcon + +### Requirements + + - Titanium Mobile SDK 6.0.3.GA or later + - iOS 10.3 or later + - Xcode 8.3 or later + +### Download + + * [Stable release](https://github.com/ccavazos/titanium-alternate-icons/releases) + +### Setup + +Unzip the module in the `modules/iphone/` folder of your project. +Add the module requirement in your `tiapp.xml` file. + +```xml + + ti.alternateicons + +``` + +In order to use this module with Titanium you will need to disable app thinning by editing the adding the following property in your `tiapp.xml` + +```xml + + false + +``` + +Next, you have to declare the icons that you will use in your by adding the following to the `tiapp.xml`. The `` named `alloyIcon` is the string that you will use to call the `set​Alternate​Icon​Name` method . + +```xml + + CFBundleIcons + + CFBundleAlternateIcons + + alloyIcon + + CFBundleIconFiles + + alloy + + + + CFBundlePrimaryIcon + + CFBundleIconFiles + + AppIcon + + + + + +``` + +Copy your icons into the `app/assets/` folder. You can try it out with `alloy@2x.png` and `alloy@3x.png` in the example folder of this repo. + +### Hyperloop + +This module is also built in Hyperloop to demonstrate the native API access with JavaScript. +You can simple require the `ti.alternateicon.js` in your application and run it! + +#### Example + +Request a new review dialog: + +```javascript +var AlternateIcon = require('ti.alternateicon'); + +if (AlternateIcon.isSupported()) { + AlternateIcon.set​Alternate​Icon​Name('alloyIcon'); +} +``` +#### Methods + +- [x] `isSupported` +- [x] `supportsAlternateIcons` +- [x] `alternateIconName` +- [x] `set​Alternate​Icon​Name` +- [x] `setDefaultIconName` + +### Author + +Cesar Cavazos ([@cesarcvz](https://twitter.com/cesarcvz) / [Web](http://ccavazos.co)) + +### License + +Apache 2.0 + +### Contributing + +Code contributions are greatly appreciated, please submit a new [pull request](https://github.com/ccavazos/titanium-alternate-icons/pull/new/master) + +### Special Thanks + +To [Hans Knoechel](https://github.com/hansemannn) because this module was created using [titanium-review-dialog](https://github.com/hansemannn/titanium-review-dialog) as a reference \ No newline at end of file diff --git a/example/alloy@2x.png b/example/alloy@2x.png new file mode 100644 index 0000000..97bc944 Binary files /dev/null and b/example/alloy@2x.png differ diff --git a/example/alloy@3x.png b/example/alloy@3x.png new file mode 100644 index 0000000..738b003 Binary files /dev/null and b/example/alloy@3x.png differ diff --git a/example/app.js b/example/app.js new file mode 100644 index 0000000..74b9d98 --- /dev/null +++ b/example/app.js @@ -0,0 +1,64 @@ +// Make sure you have done the following: +// - Disable App Thining +// - In the tiapp.xml add the following +// - Add the icon images under app/assets/ +var tiAlternateIcons = require('ti.alternateicons'); +console.info('module is => ' + tiAlternateIcons); + +// Validates that iOS is 10.3 or greater +console.info('isSupported: ' + tiAlternateIcons.isSupported()); +// Native method that returns if the alternate icons are supported +console.info('supportsAlternateIcons: ' + tiAlternateIcons.supportsAlternateIcons()); + +// Samp le window +var win = Ti.UI.createWindow({ + backgroundColor: '#FFFFFF' +}); +var buttonSetDefaultIcon = Ti.UI.createButton({ + top: 30, + title: 'Set Default Icon' +}); +var buttonSetAlternateIcon = Ti.UI.createButton({ + top: 80, + title: 'Set Alternate Icon' +}); +var buttonAlternateIcon = Ti.UI.createButton({ + top: 130, + title: 'Get Icon Name' +}); + +buttonSetDefaultIcon.addEventListener('click', function(_evt){ + if (tiAlternateIcons.isSupported() && tiAlternateIcons.supportsAlternateIcons()) { + tiAlternateIcons.setDefaultIconName(); + } else { + alert('Not supported'); + } +}); +buttonSetAlternateIcon.addEventListener('click', function(_evt){ + if (tiAlternateIcons.isSupported() && tiAlternateIcons.supportsAlternateIcons()) { + tiAlternateIcons.setAlternateIconName('alloy'); + } else { + alert('Not supported'); + } +}); +buttonAlternateIcon.addEventListener('click', function(_evt){ + if (tiAlternateIcons.isSupported() && tiAlternateIcons.supportsAlternateIcons()) { + var iconName = tiAlternateIcons.alternateIconName(); + if (iconName) { + alert('Current icon name is: ' + iconName); + } else { + alert('Default icon returns as null'); + } + } else { + alert('Not supported'); + } +}); + +win.add(buttonSetDefaultIcon); +win.add(buttonSetAlternateIcon); +win.add(buttonAlternateIcon); + +win.open(); + + + diff --git a/example/icon_black.png b/example/icon_black.png new file mode 100644 index 0000000..c294625 Binary files /dev/null and b/example/icon_black.png differ diff --git a/example/icon_white.png b/example/icon_white.png new file mode 100644 index 0000000..1a7f9ae Binary files /dev/null and b/example/icon_white.png differ diff --git a/iphone/.gitignore b/iphone/.gitignore new file mode 100644 index 0000000..24f1210 --- /dev/null +++ b/iphone/.gitignore @@ -0,0 +1,18 @@ +# Xcode +.DS_Store +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ \ No newline at end of file diff --git a/iphone/Classes/TiAlternateiconsModule.h b/iphone/Classes/TiAlternateiconsModule.h new file mode 100644 index 0000000..8becd51 --- /dev/null +++ b/iphone/Classes/TiAlternateiconsModule.h @@ -0,0 +1,18 @@ +/** + * titanium-alternate-icons + * + * Created by Your Name + * Copyright (c) 2017 Your Company. All rights reserved. + */ + +#import "TiModule.h" + +@interface TiAlternateiconsModule : TiModule + +- (NSNumber*) isSupported:(id)unused; +- (NSNumber*) supportsAlternateIcons:(id)unused; +- (NSString*) alternateIconName:(id)unused; +- (void) setAlternateIconName:(NSString*)iconName; +- (void) setDefaultIconName:(id)unused; + +@end diff --git a/iphone/Classes/TiAlternateiconsModule.m b/iphone/Classes/TiAlternateiconsModule.m new file mode 100644 index 0000000..98a102e --- /dev/null +++ b/iphone/Classes/TiAlternateiconsModule.m @@ -0,0 +1,119 @@ +/** + * titanium-alternate-icons + * + * Created by Your Name + * Copyright (c) 2017 Your Company. All rights reserved. + */ + +#import "TiAlternateiconsModule.h" +#import "TiBase.h" +#import "TiHost.h" +#import "TiUtils.h" + +@implementation TiAlternateiconsModule + +#pragma mark Internal + +// this is generated for your module, please do not change it +-(id)moduleGUID +{ + return @"1730e6ec-327b-4f48-8705-461178f9db12"; +} + +// this is generated for your module, please do not change it +-(NSString*)moduleId +{ + return @"ti.alternateicons"; +} + +#pragma mark Lifecycle + +-(void)startup +{ + // this method is called when the module is first loaded + // you *must* call the superclass + [super startup]; + + NSLog(@"[INFO] %@ loaded",self); +} + +-(void)shutdown:(id)sender +{ + // this method is called when the module is being unloaded + // typically this is during shutdown. make sure you don't do too + // much processing here or the app will be quit forceably + + // you *must* call the superclass + [super shutdown:sender]; +} + +#pragma mark Cleanup + +-(void)dealloc +{ + // release any resources that have been retained by the module + [super dealloc]; +} + +#pragma Public APIs + +-(NSNumber*)isSupported:(id)unused +{ +#ifdef __IPHONE_10_3 + return NUMBOOL([[[UIDevice currentDevice] systemVersion] compare:@"10.3" options:NSNumericSearch] != NSOrderedAscending); +#else + return NUMBOOL(NO); +#endif +} + +-(NSNumber*)supportsAlternateIcons:(id)unused +{ + ENSURE_ARG_COUNT(unused, 0); +#ifdef __IPHONE_10_3 + return NUMBOOL([[UIApplication sharedApplication] supportsAlternateIcons]); +#else + NSLog(@"[ERROR] Ti.AlternateIcons: This feature is only available on iOS 10.3 and later."); +#endif +} + +-(NSString*)alternateIconName:(id)unused +{ +#ifdef __IPHONE_10_3 + return [[UIApplication sharedApplication] alternateIconName]; +#else + NSLog(@"[ERROR] Ti.AlternateIcons: This feature is only available on iOS 10.3 and later."); +#endif +} +-(void)setAlternateIconName:(NSString*)iconName +{ + ENSURE_STRING(iconName) +#ifdef __IPHONE_10_3 + [[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) { + if (error) { + NSLog(@"[ERROR] Ti.AlternateIcons: %@", [error localizedDescription]); + } else { + NSLog(@"[INFO] Ti.AlternateIcons: Icon has been changed to %@.", iconName); + } + }]; +#else + NSLog(@"[ERROR] Ti.AlternateIcons: This feature is only available on iOS 10.3 and later."); +#endif +} +-(void)setDefaultIconName:(id)unused +{ + ENSURE_ARG_COUNT(unused, 0); +#ifdef __IPHONE_10_3 + [[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) { + if (error) { + NSLog(@"[ERROR] Ti.AlternateIcons: %@", [error localizedDescription]); + } else { + NSLog(@"[INFO] Ti.AlternateIcons: Icon has been changed to Default."); + } + }]; +#else + NSLog(@"[ERROR] Ti.AlternateIcons: This feature is only available on iOS 10.3 and later."); +#endif + +} + +@end diff --git a/iphone/Classes/TiAlternateiconsModuleAssets.h b/iphone/Classes/TiAlternateiconsModuleAssets.h new file mode 100644 index 0000000..faed407 --- /dev/null +++ b/iphone/Classes/TiAlternateiconsModuleAssets.h @@ -0,0 +1,11 @@ +/** + * This is a generated file. Do not edit or your changes will be lost + */ + +@interface TiAlternateiconsModuleAssets : NSObject +{ +} +- (NSData*) moduleAsset; +- (NSData*) resolveModuleAsset:(NSString*)path; + +@end diff --git a/iphone/Classes/TiAlternateiconsModuleAssets.m b/iphone/Classes/TiAlternateiconsModuleAssets.m new file mode 100644 index 0000000..235a76a --- /dev/null +++ b/iphone/Classes/TiAlternateiconsModuleAssets.m @@ -0,0 +1,24 @@ +/** + * This is a generated file. Do not edit or your changes will be lost + */ +#import "TiAlternateiconsModuleAssets.h" + +extern NSData* filterDataInRange(NSData* thedata, NSRange range); + +@implementation TiAlternateiconsModuleAssets + +- (NSData*) moduleAsset +{ + + + return nil; +} + +- (NSData*) resolveModuleAsset:(NSString*)path +{ + + + return nil; +} + +@end diff --git a/iphone/README b/iphone/README new file mode 100644 index 0000000..fbbb94a --- /dev/null +++ b/iphone/README @@ -0,0 +1,151 @@ +Appcelerator Titanium iPhone Module Project +=========================================== + +This is a skeleton Titanium Mobile iPhone module project. Modules can be +used to extend the functionality of Titanium by providing additional native +code that is compiled into your application at build time and can expose certain +APIs into JavaScript. + +MODULE NAMING +-------------- + +Choose a unique module id for your module. This ID usually follows a namespace +convention using DNS notation. For example, com.appcelerator.module.test. This +ID can only be used once by all public modules in Titanium. + + +COMPONENTS +----------- + +Components that are exposed by your module must follow a special naming convention. +A component (widget, proxy, etc) must be named with the pattern: + + TiProxy + +For example, if you component was called Foo, your proxy would be named: + + TiMyfirstFooProxy + +For view proxies or widgets, you must create both a view proxy and a view implementation. +If you widget was named proxy, you would create the following files: + + TiMyfirstFooProxy.h + TiMyfirstFooProxy.m + TiMyfirstFoo.h + TiMyfirstFoo.m + +The view implementation is named the same except it does contain the suffix `Proxy`. + +View implementations extend the Titanium base class `TiUIView`. View Proxies extend the +Titanium base class `TiUIViewProxy` or `TiUIWidgetProxy`. + +For proxies that are simply native objects that can be returned to JavaScript, you can +simply extend `TiProxy` and no view implementation is required. + + +GET STARTED +------------ + +1. Edit manifest with the appropriate details about your module. +2. Edit LICENSE to add your license details. +3. Place any assets (such as PNG files) that are required in the assets folder. +4. Edit the titanium.xcconfig and make sure you're building for the right Titanium version. +5. Code and build. + +BUILD TIME COMPILER CONFIG +-------------------------- + +You can edit the file `module.xcconfig` to include any build time settings that should be +set during application compilation that your module requires. This file will automatically get `#include` in the main application project. + +For more information about this file, please see the Apple documentation at: + + + + +DOCUMENTATION FOR YOUR MODULE +----------------------------- + +You should provide at least minimal documentation for your module in `documentation` folder using the Markdown syntax. + +For more information on the Markdown syntax, refer to this documentation at: + + + + +TEST HARNESS EXAMPLE FOR YOUR MODULE +------------------------------------ + +The `example` directory contains a skeleton application test harness that can be +used for testing and providing an example of usage to the users of your module. + + +INSTALL YOUR MODULE +-------------------- + +1. Run `build.py` which creates your distribution +2. cd to `/Library/Application Support/Titanium` +3. copy this zip file into the folder of your Titanium SDK + +REGISTER YOUR MODULE +--------------------- + +Register your module with your application by editing `tiapp.xml` and adding your module. +Example: + + + __MODULE_ID__ + + +When you run your project, the compiler will know automatically compile in your module +dependencies and copy appropriate image assets into the application. + +USING YOUR MODULE IN CODE +------------------------- + +To use your module in code, you will need to require it. + +For example, + + var my_module = require('__MODULE_ID__'); + my_module.foo(); + +WRITING PURE JS NATIVE MODULES +------------------------------ + +You can write a pure JavaScript "natively compiled" module. This is nice if you +want to distribute a JS module pre-compiled. + +To create a module, create a file named __MODULE_ID__.js under the assets folder. +This file must be in the Common JS format. For example: + + exports.echo = function(s) + { + return s; + }; + +Any functions and properties that are exported will be made available as part of your +module. All other code inside your JS will be private to your module. + +For pure JS module, you don't need to modify any of the Objective-C module code. You +can leave it as-is and build. + +TESTING YOUR MODULE +------------------- + +Run the `titanium.py` script to test your module or test from within XCode. +To test with the script, execute: + + titanium run --dir=YOURMODULEDIR + + +This will execute the app.js in the example folder as a Titanium application. + + +DISTRIBUTING YOUR MODULE +------------------------- + +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! + + +Cheers! diff --git a/iphone/Resources/README.md b/iphone/Resources/README.md new file mode 100644 index 0000000..bb6c641 --- /dev/null +++ b/iphone/Resources/README.md @@ -0,0 +1,10 @@ +Files in this folder are copied directory into the compiled product directory +when the iOS app is compiled: + + /build/iphone/build/Products//.app/ + +Place your module's iOS bundles and localization files in this folder. + +Files in this directory are copied directly on top of whatever files are already +in the build directory, so please be careful that your files don't clobber +essential project files or files from other modules. diff --git a/iphone/TiAlternateicons_Prefix.pch b/iphone/TiAlternateicons_Prefix.pch new file mode 100644 index 0000000..186d246 --- /dev/null +++ b/iphone/TiAlternateicons_Prefix.pch @@ -0,0 +1,5 @@ + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/iphone/manifest b/iphone/manifest new file mode 100644 index 0000000..c8de455 --- /dev/null +++ b/iphone/manifest @@ -0,0 +1,18 @@ +# +# this is your module manifest and used by Titanium +# during compilation, packaging, distribution, etc. +# +version: 1.0.0 +apiversion: 2 +architectures: armv7 arm64 i386 x86_64 +description: titanium-alternate-icons +author: Cesar Cavazos +license: Apache 2 +copyright: Copyright (c) 2017 by Cesar Cavazos + +# these should not be edited +name: titanium-alternate-icons +moduleid: ti.alternateicons +guid: 1730e6ec-327b-4f48-8705-461178f9db12 +platform: iphone +minsdk: 6.0.3.GA diff --git a/iphone/metadata.json b/iphone/metadata.json new file mode 100644 index 0000000..43a62e5 --- /dev/null +++ b/iphone/metadata.json @@ -0,0 +1 @@ +{"exports":[]} \ No newline at end of file diff --git a/iphone/module.xcconfig b/iphone/module.xcconfig new file mode 100644 index 0000000..80ca884 --- /dev/null +++ b/iphone/module.xcconfig @@ -0,0 +1,27 @@ +// +// PLACE ANY BUILD DEFINITIONS IN THIS FILE AND THEY WILL BE +// PICKED UP DURING THE APP BUILD FOR YOUR MODULE +// +// see the following webpage for instructions on the settings +// for this file: +// http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/400-Build_Configurations/build_configs.html +// + +// +// How to add a Framework (example) +// +// OTHER_LDFLAGS=$(inherited) -framework Foo +// +// Adding a framework for a specific version(s) of iPhone: +// +// OTHER_LDFLAGS[sdk=iphoneos4*]=$(inherited) -framework Foo +// OTHER_LDFLAGS[sdk=iphonesimulator4*]=$(inherited) -framework Foo +// +// +// How to add a compiler define: +// +// OTHER_CFLAGS=$(inherited) -DFOO=1 +// +// +// IMPORTANT NOTE: always use $(inherited) in your overrides +// diff --git a/iphone/platform/README.md b/iphone/platform/README.md new file mode 100644 index 0000000..183350d --- /dev/null +++ b/iphone/platform/README.md @@ -0,0 +1,11 @@ +Files in this folder are copied directory into the iOS build directory +when the iOS app is compiled: + + /build/iphone + +You can place files such as asset catalog files and storyboards in this +directory. + +Files in this directory are copied directly on top of whatever files are already +in the build directory, so please be careful that your files don't clobber +essential project files or files from other modules. diff --git a/iphone/timodule.xml b/iphone/timodule.xml new file mode 100644 index 0000000..6affb2f --- /dev/null +++ b/iphone/timodule.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/iphone/titanium-alternate-icons.xcodeproj/project.pbxproj b/iphone/titanium-alternate-icons.xcodeproj/project.pbxproj new file mode 100644 index 0000000..730f685 --- /dev/null +++ b/iphone/titanium-alternate-icons.xcodeproj/project.pbxproj @@ -0,0 +1,412 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXAggregateTarget section */ + 24416B8111C4CA220047AFDD /* Build & Test */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 24416B8A11C4CA520047AFDD /* Build configuration list for PBXAggregateTarget "Build & Test" */; + buildPhases = ( + 24416B8011C4CA220047AFDD /* ShellScript */, + ); + dependencies = ( + 24416B8511C4CA280047AFDD /* PBXTargetDependency */, + ); + name = "Build & Test"; + productName = "Build & test"; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 24DD6CF91134B3F500162E58 /* TiAlternateiconsModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DD6CF71134B3F500162E58 /* TiAlternateiconsModule.h */; }; + 24DD6CFA1134B3F500162E58 /* TiAlternateiconsModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* TiAlternateiconsModule.m */; }; + 24DE9E1111C5FE74003F90F6 /* TiAlternateiconsModuleAssets.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DE9E0F11C5FE74003F90F6 /* TiAlternateiconsModuleAssets.h */; }; + 24DE9E1211C5FE74003F90F6 /* TiAlternateiconsModuleAssets.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DE9E1011C5FE74003F90F6 /* TiAlternateiconsModuleAssets.m */; }; + AA747D9F0F9514B9006C5449 /* TiAlternateicons_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* TiAlternateicons_Prefix.pch */; }; + AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 24416B8411C4CA280047AFDD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = "titanium-alternate-icons"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 24DD6CF71134B3F500162E58 /* TiAlternateiconsModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "TiAlternateiconsModule.h"; path = "Classes/TiAlternateiconsModule.h"; sourceTree = ""; }; + 24DD6CF81134B3F500162E58 /* TiAlternateiconsModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "TiAlternateiconsModule.m"; path = "Classes/TiAlternateiconsModule.m"; sourceTree = ""; }; + 24DD6D1B1134B66800162E58 /* titanium.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = titanium.xcconfig; sourceTree = ""; }; + 24DE9E0F11C5FE74003F90F6 /* TiAlternateiconsModuleAssets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "TiAlternateiconsModuleAssets.h"; path = "Classes/TiAlternateiconsModuleAssets.h"; sourceTree = ""; }; + 24DE9E1011C5FE74003F90F6 /* TiAlternateiconsModuleAssets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "TiAlternateiconsModuleAssets.m"; path = "Classes/TiAlternateiconsModuleAssets.m"; sourceTree = ""; }; + AA747D9E0F9514B9006C5449 /* TiAlternateicons_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TiAlternateicons_Prefix.pch"; sourceTree = SOURCE_ROOT; }; + AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + D2AAC07E0554694100DB518D /* libti.alternateicons.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libti.alternateicons.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D2AAC07C0554694100DB518D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 034768DFFF38A50411DB9C8B /* Products */ = { + isa = PBXGroup; + children = ( + D2AAC07E0554694100DB518D /* libti.alternateicons.a */, + ); + name = Products; + sourceTree = ""; + }; + 0867D691FE84028FC02AAC07 /* titanium-alternate-icons */ = { + isa = PBXGroup; + children = ( + 08FB77AEFE84172EC02AAC07 /* Classes */, + 32C88DFF0371C24200C91783 /* Other Sources */, + 0867D69AFE84028FC02AAC07 /* Frameworks */, + 034768DFFF38A50411DB9C8B /* Products */, + ); + name = "titanium-alternate-icons"; + sourceTree = ""; + }; + 0867D69AFE84028FC02AAC07 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AACBBE490F95108600F1A2B1 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 08FB77AEFE84172EC02AAC07 /* Classes */ = { + isa = PBXGroup; + children = ( + 24DE9E0F11C5FE74003F90F6 /* TiAlternateiconsModuleAssets.h */, + 24DE9E1011C5FE74003F90F6 /* TiAlternateiconsModuleAssets.m */, + 24DD6CF71134B3F500162E58 /* TiAlternateiconsModule.h */, + 24DD6CF81134B3F500162E58 /* TiAlternateiconsModule.m */, + ); + name = Classes; + sourceTree = ""; + }; + 32C88DFF0371C24200C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + AA747D9E0F9514B9006C5449 /* TiAlternateicons_Prefix.pch */, + 24DD6D1B1134B66800162E58 /* titanium.xcconfig */, + ); + name = "Other Sources"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D2AAC07A0554694100DB518D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + AA747D9F0F9514B9006C5449 /* TiAlternateicons_Prefix.pch in Headers */, + 24DD6CF91134B3F500162E58 /* TiAlternateiconsModule.h in Headers */, + 24DE9E1111C5FE74003F90F6 /* TiAlternateiconsModuleAssets.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + D2AAC07D0554694100DB518D /* titanium-alternate-icons */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "titanium-alternate-icons" */; + buildPhases = ( + D2AAC07A0554694100DB518D /* Headers */, + D2AAC07B0554694100DB518D /* Sources */, + D2AAC07C0554694100DB518D /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "titanium-alternate-icons"; + productName = "titanium-alternate-icons"; + productReference = D2AAC07E0554694100DB518D /* libti.alternateicons.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0867D690FE84028FC02AAC07 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0600; + }; + buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "titanium-alternate-icons" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 0867D691FE84028FC02AAC07 /* titanium-alternate-icons */; + productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D2AAC07D0554694100DB518D /* titanium-alternate-icons */, + 24416B8111C4CA220047AFDD /* Build & Test */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXShellScriptBuildPhase section */ + 24416B8011C4CA220047AFDD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# shell script goes here\n\npython \"${TITANIUM_SDK}/titanium.py\" run --dir=\"${PROJECT_DIR}\"\nexit $?\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + D2AAC07B0554694100DB518D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 24DD6CFA1134B3F500162E58 /* TiAlternateiconsModule.m in Sources */, + 24DE9E1211C5FE74003F90F6 /* TiAlternateiconsModuleAssets.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 24416B8511C4CA280047AFDD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D2AAC07D0554694100DB518D /* titanium-alternate-icons */; + targetProxy = 24416B8411C4CA280047AFDD /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 1DEB921F08733DC00010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DSTROOT = "/tmp/TiAlternateicons.dst"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "TiAlternateicons_Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = NO; + GCC_WARN_MISSING_PARENTHESES = NO; + GCC_WARN_SHADOW = NO; + GCC_WARN_STRICT_SELECTOR_MATCH = NO; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_PARAMETER = NO; + GCC_WARN_UNUSED_VALUE = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + INSTALL_PATH = /usr/local/lib; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + LIBRARY_SEARCH_PATHS = ""; + OTHER_CFLAGS = ( + "-DDEBUG", + "-DTI_POST_1_2", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "ti.alternateicons"; + PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + RUN_CLANG_STATIC_ANALYZER = NO; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = ""; + }; + name = Debug; + }; + 1DEB922008733DC00010E9CD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + DSTROOT = "/tmp/TiAlternateicons.dst"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "TiAlternateicons_Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = NO; + GCC_WARN_MISSING_PARENTHESES = NO; + GCC_WARN_SHADOW = NO; + GCC_WARN_STRICT_SELECTOR_MATCH = NO; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_PARAMETER = NO; + GCC_WARN_UNUSED_VALUE = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + INSTALL_PATH = /usr/local/lib; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + LIBRARY_SEARCH_PATHS = ""; + OTHER_CFLAGS = "-DTI_POST_1_2"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "ti.alternateicons"; + RUN_CLANG_STATIC_ANALYZER = NO; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = ""; + }; + name = Release; + }; + 1DEB922308733DC00010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; + buildSettings = { + CLANG_CXX_LIBRARY = "libstdc++"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DSTROOT = "/tmp/TiAlternateicons.dst"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "TiAlternateicons_Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = NO; + GCC_WARN_MISSING_PARENTHESES = NO; + GCC_WARN_SHADOW = NO; + GCC_WARN_STRICT_SELECTOR_MATCH = NO; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_PARAMETER = NO; + GCC_WARN_UNUSED_VALUE = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + INSTALL_PATH = /usr/local/lib; + ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = ( + "-DDEBUG", + "-DTI_POST_1_2", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "ti.alternateicons"; + PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + RUN_CLANG_STATIC_ANALYZER = NO; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = ""; + }; + name = Debug; + }; + 1DEB922408733DC00010E9CD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LIBRARY = "libstdc++"; + DSTROOT = "/tmp/TiAlternateicons.dst"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "TiAlternateicons_Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = NO; + GCC_WARN_MISSING_PARENTHESES = NO; + GCC_WARN_SHADOW = NO; + GCC_WARN_STRICT_SELECTOR_MATCH = NO; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_PARAMETER = NO; + GCC_WARN_UNUSED_VALUE = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + INSTALL_PATH = /usr/local/lib; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + OTHER_CFLAGS = "-DTI_POST_1_2"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "ti.alternateicons"; + RUN_CLANG_STATIC_ANALYZER = NO; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = ""; + }; + name = Release; + }; + 24416B8211C4CA220047AFDD /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + PRODUCT_NAME = "Build & test"; + }; + name = Debug; + }; + 24416B8311C4CA220047AFDD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + PRODUCT_NAME = "Build & test"; + ZERO_LINK = NO; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "titanium-alternate-icons" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB921F08733DC00010E9CD /* Debug */, + 1DEB922008733DC00010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "titanium-alternate-icons" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB922308733DC00010E9CD /* Debug */, + 1DEB922408733DC00010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 24416B8A11C4CA520047AFDD /* Build configuration list for PBXAggregateTarget "Build & Test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 24416B8211C4CA220047AFDD /* Debug */, + 24416B8311C4CA220047AFDD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0867D690FE84028FC02AAC07 /* Project object */; +} diff --git a/iphone/titanium.xcconfig b/iphone/titanium.xcconfig new file mode 100644 index 0000000..665978b --- /dev/null +++ b/iphone/titanium.xcconfig @@ -0,0 +1,20 @@ +// +// +// CHANGE THESE VALUES TO REFLECT THE VERSION (AND LOCATION IF DIFFERENT) +// OF YOUR TITANIUM SDK YOU'RE BUILDING FOR +// +// +TITANIUM_SDK_VERSION = 6.0.3.GA + + +// +// THESE SHOULD BE OK GENERALLY AS-IS +// +TITANIUM_SDK = /Users/cavazos/Library/Application Support/Titanium/mobilesdk/osx/6.0.3.GA +TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" +TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" +TITANIUM_BASE_SDK3 = "$(TITANIUM_SDK)/iphone/include/JavaScriptCore" +HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) $(TITANIUM_BASE_SDK3) + + + diff --git a/ti.alternateicons.js b/ti.alternateicons.js new file mode 100644 index 0000000..7fd1625 --- /dev/null +++ b/ti.alternateicons.js @@ -0,0 +1,40 @@ +/** + * Titanium Alternate Icons (Hyperloop) + * @version 1.0.0 + * @author ccavazos + */ +var UIApplication = require('UIKit/UIApplication'); +var UIDevice = require('UIKit/UIDevice'); +var NSNumericSearch = require('Foundation').NSNumericSearch; +var NSOrderedAscending = require('Foundation').NSOrderedAscending; + +exports.isSupported = function() { + return UIDevice.currentDevice.systemVersion.compareOptions('10.3', NSNumericSearch) != NSOrderedAscending; +}; + +exports.supportsAlternateIcons = function() { + return !!UIApplication.sharedApplication.supportsAlternateIcons; +}; + +exports.alternateIconName = function() { + var iconName = String(UIApplication.sharedApplication.alternateIconName); + if (iconName == 'null') { + return null; + } else { + return iconName; + } +}; + +exports.setAlternateIconName = function(iconName) { + UIApplication.sharedApplication.setAlternateIconNameCompletionHandler(iconName, function(error){ + if (error) { + console.error('[ti.alternateicons] ', error); + } else { + console.log('[ti.alternateicons] Icon has been changed to', (iconName) ? iconName : 'Default'); + } + }); +}; + +exports.setDefaultIconName = function() { + exports.setAlternateIconName(null); +}; \ No newline at end of file