platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java in rhodes-1.5.5 vs platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java in rhodes-2.0.0.beta1
- old
+ new
@@ -21,10 +21,12 @@
package com.rhomobile.rhodes.camera;
import java.io.File;
import android.content.Intent;
+
+import com.rhomobile.rhodes.Capabilities;
import com.rhomobile.rhodes.Logger;
import com.rhomobile.rhodes.Rhodes;
import com.rhomobile.rhodes.RhodesInstance;
public class Camera {
@@ -43,10 +45,24 @@
File f = new File(BASE_CAMERA_DIR);
if (!f.exists())
f.mkdirs();
}
+ private static class CameraDisabled implements Runnable {
+
+ private String url;
+
+ public CameraDisabled(String u) {
+ url = u;
+ }
+
+ public void run() {
+ callback(url, "", "Camera disabled", false);
+ }
+
+ };
+
private static class Runner implements Runnable {
private String url;
private Class<?> cls;
@@ -62,21 +78,23 @@
intent.putExtra(INTENT_EXTRA_PREFIX + "callback", url);
r.startActivity(intent);
}
};
- public static void takePicture(String sourceUrl) {
+ public static void takePicture(String url) {
try {
- Rhodes.performOnUiThread(new Runner(sourceUrl, ImageCapture.class), false);
+ Runnable runnable = Capabilities.CAMERA_ENABLED ? new Runner(url, ImageCapture.class) :
+ new CameraDisabled(url);
+ Rhodes.performOnUiThread(runnable, false);
}
catch (Exception e) {
reportFail("takePicture", e);
}
}
- public static void choosePicture(String sourceUrl) {
+ public static void choosePicture(String url) {
try {
- Rhodes.performOnUiThread(new Runner(sourceUrl, FileList.class), false);
+ Rhodes.performOnUiThread(new Runner(url, FileList.class), false);
}
catch (Exception e) {
reportFail("choosePicture", e);
}
}