tauplatform 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +10 -0
- data/lib/build/development/platform.rb +5 -1
- data/lib/build/development/web_server.rb +2 -0
- data/lib/commonAPI/coreapi/ext/shared/TimerImpl.cpp +10 -1
- data/lib/commonAPI/eventsource/ext/platform/android/ext_native.files +4 -4
- data/lib/commonAPI/eventsource/ext/shared/EventSource.h +2 -2
- data/lib/commonAPI/mediacapture/ext/camera.xml +16 -11
- data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraEclair.java +17 -6
- data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraObject.java +304 -294
- data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraRhoListener.java +528 -282
- data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonObject.java +119 -94
- data/lib/commonAPI/mediacapture/ext/platform/wm/Mediacapture.vcproj +3 -3
- data/lib/commonAPI/mediacapture/ext/platform/wp8/src/Camera_impl.cs +63 -43
- data/lib/extensions/barcode-old/ext/barcode/platform/iphone/Rakefile +1 -1
- data/lib/framework/rhodes.rb +2 -2
- data/lib/framework/version.rb +2 -2
- data/lib/rhodes.rb +2 -2
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +7 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/socket/SSLImpl.java +11 -4
- data/platform/android/build/android.rake +6 -0
- data/platform/iphone/Classes/SimpleMainView.m +8 -3
- data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.m +1 -1
- data/platform/shared/common/RhodesApp.cpp +4 -0
- data/platform/shared/common/RhodesApp.h +8 -0
- data/platform/shared/net/CURLNetRequest.cpp +4 -2
- data/platform/shared/net/HttpServer.cpp +2 -2
- data/platform/shared/ruby/ext/rho/rhoruby.c +1 -1
- data/res/generators/templates/iphone_project/Bremen7.xcodeproj/project.pbxproj +3 -0
- data/version +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTRhN2M1OWFjNjU1MmU2ZWQ5OGVlMjRlNGExZTgzYTQ5YTUyNzEyZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGMzZTA4ZTRhZGU2ODRjY2I2MjdhMDA0OWQyODI5MTdhZTA5Y2Q4Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjY5YTcxMTc5MjgxMzg3NmQ1YzVjNTRlMzcxMTY3ZjNlMGZlODRmOTUyNTcz
|
10
|
+
OTdkZDQ5ZDA4ODhlNGMwYzI5YTNiMTZkNTFmMTk0OGJiZTMwYjE5MGU2OTk5
|
11
|
+
ZTlhNGNhNjBkOWYxMTNlMmIzMTYwYjc1NTBiMzM5MjIzZGY5Mzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmI1OWVjYTVjYzA1M2U1ZWQxNzU3NTBlYzk4NDY1ODE1MTQ4OTdkZTczYzYz
|
14
|
+
MThmZDQ1YTM1MjdhYzRlYjEyMjg4ZDdiNTExNGEwNmJkZGQ4MjYzOTkwM2M1
|
15
|
+
MDU1ZTI3YTc4ZjBhYmFmZDk0OGI3NTU5NjUyYThhMDhiMjNlZDY=
|
data/CHANGELOG
CHANGED
@@ -8,10 +8,14 @@ module RhoDevelopment
|
|
8
8
|
return /darwin/i === RbConfig::CONFIG['host_os']
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.linux?
|
12
|
+
return /linux/i === RbConfig::CONFIG['host_os']
|
13
|
+
end
|
14
|
+
|
11
15
|
def self.terminate_process(pid)
|
12
16
|
if self.windows?
|
13
17
|
system "taskkill /F /PID #{pid}"
|
14
|
-
elsif self.osx?
|
18
|
+
elsif self.osx? or self.linux?
|
15
19
|
Process.kill('SIGTERM', pid)
|
16
20
|
else
|
17
21
|
raise "Unknown platform #{RbConfig::CONFIG['host_os']}"
|
@@ -22,6 +22,8 @@ module RhoDevelopment
|
|
22
22
|
cmd = "start \"development webserver\" /d \"#{Configuration::application_root}\" rake dev:webserver:privateStart"
|
23
23
|
when /darwin/i
|
24
24
|
cmd = "osascript -e 'tell app \"Terminal\" \n do script \" cd #{Configuration::application_root}; rake dev:webserver:privateStart\" \n end tell'"
|
25
|
+
when /linux/i
|
26
|
+
cmd = "cd #{Configuration::application_root} && rake dev:webserver:privateStart &"
|
25
27
|
end
|
26
28
|
system cmd
|
27
29
|
until self.alive? do
|
@@ -9,6 +9,9 @@
|
|
9
9
|
#include "logging/RhoLog.h"
|
10
10
|
#include <stdlib.h>
|
11
11
|
|
12
|
+
|
13
|
+
extern "C" void rho_ios_log_console_output(const char* message);
|
14
|
+
|
12
15
|
namespace rho
|
13
16
|
{
|
14
17
|
class CTimerFactory;
|
@@ -53,7 +56,13 @@ namespace rho
|
|
53
56
|
|
54
57
|
virtual void run()
|
55
58
|
{
|
56
|
-
|
59
|
+
|
60
|
+
while ( !RHODESAPP().isApplicationActive() ) {
|
61
|
+
wait(10);
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
m_oResult.set("");
|
57
66
|
}
|
58
67
|
};
|
59
68
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
ext/shared/generated/cpp/
|
2
|
-
ext/shared/generated/cpp/
|
3
|
-
ext/shared/generated/cpp/
|
1
|
+
ext/shared/generated/cpp/EventSource_js_wrap.cpp
|
2
|
+
ext/shared/generated/cpp/EventSource_ruby_wrap.cpp
|
3
|
+
ext/shared/generated/cpp/EventSourceBase.cpp
|
4
4
|
ext/shared/generated/eventsource_api_init.cpp
|
5
5
|
ext/shared/generated/eventsource_js_api.cpp
|
6
6
|
ext/shared/generated/eventsource_ruby_api.c
|
7
7
|
ext/shared/EventSource.cpp
|
8
|
-
ext/shared/eventsource_impl.cpp
|
8
|
+
ext/shared/eventsource_impl.cpp
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
#pragma once
|
3
3
|
#include <vector>
|
4
|
-
#include "common/
|
4
|
+
#include "common/RhoStd.h"
|
5
5
|
#include "common/RhoThread.h"
|
6
6
|
#include "common/RhoTime.h"
|
7
7
|
#include "common/RhoMutexLock.h"
|
@@ -80,4 +80,4 @@ private:
|
|
80
80
|
String m_eventStreamOrigin;
|
81
81
|
};
|
82
82
|
|
83
|
-
}
|
83
|
+
}
|
@@ -56,9 +56,9 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
56
56
|
<PROPERTY_BAG/> <!-- object has properties, produce getProps(), setProps() methods -->
|
57
57
|
</TEMPLATES>
|
58
58
|
<CONSTANTS>
|
59
|
-
|
59
|
+
|
60
60
|
<!-- Camera Types -->
|
61
|
-
|
61
|
+
|
62
62
|
<CONSTANT name="CAMERA_TYPE_BACK" value="back" type="STRING">
|
63
63
|
<DESC>Back camera. This is not supported in WM/CE devices.</DESC>
|
64
64
|
</CONSTANT>
|
@@ -92,7 +92,7 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
92
92
|
<CONSTANT name="COLOR_MODEL_GRAYSCALE" value="grayscale" type="STRING">
|
93
93
|
<DESC>A grayscale image is captured.</DESC>
|
94
94
|
</CONSTANT>
|
95
|
-
|
95
|
+
|
96
96
|
<CONSTANT name="FLASH_ON" value="on" type="STRING">
|
97
97
|
<DESC>Flash will be used.</DESC>
|
98
98
|
</CONSTANT>
|
@@ -139,7 +139,7 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
139
139
|
</DESC>
|
140
140
|
<DESC_EB>This property is device specific. The value for this property can be either 'back' or 'front' in the case of Android devices.In the case of windows it could be either 'imager' or 'color'. WM/CE devices will use 'color'as default and if color camera not available the default value will be 'imager'. Android devices will use 'back'as default and if back camera not available the default value will be 'front'.
|
141
141
|
This Property shall return one among the values mentioned in constant section which starts with CAMERA_TYPE_...</DESC_EB>
|
142
|
-
|
142
|
+
|
143
143
|
</PROPERTY>
|
144
144
|
<PROPERTY name="maxWidth" type="INTEGER" generateAccessors="true" readOnly="true">
|
145
145
|
<PLATFORM>Android, iOS, WP8, WM, CE</PLATFORM>
|
@@ -192,7 +192,7 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
192
192
|
<DESC_EB>The format of the captured image in subsequent calls to takePicture(). On windows devices the format will be always .jpg type.
|
193
193
|
This Property shall accept/return one among the values mentioned in constant section which starts with COMPRESSION_FORMAT_...
|
194
194
|
</DESC_EB>
|
195
|
-
|
195
|
+
|
196
196
|
</PROPERTY>
|
197
197
|
<PROPERTY name="outputFormat" type="STRING" default="image">
|
198
198
|
<VER_INTRODUCED>4.0.0</VER_INTRODUCED>
|
@@ -203,7 +203,7 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
203
203
|
<DESC_EB>Specifies the way to return the captured image to the application.
|
204
204
|
This Property shall accept/return one among the values mentioned in constant section which starts with OUTPUT_FORMAT_...
|
205
205
|
</DESC_EB>
|
206
|
-
|
206
|
+
|
207
207
|
</PROPERTY>
|
208
208
|
<PROPERTY name="colorModel" type="STRING" default="rgb">
|
209
209
|
<VER_INTRODUCED>2.0.0</VER_INTRODUCED>
|
@@ -214,7 +214,7 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
214
214
|
<DESC_EB>Where supported by the hardware this property can be used to select whether to capture a color or a grayscale image.
|
215
215
|
This Property shall accept/return one among the values mentioned in constant section which starts with COLOR_MODEL_...
|
216
216
|
</DESC_EB>
|
217
|
-
|
217
|
+
|
218
218
|
</PROPERTY>
|
219
219
|
<PROPERTY name="enableEditing" type="BOOLEAN" default="true" productException="eb">
|
220
220
|
<VER_INTRODUCED>2.0.0</VER_INTRODUCED>
|
@@ -229,7 +229,7 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
229
229
|
This Property shall accept/return one among the values mentioned in constant section which starts with FLASH_...</DESC>
|
230
230
|
<DESC_EB>Specifies the flash behavior when taking a picture.
|
231
231
|
This Property shall accept/return one among the values mentioned in constant section which starts with FLASH_...</DESC_EB>
|
232
|
-
|
232
|
+
|
233
233
|
</PROPERTY>
|
234
234
|
<PROPERTY name="saveToDeviceGallery" type="BOOLEAN" default="false">
|
235
235
|
<VER_INTRODUCED>2.0.0</VER_INTRODUCED>
|
@@ -266,15 +266,20 @@ The ebapi.js file is necessary for all single API inclusions.
|
|
266
266
|
<PROPERTY name="useSystemViewfinder" type="BOOLEAN" default="false">
|
267
267
|
<VER_INTRODUCED>4.0.0</VER_INTRODUCED>
|
268
268
|
<PLATFORM>Android</PLATFORM>
|
269
|
-
<DESC>Setting the value of this property to "true", shall open the System ViewFinder with its properties. None of the Rho camera properties shall be applicable.</DESC>
|
269
|
+
<DESC>Setting the value of this property to "true", shall open the System ViewFinder with its properties. Applicable to takePicture() and choosePicture() both. None of the Rho camera properties shall be applicable except desiredWidth and desiredHeight (desired size aplly if useRealBitmapResize enabled).</DESC>
|
270
|
+
</PROPERTY>
|
271
|
+
<PROPERTY name="useRealBitmapResize" type="BOOLEAN" default="false">
|
272
|
+
<VER_INTRODUCED>4.0.0</VER_INTRODUCED>
|
273
|
+
<PLATFORM>Android</PLATFORM>
|
274
|
+
<DESC>Setting the value of this property to "true", shall use real resize captured or selected Image and scale image exactly to desired size (with keep aspect ratio). For example 3000x2000 with desired 1500x1500 will be resized to 1500x1000.</DESC>
|
270
275
|
</PROPERTY>
|
271
|
-
|
276
|
+
<PROPERTY name="aimMode" type="STRING">
|
272
277
|
<PLATFORM>WM, CE</PLATFORM>
|
273
278
|
<DESC>Specifies the aim behaviour when taking a picture. Applicable only for imager module.
|
274
279
|
This Property shall accept/return one among the values mentioned in constant section which starts with AIM_...</DESC>
|
275
280
|
<DESC_EB>Specifies the aim behaviour when taking a picture. Applicable only for imager module.
|
276
281
|
This Property shall accept/return one among the values mentioned in constant section which starts with AIM_...</DESC_EB>
|
277
|
-
|
282
|
+
|
278
283
|
</PROPERTY>
|
279
284
|
</PROPERTIES>
|
280
285
|
|
@@ -14,11 +14,11 @@ import com.rhomobile.rhodes.api.IMethodResult;
|
|
14
14
|
|
15
15
|
public class CameraEclair extends CameraObject implements ICameraObject {
|
16
16
|
private static final String TAG = CameraEclair.class.getSimpleName();
|
17
|
-
|
17
|
+
|
18
18
|
private List<Camera.Size> mSupportedPictureSizes;
|
19
19
|
|
20
|
-
CameraEclair(String id) {
|
21
|
-
super(id);
|
20
|
+
CameraEclair(String id) {
|
21
|
+
super(id);
|
22
22
|
|
23
23
|
getPropertiesMap().put("cameraType", "back");
|
24
24
|
getPropertiesMap().put("compressionFormat", "jpg");
|
@@ -99,7 +99,7 @@ public class CameraEclair extends CameraObject implements ICameraObject {
|
|
99
99
|
closeCamera();
|
100
100
|
}
|
101
101
|
});
|
102
|
-
|
102
|
+
|
103
103
|
} else {
|
104
104
|
getCamera().takePicture(null, null, new TakePictureCallback(previewActivity));
|
105
105
|
}
|
@@ -109,7 +109,18 @@ public class CameraEclair extends CameraObject implements ICameraObject {
|
|
109
109
|
protected ISize getDesiredSize() {
|
110
110
|
String strDesiredWidth = getActualPropertyMap().get("desiredWidth");
|
111
111
|
String strDesiredHeight = getActualPropertyMap().get("desiredHeight");
|
112
|
-
|
112
|
+
|
113
|
+
if (Boolean.parseBoolean(getActualPropertyMap().get("useRealBitmapResize"))) {
|
114
|
+
return null;
|
115
|
+
}
|
116
|
+
|
117
|
+
if (Integer.valueOf(strDesiredWidth) <= 0) {
|
118
|
+
strDesiredWidth = null;
|
119
|
+
}
|
120
|
+
if (Integer.valueOf(strDesiredHeight) <= 0) {
|
121
|
+
strDesiredHeight = null;
|
122
|
+
}
|
123
|
+
|
113
124
|
int minDiff = Integer.MAX_VALUE;
|
114
125
|
ISize selectedSize = null;
|
115
126
|
|
@@ -157,7 +168,7 @@ public class CameraEclair extends CameraObject implements ICameraObject {
|
|
157
168
|
supported = (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO)) || (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_MACRO));
|
158
169
|
}
|
159
170
|
return supported;
|
160
|
-
|
171
|
+
|
161
172
|
}
|
162
173
|
|
163
174
|
protected String getFlashMode() {
|
@@ -43,56 +43,56 @@ public class CameraObject extends CameraBase implements ICameraObject {
|
|
43
43
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_hhmmss");
|
44
44
|
void setActualPropertyMap(Map<String, String> props) { mActualPropertyMap = props; }
|
45
45
|
Map<String, String> getActualPropertyMap() { return mActualPropertyMap; }
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
private Camera mCamera;
|
49
49
|
private int mCameraUsers;
|
50
50
|
private Uri fileUri;
|
51
51
|
String mCurrentPhotoPath = null;
|
52
52
|
public static String userFilePath = null;
|
53
53
|
private ContentValues values = null;
|
54
|
-
|
54
|
+
|
55
55
|
int getCameraIndex() {
|
56
56
|
return CameraSingletonObject.getCameraIndex(getId());
|
57
57
|
}
|
58
58
|
@Override
|
59
59
|
public void setProperties(Map<String, String> propertyMap, IMethodResult result) {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
// TODO Auto-generated method stub
|
61
|
+
Map<String, String> temp=getPropertiesMap();
|
62
|
+
temp.putAll(propertyMap);
|
63
|
+
result.set(true);
|
64
64
|
}
|
65
65
|
@Override
|
66
|
-
public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}
|
77
|
-
|
66
|
+
public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
67
|
+
|
68
|
+
//super.getProperties(arrayofNames, result);
|
69
|
+
Map<String, Object> props = new HashMap<String, Object>();
|
70
|
+
for (String name: arrayofNames)
|
71
|
+
{
|
72
|
+
props.put(name, cameraPropGet(name));
|
73
|
+
}
|
74
|
+
result.set(props);
|
75
|
+
|
76
|
+
}
|
77
|
+
|
78
78
|
private String cameraPropGet(String name)
|
79
79
|
{
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
80
|
+
String propValue="";
|
81
|
+
Map<String, String> temp=getPropertiesMap();
|
82
|
+
if(temp.containsKey(name))
|
83
|
+
{
|
84
|
+
|
85
|
+
try{
|
86
|
+
propValue=String.valueOf(temp.get(name));
|
87
|
+
}
|
88
|
+
catch(Exception ex)
|
89
|
+
{
|
90
|
+
|
91
|
+
}
|
92
|
+
}
|
93
|
+
return propValue;
|
94
94
|
}
|
95
|
-
|
95
|
+
|
96
96
|
static class CameraSize implements ICameraObject.ISize {
|
97
97
|
private Camera.Size mSize;
|
98
98
|
CameraSize(Camera.Size size) { mSize = size; }
|
@@ -101,7 +101,7 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
101
101
|
@Override public int D2() { return mSize.width * mSize.width + mSize.height * mSize.height; }
|
102
102
|
@Override public String toString() { return "" + mSize.width + "X" + mSize.height; }
|
103
103
|
}
|
104
|
-
|
104
|
+
|
105
105
|
static class RawSize implements ICameraObject.ISize {
|
106
106
|
private int width;
|
107
107
|
private int height;
|
@@ -119,106 +119,106 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
119
119
|
mPreviewActivity = previewActivity;
|
120
120
|
}
|
121
121
|
@Override
|
122
|
-
public void onPictureTaken(byte[] data, Camera camera) {
|
122
|
+
public void onPictureTaken(byte[] data, Camera camera) {
|
123
123
|
Intent intent = new Intent();
|
124
124
|
OutputStream stream = null;
|
125
125
|
Bitmap bitmap = null;
|
126
126
|
try {
|
127
|
-
|
127
|
+
|
128
128
|
final Map<String, String> propertyMap = getActualPropertyMap();
|
129
129
|
if (propertyMap == null) {
|
130
130
|
throw new RuntimeException("Camera property map is undefined");
|
131
131
|
}
|
132
|
-
|
132
|
+
|
133
133
|
String outputFormat = propertyMap.get("outputFormat");
|
134
|
-
if(propertyMap.get("deprecated") == null || propertyMap.get("deprecated").equalsIgnoreCase("false")){
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
134
|
+
if(propertyMap.get("deprecated") == null || propertyMap.get("deprecated").equalsIgnoreCase("false")){
|
135
|
+
propertyMap.put("deprecated", "false");
|
136
|
+
deprecated_take_pic = false;
|
137
|
+
}
|
138
|
+
else
|
139
|
+
deprecated_take_pic = true;
|
140
140
|
if(propertyMap.containsKey("captureSound")){
|
141
141
|
Runnable music= new Runnable(){
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
142
|
+
public void run() {
|
143
|
+
playMusic(propertyMap.get("captureSound"));
|
144
|
+
}
|
145
|
+
};
|
146
146
|
ExecutorService exec = Executors.newSingleThreadExecutor();
|
147
147
|
exec.submit(music);
|
148
148
|
}
|
149
|
-
|
149
|
+
|
150
150
|
String filePath = null;
|
151
|
-
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_hhmmss");
|
151
|
+
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_hhmmss");
|
152
152
|
if(!propertyMap.containsKey("fileName")){
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
153
|
+
filePath = "/sdcard/DCIM/Camera/IMG_"+ dateFormat.format(new Date(System.currentTimeMillis()));
|
154
|
+
userFilePath = filePath;
|
155
|
+
}
|
156
|
+
else{
|
157
|
+
filePath = propertyMap.get("fileName");
|
158
|
+
userFilePath = filePath;
|
159
|
+
if(filePath.contains("\\")){
|
160
|
+
intent.putExtra("error", "Invalid file path");
|
161
|
+
}
|
162
|
+
}
|
163
163
|
Uri resultUri = null;
|
164
164
|
BitmapFactory.Options options=new BitmapFactory.Options();
|
165
|
-
|
165
|
+
options.inPurgeable = true;
|
166
166
|
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);
|
167
|
-
|
168
|
-
Logger.T(TAG, "outputFormat: " + outputFormat);
|
167
|
+
if (outputFormat.equalsIgnoreCase("dataUri")) {
|
168
|
+
Logger.T(TAG, "outputFormat: " + outputFormat);
|
169
169
|
filePath = getTemporaryPath(filePath)+ ".jpg";
|
170
|
-
if (Boolean.parseBoolean(propertyMap.get("saveToDeviceGallery")))
|
171
|
-
{
|
170
|
+
if (Boolean.parseBoolean(propertyMap.get("saveToDeviceGallery")))
|
171
|
+
{
|
172
172
|
ContentResolver contentResolver = ContextFactory.getContext().getContentResolver();
|
173
173
|
Logger.T(TAG, "Image size: " + bitmap.getWidth() + "X" + bitmap.getHeight());
|
174
174
|
propertyMap.put("DeviceGallery_Key", "DeviceGallery_Value");
|
175
175
|
String strUri = null;
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
resultUri = Uri.parse(strUri);
|
176
|
+
if (!propertyMap.containsKey("fileName")) {
|
177
|
+
strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, "IMG_"+ dateFormat.format(new Date(System.currentTimeMillis())), "Camera");
|
178
|
+
}
|
179
|
+
else{
|
180
|
+
strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, new File(propertyMap.get("fileName")).getName(), "Camera");
|
181
|
+
}
|
182
|
+
if (strUri != null) {
|
183
|
+
resultUri = Uri.parse(strUri);
|
184
184
|
} else {
|
185
185
|
throw new RuntimeException("Failed to save camera image to Gallery");
|
186
|
-
}
|
187
|
-
}
|
186
|
+
}
|
187
|
+
}
|
188
188
|
else
|
189
|
-
{
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
189
|
+
{
|
190
|
+
if(userFilePath.contains("sdcard")){
|
191
|
+
|
192
|
+
Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
|
193
|
+
|
194
|
+
|
195
|
+
if(isSDPresent)
|
196
|
+
{
|
197
|
+
int lastIndex = userFilePath.lastIndexOf("/");
|
198
|
+
|
199
|
+
String subfolderName = userFilePath.replaceAll("/sdcard", "");
|
200
|
+
String folderName = subfolderName.substring(subfolderName.indexOf("/")+1,subfolderName.lastIndexOf("/"));
|
201
|
+
|
202
|
+
String file_name= userFilePath.substring(lastIndex+1, userFilePath.length());
|
203
|
+
|
204
|
+
|
205
|
+
File directory = new File(Environment.getExternalStorageDirectory()+File.separator + folderName);
|
206
|
+
boolean flag = directory.mkdirs();
|
207
|
+
|
208
|
+
stream = new FileOutputStream(directory +File.separator + file_name+".jpg");
|
209
|
+
resultUri = Uri.fromFile(new File(directory +File.separator + file_name+".jpg"));
|
210
|
+
stream.write(data);
|
211
|
+
stream.flush();
|
212
|
+
stream.close();
|
213
|
+
}
|
214
|
+
}else{
|
215
|
+
stream = new FileOutputStream(filePath);
|
216
|
+
resultUri = Uri.fromFile(new File(filePath));
|
217
|
+
stream.write(data);
|
218
|
+
stream.flush();
|
219
|
+
stream.close();
|
220
|
+
}
|
221
|
+
//CameraRhoListener.getInstance().copyImgAsUserChoice(filePath);
|
222
222
|
}
|
223
223
|
StringBuilder dataBuilder = new StringBuilder();
|
224
224
|
dataBuilder.append("data:image/jpeg;base64,");
|
@@ -226,46 +226,46 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
226
226
|
propertyMap.put("captureUri", dataBuilder.toString());
|
227
227
|
propertyMap.put("dataURI", "datauri_value");
|
228
228
|
Logger.T(TAG, dataBuilder.toString());
|
229
|
-
intent.putExtra("IMAGE_WIDTH", bitmap.getWidth());
|
230
|
-
intent.putExtra("IMAGE_HEIGHT", bitmap.getHeight());
|
231
|
-
mPreviewActivity.setResult(Activity.RESULT_OK, intent);
|
229
|
+
intent.putExtra("IMAGE_WIDTH", bitmap.getWidth());
|
230
|
+
intent.putExtra("IMAGE_HEIGHT", bitmap.getHeight());
|
231
|
+
mPreviewActivity.setResult(Activity.RESULT_OK, intent);
|
232
232
|
} else
|
233
233
|
if (outputFormat.equalsIgnoreCase("image")) {
|
234
234
|
filePath = getTemporaryPath(filePath)+ ".jpg";
|
235
|
-
Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath);
|
236
|
-
if (Boolean.parseBoolean(propertyMap.get("saveToDeviceGallery")))
|
237
|
-
{
|
235
|
+
Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath);
|
236
|
+
if (Boolean.parseBoolean(propertyMap.get("saveToDeviceGallery")))
|
237
|
+
{
|
238
238
|
ContentResolver contentResolver = ContextFactory.getContext().getContentResolver();
|
239
239
|
Logger.T(TAG, "Image size: " + bitmap.getWidth() + "X" + bitmap.getHeight());
|
240
240
|
propertyMap.put("DeviceGallery_Key", "DeviceGallery_Value");
|
241
241
|
String strUri = null;
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
resultUri = Uri.parse(strUri);
|
242
|
+
if (!propertyMap.containsKey("fileName"))
|
243
|
+
strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, "IMG_"+ dateFormat.format(new Date(System.currentTimeMillis())), "Camera");
|
244
|
+
else
|
245
|
+
strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, new File(propertyMap.get("fileName")).getName(), "Camera");
|
246
|
+
if (strUri != null) {
|
247
|
+
resultUri = Uri.parse(strUri);
|
248
248
|
} else {
|
249
249
|
throw new RuntimeException("Failed to save camera image to Gallery");
|
250
|
-
}
|
251
|
-
}
|
250
|
+
}
|
251
|
+
}
|
252
252
|
else
|
253
|
-
{
|
254
|
-
stream = new FileOutputStream(filePath);
|
255
|
-
resultUri = Uri.fromFile(new File(filePath));
|
256
|
-
stream.write(data);
|
257
|
-
stream.flush();
|
258
|
-
stream.close();
|
253
|
+
{
|
254
|
+
stream = new FileOutputStream(filePath);
|
255
|
+
resultUri = Uri.fromFile(new File(filePath));
|
256
|
+
stream.write(data);
|
257
|
+
stream.flush();
|
258
|
+
stream.close();
|
259
259
|
}
|
260
|
-
|
260
|
+
|
261
261
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, resultUri);
|
262
|
-
intent.putExtra("IMAGE_WIDTH", bitmap.getWidth());
|
263
|
-
intent.putExtra("IMAGE_HEIGHT", bitmap.getHeight());
|
264
|
-
mPreviewActivity.setResult(Activity.RESULT_OK, intent);
|
265
|
-
}
|
266
|
-
|
262
|
+
intent.putExtra("IMAGE_WIDTH", bitmap.getWidth());
|
263
|
+
intent.putExtra("IMAGE_HEIGHT", bitmap.getHeight());
|
264
|
+
mPreviewActivity.setResult(Activity.RESULT_OK, intent);
|
265
|
+
}
|
266
|
+
|
267
267
|
} catch (Throwable e) {
|
268
|
-
Logger.E(TAG, e);
|
268
|
+
Logger.E(TAG, e);
|
269
269
|
if (stream != null) {
|
270
270
|
try {
|
271
271
|
stream.close();
|
@@ -273,64 +273,64 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
273
273
|
//Do nothing
|
274
274
|
}
|
275
275
|
}
|
276
|
-
intent.putExtra("error", e.getMessage());
|
277
|
-
mPreviewActivity.setResult(Activity.RESULT_CANCELED, intent);
|
276
|
+
intent.putExtra("error", e.getMessage());
|
277
|
+
mPreviewActivity.setResult(Activity.RESULT_CANCELED, intent);
|
278
|
+
}
|
279
|
+
if(bitmap != null){
|
280
|
+
bitmap.recycle();
|
281
|
+
bitmap = null;
|
282
|
+
System.gc();
|
278
283
|
}
|
279
|
-
if(bitmap != null){
|
280
|
-
bitmap.recycle();
|
281
|
-
bitmap = null;
|
282
|
-
System.gc();
|
283
|
-
}
|
284
284
|
mPreviewActivity.finish();
|
285
|
-
}
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
285
|
+
}
|
286
|
+
private void playMusic(String musicPath) {
|
287
|
+
mp = new MediaPlayer();
|
288
|
+
try {
|
289
|
+
mp.setDataSource(RhoFileApi.openFd(musicPath));
|
290
|
+
} catch (IllegalArgumentException e) {
|
291
|
+
// TODO Auto-generated catch block
|
292
|
+
e.printStackTrace();
|
293
|
+
} catch (IllegalStateException e) {
|
294
|
+
// TODO Auto-generated catch block
|
295
|
+
e.printStackTrace();
|
296
|
+
} catch (IOException e) {
|
297
|
+
// TODO Auto-generated catch block
|
298
|
+
e.printStackTrace();
|
299
|
+
}
|
300
|
+
try {
|
301
|
+
mp.prepare();
|
302
|
+
} catch (IllegalStateException e) {
|
303
|
+
// TODO Auto-generated catch block
|
304
|
+
e.printStackTrace();
|
305
|
+
} catch (IOException e) {
|
306
|
+
// TODO Auto-generated catch block
|
307
|
+
e.printStackTrace();
|
308
|
+
}
|
309
|
+
mp.start();
|
310
|
+
try {
|
311
|
+
Thread.sleep(3000);
|
312
|
+
} catch (InterruptedException e) {
|
313
|
+
// TODO Auto-generated catch block
|
314
|
+
e.printStackTrace();
|
315
|
+
}
|
316
|
+
mp.stop();
|
317
|
+
clearMediaPlayerResources();
|
318
|
+
}
|
319
|
+
|
320
|
+
private void clearMediaPlayerResources() {
|
321
|
+
// TODO Auto-generated method stub
|
322
|
+
if(mp != null){
|
323
|
+
mp.release();
|
324
|
+
mp = null;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
|
330
330
|
|
331
331
|
protected Camera getCamera() { return mCamera; }
|
332
332
|
protected void setCamera(Camera camera) { mCamera = camera; }
|
333
|
-
|
333
|
+
|
334
334
|
synchronized protected void openCamera() {
|
335
335
|
if (mCameraUsers == 0) {
|
336
336
|
setCamera(android.hardware.Camera.open());
|
@@ -347,21 +347,26 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
347
347
|
CameraObject(String id) {
|
348
348
|
super(id);
|
349
349
|
|
350
|
-
|
350
|
+
getPropertiesMap().put("ChoosePicture_Key", "");
|
351
351
|
getPropertiesMap().put("cameraType", "back");
|
352
352
|
getPropertiesMap().put("compressionFormat", "jpg");
|
353
353
|
getPropertiesMap().put("outputFormat", "image");
|
354
354
|
getPropertiesMap().put("colorModel", "rgb");
|
355
|
-
|
356
|
-
|
355
|
+
getPropertiesMap().put("useSystemViewfinder", "false");
|
356
|
+
getPropertiesMap().put("useRealBitmapResize", "false");
|
357
|
+
getPropertiesMap().put("saveToDeviceGallery", "false");
|
357
358
|
openCamera();
|
358
359
|
Camera.Parameters params = getCamera().getParameters();
|
359
360
|
closeCamera();
|
360
|
-
|
361
|
+
|
361
362
|
getPropertiesMap().put("maxWidth", String.valueOf(params.getPictureSize().width));
|
362
363
|
getPropertiesMap().put("maxHeight", String.valueOf(params.getPictureSize().height));
|
363
|
-
|
364
|
-
|
364
|
+
|
365
|
+
// default desired size not specified in documentation and XML !!!
|
366
|
+
//getPropertiesMap().put("desiredWidth", "640");
|
367
|
+
//getPropertiesMap().put("desiredHeight", "480");
|
368
|
+
getPropertiesMap().put("desiredWidth", "0");
|
369
|
+
getPropertiesMap().put("desiredHeight", "0");
|
365
370
|
}
|
366
371
|
|
367
372
|
@Override
|
@@ -388,46 +393,47 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
388
393
|
Logger.E(TAG, e);
|
389
394
|
return;
|
390
395
|
}
|
391
|
-
}
|
396
|
+
}
|
392
397
|
}
|
393
398
|
|
394
399
|
@SuppressWarnings("deprecation")
|
395
400
|
@SuppressLint("NewApi")
|
396
|
-
|
401
|
+
@Override
|
397
402
|
public ISize setPreviewSize(int width, int height) {
|
398
|
-
|
399
|
-
Camera.Parameters parameters = camera.getParameters();
|
400
|
-
List<android.hardware.Camera.Size> sizes = camera.getParameters().getSupportedPictureSizes();
|
401
|
-
android.hardware.Camera.Size maxSize=sizes.get(0);
|
402
|
-
if(getActualPropertyMap().containsKey("desiredWidth") || getActualPropertyMap().containsKey("desiredHeight"))
|
403
|
-
|
404
|
-
int
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
403
|
+
Camera camera = getCamera();
|
404
|
+
Camera.Parameters parameters = camera.getParameters();
|
405
|
+
List<android.hardware.Camera.Size> sizes = camera.getParameters().getSupportedPictureSizes();
|
406
|
+
android.hardware.Camera.Size maxSize=sizes.get(0);
|
407
|
+
if((getActualPropertyMap().containsKey("desiredWidth") || getActualPropertyMap().containsKey("desiredHeight")) &&
|
408
|
+
(!Boolean.parseBoolean(getActualPropertyMap().get("useRealBitmapResize")))){
|
409
|
+
int desired_width = Integer.parseInt(getActualPropertyMap().get("desiredWidth"));
|
410
|
+
int desired_height = Integer.parseInt(getActualPropertyMap().get("desiredHeight"));
|
411
|
+
if(desired_width > 0 && desired_width <= maxSize.width && desired_height > 0 && desired_height <= maxSize.height){
|
412
|
+
Camera.Size previewSize = getOptimalPreviewSize(parameters.getSupportedPictureSizes(), desired_width, desired_height);
|
413
|
+
Logger.T(TAG, "Selected size: " + previewSize.width + "x" + previewSize.height);
|
414
|
+
parameters.setPreviewSize(previewSize.width, previewSize.height);
|
415
|
+
}
|
416
|
+
else if(desired_width > maxSize.width || desired_height > maxSize.height){
|
417
|
+
parameters.setPreviewSize(maxSize.width , maxSize.height);
|
418
|
+
}
|
419
|
+
else{
|
420
|
+
parameters.setPreviewSize(320, 240);
|
421
|
+
}
|
416
422
|
}
|
417
423
|
else{
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
424
|
+
Camera.Size previewSize = getOptimalPreviewSize(parameters.getSupportedPictureSizes(), width, height);
|
425
|
+
Logger.T(TAG, "Selected size: " + previewSize.width + "x" + previewSize.height);
|
426
|
+
parameters.setPreviewSize(previewSize.width, previewSize.height);
|
427
|
+
}
|
422
428
|
camera.stopPreview();
|
423
429
|
try{
|
424
|
-
|
430
|
+
camera.setParameters(parameters);
|
425
431
|
}
|
426
|
-
catch(RuntimeException e){
|
427
|
-
|
432
|
+
catch(RuntimeException e){
|
433
|
+
e.printStackTrace();
|
428
434
|
}
|
429
435
|
camera.startPreview();
|
430
|
-
|
436
|
+
|
431
437
|
return new CameraSize(camera.getParameters().getPreviewSize());
|
432
438
|
}
|
433
439
|
|
@@ -448,9 +454,9 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
448
454
|
|
449
455
|
double scale = (double) size.width / w;
|
450
456
|
double ratio = (double) size.width / size.height;
|
451
|
-
|
457
|
+
|
452
458
|
Logger.T(TAG, "Target ratio: " + targetRatio + ", ratio: " + ratio + ", scale: " + scale);
|
453
|
-
|
459
|
+
|
454
460
|
if (size.width > w || size.height > h) continue;
|
455
461
|
if (Math.abs(1 - scale) > SCALE_TOLERANCE) continue;
|
456
462
|
if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
|
@@ -513,46 +519,50 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
513
519
|
|
514
520
|
@Override
|
515
521
|
public void takePicture(Map<String, String> propertyMap, IMethodResult result) {
|
522
|
+
|
523
|
+
CameraSingletonObject.deprecated_choose_pic = false;
|
524
|
+
deprecated_take_pic = false;
|
525
|
+
|
516
526
|
Logger.T(TAG, "takePicture");
|
517
527
|
try {
|
518
528
|
Map<String, String> actualPropertyMap = new HashMap<String, String>();
|
519
529
|
actualPropertyMap.putAll(getPropertiesMap());
|
520
530
|
actualPropertyMap.putAll(propertyMap);
|
521
531
|
setActualPropertyMap(actualPropertyMap);
|
522
|
-
|
532
|
+
|
523
533
|
String outputFormat = actualPropertyMap.get("outputFormat");
|
524
534
|
String filePath = null;
|
525
535
|
if(!actualPropertyMap.containsKey("fileName")){
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
536
|
+
filePath = "/sdcard/DCIM/Camera/IMG_"+ dateFormat.format(new Date(System.currentTimeMillis())) + ".jpg";
|
537
|
+
}
|
538
|
+
else{
|
539
|
+
filePath = actualPropertyMap.get("fileName");
|
540
|
+
}
|
531
541
|
if (outputFormat.equalsIgnoreCase("image")) {
|
532
|
-
|
533
|
-
Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath);
|
542
|
+
filePath = actualPropertyMap.get("fileName") + ".jpg";
|
543
|
+
Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath);
|
534
544
|
} else
|
535
545
|
if (outputFormat.equalsIgnoreCase("dataUri")) {
|
536
|
-
Logger.T(TAG, "outputFormat: " + outputFormat);
|
546
|
+
Logger.T(TAG, "outputFormat: " + outputFormat);
|
537
547
|
} else {
|
538
548
|
throw new RuntimeException("Unknown 'outputFormat' value: " + outputFormat);
|
539
549
|
}
|
540
|
-
|
550
|
+
|
541
551
|
Intent intent = null;
|
542
552
|
if (Boolean.parseBoolean(actualPropertyMap.get("useSystemViewfinder"))) {
|
543
553
|
if (outputFormat.equalsIgnoreCase("image")) {
|
544
554
|
values = new ContentValues();
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
555
|
+
fileUri = RhodesActivity.getContext().getContentResolver().insert(
|
556
|
+
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
557
|
+
intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
558
|
+
actualPropertyMap.put("captureUri", fileUri.toString());
|
559
|
+
propertyMap.put("dataURI", "");
|
560
|
+
// intent is null with MediaStore.EXTRA_OUTPUT so adding fileuri to map and get it with same key
|
561
|
+
// if instead of MediaStore.EXTRA_OUTPUT any other key is used then the bitmap is null though the file is getting created
|
562
|
+
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
|
553
563
|
} else
|
554
564
|
if (outputFormat.equalsIgnoreCase("dataUri")) {
|
555
|
-
|
565
|
+
|
556
566
|
}
|
557
567
|
} else {
|
558
568
|
intent = new Intent(ContextFactory.getUiContext(), CameraActivity.class);
|
@@ -560,7 +570,7 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
560
570
|
}
|
561
571
|
((CameraFactory)CameraFactorySingleton.getInstance()).getRhoListener().setMethodResult(result);
|
562
572
|
((CameraFactory)CameraFactorySingleton.getInstance()).getRhoListener().setActualPropertyMap(actualPropertyMap);
|
563
|
-
|
573
|
+
|
564
574
|
RhodesActivity.safeGetInstance().startActivityForResult(intent, RhoExtManager.getInstance().getActivityResultNextRequestCode(CameraRhoListener.getInstance()));
|
565
575
|
} catch (RuntimeException e) {
|
566
576
|
Logger.E(TAG, e);
|
@@ -583,13 +593,13 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
583
593
|
return null;
|
584
594
|
}
|
585
595
|
}
|
586
|
-
|
596
|
+
|
587
597
|
@Override
|
588
598
|
public void getSupportedSizeList(IMethodResult result) {
|
589
599
|
}
|
590
600
|
|
591
601
|
@SuppressLint("NewApi")
|
592
|
-
|
602
|
+
@Override
|
593
603
|
public void doTakePicture(Activity previewActivity, int rotation) {
|
594
604
|
Logger.T(TAG, "doTakePicture: rotation: " + rotation);
|
595
605
|
openCamera();
|
@@ -599,64 +609,64 @@ public void getProperties(List<String> arrayofNames, IMethodResult result) {
|
|
599
609
|
getCamera().takePicture(null, null, new TakePictureCallback(previewActivity));
|
600
610
|
closeCamera();
|
601
611
|
}
|
602
|
-
|
612
|
+
|
603
613
|
public void finalize() {
|
604
614
|
if (getCamera() != null) {
|
605
615
|
getCamera().release();
|
606
616
|
}
|
607
617
|
}
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
618
|
+
@Override
|
619
|
+
public void showPreview(Map<String, String> propertyMap,
|
620
|
+
IMethodResult result) {
|
621
|
+
// TODO Auto-generated method stub
|
622
|
+
|
623
|
+
}
|
624
|
+
@Override
|
625
|
+
public void hidePreview(IMethodResult result) {
|
626
|
+
// TODO Auto-generated method stub
|
627
|
+
|
628
|
+
}
|
629
|
+
@Override
|
630
|
+
public void capture(IMethodResult result) {
|
631
|
+
// TODO Auto-generated method stub
|
632
|
+
|
633
|
+
}
|
634
|
+
|
635
|
+
@Override
|
636
|
+
public void setDisplayOrientation(int rotate) {
|
637
|
+
Camera camera = getCamera();
|
638
|
+
camera.setDisplayOrientation(rotate);
|
639
|
+
}
|
640
|
+
|
641
|
+
|
642
|
+
/**
|
643
|
+
* Checks the device if it has
|
644
|
+
* auto focus feature and sets auto focus
|
645
|
+
* @param Preview Activity
|
646
|
+
*
|
647
|
+
*/
|
648
|
+
|
649
|
+
@Override
|
650
|
+
public void setFocus(final Activity preview) {
|
651
|
+
openCamera();
|
652
|
+
if (hasAutoFocus()) {
|
653
|
+
getCamera().autoFocus(new Camera.AutoFocusCallback() {
|
654
|
+
public void onAutoFocus(boolean success, Camera camera) {
|
655
|
+
}
|
656
|
+
});
|
657
|
+
|
658
|
+
}
|
659
|
+
closeCamera();
|
660
|
+
}
|
661
|
+
|
662
|
+
private boolean hasAutoFocus() {
|
653
663
|
String focusMode = getCamera().getParameters().getFocusMode();
|
654
664
|
boolean supported = false;
|
655
665
|
if (focusMode != null) {
|
656
666
|
supported = (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO)) || (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_MACRO));
|
657
667
|
}
|
658
668
|
return supported;
|
659
|
-
|
669
|
+
|
660
670
|
}
|
661
|
-
|
671
|
+
|
662
672
|
}
|