Skip to content

Commit

Permalink
Merge pull request #4566 from billdawson/timob-7401
Browse files Browse the repository at this point in the history
TIMOB-7401 Android: Implement switchCamera
  • Loading branch information
ayeung committed Aug 20, 2013
2 parents 0f60983 + c27d353 commit 4fa3b29
Show file tree
Hide file tree
Showing 23 changed files with 262 additions and 88 deletions.
2 changes: 1 addition & 1 deletion android/modules/accelerometer/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/analytics/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/android/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/app/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/calendar/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium-android"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/contacts/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/database/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/filesystem/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/geolocation/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/gesture/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/locale/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/map/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
Expand Down
2 changes: 1 addition & 1 deletion android/modules/media/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/titanium-dist/lib/kroll-apt.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium"/>
<classpathentry combineaccessrules="false" kind="src" path="/titanium-filesystem"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.appcelerator.titanium.util.TiUIHelper;

import ti.modules.titanium.media.android.AndroidModule.MediaScannerClient;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void vibrate(@Kroll.argument(optional=true) long[] pattern)
}

@Kroll.method
public void showCamera(HashMap options)
public void showCamera(@SuppressWarnings("rawtypes") HashMap options)
{
Activity activity = TiApplication.getInstance().getCurrentActivity();

Expand Down Expand Up @@ -180,6 +181,15 @@ public void showCamera(HashMap options)
TiCameraActivity.errorCallback = errorCallback;
TiCameraActivity.cancelCallback = cancelCallback;
TiCameraActivity.saveToPhotoGallery = saveToPhotoGallery;
TiCameraActivity.whichCamera = CAMERA_REAR; // default.

// This option is only applicable when running the custom
// TiCameraActivity, since we can't direct the built-in
// Activity to open a specific camera.
Object whichCamera = options.get("whichCamera");
if (whichCamera != null) {
TiCameraActivity.whichCamera = TiConvert.toInt(whichCamera);
}
TiCameraActivity.autohide = autohide;

Intent intent = new Intent(activity, TiCameraActivity.class);
Expand Down Expand Up @@ -582,6 +592,7 @@ private void moveImage(String source, String dest)
}
}

@SuppressLint("DefaultLocale")
private void processImage(Activity activity)
{
String localUrl = imageUrl;
Expand Down Expand Up @@ -889,7 +900,21 @@ public void takePicture()
}
}

@Kroll.method @Kroll.getProperty
@Kroll.method
public void switchCamera(int whichCamera)
{
TiCameraActivity activity = TiCameraActivity.cameraActivity;

if (activity == null || !activity.isPreviewRunning()) {
Log.e(TAG, "Camera preview is not open, unable to switch camera.");
return;
}

activity.switchCamera(whichCamera);
}

@Kroll.method
@Kroll.getProperty
public boolean getIsCameraSupported()
{
return Camera.getNumberOfCameras() > 0;
Expand Down

0 comments on commit 4fa3b29

Please sign in to comment.