Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View benbahrenburg's full-sized avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
@benbahrenburg
benbahrenburg / read.js
Created November 8, 2014 23:56
NoteEvents - Read Script
function read(query, user, request) {
query.where({ userId: user.userId });
request.execute();
}
@benbahrenburg
benbahrenburg / delete.js
Last active August 29, 2015 14:08
NoteEvents - Delete Script
function del(id, user, request) {
var table = tables.getTable('noteEvents');
table.where({
id: id, userId : user.userId
}).read({
success: delItems
});
function delItems(items) {
if (items.length > 0) {
@benbahrenburg
benbahrenburg / gist:d4efb4fc6a2de91b1ba8
Last active August 29, 2015 14:10
Check if passcode enabled
private boolean deviceHasPasscodeEnabled()
{
String LOCKSCREEN_UTILS = "com.android.internal.widget.LockPatternUtils";
try
{
Class<?> lockUtilsClass = Class.forName(LOCKSCREEN_UTILS);
// "this" is a Context, in my case an Activity
Object lockUtils = lockUtilsClass.getConstructor(Context.class).newInstance(this);
Method method = lockUtilsClass.getMethod("getActivePasswordQuality");
@benbahrenburg
benbahrenburg / gist:4f7794ece60831c14182
Created December 3, 2014 11:01
Creating ApplicationSupport Directory
BOOL supportDirExists; // Add class level variable
//Update to FilesystemModule.m
//https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/FilesystemModule.m#L132
-(NSString*)applicationSupportDirectory
{
if(!supportDirExists){
NSString *supportDir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject];
if ([[NSFileManager defaultManager] fileExistsAtPath:supportDir isDirectory:NULL]) {
@benbahrenburg
benbahrenburg / app.js
Created March 15, 2015 02:57
TIMOB-17458
//To test the method use the following
var dir = Ti.Filesystem.getApplicationSupportDirectory();
console.log(dir);
var f = Titanium.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory);
console.log('Directory Exists: '+ (f.exists() ? 'Yes' : 'No'));
var testfile = Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory, 'text.txt');
if(testfile.exists()){
testfile.deleteFile();
@benbahrenburg
benbahrenburg / app.js
Created March 15, 2015 17:11
TIMOB-17458 - How to test
var dir = Ti.Filesystem.getApplicationSupportDirectory();
console.log(dir);
var f = Titanium.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory);
console.log('Directory Exists: '+ (f.exists() ? 'Yes' : 'No'));
console.log('Needs to be yes to pass'));
var testfile = Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory, 'text.txt');
if(testfile.exists()){
testfile.deleteFile();
}
@benbahrenburg
benbahrenburg / readme.md
Last active August 29, 2015 14:19
Exploring how to do openParentApplication in Titanium

This gist outlines how to use an experimental build of the Ti SDK that includes the delegate needed for openParentApplication support

Steps:

  1. Download the latest master nightly build
  2. You need to replace the following four files in your nightly build with the ones listed below

https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiApp.h https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiApp.m https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiAppiOSProxy.m

@benbahrenburg
benbahrenburg / readme.md
Last active August 29, 2015 14:20
TIMOB-18854 : Add Delegate & Reply for openParentApplication to Titanium

This pull request adds support for a Apple Watch Extension to be able to openParentApplication and have a Titanium application reply.

This pull request is related to the Jira ticket TIMOB-18854.

This pull request consists of a few different parts.

1.Application Delegate

This pull request adds a delegate method to Tiapp.m this delegate raises the Ti.App.iOS watchkitextensionrequest event. The userInfo provided by the extension openParentApplication is passed through to the watchkitextensionrequest event. The reply method of the delegate is captured and placed into an NSDictionary. This allows for the reply message to later be called as part of the sendWatchExtensionReply method.

@benbahrenburg
benbahrenburg / index.js
Created April 27, 2015 04:26
iOS Center Button for tabGroup
var btnAction = Ti.UI.createButton({
title:"I'm a button",
backgroundColor:"#e7e7e8",
width:85, height:55, bottom:0, borderColor:"#999"
});
$.tbgroup.add(btnAction);
$.tbgroup.open();
@benbahrenburg
benbahrenburg / TiApp.m
Created June 14, 2015 06:24
Titanium iOS 9 support for hand off
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler
{
NSMutableDictionary *dict = [NSMutableDictionary
dictionaryWithObjectsAndKeys:[userActivity activityType],@"activityType",
nil];
if([userActivity title] !=nil){
[dict setObject:[userActivity title] forKey:@"title"];
}