1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
|
#include <jni.h>
#include "com/mapswithme/core/jni_helper.hpp"
#include "com/mapswithme/maps/Framework.hpp"
#include "coding/multilang_utf8_string.hpp"
#include "base/assert.hpp"
#include "base/logging.hpp"
#include "base/string_utils.hpp"
#include "indexer/cuisines.hpp"
#include "indexer/editable_map_object.hpp"
#include "indexer/osm_editor.hpp"
#include "std/algorithm.hpp"
#include "std/set.hpp"
#include "std/target_os.hpp"
#include "std/vector.hpp"
namespace
{
using TCuisine = pair<string, string>;
osm::EditableMapObject g_editableMapObject;
jclass g_featureCategoryClazz;
jmethodID g_featureCtor;
jclass g_localNameClazz;
jmethodID g_localNameCtor;
jfieldID g_localNameFieldCode;
jfieldID g_localNameFieldName;
jclass g_localStreetClazz;
jmethodID g_localStreetCtor;
jfieldID g_localStreetFieldDef;
jfieldID g_localStreetFieldLoc;
jclass g_namesDataSourceClassID;
jmethodID g_namesDataSourceConstructorID;
jobject ToJavaFeatureCategory(JNIEnv * env, osm::NewFeatureCategories::TName const & category)
{
return env->NewObject(g_featureCategoryClazz, g_featureCtor, category.second,
jni::TScopedLocalRef(env, jni::ToJavaString(env, category.first)).get());
}
jobject ToJavaName(JNIEnv * env, osm::LocalizedName const & name)
{
jni::TScopedLocalRef jName(env, jni::ToJavaString(env, name.m_name));
jni::TScopedLocalRef jLang(env, jni::ToJavaString(env, name.m_lang));
jni::TScopedLocalRef jLangName(env, jni::ToJavaString(env, name.m_langName));
return env->NewObject(g_localNameClazz, g_localNameCtor, name.m_code,
jName.get(), jLang.get(), jLangName.get());
}
jobject ToJavaStreet(JNIEnv * env, osm::LocalizedStreet const & street)
{
return env->NewObject(g_localStreetClazz, g_localStreetCtor,
jni::TScopedLocalRef(env, jni::ToJavaString(env, street.m_defaultName)).get(),
jni::TScopedLocalRef(env, jni::ToJavaString(env, street.m_localizedName)).get());
}
osm::NewFeatureCategories & GetFeatureCategories()
{
static osm::NewFeatureCategories categories = g_framework->NativeFramework()->GetEditorCategories();
return categories;
}
} // namespace
extern "C"
{
using osm::Editor;
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeInit(JNIEnv * env, jclass)
{
g_featureCategoryClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/editor/data/FeatureCategory");
// FeatureCategory(int category, String name)
g_featureCtor = jni::GetConstructorID(env, g_featureCategoryClazz, "(ILjava/lang/String;)V");
g_localNameClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/editor/data/LocalizedName");
// LocalizedName(int code, @NonNull String name, @NonNull String lang, @NonNull String langName)
g_localNameCtor = jni::GetConstructorID(env, g_localNameClazz, "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
g_localNameFieldCode = env->GetFieldID(g_localNameClazz, "code", "I");
g_localNameFieldName = env->GetFieldID(g_localNameClazz, "name", "Ljava/lang/String;");
g_localStreetClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/editor/data/LocalizedStreet");
// LocalizedStreet(@NonNull String defaultName, @NonNull String localizedName)
g_localStreetCtor = jni::GetConstructorID(env, g_localStreetClazz, "(Ljava/lang/String;Ljava/lang/String;)V");
g_localStreetFieldDef = env->GetFieldID(g_localStreetClazz, "defaultName", "Ljava/lang/String;");
g_localStreetFieldLoc = env->GetFieldID(g_localStreetClazz, "localizedName", "Ljava/lang/String;");
g_namesDataSourceClassID = jni::GetGlobalClassRef(env, "com/mapswithme/maps/editor/data/NamesDataSource");
g_namesDataSourceConstructorID = jni::GetConstructorID(env, g_namesDataSourceClassID, "([Lcom/mapswithme/maps/editor/data/LocalizedName;I)V");
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetOpeningHours(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetOpeningHours());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetOpeningHours(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetOpeningHours(jni::ToNativeString(env, value));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetPhone(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetPhone());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetPhone(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetPhone(jni::ToNativeString(env, value));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetWebsite(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetWebsite());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetWebsite(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetWebsite(jni::ToNativeString(env, value));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetEmail(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetEmail());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetEmail(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetEmail(jni::ToNativeString(env, value));
}
JNIEXPORT jint JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetStars(JNIEnv * env, jclass)
{
return g_editableMapObject.GetStars();
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetStars(JNIEnv * env, jclass, jint value)
{
g_editableMapObject.SetStars(value);
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetOperator(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetOperator());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetOperator(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetOperator(jni::ToNativeString(env, value));
}
JNIEXPORT jdouble JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetElevation(JNIEnv * env, jclass)
{
double elevation;
return g_editableMapObject.GetElevation(elevation) ? elevation : -1;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetElevation(JNIEnv * env, jclass, jdouble value)
{
g_editableMapObject.SetElevation(value);
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetWikipedia(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetWikipedia());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetWikipedia(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetWikipedia(jni::ToNativeString(env, value));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetFlats(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetFlats());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetFlats(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetFlats(jni::ToNativeString(env, value));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetBuildingLevels(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetBuildingLevels());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetBuildingLevels(JNIEnv * env, jclass, jstring value)
{
g_editableMapObject.SetBuildingLevels(jni::ToNativeString(env, value));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetZipCode(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetPostcode());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetZipCode(JNIEnv * env, jclass clazz, jstring value)
{
g_editableMapObject.SetPostcode(jni::ToNativeString(env, value));
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeHasWifi(JNIEnv *, jclass)
{
return g_editableMapObject.GetInternet() == osm::Internet::Wlan;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetHasWifi(JNIEnv *, jclass, jboolean hasWifi)
{
g_editableMapObject.SetInternet(hasWifi ? osm::Internet::Wlan : osm::Internet::Unknown);
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSaveEditedFeature(JNIEnv *, jclass)
{
switch (g_framework->NativeFramework()->SaveEditedMapObject(g_editableMapObject))
{
case osm::Editor::NothingWasChanged:
case osm::Editor::SavedSuccessfully:
return true;
case osm::Editor::NoFreeSpaceError:
return false;
}
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeShouldShowEditPlace(JNIEnv *, jclass)
{
return g_framework->GetPlacePageInfo().ShouldShowEditPlace();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeShouldShowAddPlace(JNIEnv *, jclass)
{
return g_framework->GetPlacePageInfo().ShouldShowAddPlace();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeShouldShowAddBusiness(JNIEnv *, jclass)
{
return g_framework->GetPlacePageInfo().ShouldShowAddBusiness();
}
JNIEXPORT jintArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetEditableFields(JNIEnv * env, jclass clazz)
{
auto const & editable = g_editableMapObject.GetEditableFields();
int const size = editable.size();
jintArray jEditableFields = env->NewIntArray(size);
jint * arr = env->GetIntArrayElements(jEditableFields, 0);
for (int i = 0; i < size; ++i)
arr[i] = editable[i];
env->ReleaseIntArrayElements(jEditableFields, arr, 0);
return jEditableFields;
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsAddressEditable(JNIEnv * env, jclass clazz)
{
return g_editableMapObject.IsAddressEditable();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsNameEditable(JNIEnv * env, jclass clazz)
{
return g_editableMapObject.IsNameEditable();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsBuilding(JNIEnv * env, jclass clazz)
{
return g_editableMapObject.IsBuilding();
}
JNIEXPORT jobject JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetNamesDataSource(JNIEnv * env, jclass)
{
auto const namesDataSource = g_editableMapObject.GetNamesDataSource();
jobjectArray names = jni::ToJavaArray(env, g_localNameClazz, namesDataSource.names, ToJavaName);
jint mandatoryNamesCount = namesDataSource.mandatoryNamesCount;
return env->NewObject(g_namesDataSourceClassID, g_namesDataSourceConstructorID, names, mandatoryNamesCount);
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetNames(JNIEnv * env, jclass, jobjectArray names)
{
int const length = env->GetArrayLength(names);
for (int i = 0; i < length; i++)
{
auto jName = env->GetObjectArrayElement(names, i);
g_editableMapObject.SetName(jni::ToNativeString(env, static_cast<jstring>(env->GetObjectField(jName, g_localNameFieldName))),
env->GetIntField(jName, g_localNameFieldCode));
}
}
JNIEXPORT jobject JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetStreet(JNIEnv * env, jclass)
{
return ToJavaStreet(env, g_editableMapObject.GetStreet());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetStreet(JNIEnv * env, jclass, jobject street)
{
g_editableMapObject.SetStreet({jni::ToNativeString(env, (jstring) env->GetObjectField(street, g_localStreetFieldDef)),
jni::ToNativeString(env, (jstring) env->GetObjectField(street, g_localStreetFieldLoc))});
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetNearbyStreets(JNIEnv * env, jclass clazz)
{
return jni::ToJavaArray(env, g_localStreetClazz, g_editableMapObject.GetNearbyStreets(), ToJavaStreet);
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetSupportedLanguages(JNIEnv * env, jclass clazz)
{
using TLang = StringUtf8Multilang::Lang;
//public Language(@NonNull String code, @NonNull String name)
static jclass const langClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/editor/data/Language");
static jmethodID const langCtor = jni::GetConstructorID(env, langClass, "(Ljava/lang/String;Ljava/lang/String;)V");
return jni::ToJavaArray(env, langClass, StringUtf8Multilang::GetSupportedLanguages(),
[](JNIEnv * env, TLang const & lang)
{
jni::TScopedLocalRef const code(env, jni::ToJavaString(env, lang.m_code));
jni::TScopedLocalRef const name(env, jni::ToJavaString(env, lang.m_name));
return env->NewObject(langClass, langCtor, code.get(), name.get());
});
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetHouseNumber(JNIEnv * env, jclass)
{
return jni::ToJavaString(env, g_editableMapObject.GetHouseNumber());
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetHouseNumber(JNIEnv * env, jclass, jstring houseNumber)
{
g_editableMapObject.SetHouseNumber(jni::ToNativeString(env, houseNumber));
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeHasSomethingToUpload(JNIEnv * env, jclass clazz)
{
return Editor::Instance().HaveMapEditsOrNotesToUpload();
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeUploadChanges(JNIEnv * env, jclass clazz, jstring token, jstring secret,
jstring appVersion, jstring appId)
{
// TODO: Handle upload status in callback
Editor::Instance().UploadChanges(jni::ToNativeString(env, token), jni::ToNativeString(env, secret),
{{"created_by", "MAPS.ME " OMIM_OS_NAME " " + jni::ToNativeString(env, appVersion)},
{"bundle_id", jni::ToNativeString(env, appId)}}, nullptr);
}
JNIEXPORT jlongArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetStats(JNIEnv * env, jclass clazz)
{
auto const stats = Editor::Instance().GetStats();
jlongArray result = env->NewLongArray(3);
jlong buf[] = {stats.m_edits.size(), stats.m_uploadedCount, stats.m_lastUploadTimestamp};
env->SetLongArrayRegion(result, 0, 3, buf);
return result;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeClearLocalEdits(JNIEnv * env, jclass clazz)
{
Editor::Instance().ClearAllLocalEdits();
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeStartEdit(JNIEnv *, jclass)
{
::Framework * frm = g_framework->NativeFramework();
place_page::Info const & info = g_framework->GetPlacePageInfo();
CHECK(frm->GetEditableMapObject(info.GetID(), g_editableMapObject), ("Invalid feature in the place page."));
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeCreateMapObject(JNIEnv *, jclass, jint featureCategory)
{
::Framework * frm = g_framework->NativeFramework();
CHECK(frm->CreateMapObject(frm->GetViewportCenter(), featureCategory, g_editableMapObject),
("Couldn't create mapobject, wrong coordinates of missing mwm"));
}
// static void nativeCreateNote(String text);
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeCreateNote(JNIEnv * env, jclass clazz, jstring text)
{
g_framework->NativeFramework()->CreateNote(g_editableMapObject.GetLatLon(), g_editableMapObject.GetID(),
osm::Editor::NoteProblemType::General, jni::ToNativeString(env, text));
}
// static void nativePlaceDoesNotExist(String comment);
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativePlaceDoesNotExist(JNIEnv * env, jclass clazz, jstring comment)
{
g_framework->NativeFramework()->CreateNote(g_editableMapObject.GetLatLon(), g_editableMapObject.GetID(),
osm::Editor::NoteProblemType::PlaceDoesNotExist, jni::ToNativeString(env, comment));
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeRollbackMapObject(JNIEnv * env, jclass clazz)
{
g_framework->NativeFramework()->RollBackChanges(g_editableMapObject.GetID());
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetAllFeatureCategories(JNIEnv * env, jclass clazz, jstring jLang)
{
string const & lang = jni::ToNativeString(env, jLang);
GetFeatureCategories().AddLanguage(lang);
return jni::ToJavaArray(env, g_featureCategoryClazz,
GetFeatureCategories().GetAllCategoryNames(lang),
ToJavaFeatureCategory);
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSearchFeatureCategories(JNIEnv * env, jclass clazz, jstring query, jstring jLang)
{
string const & lang = jni::ToNativeString(env, jLang);
GetFeatureCategories().AddLanguage(lang);
return jni::ToJavaArray(env, g_featureCategoryClazz,
GetFeatureCategories().Search(jni::ToNativeString(env, query), lang),
ToJavaFeatureCategory);
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetCuisines(JNIEnv * env, jclass clazz)
{
osm::TAllCuisines const & cuisines = osm::Cuisines::Instance().AllSupportedCuisines();
vector<string> keys;
keys.reserve(cuisines.size());
for (TCuisine const & cuisine : cuisines)
keys.push_back(cuisine.first);
return jni::ToJavaStringArray(env, keys);
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetSelectedCuisines(JNIEnv * env, jclass clazz)
{
return jni::ToJavaStringArray(env, g_editableMapObject.GetCuisines());
}
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeTranslateCuisines(JNIEnv * env, jclass clazz, jobjectArray jKeys)
{
int const length = env->GetArrayLength(jKeys);
vector<string> translations;
translations.reserve(length);
for (int i = 0; i < length; i++)
{
string const & key = jni::ToNativeString(env, (jstring) env->GetObjectArrayElement(jKeys, i));
translations.push_back(osm::Cuisines::Instance().Translate(key));
}
return jni::ToJavaStringArray(env, translations);
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeSetSelectedCuisines(JNIEnv * env, jclass clazz, jobjectArray jKeys)
{
int const length = env->GetArrayLength(jKeys);
vector<string> cuisines;
cuisines.reserve(length);
for (int i = 0; i < length; i++)
cuisines.push_back(jni::ToNativeString(env, (jstring) env->GetObjectArrayElement(jKeys, i)));
g_editableMapObject.SetCuisines(cuisines);
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetFormattedCuisine(JNIEnv * env, jclass clazz)
{
return jni::ToJavaString(env, g_editableMapObject.FormatCuisines());
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetMwmName(JNIEnv * env, jclass clazz)
{
return jni::ToJavaString(env, g_editableMapObject.GetID().GetMwmName());
}
JNIEXPORT jlong JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetMwmVersion(JNIEnv * env, jclass clazz)
{
return g_editableMapObject.GetID().GetMwmVersion();
}
// static boolean nativeIsHouseValid(String houseNumber);
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsHouseValid(JNIEnv * env, jclass clazz, jstring houseNumber)
{
return osm::EditableMapObject::ValidateHouseNumber(jni::ToNativeString(env, houseNumber));
}
// static boolean nativeIsLevelValid(String level);
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsLevelValid(JNIEnv * env, jclass clazz, jstring level)
{
return osm::EditableMapObject::ValidateBuildingLevels(jni::ToNativeString(env, level));
}
// static boolean nativeIsFlatValid(String flats)
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsFlatValid(JNIEnv * env, jclass clazz, jstring flats)
{
return osm::EditableMapObject::ValidateFlats(jni::ToNativeString(env, flats));
}
// static boolean nativeIsPostCodeValid(String zipCode)
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsZipcodeValid(JNIEnv * env, jclass clazz, jstring zipCode)
{
return osm::EditableMapObject::ValidatePostCode(jni::ToNativeString(env, zipCode));
}
// static boolean nativeIsPhoneValid(String phone)
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsPhoneValid(JNIEnv * env, jclass clazz, jstring phone)
{
return osm::EditableMapObject::ValidatePhone(jni::ToNativeString(env, phone));
}
// static boolean nativeIsWebsiteValid(String website)
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsWebsiteValid(JNIEnv * env, jclass clazz, jstring website)
{
return osm::EditableMapObject::ValidateWebsite(jni::ToNativeString(env, website));
}
// static boolean nativeIsEmailValid(String email)
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsEmailValid(JNIEnv * env, jclass clazz, jstring email)
{
return osm::EditableMapObject::ValidateEmail(jni::ToNativeString(env, email));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetCategory(JNIEnv * env, jclass clazz)
{
return jni::ToJavaString(env, g_editableMapObject.GetLocalizedType());
}
// @FeatureStatus
// static native int nativeGetMapObjectStatus();
JNIEXPORT jint JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeGetMapObjectStatus(JNIEnv * env, jclass clazz)
{
return static_cast<jint>(osm::Editor::Instance().GetFeatureStatus(g_editableMapObject.GetID()));
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeIsMapObjectUploaded(JNIEnv * env, jclass clazz)
{
return osm::Editor::Instance().IsFeatureUploaded(g_editableMapObject.GetID().m_mwmId, g_editableMapObject.GetID().m_index);
}
// static nativeMakeLocalizedName(String langCode, String name);
JNIEXPORT jobject JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeMakeLocalizedName(JNIEnv * env, jclass clazz, jstring code, jstring name)
{
osm::LocalizedName localizedName(jni::ToNativeString(env, code), jni::ToNativeString(env, name));
return ToJavaName(env, localizedName);
}
} // extern "C"
|