Skip to content

Commit

Permalink
Merge branch 'master' into 1_8_X
Browse files Browse the repository at this point in the history
Conflicts:
	android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBinding.fm
	android/runtime/v8/src/native/V8Function.cpp
	apidoc/Titanium/UI/TableView.yml
	iphone/Classes/TiUITableView.m
	iphone/Classes/TiUIWindowProxy.m
	mobileweb/src/loader.js
	mobileweb/src/styleable.js
	mobileweb/src/touchable.js
  • Loading branch information
marshall committed Feb 15, 2012
2 parents cacde6b + 4d82f5a commit 43d708c
Show file tree
Hide file tree
Showing 364 changed files with 13,770 additions and 10,906 deletions.
3 changes: 2 additions & 1 deletion CREDITS
Expand Up @@ -16,7 +16,8 @@ We would like to thank the following for their contributions:
- Bill Dawson
- Josh Roesslein
- Ben Ramsey

- Chris Barber
- Bryan Hughes

If you're interested in contributing to Titanium, please let us know
by emailing info@appcelerator.com. Or, better yet, fork the Github
Expand Down
19 changes: 16 additions & 3 deletions android/build/common.xml
Expand Up @@ -36,9 +36,12 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<property name="kroll.common.project.dir" location="${ti.android.root}/runtime/common"/>
<property name="kroll.v8.project.dir" location="${ti.android.root}/runtime/v8"/>
<property name="kroll.rhino.project.dir" location="${ti.android.root}/runtime/rhino"/>
<property name="ndk.build" location="${kroll.v8.project.dir}/ndk-build.sh"/>
<property name="kroll.runtime" value="all"/>

<condition property="ndk.build" value="${kroll.v8.project.dir}/ndk-build.cmd" else="${kroll.v8.project.dir}/ndk-build.sh">
<os family="windows"/>
</condition>

<property name="modules.dir" location="${ti.android.root}/modules"/>
<property name="ui.module.dir" location="${modules.dir}/ui"/>

Expand All @@ -59,6 +62,16 @@ Common ant tasks and macros for building Android-based Titanium modules and proj

<property name="android.ndk" value="${env.ANDROID_NDK}"/>

<if>
<isset property="env.TI_DEBUG"/>
<then>
<property name="ti.debug" value="${env.TI_DEBUG}"/>
</then>
<else>
<property name="ti.debug" value="0"/>
</else>
</if>

<if>
<isset property="env.ANDROID_PLATFORM"/>
<then>
Expand Down Expand Up @@ -356,7 +369,7 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<!-- moduleId (Titanium for platform) -->
<arg value="titanium"/>
<!-- bindingsClassName (empty for platform) -->
<arg value=""/>
<arg value=" "/>
<fileset dir="${dist.json.dir}" includes="**/*.json"/>
</apply>
</sequential>
Expand All @@ -374,7 +387,7 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<property name="ndk.build.args" value=""/>
<exec executable="${ndk.build}" dir="${kroll.v8.project.dir}" failonerror="true">
<env key="ANDROID_NDK" file="${android.ndk}"/>
<arg value="TI_DEBUG=0"/>
<arg value="TI_DEBUG=${ti.debug}"/>
<arg line="${ndk.build.args}"/>
</exec>
<copy todir="${dist.dir}">
Expand Down
@@ -1,12 +1,33 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

package org.appcelerator.kroll.runtime.rhino;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.Collections;
import org.appcelerator.kroll.common.Log;
import java.lang.reflect.Method;


