rhodes 2.2.4.beta.1 → 2.2.5.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/Rakefile +119 -3
- data/lib/build/jake.rb +15 -1
- data/lib/framework/dateME.rb +6 -1
- data/lib/framework/rho/render.rb +18 -15
- data/lib/framework/rho/rho.rb +105 -43
- data/lib/framework/rho/rhoapplication.rb +1 -1
- data/lib/framework/rho/rhocontact.rb +41 -13
- data/lib/framework/rho/rhocontroller.rb +10 -1
- data/lib/framework/rho/rhoevent_c.rb +6 -1
- data/lib/framework/rho/rhosupport.rb +1 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rholang/rhomsg_de.rb +1 -1
- data/lib/framework/rholang/rhomsg_es.rb +1 -1
- data/lib/framework/rholang/rhomsg_it.rb +28 -0
- data/lib/framework/rhom/rhom.rb +6 -0
- data/lib/framework/rhom/rhom_model.rb +14 -7
- data/lib/framework/rhom/rhom_object_factory.rb +121 -56
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.full.xml +62 -0
- data/platform/android/Rhodes/AndroidManifest.xml +3 -34
- data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +17 -2
- data/platform/android/Rhodes/jni/src/alert.cpp +16 -0
- data/platform/android/Rhodes/jni/src/callbacks.cpp +27 -3
- data/platform/android/Rhodes/jni/src/nativebar.cpp +3 -0
- data/platform/android/Rhodes/jni/src/nativeview.cpp +131 -1
- data/platform/android/Rhodes/jni/src/phonebook.cpp +102 -41
- data/platform/android/Rhodes/jni/src/rhodes.cpp +113 -32
- data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +9 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +184 -49
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +49 -25
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +104 -57
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +36 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +24 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +7 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +185 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +54 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +107 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +72 -24
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +22 -21
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +91 -11
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +10 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +10 -0
- data/platform/android/build/android.rake +50 -9
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Parser.java +3 -2
- data/platform/bb/Hsqldb/src/org/hsqldb/SchemaManager.java +3 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Session.java +7 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +2 -2
- data/platform/bb/RubyVM/RubyVM.jdp +1 -0
- data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +22 -0
- data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +5 -0
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +51 -4
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +21 -10
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +82 -33
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +59 -6
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyFloat_Methods.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +19 -7
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/ArrayPacker.java +1 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFloat.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +55 -11
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +18 -2
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +8 -5
- data/platform/bb/RubyVM/src/j2me/lang/CharacterMe.java +1 -1
- data/platform/bb/RubyVM/src/j2me/util/StringParser.java +2 -0
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +21 -2
- data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +3 -3
- data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +1 -1
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +1 -2
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +15 -16
- data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +4 -0
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +58 -0
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +90 -4
- data/platform/iphone/Classes/AppManager/AppManager.m +43 -5
- data/platform/iphone/Classes/Event/Event.h +2 -0
- data/platform/iphone/Classes/Event/Event.m +12 -1
- data/platform/iphone/Classes/GeoLocation/LocationController.m +9 -3
- data/platform/iphone/Classes/MapView/MapViewController.m +20 -9
- data/platform/iphone/Classes/NativeBar.m +27 -0
- data/platform/iphone/Classes/Phonebook/phonebook.m +17 -0
- data/platform/iphone/Classes/RhoAlert.m +61 -1
- data/platform/iphone/Classes/RhoMainView.h +1 -0
- data/platform/iphone/Classes/Rhodes.h +2 -0
- data/platform/iphone/Classes/Rhodes.m +108 -1
- data/platform/iphone/Classes/SimpleMainView.h +4 -0
- data/platform/iphone/Classes/SimpleMainView.m +30 -3
- data/platform/iphone/Classes/SplashViewController.m +3 -1
- data/platform/iphone/Classes/TabbedMainView.h +2 -0
- data/platform/iphone/Classes/TabbedMainView.m +63 -11
- data/platform/iphone/Classes/rho/net/NetRequestImpl.m +26 -0
- data/platform/iphone/Info.plist +12 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +8 -0
- data/platform/iphone/rbuild/iphone.rake +181 -25
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +5 -5
- data/platform/shared/common/IRhoThreadImpl.h +1 -1
- data/platform/shared/common/PosixThreadImpl.cpp +5 -3
- data/platform/shared/common/PosixThreadImpl.h +1 -1
- data/platform/shared/common/RhoFilePath.h +11 -0
- data/platform/shared/common/RhoNativeViewManager.h +17 -0
- data/platform/shared/common/RhoThread.h +1 -1
- data/platform/shared/common/RhodesApp.cpp +29 -8
- data/platform/shared/common/ThreadQueue.cpp +5 -3
- data/platform/shared/common/ThreadQueue.h +2 -1
- data/platform/shared/common/app_build_configs.c +25 -0
- data/platform/shared/common/app_build_configs.h +11 -0
- data/platform/shared/net/AsyncHttp.cpp +5 -5
- data/platform/shared/net/CURLNetRequest.cpp +25 -7
- data/platform/shared/net/CURLNetRequest.h +2 -1
- data/platform/shared/net/HttpServer.cpp +28 -0
- data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +26 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +6 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
- data/platform/shared/ruby/ext/rho/rhosupport.c +15 -2
- data/platform/shared/ruby/ext/syncengine/syncengine.i +14 -2
- data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +97 -2
- data/platform/shared/ruby/ext/system/system.i +13 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +104 -1
- data/platform/shared/rubyext/RhoAppAdapter.cpp +7 -0
- data/platform/shared/sync/SyncEngine.cpp +43 -3
- data/platform/shared/sync/SyncEngine.h +13 -0
- data/platform/shared/sync/SyncNotify.cpp +41 -23
- data/platform/shared/sync/SyncNotify.h +18 -4
- data/platform/shared/sync/SyncSource.cpp +52 -14
- data/platform/shared/sync/SyncSource.h +1 -0
- data/platform/shared/sync/SyncThread.cpp +29 -9
- data/platform/shared/sync/SyncThread.h +4 -2
- data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
- data/platform/wm/build/build_inf.js +15 -9
- data/platform/wm/build/wm.rake +10 -5
- data/platform/wm/rhodes/Alert.cpp +10 -0
- data/platform/wm/rhodes/Alert.h +3 -3
- data/platform/wm/rhodes/MainWindow.cpp +171 -26
- data/platform/wm/rhodes/MainWindow.h +23 -1
- data/platform/wm/rhodes/MetaHandler.cpp +192 -0
- data/platform/wm/rhodes/MetaHandler.h +31 -0
- data/platform/wm/rhodes/RhoNativeViewManager.cpp +126 -0
- data/platform/wm/rhodes/RhoNativeViewManagerWM.h +20 -0
- data/platform/wm/rhodes/Rhodes.cpp +91 -2
- data/platform/wm/rhodes/Rhodes.rc +15 -6
- data/platform/wm/rhodes/SyncStatusDlg.cpp +32 -0
- data/platform/wm/rhodes/SyncStatusDlg.h +29 -0
- data/platform/wm/rhodes/resource.h +5 -2
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +3 -1
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +146 -14
- data/platform/wm/rhodes/rhodes.vcproj +28 -0
- data/rakefile.rb +119 -3
- data/res/build-tools/iphonesim/README +58 -0
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.h +43 -0
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +224 -0
- data/res/build-tools/iphonesim/Source/main.m +52 -0
- data/res/build-tools/iphonesim/Source/nsprintf.h +3 -0
- data/res/build-tools/iphonesim/Source/nsprintf.m +42 -0
- data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
- data/res/build-tools/iphonesim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +124 -0
- data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +261 -0
- data/res/build-tools/iphonesim/iphonesim_Prefix.pch +7 -0
- data/res/generators/rhogen.rb +5 -0
- data/res/generators/templates/application/app/layout.erb +7 -13
- data/res/generators/templates/application/app/loading.png +0 -0
- data/res/generators/templates/application/build.yml +3 -0
- data/res/generators/templates/application/icon/icon114.png +0 -0
- data/res/generators/templates/application/icon/icon57.png +0 -0
- data/res/generators/templates/application/icon/icon72.png +0 -0
- data/res/generators/templates/application/public/css/iphone.css +96 -0
- data/res/generators/templates/application/public/images/backButton.png +0 -0
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +2 -1
- data/res/generators/templates/application/rhoconfig.txt +2 -0
- data/rhodes.gemspec +1 -1
- data/spec/phone_spec/app/spec/array_pack_spec.rb +108 -0
- data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
- data/spec/phone_spec/app/spec/date_spec.rb +27 -0
- data/spec/phone_spec/app/spec/fixtures/classes.rb +91 -0
- data/spec/phone_spec/app/spec/lstrip_spec.rb +57 -0
- data/spec/phone_spec/app/spec/rho_spec.rb +50 -19
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +78 -0
- data/spec/phone_spec/app/spec/rstrip_spec.rb +51 -0
- data/spec/phone_spec/app/spec/strip_spec.rb +50 -0
- data/spec/phone_spec/app/spec/syncengine_spec.rb +46 -3
- data/spec/phone_spec/app/spec_runner.rb +6 -0
- metadata +34 -4
@@ -3,6 +3,7 @@ package com.rhomobile.rhodes.phonebook;
|
|
3
3
|
import java.util.HashMap;
|
4
4
|
import java.util.Map;
|
5
5
|
|
6
|
+
import com.rhomobile.rhodes.Logger;
|
6
7
|
import com.rhomobile.rhodes.RhodesService;
|
7
8
|
|
8
9
|
import android.accounts.Account;
|
@@ -22,8 +23,10 @@ import android.provider.ContactsContract.RawContacts;
|
|
22
23
|
|
23
24
|
public class ContactAccessorNew implements ContactAccessor {
|
24
25
|
|
25
|
-
|
26
|
+
private static final String TAG = "ContactsAccessorNew";
|
27
|
+
private static final boolean logging_enable = false;
|
26
28
|
|
29
|
+
/*
|
27
30
|
private static final String PB_ID = Phonebook.PB_ID;
|
28
31
|
private static final String PB_FIRST_NAME = Phonebook.PB_FIRST_NAME;
|
29
32
|
private static final String PB_LAST_NAME = Phonebook.PB_LAST_NAME;
|
@@ -32,11 +35,14 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
32
35
|
private static final String PB_BUSINESS_NUMBER = Phonebook.PB_BUSINESS_NUMBER;
|
33
36
|
private static final String PB_EMAIL_ADDRESS = Phonebook.PB_EMAIL_ADDRESS;
|
34
37
|
private static final String PB_COMPANY_NAME = Phonebook.PB_COMPANY_NAME;
|
38
|
+
*/
|
35
39
|
|
36
40
|
private ContentResolver cr;
|
37
41
|
private String accName;
|
38
42
|
private String accType;
|
39
43
|
|
44
|
+
|
45
|
+
|
40
46
|
public ContactAccessorNew() throws Exception {
|
41
47
|
Context ctx = RhodesService.getInstance().getContext();
|
42
48
|
|
@@ -54,9 +60,10 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
54
60
|
cr = ctx.getContentResolver();
|
55
61
|
}
|
56
62
|
|
57
|
-
|
58
|
-
|
59
|
-
contact.
|
63
|
+
public void fillName(String id, Contact contact) {
|
64
|
+
if (logging_enable) Logger.I(TAG, "fillName("+id+")");
|
65
|
+
contact.setFieldInner(Phonebook.PB_I_FIRST_NAME, "");
|
66
|
+
contact.setFieldInner(Phonebook.PB_I_LAST_NAME, "");
|
60
67
|
|
61
68
|
Cursor cursor = cr.query(Data.CONTENT_URI,
|
62
69
|
new String[] {StructuredName.DISPLAY_NAME},
|
@@ -64,27 +71,34 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
64
71
|
new String[] {id, StructuredName.CONTENT_ITEM_TYPE},
|
65
72
|
null);
|
66
73
|
try {
|
67
|
-
if (!cursor.moveToFirst())
|
74
|
+
if (!cursor.moveToFirst()) {
|
75
|
+
if (logging_enable) Logger.I(TAG, "fillName() not found record with ID");
|
68
76
|
return;
|
77
|
+
}
|
69
78
|
|
70
79
|
String name = cursor.getString(cursor.getColumnIndex(StructuredName.DISPLAY_NAME));
|
71
80
|
if (name != null) {
|
72
81
|
String[] names = name.split(" ");
|
82
|
+
if (logging_enable) Logger.I(TAG, "fillName() names = "+name);
|
73
83
|
if (names.length == 1) {
|
74
|
-
contact.
|
84
|
+
contact.setFieldInner(Phonebook.PB_I_FIRST_NAME, name);
|
75
85
|
}
|
76
|
-
else {
|
77
|
-
contact.
|
78
|
-
contact.
|
86
|
+
else if (names.length > 1) {
|
87
|
+
contact.setFieldInner(Phonebook.PB_I_FIRST_NAME, names[0]);
|
88
|
+
contact.setFieldInner(Phonebook.PB_I_LAST_NAME, names[1]);
|
79
89
|
}
|
80
90
|
}
|
91
|
+
else {
|
92
|
+
if (logging_enable) Logger.I(TAG, "fillName() name == NULL");
|
93
|
+
|
94
|
+
}
|
81
95
|
}
|
82
96
|
finally {
|
83
97
|
cursor.close();
|
84
98
|
}
|
85
99
|
}
|
86
100
|
|
87
|
-
|
101
|
+
public void fillPhones(String id, Contact contact) {
|
88
102
|
Cursor cursor = cr.query(Data.CONTENT_URI,
|
89
103
|
new String[] {Phone.NUMBER, Phone.TYPE},
|
90
104
|
Data.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
@@ -99,13 +113,13 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
99
113
|
do {
|
100
114
|
switch (cursor.getInt(typeColumn)) {
|
101
115
|
case Phone.TYPE_HOME:
|
102
|
-
contact.
|
116
|
+
contact.setFieldInner(Phonebook.PB_I_HOME_NUMBER, cursor.getString(numColumn));
|
103
117
|
break;
|
104
118
|
case Phone.TYPE_WORK:
|
105
|
-
contact.
|
119
|
+
contact.setFieldInner(Phonebook.PB_I_BUSINESS_NUMBER, cursor.getString(numColumn));
|
106
120
|
break;
|
107
121
|
case Phone.TYPE_MOBILE:
|
108
|
-
contact.
|
122
|
+
contact.setFieldInner(Phonebook.PB_I_MOBILE_NUMBER, cursor.getString(numColumn));
|
109
123
|
break;
|
110
124
|
}
|
111
125
|
} while (cursor.moveToNext());
|
@@ -115,7 +129,7 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
115
129
|
}
|
116
130
|
}
|
117
131
|
|
118
|
-
|
132
|
+
public void fillEmails(String id, Contact contact) {
|
119
133
|
Cursor cursor = cr.query(Data.CONTENT_URI,
|
120
134
|
new String[] {Email.DATA},
|
121
135
|
Data.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
@@ -126,14 +140,14 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
126
140
|
return;
|
127
141
|
|
128
142
|
String data = cursor.getString(cursor.getColumnIndex(Email.DATA));
|
129
|
-
contact.
|
143
|
+
contact.setFieldInner(Phonebook.PB_I_EMAIL_ADDRESS, data);
|
130
144
|
}
|
131
145
|
finally {
|
132
146
|
cursor.close();
|
133
147
|
}
|
134
148
|
}
|
135
149
|
|
136
|
-
|
150
|
+
public void fillCompany(String id, Contact contact) {
|
137
151
|
Cursor cursor = cr.query(Data.CONTENT_URI,
|
138
152
|
new String[] {Organization.COMPANY},
|
139
153
|
Data.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
@@ -143,7 +157,7 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
143
157
|
if (!cursor.moveToFirst())
|
144
158
|
return;
|
145
159
|
String company = cursor.getString(cursor.getColumnIndex(Organization.COMPANY));
|
146
|
-
contact.
|
160
|
+
contact.setFieldInner(Phonebook.PB_I_COMPANY_NAME, company);
|
147
161
|
}
|
148
162
|
finally {
|
149
163
|
cursor.close();
|
@@ -162,6 +176,7 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
162
176
|
|
163
177
|
do {
|
164
178
|
Contact contact = new Contact();
|
179
|
+
contact.setAccessor(this);
|
165
180
|
|
166
181
|
String id = cursor.getString(cursor.getColumnIndex(RawContacts._ID));
|
167
182
|
contact.setId(id);
|
@@ -170,8 +185,9 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
170
185
|
fillPhones(id, contact);
|
171
186
|
fillEmails(id, contact);
|
172
187
|
fillCompany(id, contact);
|
188
|
+
contact.makeAllFilled();
|
173
189
|
|
174
|
-
contacts.put(contact.getField(
|
190
|
+
contacts.put(contact.getField(Phonebook.PB_I_ID), contact);
|
175
191
|
} while (cursor.moveToNext());
|
176
192
|
}
|
177
193
|
finally {
|
@@ -181,6 +197,35 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
181
197
|
return contacts;
|
182
198
|
}
|
183
199
|
|
200
|
+
public Contact getContactByID(String id) {
|
201
|
+
if (logging_enable) Logger.I(TAG, "getContactByID("+id+")");
|
202
|
+
|
203
|
+
Contact contact = null;
|
204
|
+
|
205
|
+
Cursor cursor = cr.query(Data.CONTENT_URI,
|
206
|
+
new String[] {RawContacts._ID},
|
207
|
+
Data.RAW_CONTACT_ID + "=?",
|
208
|
+
new String[] {id},
|
209
|
+
null);
|
210
|
+
|
211
|
+
try {
|
212
|
+
if (!cursor.moveToFirst()) {
|
213
|
+
if (logging_enable) Logger.I(TAG, "getContactByID() not found");
|
214
|
+
return null;
|
215
|
+
}
|
216
|
+
contact = new Contact();
|
217
|
+
contact.setAccessor(this);
|
218
|
+
|
219
|
+
//String idd = cursor.getString(cursor.getColumnIndex(RawContacts._ID));
|
220
|
+
contact.setId(id);
|
221
|
+
}
|
222
|
+
finally {
|
223
|
+
cursor.close();
|
224
|
+
}
|
225
|
+
if (logging_enable) Logger.I(TAG, "getContactByID() found");
|
226
|
+
return contact;
|
227
|
+
}
|
228
|
+
|
184
229
|
private void create(Contact contact) throws Exception {
|
185
230
|
String id = contact.id();
|
186
231
|
|
@@ -192,6 +237,8 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
192
237
|
Uri uri = cr.insert(RawContacts.CONTENT_URI, values);
|
193
238
|
id = String.valueOf(ContentUris.parseId(uri));
|
194
239
|
contact.setId(id);
|
240
|
+
contact.setAccessor(this);
|
241
|
+
contact.makeAllFilled();
|
195
242
|
}
|
196
243
|
}
|
197
244
|
|
@@ -240,8 +287,8 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
240
287
|
}
|
241
288
|
|
242
289
|
private void updateName(Contact contact) throws Exception {
|
243
|
-
String firstName = contact.getField(
|
244
|
-
String lastName = contact.getField(
|
290
|
+
String firstName = contact.getField(Phonebook.PB_I_FIRST_NAME);
|
291
|
+
String lastName = contact.getField(Phonebook.PB_I_LAST_NAME);
|
245
292
|
|
246
293
|
ContentValues values = new ContentValues();
|
247
294
|
values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
|
@@ -252,11 +299,11 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
252
299
|
}
|
253
300
|
|
254
301
|
private void updatePhones(Contact contact) throws Exception {
|
255
|
-
|
302
|
+
int[] phones = {Phonebook.PB_I_MOBILE_NUMBER, Phonebook.PB_I_HOME_NUMBER, Phonebook.PB_I_BUSINESS_NUMBER};
|
256
303
|
int[] types = {Phone.TYPE_MOBILE, Phone.TYPE_HOME, Phone.TYPE_WORK};
|
257
304
|
|
258
305
|
for (int i = 0; i < phones.length; ++i) {
|
259
|
-
|
306
|
+
int phName = phones[i];
|
260
307
|
String value = contact.getField(phName);
|
261
308
|
if (value == null || value.length() == 0)
|
262
309
|
continue;
|
@@ -270,7 +317,7 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
270
317
|
}
|
271
318
|
|
272
319
|
private void updateEmails(Contact contact) throws Exception {
|
273
|
-
String value = contact.getField(
|
320
|
+
String value = contact.getField(Phonebook.PB_I_EMAIL_ADDRESS);
|
274
321
|
if (value == null || value.length() == 0)
|
275
322
|
return;
|
276
323
|
|
@@ -281,7 +328,7 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
281
328
|
}
|
282
329
|
|
283
330
|
private void updateCompany(Contact contact) throws Exception {
|
284
|
-
String value = contact.getField(
|
331
|
+
String value = contact.getField(Phonebook.PB_I_COMPANY_NAME);
|
285
332
|
if (value == null || value.length() == 0)
|
286
333
|
return;
|
287
334
|
|
@@ -298,6 +345,7 @@ public class ContactAccessorNew implements ContactAccessor {
|
|
298
345
|
updatePhones(contact);
|
299
346
|
updateEmails(contact);
|
300
347
|
updateCompany(contact);
|
348
|
+
contact.makeAllFilled();
|
301
349
|
}
|
302
350
|
|
303
351
|
public void remove(Contact contact) {
|
@@ -20,6 +20,7 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
20
20
|
|
21
21
|
//private static final String TAG = "ContactsAccessorOld";
|
22
22
|
|
23
|
+
/*
|
23
24
|
private static final String PB_ID = Phonebook.PB_ID;
|
24
25
|
private static final String PB_FIRST_NAME = Phonebook.PB_FIRST_NAME;
|
25
26
|
private static final String PB_LAST_NAME = Phonebook.PB_LAST_NAME;
|
@@ -28,7 +29,7 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
28
29
|
private static final String PB_BUSINESS_NUMBER = Phonebook.PB_BUSINESS_NUMBER;
|
29
30
|
private static final String PB_EMAIL_ADDRESS = Phonebook.PB_EMAIL_ADDRESS;
|
30
31
|
private static final String PB_COMPANY_NAME = Phonebook.PB_COMPANY_NAME;
|
31
|
-
|
32
|
+
*/
|
32
33
|
private ContentResolver cr;
|
33
34
|
|
34
35
|
public ContactAccessorOld() {
|
@@ -48,13 +49,13 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
48
49
|
for (int i = 0, lim = cursor.getCount(); i < lim; ++i) {
|
49
50
|
switch (cursor.getInt(typeColumn)) {
|
50
51
|
case Phones.TYPE_WORK:
|
51
|
-
contact.
|
52
|
+
contact.setFieldInner(Phonebook.PB_I_BUSINESS_NUMBER, cursor.getString(numColumn));
|
52
53
|
break;
|
53
54
|
case Phones.TYPE_HOME:
|
54
|
-
contact.
|
55
|
+
contact.setFieldInner(Phonebook.PB_I_HOME_NUMBER, cursor.getString(numColumn));
|
55
56
|
break;
|
56
57
|
case Phones.TYPE_MOBILE:
|
57
|
-
contact.
|
58
|
+
contact.setFieldInner(Phonebook.PB_I_MOBILE_NUMBER, cursor.getString(numColumn));
|
58
59
|
break;
|
59
60
|
}
|
60
61
|
cursor.moveToNext();
|
@@ -81,18 +82,18 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
81
82
|
|
82
83
|
//contact.setField(PB_COMPANY_NAME, cursor.getString(cursor.getColumnIndex(People.COMPANY)));
|
83
84
|
|
84
|
-
contact.
|
85
|
-
contact.
|
85
|
+
contact.setFieldInner(Phonebook.PB_I_FIRST_NAME, "");
|
86
|
+
contact.setFieldInner(Phonebook.PB_I_LAST_NAME, "");
|
86
87
|
String name = cursor.getString(cursor.getColumnIndex(People.NAME));
|
87
88
|
if (name != null) {
|
88
89
|
String[] names = name.split(" ");
|
89
90
|
|
90
91
|
if (names.length == 1) {
|
91
|
-
contact.
|
92
|
+
contact.setFieldInner(Phonebook.PB_I_FIRST_NAME, names[0]);
|
92
93
|
}
|
93
94
|
else if (names.length > 1) {
|
94
|
-
contact.
|
95
|
-
contact.
|
95
|
+
contact.setFieldInner(Phonebook.PB_I_FIRST_NAME, names[0]);
|
96
|
+
contact.setFieldInner(Phonebook.PB_I_LAST_NAME, name.replaceFirst(names[0] + " ", ""));
|
96
97
|
}
|
97
98
|
}
|
98
99
|
|
@@ -115,7 +116,7 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
115
116
|
.getColumnIndex(Organizations.COMPANY);
|
116
117
|
|
117
118
|
if (numberColumn != -1)
|
118
|
-
contact.
|
119
|
+
contact.setFieldInner(Phonebook.PB_I_COMPANY_NAME,
|
119
120
|
organizationCursor.getString(numberColumn));
|
120
121
|
}
|
121
122
|
}
|
@@ -141,7 +142,7 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
141
142
|
for (int j = 0; j < contactCursorCount; j++) {
|
142
143
|
switch (contactCursor.getInt(typeColumn)) {
|
143
144
|
case Contacts.ContactMethods.TYPE_HOME:
|
144
|
-
contact.
|
145
|
+
contact.setFieldInner(Phonebook.PB_I_EMAIL_ADDRESS, contactCursor.getString(numberColumn));
|
145
146
|
break;
|
146
147
|
}
|
147
148
|
contactCursor.moveToNext();
|
@@ -151,8 +152,8 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
151
152
|
finally {
|
152
153
|
contactCursor.close();
|
153
154
|
}
|
154
|
-
|
155
|
-
contacts.put(contact.getField(
|
155
|
+
contact.makeAllFilled();
|
156
|
+
contacts.put(contact.getField(Phonebook.PB_I_ID), contact);
|
156
157
|
} while (cursor.moveToNext());
|
157
158
|
}
|
158
159
|
finally {
|
@@ -166,8 +167,8 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
166
167
|
String rbID = contact.id();
|
167
168
|
Uri uri = null;
|
168
169
|
|
169
|
-
String firstName = contact.getField(
|
170
|
-
String lastName = contact.getField(
|
170
|
+
String firstName = contact.getField(Phonebook.PB_I_FIRST_NAME);
|
171
|
+
String lastName = contact.getField(Phonebook.PB_I_LAST_NAME);
|
171
172
|
String name = firstName + " " + lastName;
|
172
173
|
|
173
174
|
boolean isNew = false;
|
@@ -200,10 +201,10 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
200
201
|
|
201
202
|
contact.setId(pathLeaf);
|
202
203
|
|
203
|
-
|
204
|
+
int[] phones = {Phonebook.PB_I_MOBILE_NUMBER, Phonebook.PB_I_HOME_NUMBER, Phonebook.PB_I_BUSINESS_NUMBER};
|
204
205
|
int[] types = {Phones.TYPE_MOBILE, Phones.TYPE_HOME, Phones.TYPE_WORK};
|
205
206
|
for (int i = 0; i < phones.length; ++i) {
|
206
|
-
|
207
|
+
int phName = phones[i];
|
207
208
|
String value = contact.getField(phName);
|
208
209
|
if (value == null)
|
209
210
|
continue;
|
@@ -223,13 +224,13 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
223
224
|
}
|
224
225
|
|
225
226
|
// add email
|
226
|
-
if (contact.getField(
|
227
|
+
if (contact.getField(Phonebook.PB_I_EMAIL_ADDRESS) != null) {
|
227
228
|
ContentValues email = new ContentValues();
|
228
229
|
email.put(Contacts.ContactMethods.PERSON_ID, pathLeaf);
|
229
230
|
email.put(Contacts.ContactMethods.KIND,
|
230
231
|
Contacts.ContactMethods.TYPE_HOME);
|
231
232
|
|
232
|
-
email.put(Contacts.ContactMethods.DATA, contact.getField(
|
233
|
+
email.put(Contacts.ContactMethods.DATA, contact.getField(Phonebook.PB_I_EMAIL_ADDRESS));
|
233
234
|
|
234
235
|
email.put(Contacts.ContactMethods.TYPE,
|
235
236
|
Contacts.ContactMethods.CONTENT_EMAIL_ITEM_TYPE);
|
@@ -242,7 +243,7 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
242
243
|
}
|
243
244
|
}
|
244
245
|
// add organization
|
245
|
-
if (contact.getField(
|
246
|
+
if (contact.getField(Phonebook.PB_I_COMPANY_NAME) != null) {
|
246
247
|
Uri orgUri = Uri.withAppendedPath(uri,
|
247
248
|
Contacts.Organizations.CONTENT_DIRECTORY);
|
248
249
|
|
@@ -252,7 +253,7 @@ public class ContactAccessorOld implements ContactAccessor {
|
|
252
253
|
Contacts.Organizations.TYPE_WORK);
|
253
254
|
|
254
255
|
company.put(Contacts.Organizations.COMPANY, contact
|
255
|
-
.getField(
|
256
|
+
.getField(Phonebook.PB_I_COMPANY_NAME));
|
256
257
|
|
257
258
|
Uri companyUpdate = cr.insert(orgUri, company);
|
258
259
|
|
@@ -20,6 +20,7 @@
|
|
20
20
|
*/
|
21
21
|
package com.rhomobile.rhodes.phonebook;
|
22
22
|
|
23
|
+
import java.util.HashMap;
|
23
24
|
import java.util.Iterator;
|
24
25
|
import java.util.Map;
|
25
26
|
|
@@ -32,6 +33,7 @@ import com.rhomobile.rhodes.Logger;
|
|
32
33
|
public class Phonebook {
|
33
34
|
|
34
35
|
private static final String TAG = "Phonebook";
|
36
|
+
private static final boolean logging_enable = false;
|
35
37
|
|
36
38
|
public static final String PB_ID = "id";
|
37
39
|
public static final String PB_FIRST_NAME = "first_name";
|
@@ -42,9 +44,24 @@ public class Phonebook {
|
|
42
44
|
public static final String PB_EMAIL_ADDRESS = "email_address";
|
43
45
|
public static final String PB_COMPANY_NAME = "company_name";
|
44
46
|
|
47
|
+
public static final int PB_FIELDS_COUNT = 8;
|
48
|
+
public static final int PB_I_ID = 0;
|
49
|
+
public static final int PB_I_FIRST_NAME = 1;
|
50
|
+
public static final int PB_I_LAST_NAME = 2;
|
51
|
+
public static final int PB_I_MOBILE_NUMBER = 3;
|
52
|
+
public static final int PB_I_HOME_NUMBER = 4;
|
53
|
+
public static final int PB_I_BUSINESS_NUMBER = 5;
|
54
|
+
public static final int PB_I_EMAIL_ADDRESS = 6;
|
55
|
+
public static final int PB_I_COMPANY_NAME = 7;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
45
61
|
private Map<String, Contact> contactList;
|
46
62
|
private ContactAccessor accessor;
|
47
63
|
private Iterator<Contact> iter = null;
|
64
|
+
private boolean mIsFullListReceived = false;
|
48
65
|
|
49
66
|
private boolean checkState() {
|
50
67
|
if (!Capabilities.PIM_ENABLED)
|
@@ -78,8 +95,23 @@ public class Phonebook {
|
|
78
95
|
return;
|
79
96
|
|
80
97
|
accessor = createAccessor();
|
81
|
-
contactList =
|
82
|
-
|
98
|
+
contactList = new HashMap<String, Contact>();
|
99
|
+
}
|
100
|
+
catch (Exception e) {
|
101
|
+
Logger.E(TAG, e);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
public void prepareFullList() {
|
106
|
+
if (!checkState())
|
107
|
+
return;
|
108
|
+
try {
|
109
|
+
if (!mIsFullListReceived) {
|
110
|
+
Logger.I(TAG, "Phonebook.prepareFullList()");
|
111
|
+
contactList = accessor.getAll();
|
112
|
+
mIsFullListReceived = true;
|
113
|
+
}
|
114
|
+
//moveToBegin();
|
83
115
|
}
|
84
116
|
catch (Exception e) {
|
85
117
|
Logger.E(TAG, e);
|
@@ -97,12 +129,14 @@ public class Phonebook {
|
|
97
129
|
Logger.E(TAG, e);
|
98
130
|
}
|
99
131
|
}
|
100
|
-
|
132
|
+
|
101
133
|
public void moveToBegin() {
|
102
134
|
try {
|
103
135
|
if (!checkState())
|
104
136
|
return;
|
105
|
-
|
137
|
+
if (!mIsFullListReceived) {
|
138
|
+
prepareFullList();
|
139
|
+
}
|
106
140
|
iter = contactList.values().iterator();
|
107
141
|
}
|
108
142
|
catch (Exception e) {
|
@@ -114,6 +148,9 @@ public class Phonebook {
|
|
114
148
|
try {
|
115
149
|
if (!checkState())
|
116
150
|
return false;
|
151
|
+
//if (!mIsFullListReceived) {
|
152
|
+
// prepareFullList();
|
153
|
+
//}
|
117
154
|
|
118
155
|
return iter.hasNext();
|
119
156
|
}
|
@@ -127,6 +164,9 @@ public class Phonebook {
|
|
127
164
|
try {
|
128
165
|
if (!checkState())
|
129
166
|
return null;
|
167
|
+
//if (!mIsFullListReceived) {
|
168
|
+
// prepareFullList();
|
169
|
+
//}
|
130
170
|
|
131
171
|
return iter.next();
|
132
172
|
}
|
@@ -140,6 +180,9 @@ public class Phonebook {
|
|
140
180
|
try {
|
141
181
|
if (!checkState())
|
142
182
|
return null;
|
183
|
+
//if (!mIsFullListReceived) {
|
184
|
+
// prepareFullList();
|
185
|
+
//}
|
143
186
|
|
144
187
|
moveToBegin();
|
145
188
|
if (!iter.hasNext())
|
@@ -156,6 +199,9 @@ public class Phonebook {
|
|
156
199
|
try {
|
157
200
|
if (!checkState())
|
158
201
|
return null;
|
202
|
+
//if (!mIsFullListReceived) {
|
203
|
+
// prepareFullList();
|
204
|
+
//}
|
159
205
|
|
160
206
|
return iter.next();
|
161
207
|
}
|
@@ -165,12 +211,46 @@ public class Phonebook {
|
|
165
211
|
}
|
166
212
|
}
|
167
213
|
|
168
|
-
public Contact getRecord(String
|
214
|
+
public Contact getRecord(String idd) {
|
215
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord("+idd+")");
|
169
216
|
try {
|
170
|
-
if (!checkState())
|
171
|
-
|
172
|
-
|
173
|
-
|
217
|
+
//if (!checkState())
|
218
|
+
// return null;
|
219
|
+
if (contactList == null) {
|
220
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() contackList is null !");
|
221
|
+
}
|
222
|
+
if ((accessor != null) && (accessor instanceof ContactAccessorNew)) {
|
223
|
+
//if (false) {
|
224
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() new accessor !");
|
225
|
+
Contact c = contactList.get(idd);
|
226
|
+
if (c != null) {
|
227
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() found in list");
|
228
|
+
return c;
|
229
|
+
}
|
230
|
+
c = ((ContactAccessorNew)accessor).getContactByID(Contact.convertRhodeIDtoPlatformID(idd));
|
231
|
+
if (c != null) {
|
232
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() found in system");
|
233
|
+
contactList.put(c.getField(Phonebook.PB_I_ID), c);
|
234
|
+
}
|
235
|
+
else {
|
236
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() not found in system");
|
237
|
+
}
|
238
|
+
return c;
|
239
|
+
}
|
240
|
+
else {
|
241
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() old accessor class");
|
242
|
+
if (!mIsFullListReceived) {
|
243
|
+
prepareFullList();
|
244
|
+
}
|
245
|
+
}
|
246
|
+
Contact cc = contactList.get(idd);
|
247
|
+
if (cc != null) {
|
248
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() return record");
|
249
|
+
}
|
250
|
+
else {
|
251
|
+
if (logging_enable) Logger.I(TAG, "Phonebook.getRecord() return NULL");
|
252
|
+
}
|
253
|
+
return cc;
|
174
254
|
}
|
175
255
|
catch (Exception e) {
|
176
256
|
Logger.E(TAG, e);
|
@@ -184,7 +264,7 @@ public class Phonebook {
|
|
184
264
|
return;
|
185
265
|
|
186
266
|
accessor.remove(contact);
|
187
|
-
contactList.remove(contact.getField(
|
267
|
+
contactList.remove(contact.getField(Phonebook.PB_I_ID));
|
188
268
|
}
|
189
269
|
catch (Exception e) {
|
190
270
|
Logger.E(TAG, e);
|
@@ -197,7 +277,7 @@ public class Phonebook {
|
|
197
277
|
return;
|
198
278
|
|
199
279
|
accessor.save(contact);
|
200
|
-
contactList.put(contact.getField(
|
280
|
+
contactList.put(contact.getField(Phonebook.PB_I_ID), contact);
|
201
281
|
}
|
202
282
|
catch (Exception e) {
|
203
283
|
Logger.E(TAG, e);
|
@@ -27,6 +27,16 @@ public class PerformOnUiThread implements Runnable {
|
|
27
27
|
}
|
28
28
|
}
|
29
29
|
|
30
|
+
public static void exec(Runnable r, int delay) {
|
31
|
+
try {
|
32
|
+
RhodesService rhodes = RhodesService.getInstance();
|
33
|
+
rhodes.post(r, delay);
|
34
|
+
}
|
35
|
+
catch (Exception e) {
|
36
|
+
Logger.E(TAG, "exec failed: " + e.getMessage());
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
30
40
|
public static void exec(Runnable r, boolean wait) {
|
31
41
|
try {
|
32
42
|
RhodesService rhodes = RhodesService.getInstance();
|
@@ -1,7 +1,11 @@
|
|
1
1
|
package com.rhomobile.rhodes.webview;
|
2
2
|
|
3
|
+
import android.webkit.WebChromeClient;
|
4
|
+
import android.webkit.WebStorage;
|
5
|
+
|
3
6
|
import com.rhomobile.rhodes.Logger;
|
4
7
|
|
8
|
+
|
5
9
|
public class ChromeClientNew extends ChromeClientOld {
|
6
10
|
|
7
11
|
private static final String TAG = "ChromeClientNew";
|
@@ -10,5 +14,12 @@ public class ChromeClientNew extends ChromeClientOld {
|
|
10
14
|
public void onConsoleMessage(String message, int lineNumber, String sourceID) {
|
11
15
|
Logger.D(TAG, message + " -- From line " + lineNumber + " of " + sourceID);
|
12
16
|
}
|
17
|
+
|
18
|
+
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
|
19
|
+
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
|
20
|
+
quotaUpdater.updateQuota(estimatedSize * 2);
|
21
|
+
}
|
13
22
|
|
14
23
|
}
|
24
|
+
|
25
|
+
|
@@ -1,5 +1,8 @@
|
|
1
1
|
package com.rhomobile.rhodes.webview;
|
2
2
|
|
3
|
+
import com.rhomobile.rhodes.RhodesService;
|
4
|
+
|
5
|
+
import android.content.Context;
|
3
6
|
import android.webkit.WebSettings;
|
4
7
|
import android.webkit.WebView;
|
5
8
|
|
@@ -11,6 +14,13 @@ public class RhoWebSettingsNew implements RhoWebSettings {
|
|
11
14
|
|
12
15
|
webSettings.setAppCacheEnabled(true);
|
13
16
|
|
17
|
+
|
18
|
+
webSettings.setDatabaseEnabled(true);
|
19
|
+
webSettings.setJavaScriptEnabled(true);
|
20
|
+
|
21
|
+
String databasePath = RhodesService.getInstance().getContext().getDir("database", Context.MODE_PRIVATE).getPath();
|
22
|
+
webSettings.setDatabasePath(databasePath);
|
23
|
+
|
14
24
|
return webSettings;
|
15
25
|
}
|
16
26
|
|