/[zanavi_public1]/navit/navit/android.c
ZANavi

Diff of /navit/navit/android.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 28 Revision 29
285// ------------------------- COPIED STUFF --- this is generally bad ------------------ 285// ------------------------- COPIED STUFF --- this is generally bad ------------------
286 286
287 287
288 288
289 289
290JavaVM *cachedJVM = NULL;
290 291
292JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved)
293{
294 JNIEnv *env_this;
295 cachedJVM = jvm;
296 if ((*jvm)->GetEnv(jvm, (void**)&env_this, JNI_VERSION_1_6))
297 {
298 dbg(0,"Could not get JVM\n");
299 return JNI_ERR;
300 }
301
302 dbg(0,"++ Found JWM ++\n");
303 return JNI_VERSION_1_6;
304}
305
306JNIEnv* jni_getenv()
307{
308 JNIEnv* env_this;
309 (*cachedJVM)->GetEnv(cachedJVM, (void**)&env_this, JNI_VERSION_1_6);
310 return env_this;
311}
291 312
292 313
293static void gui_internal_search_list_set_default_country2(struct gui_priv *this) 314static void gui_internal_search_list_set_default_country2(struct gui_priv *this)
294{ 315{
295#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 316#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
552 pc.y = c.y; 573 pc.y = c.y;
553 pc.pro = transform_get_projection(global_navit->trans); 574 pc.pro = transform_get_projection(global_navit->trans);
554 navit_set_position(global_navit, &pc); 575 navit_set_position(global_navit, &pc);
555 */ 576 */
556 577
578 dbg(0,"call async java draw -start-\n");
557 navit_draw(global_navit); 579 navit_draw(global_navit);
580 // navit_draw_async(global_navit, 1);
581 dbg(0,"call async java draw --end--\n");
582
583 // remove the "wait" screen
584#ifdef HAVE_API_ANDROID
585 android_return_generic_int(2, 0);
586#endif
587
558} 588}
559 589
560 590
561JNIEXPORT void JNICALL 591JNIEXPORT void JNICALL
562Java_com_zoffcc_applications_zanavi_NavitTimeout_TimeoutCallback(JNIEnv* env, jobject thiz, int delete, int id) 592Java_com_zoffcc_applications_zanavi_NavitTimeout_TimeoutCallback(JNIEnv* env, jobject thiz, int delete, int id)
570 callback_call_0((struct callback *) id); 600 callback_call_0((struct callback *) id);
571 // ICS 601 // ICS
572 //dbg(0,"timeout 2\n"); 602 //dbg(0,"timeout 2\n");
573 if (delete) 603 if (delete)
574 { 604 {
575 //dbg(0,"timeout 3\n"); 605 dbg(0,"timeout 3\n");
576 // ICS 606 // ICS
607 jobject this_global = (*jnienv)->NewGlobalRef(jnienv, thiz);
608 dbg(0,"timeout 3.1\n");
577 (*jnienv)->DeleteGlobalRef(jnienv, thiz); 609 (*jnienv)->DeleteGlobalRef(jnienv, this_global);
578 // ICS 610 // ICS
579 //dbg(0,"timeout 4\n"); 611 dbg(0,"timeout 4\n");
580 } 612 }
581} 613}
582 614
583JNIEXPORT void JNICALL 615JNIEXPORT void JNICALL
584Java_com_zoffcc_applications_zanavi_NavitIdle_IdleCallback(JNIEnv* env, jobject thiz, int id) 616Java_com_zoffcc_applications_zanavi_NavitIdle_IdleCallback(JNIEnv* env, jobject thiz, int id)
675{ 707{
676#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 708#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
677 dbg(0,"+#+:enter\n"); 709 dbg(0,"+#+:enter\n");
678#endif 710#endif
679 //DBG dbg(0,"Enter\n"); 711 //DBG dbg(0,"Enter\n");
712
713 JNIEnv *jnienv2;
714 jnienv2 = jni_getenv();
715
680 if (NavitGraphicsClass2 == NULL) 716 if (NavitGraphicsClass2 == NULL)
681 { 717 {
682 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2)) 718 if (!android_find_class_global("com/zoffcc/applications/zanavi/NavitGraphics", &NavitGraphicsClass2))
683 { 719 {
684 NavitGraphicsClass2 = NULL; 720 NavitGraphicsClass2 = NULL;
695 { 731 {
696 //DBG dbg(0, "no method found\n"); 732 //DBG dbg(0, "no method found\n");
697 return; /* exception thrown */ 733 return; /* exception thrown */
698 } 734 }
699 //DBG dbg(0,"xa1\n"); 735 //DBG dbg(0,"xa1\n");
700 // -crash- (*jnienv)->CallVoidMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); 736 // -crash- (*jnienv2)->CallVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
701 (*jnienv)->CallStaticVoidMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); 737 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
702 // -works- (*jnienv)->CallStaticObjectMethod(jnienv, NavitGraphicsClass2, return_generic_int, id, i); 738 // -works- (*jnienv2)->CallStaticObjectMethod(jnienv2, NavitGraphicsClass2, return_generic_int, id, i);
703 //DBG dbg(0,"xa2\n"); 739 //DBG dbg(0,"xa2\n");
704} 740}
705 741
706JNIEXPORT void JNICALL 742JNIEXPORT void JNICALL
707Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList(JNIEnv* env, jobject thiz, int id, int partial, jobject str, int search_flags, jobject search_country, jobject latlon, int radius) 743Java_com_zoffcc_applications_zanavi_NavitGraphics_CallbackSearchResultList(JNIEnv* env, jobject thiz, int id, int partial, jobject str, int search_flags, jobject search_country, jobject latlon, int radius)
1413 c24.x = c22.x; 1449 c24.x = c22.x;
1414 c24.y = c22.y; 1450 c24.y = c22.y;
1415 c24.pro = transform_get_projection(global_navit->trans); 1451 c24.pro = transform_get_projection(global_navit->trans);
1416 result = navit_find_nearest_street_coords(global_navit->mapsets->data, &c24); 1452 result = navit_find_nearest_street_coords(global_navit->mapsets->data, &c24);
1417 } 1453 }
1418 1454 else if (i == 8)
1455 {
1456 // input: x,y pixel on screen
1457 // output: nearest street or housenumber
1458 struct coord c22;
1459 struct point p;
1460 struct pcoord c24;
1461 p.x = a;
1462 p.y = b;
1463 transform_reverse(global_navit->trans, &p, &c22);
1464 c24.x = c22.x;
1465 c24.y = c22.y;
1466 c24.pro = transform_get_projection(global_navit->trans);
1467 result = navit_find_nearest_street_hn(global_navit->mapsets->data, &c24);
1468 }
1469 else if (i == 9)
1470 {
1471 // input: x,y pixel on screen
1472 // output: item dump of nearest item
1473 struct coord c22;
1474 struct point p;
1475 struct pcoord c24;
1476 p.x = a;
1477 p.y = b;
1478 transform_reverse(global_navit->trans, &p, &c22);
1479 c24.x = c22.x;
1480 c24.y = c22.y;
1481 c24.pro = transform_get_projection(global_navit->trans);
1482 result = navit_find_nearest_item_dump(global_navit->mapsets->data, &c24, 0);
1483 }
1484 else if (i == 10)
1485 {
1486 // input: x,y pixel on screen
1487 // output: item dump of nearest item (pretty output to show to user)
1488 struct coord c22;
1489 struct point p;
1490 struct pcoord c24;
1491 p.x = a;
1492 p.y = b;
1493 transform_reverse(global_navit->trans, &p, &c22);
1494 c24.x = c22.x;
1495 c24.y = c22.y;
1496 c24.pro = transform_get_projection(global_navit->trans);
1497 result = navit_find_nearest_item_dump(global_navit->mapsets->data, &c24, 1);
1498 }
1419 1499
1420 // dbg(0, "result=%s\n", result); 1500 // dbg(0, "result=%s\n", result);
1421 jstring js = (*env)->NewStringUTF(env, result); 1501 jstring js = (*env)->NewStringUTF(env, result);
1422 g_free(result); 1502 g_free(result);
1423 1503
2129 navit_set_destination(global_navit, &pc, name, 1); 2209 navit_set_destination(global_navit, &pc, name, 1);
2130 2210
2131 } 2211 }
2132 } 2212 }
2133 2213
2134 //DBG dbg(0,"deleteglobalref\n"); 2214 // dbg(0,"deleteglobalref\n");
2135 2215
2136 (*env)->DeleteGlobalRef(env, str); 2216 (*env)->DeleteGlobalRef(env, str);
2137 str = NULL; 2217 str = NULL;
2138 2218
2139 //DBG dbg(0,"leave\n"); 2219 // dbg(0,"leave\n");
2140 2220
2141} 2221}
2142 2222
2143void android_send_generic_text(int id, char *text) 2223void android_send_generic_text(int id, char *text)
2144{ 2224{
2166 //DBG dbg(0, "no method found\n"); 2246 //DBG dbg(0, "no method found\n");
2167 return; /* exception thrown */ 2247 return; /* exception thrown */
2168 } 2248 }
2169 //DBG dbg(0,"x3\n"); 2249 //DBG dbg(0,"x3\n");
2170 2250
2251 JNIEnv *jnienv2;
2252 jnienv2 = jni_getenv();
2253
2171 jstring string1 = (*jnienv)->NewStringUTF(jnienv, text); 2254 jstring string1 = (*jnienv2)->NewStringUTF(jnienv2, text);
2172 (*jnienv)->CallStaticVoidMethod(jnienv, NavitGraphicsClass2, send_generic_text, id, string1); 2255 (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, send_generic_text, id, string1);
2173 (*jnienv)->DeleteLocalRef(jnienv, string1); 2256 (*jnienv2)->DeleteLocalRef(jnienv2, string1);
2174 2257
2175 //DBG dbg(0,"leave\n"); 2258 //DBG dbg(0,"leave\n");
2176} 2259}
2177 2260

Legend:
Removed from v.28  
changed lines
  Added in v.29

   
Visit the ZANavi Wiki