rhodes 3.3.3.beta.1 → 3.3.3.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Manifest.txt +23 -9
- data/Rakefile +13 -2
- data/doc/build.txt +18 -11
- data/doc/device-caps.txt +4 -68
- data/doc/rhom.txt +33 -0
- data/doc/test-log-debug.txt +18 -42
- data/lib/framework/rho/render.rb +1 -1
- data/lib/framework/rho/rho.rb +31 -1
- data/lib/framework/rho/rhocontroller.rb +2 -2
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhoframework.rb +4 -0
- data/lib/framework/rholang/localization_simplified.rb +1 -1
- data/lib/framework/rhom/rhom_object_factory.rb +22 -1
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +25 -9
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_extmanager_RhoExtManagerImpl.h +21 -0
- data/platform/android/Rhodes/jni/src/extmanager.cpp +36 -0
- data/platform/android/Rhodes/jni/src/nativeview.cpp +1 -1
- data/platform/android/Rhodes/jni/src/rhodesapp.cpp +14 -5
- data/platform/android/Rhodes/jni/src/rhodessystem.cpp +5 -0
- data/platform/android/Rhodes/jni/src/signature.cpp +29 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +3 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +4 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +42 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +61 -10
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtData.java +6 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java +39 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java +18 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtDataImpl.java +18 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerImpl.java +142 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerSingleton.java +15 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +6 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +25 -13
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +15 -9
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +15 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +3 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/ImageCapture.java +14 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/Signature.java +218 -51
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureProperties.java +94 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +122 -37
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +6 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/{WebView.java → IRhoWebView.java} +2 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java +4 -0
- data/platform/android/build/RhodesSRC_build.files +8 -1
- data/platform/android/build/android.rake +5 -1
- data/platform/android/build/librhodes_build.files +1 -0
- data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +22 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +15 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +4 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyRuntime.java +4 -2
- data/platform/bb/build/rhodes_build.files +2 -0
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +1 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/PNGEncoder.java +613 -0
- data/platform/bb/rhodes/src/com/rho/rubyext/SignatureCapture.java +314 -0
- data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +1 -1
- data/platform/iphone/Classes/AppManager/AppManager.m +11 -0
- data/platform/iphone/Classes/Rhodes.m +1 -1
- data/platform/iphone/Classes/Signature/SignatureDelegate.h +5 -1
- data/platform/iphone/Classes/Signature/SignatureDelegate.m +186 -5
- data/platform/iphone/Classes/Signature/SignatureView.h +12 -0
- data/platform/iphone/Classes/Signature/SignatureView.m +11 -3
- data/platform/iphone/Classes/SimpleMainView.m +4 -0
- data/platform/iphone/Classes/rho/net/NetRequestImpl.m +98 -3
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/rbuild/iphone.rake +18 -5
- data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +1 -1
- data/platform/shared/common/ExtManager.h +64 -9
- data/platform/shared/common/RhoSimConf.h +1 -0
- data/platform/shared/common/RhodesApp.cpp +77 -28
- data/platform/shared/common/RhodesApp.h +9 -4
- data/platform/shared/common/RhodesAppBase.cpp +4 -3
- data/platform/shared/common/RhodesAppBase.h +5 -3
- data/platform/shared/net/HttpServer.cpp +4 -4
- data/platform/shared/net/HttpServer.h +2 -2
- data/platform/shared/qt/rhodes/impl/MainWindowImpl.cpp +1 -1
- data/platform/shared/qt/rhodes/main.cpp +1 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +12 -2
- data/platform/shared/ruby/ext/rho/rhosupport.c +11 -1
- data/platform/shared/ruby/thread_win32.c +2 -1
- data/platform/shared/rubyext/System.cpp +6 -0
- data/platform/shared/sync/SyncSource.cpp +15 -0
- data/platform/wm/RhoLib/RhoLib.vcproj +0 -4
- data/platform/wm/build/build_inf.js +34 -4
- data/platform/wm/build/wm.rake +75 -25
- data/platform/wm/rhodes/AppManager.cpp +14 -3
- data/platform/wm/rhodes/IBrowserEngine.h +7 -0
- data/platform/wm/rhodes/IEBrowserEngine.cpp +43 -0
- data/platform/wm/rhodes/IEBrowserEngine.h +7 -0
- data/platform/wm/rhodes/LogOptionsDlg.cpp +1 -1
- data/platform/wm/rhodes/MainWindow.cpp +92 -7
- data/platform/wm/rhodes/MainWindow.h +28 -1
- data/platform/wm/rhodes/MapView/MapViewManager.cpp +4 -4
- data/platform/wm/rhodes/Rhodes.cpp +149 -10
- data/platform/wm/rhodes/resource.h +5 -1
- data/platform/wm/rhodes/rho/common/ExtManager.cpp +307 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +1 -1
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.cpp +1 -1
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +14 -2
- data/platform/wm/rhodes/rho/rubyext/WebView.cpp +6 -3
- data/platform/wm/rhodes/rhodes.vcproj +5 -1
- data/platform/wm/rhodes/simulator/MainWindowQt.cpp +22 -1
- data/platform/wm/rhodes/simulator/MainWindowQt.h +4 -0
- data/platform/wp7/RhoRubyExtGen/RhoWebView.cs +1 -1
- data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +1 -1
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +33 -38
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +134 -29
- data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +12 -2
- data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +17 -1
- data/platform/wp7/RhoRubyLib/views/RhoTabHeader.xaml +3 -3
- data/platform/wp7/RhoRubyLib/views/RhoView.xaml.cs +48 -8
- data/rakefile.rb +13 -2
- data/res/build-tools/iphonesim/build/Release/iphonesim_43 +0 -0
- data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +158 -0
- data/res/generators/rhogen.rb +33 -28
- data/res/generators/templates/application/app/layout.erb +6 -5
- data/res/generators/templates/application/public/css/android.css +21 -315
- data/res/generators/templates/application/public/css/iphone.css +1 -499
- data/res/generators/templates/application/public/css/jqmobile-patch.css +18 -5
- data/res/generators/templates/application/public/css/windows_phone7.css +378 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-18-black.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-36-black.png +0 -0
- data/res/generators/templates/application/public/jqmobile/{jquery.mobile-1.0.css → jquery.mobile-1.0.1.css} +33 -11
- data/res/generators/templates/application/public/jqmobile/{jquery.mobile-1.0.js → jquery.mobile-1.0.1.js} +249 -125
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.1.min.css +2 -0
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.1.min.js +177 -0
- data/res/generators/templates/application/public/jqmobile/{jquery.mobile.structure-1.0.css → jquery.mobile.structure-1.0.1.css} +33 -11
- data/res/generators/templates/application/public/jqmobile/jquery.mobile.structure-1.0.1.min.css +2 -0
- data/res/generators/templates/application/public/jquery/jquery.json-2.3.js +193 -0
- data/res/generators/templates/application/public/jquery/jquery.json-2.3.min.js +23 -0
- data/res/generators/templates/application/public/js/jquery-wp7-patch.js +68 -20
- data/spec/phone_spec/app/Case/case.rb +22 -0
- data/spec/phone_spec/app/Customer/customer.rb +16 -0
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +108 -11
- data/spec/phone_spec/app/spec/syncengine_spec.rb +43 -1
- data/spec/phone_spec/build.yml +2 -1
- data/version +1 -1
- metadata +27 -13
- data/platform/shared/common/ExtManager.cpp +0 -103
- data/res/generators/templates/application/public/jqmobile/jquery-mobile-iphone.css +0 -9
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.min.css +0 -2
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.min.js +0 -172
- data/res/generators/templates/application/public/jqmobile/jquery.mobile.structure-1.0.min.css +0 -2
@@ -0,0 +1,314 @@
|
|
1
|
+
package com.rho.rubyext;
|
2
|
+
|
3
|
+
import com.rho.RhoEmptyLogger;
|
4
|
+
import com.rho.RhoLogger;
|
5
|
+
import com.rho.RhodesApp;
|
6
|
+
import com.rho.db.DBAdapter;
|
7
|
+
import com.rho.file.RhoFile;
|
8
|
+
import com.xruby.runtime.builtin.RubyHash;
|
9
|
+
import com.xruby.runtime.lang.RubyBlock;
|
10
|
+
import com.xruby.runtime.lang.RubyID;
|
11
|
+
import com.xruby.runtime.lang.RubyModule;
|
12
|
+
import com.xruby.runtime.lang.RubyConstant;
|
13
|
+
import com.xruby.runtime.lang.RubyException;
|
14
|
+
import com.xruby.runtime.lang.RubyTwoArgMethod;
|
15
|
+
import com.xruby.runtime.lang.RubyValue;
|
16
|
+
|
17
|
+
import net.rim.device.api.i18n.SimpleDateFormat;
|
18
|
+
import net.rim.device.api.system.Bitmap;
|
19
|
+
import net.rim.device.api.system.Display;
|
20
|
+
import net.rim.device.api.system.EncodedImage;
|
21
|
+
import net.rim.device.api.ui.Graphics;
|
22
|
+
import net.rim.device.api.ui.MenuItem;
|
23
|
+
import net.rim.device.api.ui.TouchEvent;
|
24
|
+
import net.rim.device.api.ui.TouchGesture;
|
25
|
+
import net.rim.device.api.ui.Ui;
|
26
|
+
import net.rim.device.api.ui.UiApplication;
|
27
|
+
import net.rim.device.api.ui.component.BitmapField;
|
28
|
+
import net.rim.device.api.ui.component.Dialog;
|
29
|
+
import net.rim.device.api.ui.component.Menu;
|
30
|
+
import net.rim.device.api.ui.container.MainScreen;
|
31
|
+
|
32
|
+
import java.io.ByteArrayOutputStream;
|
33
|
+
import java.io.DataOutputStream;
|
34
|
+
import java.io.IOException;
|
35
|
+
import java.io.InputStream;
|
36
|
+
import java.util.Date;
|
37
|
+
|
38
|
+
import javax.microedition.io.Connector;
|
39
|
+
import javax.microedition.io.file.FileConnection;
|
40
|
+
|
41
|
+
import rhomobile.Utilities;
|
42
|
+
|
43
|
+
public class SignatureCapture extends MainScreen
|
44
|
+
{
|
45
|
+
private static final RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
|
46
|
+
new RhoLogger("Alert");
|
47
|
+
|
48
|
+
private static RhodesApp RHODESAPP(){ return RhodesApp.getInstance(); }
|
49
|
+
|
50
|
+
public static final RubyID filePathID = RubyID.intern("filePath");
|
51
|
+
|
52
|
+
private RubyHash m_hashParams;
|
53
|
+
private String m_strFilePath = "";
|
54
|
+
private boolean m_bIsCanceled = false;
|
55
|
+
|
56
|
+
//Current Bitmap instance
|
57
|
+
private Bitmap _bitmap;
|
58
|
+
|
59
|
+
//A custom BitmapField for drawing a signature
|
60
|
+
private SignatureField _signatureField;
|
61
|
+
|
62
|
+
boolean isCanceled(){ return m_bIsCanceled; }
|
63
|
+
/**
|
64
|
+
* Constructor
|
65
|
+
*/
|
66
|
+
public SignatureCapture( RubyHash hashParams )
|
67
|
+
{
|
68
|
+
super();
|
69
|
+
m_hashParams = hashParams;
|
70
|
+
|
71
|
+
setTitle("Please Sign Your Name");
|
72
|
+
Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_NORTH);
|
73
|
+
try {
|
74
|
+
|
75
|
+
//Get the local resource background image to initialize the signature field
|
76
|
+
Class cl = Class.forName("com.rho.rubyext.SignatureCapture");
|
77
|
+
InputStream is = cl.getResourceAsStream("/background.png");
|
78
|
+
ByteArrayOutputStream bas = new ByteArrayOutputStream();
|
79
|
+
byte[] buffer = new byte[1024];
|
80
|
+
while (is.read(buffer) != -1) {
|
81
|
+
bas.write(buffer, 0, buffer.length);
|
82
|
+
}
|
83
|
+
EncodedImage image = EncodedImage.createEncodedImage(bas.toByteArray(), 0, bas.size());
|
84
|
+
//Set the background as the current bitmap
|
85
|
+
_bitmap = image.getBitmap();
|
86
|
+
} catch (IOException e) {
|
87
|
+
LOG.ERROR("Save signature failed.", e);
|
88
|
+
} catch (ClassNotFoundException e) {
|
89
|
+
LOG.ERROR("Save signature failed.", e);
|
90
|
+
}
|
91
|
+
//Create a new SignatureField with current _bitmap instance
|
92
|
+
_signatureField = new SignatureField(_bitmap);
|
93
|
+
add(_signatureField);
|
94
|
+
}
|
95
|
+
|
96
|
+
private static String getHashStringValue(RubyHash hash, RubyID id)
|
97
|
+
{
|
98
|
+
if ( hash == null )
|
99
|
+
return "";
|
100
|
+
|
101
|
+
RubyValue val = hash.get(id.toSymbol());
|
102
|
+
|
103
|
+
return val != null && val != RubyConstant.QNIL ? val.toStr() : "";
|
104
|
+
}
|
105
|
+
|
106
|
+
private String getFilePath()throws Exception
|
107
|
+
{
|
108
|
+
if ( m_strFilePath.length() > 0 )
|
109
|
+
return m_strFilePath;
|
110
|
+
|
111
|
+
m_strFilePath = getHashStringValue(m_hashParams, filePathID );
|
112
|
+
if ( m_strFilePath.length() > 0 )
|
113
|
+
return m_strFilePath;
|
114
|
+
|
115
|
+
m_strFilePath = DBAdapter.makeBlobFolderName();
|
116
|
+
SimpleDateFormat format =
|
117
|
+
new SimpleDateFormat("MMM_dd_yyyy_HH_mm_ss_zzz");
|
118
|
+
|
119
|
+
String name = format.format(new Date());
|
120
|
+
name = Utilities.replaceAll(name,"/","_");
|
121
|
+
m_strFilePath += "image_" + name + ".png";
|
122
|
+
|
123
|
+
return m_strFilePath;
|
124
|
+
}
|
125
|
+
|
126
|
+
/**
|
127
|
+
* MenuItem to Capture the signature and save it to an image file
|
128
|
+
*/
|
129
|
+
private MenuItem _captureItem = new MenuItem("Capture", 200000, 10) {
|
130
|
+
public void run() {
|
131
|
+
//Create a new instance of the encoder to encode the bitmap into an image
|
132
|
+
PNGEncoder encoder = new PNGEncoder(_bitmap, true);
|
133
|
+
try {
|
134
|
+
byte[] imageBytes = encoder.encode(true);
|
135
|
+
EncodedImage image = EncodedImage.createEncodedImage(imageBytes, 0, imageBytes.length);
|
136
|
+
try {
|
137
|
+
String fileName = getFilePath();
|
138
|
+
|
139
|
+
FileConnection fconn = (FileConnection) Connector.open(fileName);
|
140
|
+
if (!fconn.exists())
|
141
|
+
fconn.create();
|
142
|
+
DataOutputStream ds = fconn.openDataOutputStream();
|
143
|
+
ds.write(image.getData());
|
144
|
+
ds.close();
|
145
|
+
fconn.close();
|
146
|
+
} catch (Exception e) {
|
147
|
+
LOG.ERROR("Save signature failed.", e);
|
148
|
+
}
|
149
|
+
} catch (IOException e) {
|
150
|
+
LOG.ERROR("Save signature failed.", e);
|
151
|
+
}
|
152
|
+
|
153
|
+
onClose();
|
154
|
+
}
|
155
|
+
};
|
156
|
+
|
157
|
+
/**
|
158
|
+
* MenuItem to clear the signature field
|
159
|
+
*/
|
160
|
+
private MenuItem _clearItem = new MenuItem("Clear", 200000, 10) {
|
161
|
+
public void run() {
|
162
|
+
_signatureField.clear();
|
163
|
+
}
|
164
|
+
|
165
|
+
};
|
166
|
+
|
167
|
+
/**
|
168
|
+
* MenuItem to close the application
|
169
|
+
*/
|
170
|
+
private MenuItem _closeItem = new MenuItem("Close", 200000, 10) {
|
171
|
+
public void run() {
|
172
|
+
m_bIsCanceled = true;
|
173
|
+
onClose();
|
174
|
+
}
|
175
|
+
};
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Create the menu
|
179
|
+
*/
|
180
|
+
protected void makeMenu(Menu menu, int instance) {
|
181
|
+
menu.add(_captureItem);
|
182
|
+
menu.add(_clearItem);
|
183
|
+
menu.add(_closeItem);
|
184
|
+
}
|
185
|
+
|
186
|
+
final class SignatureField extends BitmapField {
|
187
|
+
|
188
|
+
private Graphics _graphics;
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Constructor
|
192
|
+
*/
|
193
|
+
public SignatureField(Bitmap b) {
|
194
|
+
this.setBitmap(b);
|
195
|
+
_graphics = new Graphics(b);
|
196
|
+
}
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Handle touch events
|
200
|
+
*/
|
201
|
+
protected boolean touchEvent(TouchEvent message) {
|
202
|
+
try {
|
203
|
+
if (message.getEvent() == TouchEvent.MOVE) { //Move event fired
|
204
|
+
//Get the move points
|
205
|
+
int pointsSize = message.getMovePointsSize();
|
206
|
+
|
207
|
+
if (pointsSize > 1)
|
208
|
+
{
|
209
|
+
int[] xPoints = new int[pointsSize];
|
210
|
+
int[] yPoints = new int[pointsSize];
|
211
|
+
message.getMovePoints(1, xPoints, yPoints, null);
|
212
|
+
drawPath(xPoints,yPoints);
|
213
|
+
}
|
214
|
+
} else if (message.getEvent() == TouchEvent.GESTURE) { //Gesture event fired
|
215
|
+
TouchGesture gesture = message.getGesture();
|
216
|
+
if (gesture.getEvent() == TouchGesture.TAP) { //Tap Gesture
|
217
|
+
//Since we have a tap only draw a single point
|
218
|
+
int xPoint = message.getX(1);
|
219
|
+
int yPoint = message.getY(1);
|
220
|
+
drawPoint(xPoint,yPoint);
|
221
|
+
} else if (gesture.getEvent() == TouchGesture.SWIPE) { //Swipe Gesture
|
222
|
+
//Get the move points
|
223
|
+
int pointsSize = message.getMovePointsSize();
|
224
|
+
int[] xPoints = new int[pointsSize];
|
225
|
+
int[] yPoints = new int[pointsSize];
|
226
|
+
message.getMovePoints(1, xPoints, yPoints, null);
|
227
|
+
drawPath(xPoints,yPoints);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
} catch (Throwable e) {
|
231
|
+
throw new RuntimeException(e.toString());
|
232
|
+
}
|
233
|
+
return true;
|
234
|
+
}
|
235
|
+
|
236
|
+
/**
|
237
|
+
* Draw a path through the set of points
|
238
|
+
*/
|
239
|
+
private void drawPath(int[] xPoints, int[] yPoints) {
|
240
|
+
int oldColor = _graphics.getColor();
|
241
|
+
//Draw a path through the points
|
242
|
+
_graphics.setColor(0x000000);
|
243
|
+
_graphics.drawPathOutline(xPoints,yPoints, null, null, false);
|
244
|
+
_graphics.setColor(oldColor);
|
245
|
+
//Repaint
|
246
|
+
invalidate();
|
247
|
+
}
|
248
|
+
|
249
|
+
/**
|
250
|
+
* Draw a point
|
251
|
+
*/
|
252
|
+
private void drawPoint(int xPoint, int yPoint) {
|
253
|
+
int oldColor = _graphics.getColor();
|
254
|
+
_graphics.setColor(0x000000);
|
255
|
+
_graphics.drawPoint(xPoint, yPoint);
|
256
|
+
_graphics.setColor(oldColor);
|
257
|
+
//Repaint
|
258
|
+
invalidate();
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Clear the field
|
263
|
+
*/
|
264
|
+
private void clear() {
|
265
|
+
int oldColor = _graphics.getColor();
|
266
|
+
_graphics.setColor(0xFFFFFF);
|
267
|
+
_graphics.fillRect(0, 0, _bitmap.getWidth(), _bitmap.getHeight());
|
268
|
+
_graphics.setColor(oldColor);
|
269
|
+
invalidate();
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
public static void initMethods(RubyModule klass) {
|
274
|
+
klass.getSingletonClass().defineMethod("take", new RubyTwoArgMethod()
|
275
|
+
{
|
276
|
+
protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block)
|
277
|
+
{
|
278
|
+
try {
|
279
|
+
final String strCallback = arg0.toStr();
|
280
|
+
final RubyHash hashParams = (RubyHash)arg1;
|
281
|
+
|
282
|
+
LOG.INFO("take: " + strCallback);
|
283
|
+
|
284
|
+
|
285
|
+
UiApplication.getUiApplication().invokeLater( new Runnable()
|
286
|
+
{
|
287
|
+
public void run()
|
288
|
+
{
|
289
|
+
try
|
290
|
+
{
|
291
|
+
SignatureCapture oSignature = new SignatureCapture(hashParams);
|
292
|
+
UiApplication.getUiApplication().pushModalScreen(oSignature);
|
293
|
+
|
294
|
+
com.rho.FilePath oFilePath = new com.rho.FilePath( oSignature.getFilePath() );
|
295
|
+
String strStatus = oSignature.isCanceled() ? "" : ( !RhoFile.isFileExist(oSignature.getFilePath()) ? "Error" : "");
|
296
|
+
|
297
|
+
RHODESAPP().callSignatureCallback( strCallback, oFilePath.getBaseName(), strStatus, oSignature.isCanceled() );
|
298
|
+
}catch(Exception exc)
|
299
|
+
{
|
300
|
+
LOG.ERROR("Display signature screen failed.", exc);
|
301
|
+
}
|
302
|
+
}
|
303
|
+
});
|
304
|
+
|
305
|
+
return RubyConstant.QNIL;
|
306
|
+
} catch(Exception e) {
|
307
|
+
LOG.ERROR("take failed", e);
|
308
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
309
|
+
}
|
310
|
+
|
311
|
+
}
|
312
|
+
});
|
313
|
+
}
|
314
|
+
}
|
@@ -45,7 +45,7 @@ public class WebView
|
|
45
45
|
RhodesApplication.getInstance().navigateUrl(url);
|
46
46
|
}
|
47
47
|
|
48
|
-
public static void initMethods(
|
48
|
+
public static void initMethods(RubyModule klass) {
|
49
49
|
klass.getSingletonClass().defineMethod("refresh", new RubyNoArgMethod() {
|
50
50
|
protected RubyValue run(RubyValue receiver, RubyBlock block)
|
51
51
|
{
|
@@ -53,6 +53,8 @@
|
|
53
53
|
static bool UnzipApplication(const char* appRoot, const void* zipbuf, unsigned int ziplen);
|
54
54
|
//const char* RhoGetRootPath();
|
55
55
|
|
56
|
+
VALUE rho_sys_has_wifi_network();
|
57
|
+
VALUE rho_sys_has_cell_network();
|
56
58
|
|
57
59
|
|
58
60
|
BOOL isPathIsSymLink(NSFileManager *fileManager, NSString* path) {
|
@@ -493,6 +495,11 @@ const char* rho_native_rhopath()
|
|
493
495
|
return root;
|
494
496
|
}
|
495
497
|
|
498
|
+
const char* rho_native_reruntimepath()
|
499
|
+
{
|
500
|
+
return rho_native_rhopath();
|
501
|
+
}
|
502
|
+
|
496
503
|
const char* rho_native_rhouserpath()
|
497
504
|
{
|
498
505
|
BOOL user_path_in_root = NO;
|
@@ -717,6 +724,10 @@ int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
|
|
717
724
|
}
|
718
725
|
else if (strcasecmp("has_network", szPropName) == 0)
|
719
726
|
{*resValue = rho_sys_has_network(); return 1; }
|
727
|
+
else if (strcasecmp("has_wifi_network", szPropName) == 0)
|
728
|
+
{*resValue = rho_sys_has_wifi_network(); return 1; }
|
729
|
+
else if (strcasecmp("has_cell_network", szPropName) == 0)
|
730
|
+
{*resValue = rho_sys_has_cell_network(); return 1; }
|
720
731
|
else if (strcasecmp("has_camera", szPropName) == 0) {
|
721
732
|
int has_camera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
|
722
733
|
*resValue = rho_ruby_create_boolean(has_camera);
|
@@ -636,7 +636,7 @@ static Rhodes *instance = NULL;
|
|
636
636
|
NSLog(@"Init delegates");
|
637
637
|
dateTimePickerDelegate = [[DateTimePickerDelegate alloc] init];
|
638
638
|
pickImageDelegate = [[PickImageDelegate alloc] init];
|
639
|
-
signatureDelegate = [
|
639
|
+
signatureDelegate = [SignatureDelegate getSharedInstance];
|
640
640
|
nvDelegate = [[NVDelegate alloc] init];
|
641
641
|
|
642
642
|
#ifdef APP_BUILD_CAPABILITY_PUSH
|
@@ -27,6 +27,7 @@
|
|
27
27
|
#import <UIKit/UIKit.h>
|
28
28
|
#import <Foundation/Foundation.h>
|
29
29
|
#import "RhoDelegate.h"
|
30
|
+
#import "SignatureView.h"
|
30
31
|
#import "SignatureViewController.h"
|
31
32
|
|
32
33
|
@interface SignatureDelegate : RhoDelegate {
|
@@ -37,9 +38,12 @@
|
|
37
38
|
unsigned int penColor;
|
38
39
|
float penWidth;
|
39
40
|
unsigned int bgColor;
|
41
|
+
SignatureView* signatureInlineView;
|
40
42
|
}
|
41
43
|
|
42
44
|
|
45
|
+
+(id) getSharedInstance;
|
46
|
+
|
43
47
|
-(void)doDone:(UIImage*)image;
|
44
48
|
-(void)doCancel;
|
45
49
|
-(void)setSignatureViewControllerValue:(SignatureViewController *)svc;
|
@@ -51,6 +55,6 @@
|
|
51
55
|
-(void)setPenWidth:(float)value;
|
52
56
|
-(void)setBgColor:(unsigned int)value;
|
53
57
|
|
54
|
-
|
58
|
+
-(void)hideSignatureInlineView;
|
55
59
|
|
56
60
|
@end
|
@@ -30,14 +30,26 @@
|
|
30
30
|
#import "common/RhodesApp.h"
|
31
31
|
#include "ruby/ext/rho/rhoruby.h"
|
32
32
|
|
33
|
+
SignatureDelegate* ourSD = nil;
|
34
|
+
|
33
35
|
|
34
36
|
@implementation SignatureDelegate
|
35
37
|
|
38
|
+
+(id) getSharedInstance
|
39
|
+
{
|
40
|
+
if (ourSD == nil) {
|
41
|
+
ourSD = [[SignatureDelegate alloc] init];
|
42
|
+
}
|
43
|
+
return ourSD;
|
44
|
+
}
|
45
|
+
|
46
|
+
|
36
47
|
-(id) init
|
37
48
|
{
|
38
49
|
if (self = [super init])
|
39
50
|
{
|
40
51
|
signatureViewController = nil;
|
52
|
+
signatureInlineView = nil;
|
41
53
|
parentView = nil;
|
42
54
|
prevView = nil;
|
43
55
|
imageFormat = nil;
|
@@ -139,6 +151,83 @@
|
|
139
151
|
prevView = nil;
|
140
152
|
}
|
141
153
|
|
154
|
+
-(void)hideSignatureInlineViewCommand
|
155
|
+
{
|
156
|
+
if (signatureInlineView != nil) {
|
157
|
+
[signatureInlineView removeFromSuperview];
|
158
|
+
[signatureInlineView release];
|
159
|
+
signatureInlineView = nil;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
-(void)hideSignatureInlineView
|
164
|
+
{
|
165
|
+
[self performSelectorOnMainThread:@selector(hideSignatureInlineViewCommand) withObject:nil waitUntilDone:NO];
|
166
|
+
}
|
167
|
+
|
168
|
+
|
169
|
+
-(void)showSignatureInlineViewCommand:(SignatureViewProperties*)properties
|
170
|
+
{
|
171
|
+
[self hideSignatureInlineViewCommand];
|
172
|
+
|
173
|
+
CGRect rect;
|
174
|
+
|
175
|
+
rect.origin.x = properties.left;
|
176
|
+
rect.origin.y = properties.top;
|
177
|
+
rect.size.width = properties.width;
|
178
|
+
rect.size.height = properties.height;
|
179
|
+
|
180
|
+
signatureInlineView = [[SignatureView alloc] initWithFrame:rect];
|
181
|
+
|
182
|
+
[signatureInlineView setPenColor:properties.penColor];
|
183
|
+
[signatureInlineView setPenWidth:properties.penWidth];
|
184
|
+
[signatureInlineView setBgColor:properties.bgColor];
|
185
|
+
|
186
|
+
signatureInlineView.opaque = NO;
|
187
|
+
signatureInlineView.backgroundColor = [UIColor colorWithWhite:1 alpha:0];
|
188
|
+
|
189
|
+
|
190
|
+
UIWebView* webView = [[[Rhodes sharedInstance] mainView] getWebView:-1];
|
191
|
+
if (webView != nil) {
|
192
|
+
UIView* v = webView;//[[webView subviews] objectAtIndex:0];
|
193
|
+
//UIView* v = [[webView subviews] objectAtIndex:0];
|
194
|
+
[v addSubview:signatureInlineView];
|
195
|
+
[v bringSubviewToFront:signatureInlineView];
|
196
|
+
[v setNeedsDisplay];
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
-(void)showSignatureInlineView:(SignatureViewProperties*)properties
|
202
|
+
{
|
203
|
+
[self performSelectorOnMainThread:@selector(showSignatureInlineViewCommand:) withObject:properties waitUntilDone:NO];
|
204
|
+
}
|
205
|
+
|
206
|
+
-(void)clearSignatureInlineViewCommand
|
207
|
+
{
|
208
|
+
if (signatureInlineView != nil) {
|
209
|
+
[signatureInlineView doClear];
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
-(void)clearSignatureInlineView
|
214
|
+
{
|
215
|
+
[self performSelectorOnMainThread:@selector(clearSignatureInlineViewCommand) withObject:nil waitUntilDone:NO];
|
216
|
+
}
|
217
|
+
|
218
|
+
-(void)captureInlineSignatureCommand
|
219
|
+
{
|
220
|
+
if (signatureInlineView != nil) {
|
221
|
+
UIImage* img = [signatureInlineView makeUIImage];
|
222
|
+
[self hideSignatureInlineViewCommand];
|
223
|
+
[self useImage:img];
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
-(void)captureInlineSignature
|
228
|
+
{
|
229
|
+
[self performSelectorOnMainThread:@selector(captureInlineSignatureCommand) withObject:nil waitUntilDone:NO];
|
230
|
+
}
|
142
231
|
|
143
232
|
|
144
233
|
@end
|
@@ -184,24 +273,116 @@ void rho_signature_take(char* callback_url, rho_param* p) {
|
|
184
273
|
Rhodes* rho = [Rhodes sharedInstance];
|
185
274
|
SignatureDelegate* deleg = rho.signatureDelegate;
|
186
275
|
[deleg setImageFormat:iformat];
|
187
|
-
[deleg setPenColor:(unsigned int)[ns_penColor longLongValue]];
|
276
|
+
[deleg setPenColor:((unsigned int)[ns_penColor longLongValue] | 0xFF000000)];
|
188
277
|
[deleg setPenWidth:[ns_penWidth floatValue]];
|
189
|
-
[deleg setBgColor:(unsigned int)[ns_bgColor longLongValue]];
|
278
|
+
[deleg setBgColor:((unsigned int)[ns_bgColor longLongValue] | 0xFF000000)];
|
190
279
|
[[Rhodes sharedInstance] performSelectorOnMainThread:@selector(takeSignature:)
|
191
280
|
withObject:url waitUntilDone:NO];
|
192
281
|
}
|
193
282
|
|
283
|
+
|
194
284
|
void rho_signature_visible(bool b, rho_param* p)
|
195
285
|
{
|
196
|
-
|
286
|
+
if (!b) {
|
287
|
+
SignatureDelegate* deleg = [SignatureDelegate getSharedInstance];
|
288
|
+
[deleg hideSignatureInlineView];
|
289
|
+
return;
|
290
|
+
}
|
291
|
+
|
292
|
+
|
293
|
+
char* image_format = 0;
|
294
|
+
char* penColor = 0;
|
295
|
+
char* penWidth = 0;
|
296
|
+
char* bgColor = 0;
|
297
|
+
char* left = 0;
|
298
|
+
char* top = 0;
|
299
|
+
char* width = 0;
|
300
|
+
char* height = 0;
|
301
|
+
|
302
|
+
if (p)
|
303
|
+
{
|
304
|
+
rho_param* pFF = rho_param_hash_get(p, "imageFormat");
|
305
|
+
if ( pFF )
|
306
|
+
image_format = pFF->v.string;
|
307
|
+
pFF = rho_param_hash_get(p, "penColor");
|
308
|
+
if ( pFF )
|
309
|
+
penColor = pFF->v.string;
|
310
|
+
pFF = rho_param_hash_get(p, "penWidth");
|
311
|
+
if ( pFF )
|
312
|
+
penWidth = pFF->v.string;
|
313
|
+
pFF = rho_param_hash_get(p, "bgColor");
|
314
|
+
if ( pFF )
|
315
|
+
bgColor = pFF->v.string;
|
316
|
+
pFF = rho_param_hash_get(p, "left");
|
317
|
+
if ( pFF )
|
318
|
+
left = pFF->v.string;
|
319
|
+
pFF = rho_param_hash_get(p, "top");
|
320
|
+
if ( pFF )
|
321
|
+
top = pFF->v.string;
|
322
|
+
pFF = rho_param_hash_get(p, "width");
|
323
|
+
if ( pFF )
|
324
|
+
width = pFF->v.string;
|
325
|
+
pFF = rho_param_hash_get(p, "height");
|
326
|
+
if ( pFF )
|
327
|
+
height = pFF->v.string;
|
328
|
+
}
|
329
|
+
|
330
|
+
if (!image_format)
|
331
|
+
image_format = "png";
|
332
|
+
if (!penColor)
|
333
|
+
penColor = "0xFF66009A";
|
334
|
+
if (!penWidth)
|
335
|
+
penWidth = "3";
|
336
|
+
if (!bgColor)
|
337
|
+
bgColor = "0xFFFFFFFF";
|
338
|
+
if (!left)
|
339
|
+
left = "0";
|
340
|
+
if (!top)
|
341
|
+
top = "0";
|
342
|
+
if (!width)
|
343
|
+
width = "100";
|
344
|
+
if (!height)
|
345
|
+
height = "100";
|
346
|
+
|
347
|
+
NSString *iformat = [NSString stringWithUTF8String:image_format];
|
348
|
+
NSString* ns_penColor = [NSString stringWithUTF8String:penColor];
|
349
|
+
NSString* ns_penWidth = [NSString stringWithUTF8String:penWidth];
|
350
|
+
NSString* ns_bgColor = [NSString stringWithUTF8String:bgColor];
|
351
|
+
NSString* ns_left = [NSString stringWithUTF8String:left];
|
352
|
+
NSString* ns_top = [NSString stringWithUTF8String:top];
|
353
|
+
NSString* ns_width = [NSString stringWithUTF8String:width];
|
354
|
+
NSString* ns_height = [NSString stringWithUTF8String:height];
|
355
|
+
|
356
|
+
SignatureViewProperties* props = [[SignatureViewProperties alloc] init];
|
357
|
+
|
358
|
+
props.penColor = (unsigned int)[ns_penColor longLongValue];
|
359
|
+
props.penWidth = (float)[ns_penWidth floatValue];
|
360
|
+
props.bgColor = (unsigned int)[ns_bgColor longLongValue];
|
361
|
+
props.left = (int)[ns_left longLongValue];
|
362
|
+
props.top = (int)[ns_top longLongValue];
|
363
|
+
props.width = (int)[ns_width longLongValue];
|
364
|
+
props.height = (int)[ns_height longLongValue];
|
365
|
+
|
366
|
+
SignatureDelegate* deleg = [SignatureDelegate getSharedInstance];
|
367
|
+
|
368
|
+
[deleg setImageFormat:iformat];
|
369
|
+
|
370
|
+
[deleg showSignatureInlineView:props];
|
371
|
+
|
197
372
|
}
|
198
373
|
|
199
374
|
void rho_signature_capture(const char* callback_url)
|
200
375
|
{
|
201
|
-
|
376
|
+
SignatureDelegate* deleg = [SignatureDelegate getSharedInstance];
|
377
|
+
|
378
|
+
[deleg setPostUrl:[NSString stringWithUTF8String:callback_url]];
|
379
|
+
|
380
|
+
[deleg captureInlineSignature];
|
202
381
|
}
|
203
382
|
|
204
383
|
void rho_signature_clear()
|
205
384
|
{
|
206
|
-
|
385
|
+
SignatureDelegate* deleg = [SignatureDelegate getSharedInstance];
|
386
|
+
[deleg clearSignatureInlineView];
|
387
|
+
|
207
388
|
}
|