public class KrollGeneratedBindings
{
private static HashMap<String, GeneratedBinding> genBindings =
new HashMap<String, GeneratedBinding>();

<#-- Track the prototypes that are actually in use in the program, so
we can dispose just those. See TIMOB-7252 for why.-->
private static HashSet<Class<? extends Proxy>> usedPrototypeClasses =
new HashSet<Class<? extends Proxy>>();

private static final String DISPOSE = "dispose";
private static final String TAG = "KrollGeneratedBindings";

private static class GeneratedBinding
{
public GeneratedBinding(Class<? extends Proxy> proxyClass, String apiName)
Expand Down Expand Up @@ -47,8 +68,25 @@ public class KrollGeneratedBindings

public static void dispose()
{
<#list bindings as binding>
${binding.class}Prototype.dispose();
</#list>
if (usedPrototypeClasses == null) {
return;
}
for (Class<? extends Proxy> cls : usedPrototypeClasses) {
if (cls == null) {
continue;
}
try {
Method disposeMethod = cls.getMethod(DISPOSE);
disposeMethod.invoke(null);
} catch(Exception e) {
Log.e(TAG, e.getClass().getSimpleName() + " disposing " + cls.getSimpleName() + ": " + e.getMessage());
}
}
usedPrototypeClasses.clear();
}

public static void registerUsedPrototypeClass(Class<? extends Proxy> cls)
{
usedPrototypeClasses.add(cls);
}
}
Expand Up @@ -521,7 +521,6 @@ fails, a JS exception is returned.
<#local type = "Local<Number>">
<#local valueExpr = expr + "->ToNumber()">
<#local stringExpr = expr + "->ToString()">
<#local postAssignmentCheck = "titanium::V8Util::isNaN(" + current_arg + ")">
<#elseif info?keys?seq_contains("jsHandleCast")>
<#local type = "Local<" + info.jsType + ">">
<#local valueExpr = "Local<" + info.jsType + ">::Cast(" + expr + ")">
Expand All @@ -532,17 +531,8 @@ fails, a JS exception is returned.
</#if>

<#t>
${type} ${current_arg};
<#if nullCheck == 1>
if (!${expr}->IsNull()) {
${current_arg} = ${valueExpr};
}
<#else>
${current_arg} = ${valueExpr};
</#if>

<#if info.jsType == "Number">
if (${postAssignmentCheck} || ${stringExpr}->Length() == 0) {
if (titanium::V8Util::isNaN(${expr}) || ${stringExpr}->Length() == 0) {
const char *error = "Invalid value, expected type ${info.jsType}.";
LOGE(TAG, error);
<#if !(logOnly!false)>
Expand All @@ -552,8 +542,9 @@ fails, a JS exception is returned.
</#if>
<#t>
if (!${expr}->IsNull()) {
${type} ${current_arg} = ${valueExpr};
jArguments[${index}].${info.jvalue} =
titanium::TypeConverter::${info.jsToJavaConverter}(arg_${index}<#if checkNew>, &isNew_${index}</#if>);
titanium::TypeConverter::${info.jsToJavaConverter}(${current_arg}<#if checkNew>, &isNew_${index}</#if>);
} else {
jArguments[${index}].${info.jvalue} = NULL;
}
Expand Down
@@ -1,9 +1,10 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

package ${packageName};

import org.mozilla.javascript.Context;
Expand All @@ -22,6 +23,7 @@ import org.appcelerator.kroll.KrollRuntime;
import org.appcelerator.kroll.common.TiConfig;

import org.appcelerator.kroll.runtime.rhino.KrollBindings;
import org.appcelerator.kroll.runtime.rhino.KrollGeneratedBindings;
import org.appcelerator.kroll.runtime.rhino.Proxy;
import org.appcelerator.kroll.runtime.rhino.ProxyFactory;
import org.appcelerator.kroll.runtime.rhino.RhinoRuntime;
Expand Down Expand Up @@ -66,13 +68,18 @@ public class ${className}Prototype extends ${superProxy}

public static void dispose()
{
if (DBG) {
Log.d(TAG, "dispose()");
}
${protoVar} = null;
}

public ${className}Prototype()
{
if (${protoVar} == null && getClass().equals(${className}Prototype.class)) {
${protoVar} = this;
<#-- Enables us later to only dispose() classes that were actually used. Helps avoid VFY warnings in Android. -->
KrollGeneratedBindings.registerUsedPrototypeClass(getClass());
}

<#if isModule>
Expand Down
@@ -1,7 +1,14 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2012 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
package ti.modules.titanium.app;

import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiBaseActivity;
import org.appcelerator.titanium.TiContext;
Expand Down Expand Up @@ -41,19 +48,22 @@ public RProxy getR()
@Kroll.method
public ActivityProxy getTopActivity()
{
try {
TiApplication.getInstance().rootActivityLatch.await();

} catch (InterruptedException e) {
e.printStackTrace();
}

Activity activity = TiApplication.getInstance().getCurrentActivity();
TiApplication tiApp = TiApplication.getInstance();
Activity activity = tiApp.getCurrentActivity();
if (activity == null || !(activity instanceof TiBaseActivity)) {
activity = TiApplication.getInstance().getRootActivity();
try {
tiApp.rootActivityLatch.await();
activity = tiApp.getRootActivity();
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted awaiting rootActivityLatch");
}
}

return ((TiBaseActivity)activity).getActivityProxy();
if (activity instanceof TiBaseActivity) {
return ((TiBaseActivity)activity).getActivityProxy();
} else {
return null;
}
}
}

Expand Up @@ -5,6 +5,7 @@
import org.appcelerator.titanium.ITiAppInfo;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.titanium.util.TiPlatformHelper;

@Kroll.module
public class AppModule extends KrollModule
Expand Down Expand Up @@ -67,7 +68,17 @@ public String getCopyright() {
public String getGUID() {
return appInfo.getGUID();
}


@Kroll.getProperty @Kroll.method
public String getDeployType() {
return TiApplication.getInstance().getDeployType();
}

@Kroll.getProperty @Kroll.method
public String getSessionId() {
return TiPlatformHelper.getSessionId();
}

@Kroll.method
public String appURLToPath(String url) {
return resolveUrl(null, url);
Expand Down
Expand Up @@ -41,6 +41,7 @@

import ti.modules.titanium.media.android.AndroidModule.MediaScannerClient;
import android.app.Activity;
import android.app.Application;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
Expand All @@ -63,6 +64,7 @@ public class MediaModule extends KrollModule

private static final long[] DEFAULT_VIBRATE_PATTERN = { 100L, 250L };
private static final String PHOTO_DCIM_CAMERA = "/sdcard/dcim/Camera";
private static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; // Needed until api 9 is our minimum supported.

@Kroll.constant public static final int UNKNOWN_ERROR = 0;
@Kroll.constant public static final int DEVICE_BUSY = 1;
Expand Down Expand Up @@ -692,5 +694,23 @@ public void takePicture()
Log.e(LCAT, "camera preview is not open, unable to take photo");
}
}

@Kroll.method @Kroll.getProperty
public boolean getIsCameraSupported()
{
Application application = TiApplication.getInstance();
if (application == null) {
Log.w(LCAT, "Could not retrieve application instance, returning false for isCameraSupported.");
return false;
}

PackageManager pm = application.getPackageManager();
if (pm == null) {
Log.w(LCAT, "Could not retrieve PackageManager instance, returning false for isCameraSupported.");
}

return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) ||
pm.hasSystemFeature(FEATURE_CAMERA_FRONT);
}
}

Expand Up @@ -313,7 +313,11 @@ public void setTime(int position)
position = duration;
}

mp.seekTo(position);
try {
mp.seekTo(position);
} catch (IllegalStateException e) {
Log.w(LCAT, "Error calling seekTo() in an incorrect state. Ignoring.");
}
}

proxy.setProperty(TiC.PROPERTY_TIME, position);
Expand Down Expand Up @@ -383,6 +387,7 @@ public void stop()
}
try {
mp.prepare();
mp.seekTo(0);
} catch (IOException e) {
Log.e(LCAT,"Error while preparing audio after stop(). Ignoring.");
} catch (IllegalStateException e) {
Expand Down
Expand Up @@ -134,8 +134,10 @@ public void handleCreationDict(KrollDict options)
if (mcStyle != null) {
mediaControlStyle = TiConvert.toInt(mcStyle);
} else if (mcModeDeprecated != null) {
Log.w(LCAT, "movieControlMode is deprecated. Use mediaControlStyle instead.");
mediaControlStyle = TiConvert.toInt(mcModeDeprecated);
} else if (mcStyleDeprecated != null) {
Log.w(LCAT, "movieControlStyle is deprecated. Use mediaControlStyle instead.");
mediaControlStyle = TiConvert.toInt(mcStyleDeprecated);
}

Expand Down Expand Up @@ -445,12 +447,14 @@ public void setMovieControlMode(int style)
@Kroll.getProperty @Kroll.method
public int getMovieControlStyle()
{
Log.w(LCAT, "movieControlStyle is deprecated. Use mediaControlStyle instead.");
return getMediaControlStyle();
}

@Kroll.setProperty @Kroll.method
public void setMovieControlStyle(int style)
{
Log.w(LCAT, "movieControlStyle is deprecated. Use mediaControlStyle instead.");
setMediaControlStyle(style);
}

Expand Down

0 comments on commit 43d708c

Please sign in to comment.