/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitAndroidOverlay.java
ZANavi

Contents of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitAndroidOverlay.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Mon Feb 4 17:41:59 2013 UTC (11 years, 1 month ago) by zoff99
File size: 29954 byte(s)
new map version, lots of fixes and experimental new features
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011 -2012 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2008 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38
39 package com.zoffcc.applications.zanavi;
40
41 import android.content.Context;
42 import android.content.DialogInterface;
43 import android.graphics.Canvas;
44 import android.graphics.Color;
45 import android.graphics.Paint;
46 import android.graphics.Paint.Style;
47 import android.graphics.RectF;
48 import android.os.Bundle;
49 import android.os.Message;
50 import android.view.MotionEvent;
51 import android.widget.ImageView;
52
53 public class NavitAndroidOverlay extends ImageView
54 {
55 public Boolean draw_bubble = false;
56 public static Boolean confirmed_bubble = false;
57 public static int confirmed_bubble_part = 0; // 0 -> left side, 1 -> right side
58 public long bubble_showing_since = 0L;
59 public static long bubble_max_showing_timespan = 8000L; // 8 secs.
60 public RectF follow_button_rect = new RectF(-100, 1, 1, 1);
61 public RectF zoomin_button_rect = new RectF(-100, 1, 1, 1);
62 public RectF zoomout_button_rect = new RectF(-100, 1, 1, 1);
63 public RectF mapdrawing_button_rect = new RectF(-100, 1, 1, 1);
64 public static int zoomin_ltx = 0;
65 public static int zoomin_lty = 0;
66 public static int zoomout_ltx = 0;
67 public static int zoomout_lty = 0;
68 public static int mapdrawing_ltx = 0;
69 public static int mapdrawing_lty = 0;
70 public int mCanvasHeight = 1;
71 public int mCanvasWidth = 1;
72 public static float draw_factor = 1.0f;
73
74 public static BubbleThread bubble_thread = null;
75
76 public static NavitGraphics.OverlayDrawThread overlay_draw_thread1;
77
78 private class BubbleThread extends Thread
79 {
80 private Boolean running;
81 private long bubble_showing_since = 0L;
82 private NavitAndroidOverlay a_overlay = null;
83
84 BubbleThread(NavitAndroidOverlay a_ov)
85 {
86 this.running = true;
87 this.a_overlay = a_ov;
88 this.bubble_showing_since = System.currentTimeMillis();
89 //Log.e("Navit", "BubbleThread created");
90 }
91
92 public void stop_me()
93 {
94 this.running = false;
95 }
96
97 public void run()
98 {
99 // Log.e("Navit", "BubbleThread started");
100 while (this.running)
101 {
102 if ((System.currentTimeMillis() - this.bubble_showing_since) > bubble_max_showing_timespan)
103 {
104 //Log.e("Navit", "BubbleThread: bubble displaying too long, hide it");
105 // with invalidate we call the onDraw() function, that will take care of it
106 //System.out.println("invalidate 001");
107 this.a_overlay.postInvalidate();
108 this.running = false;
109 }
110 else
111 {
112 try
113 {
114 Thread.sleep(280);
115 }
116 catch (InterruptedException e)
117 {
118 // e.printStackTrace();
119 }
120 }
121 }
122 //Log.e("Navit", "BubbleThread ended");
123 }
124 }
125
126 public static class NavitAndroidOverlayBubble
127 {
128 int x;
129 int y;
130 String text = null;
131 }
132
133 private NavitAndroidOverlayBubble bubble_001 = null;
134
135 public NavitAndroidOverlay(Context context)
136 {
137 super(context);
138 }
139
140 public void show_bubble()
141 {
142 //System.out.println("NavitAndroidOverlay -> show_bubble");
143 if (!this.draw_bubble)
144 {
145 confirmed_bubble = false;
146 this.draw_bubble = true;
147 this.bubble_showing_since = System.currentTimeMillis();
148 bubble_thread = new BubbleThread(this);
149 bubble_thread.start();
150
151 // test test DEBUG
152 /*
153 * Message msg = new Message();
154 * Bundle b = new Bundle();
155 * b.putInt("Callback", 4);
156 * b.putInt("x", this.bubble_001.x);
157 * b.putInt("y", this.bubble_001.y);
158 * msg.setData(b);
159 * Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
160 */
161 }
162 }
163
164 public Boolean get_show_bubble()
165 {
166 return this.draw_bubble;
167 }
168
169 public void hide_bubble()
170 {
171 // Log.e("NavitGraphics", "NavitAndroidOverlay -> hide_bubble");
172 confirmed_bubble = false;
173 this.draw_bubble = false;
174 this.bubble_showing_since = 0L;
175 try
176 {
177 bubble_thread.stop_me();
178 // bubble_thread.stop();
179 }
180 catch (Exception e)
181 {
182
183 }
184 //this.postInvalidate();
185 }
186
187 public void set_bubble(NavitAndroidOverlayBubble b)
188 {
189 this.bubble_001 = b;
190 }
191
192 @Override
193 public boolean onTouchEvent(MotionEvent event)
194 {
195 //if (NavitGraphics.wait_for_redraw_map == true)
196 //{
197 // Log.e("NavitGraphics", "GD NavitAndroidOverlay GD -> onTouchEvent");
198 // Message msg = new Message();
199 // Bundle b = new Bundle();
200 // b.putInt("Callback", 50);
201 // msg.setData(b);
202 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
203 //}
204 //else
205 //{
206 // // Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent");
207 //}
208 super.onTouchEvent(event);
209
210 int action = event.getAction();
211 int x = (int) event.getX();
212 int y = (int) event.getY();
213
214 //Log.e("NavitGraphics", "NavitAndroidOverlay -> action=" + action);
215
216 //if (action == MotionEvent.ACTION_UP)
217 //{
218 // Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent ACTION_UP");
219 // if (NavitGraphics.in_map)
220 // {
221 // return false;
222 // }
223 //}
224
225 if (action == MotionEvent.ACTION_DOWN)
226 {
227 if ((this.draw_bubble) && (!confirmed_bubble))
228 {
229 int dx = (int) ((20 / 1.5f) * draw_factor);
230 int dy = (int) ((-100 / 1.5f) * draw_factor);
231 int bubble_size_x = (int) ((150 / 1.5f) * draw_factor);
232 int bubble_size_y = (int) ((60 / 1.5f) * draw_factor);
233 RectF box_rect_left = new RectF(this.bubble_001.x + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x / 2 + dx, this.bubble_001.y + bubble_size_y + dy);
234 RectF box_rect_right = new RectF(this.bubble_001.x + bubble_size_x / 2 + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy);
235 if (box_rect_left.contains(x, y))
236 {
237 // bubble touched to confirm destination
238 confirmed_bubble = true;
239 confirmed_bubble_part = 0;
240 // draw confirmed bubble
241 //System.out.println("invalidate 002");
242 this.postInvalidate();
243 String dest_name = "Point on Screen";
244
245 // remeber recent dest.
246 try
247 {
248 dest_name = NavitGraphics.CallbackGeoCalc(8, this.bubble_001.x, this.bubble_001.y);
249 // System.out.println("x:"+dest_name+":y");
250 if ((dest_name.equals(" ")) || (dest_name == null))
251 {
252 dest_name = "Point on Screen";
253 }
254
255 Navit.remember_destination_xy(dest_name, this.bubble_001.x, this.bubble_001.y);
256 }
257 catch (Exception e)
258 {
259 e.printStackTrace();
260 }
261
262 // DEBUG: clear route rectangle list
263 NavitGraphics.route_rects.clear();
264
265 if (NavitGraphics.navit_route_status == 0)
266 {
267 Navit.destination_set();
268
269 Message msg = new Message();
270 Bundle b = new Bundle();
271 b.putInt("Callback", 4);
272 b.putInt("x", this.bubble_001.x);
273 b.putInt("y", this.bubble_001.y);
274 msg.setData(b);
275 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
276 }
277 else
278 {
279 Message msg = new Message();
280 Bundle b = new Bundle();
281 b.putInt("Callback", 49);
282 b.putInt("x", this.bubble_001.x);
283 b.putInt("y", this.bubble_001.y);
284 msg.setData(b);
285 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
286 }
287
288 // try
289 // {
290 // Navit.follow_button_on();
291 // }
292 // catch (Exception e2)
293 // {
294 // e2.printStackTrace();
295 // }
296
297 // consume the event
298 return true;
299 }
300 else if (box_rect_right.contains(x, y))
301 {
302 // bubble touched to confirm destination
303 confirmed_bubble = true;
304 confirmed_bubble_part = 1;
305 // draw confirmed bubble
306 //System.out.println("invalidate 003");
307 this.postInvalidate();
308
309 // whats here?
310 String item_dump_pretty = NavitGraphics.CallbackGeoCalc(10, this.bubble_001.x, this.bubble_001.y);
311 try
312 {
313 String item_dump_pretty_parsed = "";
314 String[] item_dump_lines = item_dump_pretty.split("\n");
315 int jk = 0;
316 String sep = "";
317 for (jk = 0; jk < item_dump_lines.length; jk++)
318 {
319 if (item_dump_lines[jk].startsWith("+*TYPE*+:"))
320 {
321 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(9);
322 }
323 else if (item_dump_lines[jk].startsWith("flags="))
324 {
325
326 }
327 else if (item_dump_lines[jk].startsWith("maxspeed="))
328 {
329 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
330 }
331 else if (item_dump_lines[jk].startsWith("label="))
332 {
333 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(6);
334 }
335 else if (item_dump_lines[jk].startsWith("street_name="))
336 {
337 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(12);
338 }
339 else if (item_dump_lines[jk].startsWith("street_name_systematic="))
340 {
341 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(23);
342 }
343 else
344 {
345 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
346 }
347
348 if (jk == 0)
349 {
350 sep = "\n";
351 }
352 }
353
354 Navit.generic_alert_box.setMessage(item_dump_pretty_parsed).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
355 {
356 public void onClick(DialogInterface dialog, int id)
357 {
358 // Handle Ok
359 }
360 }).create();
361 Navit.generic_alert_box.setCancelable(true);
362 Navit.generic_alert_box.setTitle(Navit.get_text("What's here")); // TRANS
363 Navit.generic_alert_box.show();
364 }
365 catch (Exception e)
366 {
367 e.printStackTrace();
368 }
369
370 return true;
371 }
372
373 }
374 }
375
376 if (action == MotionEvent.ACTION_DOWN)
377 {
378 //Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent ACTION_DOWN");
379 if (this.follow_button_rect.contains(x, y))
380 {
381 if (NavitGraphics.in_map)
382 {
383 // toggle follow mode
384 Navit.toggle_follow_button();
385 //System.out.println("invalidate 004");
386 this.postInvalidate();
387 // consume the event
388 return true;
389 }
390 }
391 else if (this.mapdrawing_button_rect.contains(x, y))
392 {
393 if (NavitGraphics.in_map)
394 {
395 try
396 {
397 Message msg = new Message();
398 Bundle b = new Bundle();
399 if (NavitGraphics.MAP_DISPLAY_OFF)
400 {
401 NavitGraphics.MAP_DISPLAY_OFF = false;
402 b.putInt("Callback", 63);
403 }
404 else
405 {
406 NavitGraphics.MAP_DISPLAY_OFF = true;
407 b.putInt("Callback", 62);
408 }
409 msg.setData(b);
410 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
411 // redraw map
412 Message msg2 = new Message();
413 Bundle b2 = new Bundle();
414 b2.putInt("Callback", 64);
415 msg2.setData(b2);
416 Navit.N_NavitGraphics.callback_handler.sendMessage(msg2);
417
418 }
419 catch (Exception e)
420 {
421 e.printStackTrace();
422 }
423 // consume the event
424 return true;
425 }
426 }
427 else if (this.zoomin_button_rect.contains(x, y))
428 {
429 if (NavitGraphics.in_map)
430 {
431 try
432 {
433 if (overlay_draw_thread1 == null)
434 {
435 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
436 //overlay_draw_thread1.start();
437 }
438 }
439 catch (Exception e)
440 {
441 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
442 //overlay_draw_thread1.start();
443 }
444
445 // System.out.println("ZZZZZZZZ O.11");
446 // //if (NavitGraphics.wait_for_redraw_map == true)
447 // {
448 // System.out.println("ZZZZZZZZ O.11.A");
449 // // stop drawing the map
450 // try
451 // {
452 // NavitGraphics.CallbackMessageChannel(50, "");
453 // // Message msg = new Message();
454 // // Bundle b = new Bundle();
455 // // b.putInt("Callback", 50);
456 // // msg.setData(b);
457 // // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
458 // }
459 // catch (Exception e)
460 // {
461 // e.printStackTrace();
462 // }
463 // }
464 NavitGraphics.wait_for_redraw_map = true;
465 //System.out.println("invalidate 005");
466 this.invalidate();
467 //System.out.println("wait_for_redraw_map=true o1");
468 //Log.e("NavitGraphics", "wait_for_redraw_map=true o1");
469 // zoom in
470 try
471 {
472 // NavitGraphics.CallbackMessageChannel(1, "");
473 Message msg = new Message();
474 Bundle b = new Bundle();
475 b.putInt("Callback", 1);
476 msg.setData(b);
477 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
478 }
479 catch (Exception e)
480 {
481 e.printStackTrace();
482 }
483 // consume the event
484 return true;
485 }
486 }
487 else if (this.zoomout_button_rect.contains(x, y))
488 {
489 if (NavitGraphics.in_map)
490 {
491 try
492 {
493 if (overlay_draw_thread1 == null)
494 {
495 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
496 //overlay_draw_thread1.start();
497 }
498 }
499 catch (Exception e)
500 {
501 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
502 //overlay_draw_thread1.start();
503 }
504
505 // System.out.println("ZZZZZZZZ O.22");
506 // if (NavitGraphics.wait_for_redraw_map == true)
507 // {
508 // System.out.println("ZZZZZZZZ O.22.A");
509 // // stop drawing the map
510 // try
511 // {
512 // NavitGraphics.CallbackMessageChannel(50, "");
513 // // Message msg = new Message();
514 // // Bundle b = new Bundle();
515 // // b.putInt("Callback", 50);
516 // // msg.setData(b);
517 // // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
518 // }
519 // catch (Exception e)
520 // {
521 // e.printStackTrace();
522 // }
523 // }
524
525 try
526 {
527 NavitGraphics.wait_for_redraw_map = true;
528 //System.out.println("invalidate 006");
529 this.invalidate();
530 //System.out.println("wait_for_redraw_map=true o2");
531 //Log.e("NavitGraphics", "wait_for_redraw_map=true o2");
532 // zoom out
533
534 // NavitGraphics.CallbackMessageChannel(2, "");
535 Message msg = new Message();
536 Bundle b = new Bundle();
537 b.putInt("Callback", 2);
538 msg.setData(b);
539 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
540 }
541 catch (Exception e)
542 {
543 e.printStackTrace();
544 }
545 // consume the event
546 return true;
547 }
548 }
549 else
550 {
551 try
552 {
553 if (overlay_draw_thread1 == null)
554 {
555 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
556 //overlay_draw_thread1.start();
557 }
558 }
559 catch (Exception e)
560 {
561 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
562 //overlay_draw_thread1.start();
563 }
564 }
565 }
566
567 // test if we touched the grey rectangle
568 //
569 // if ((x < 300) && (x > 10) && (y < 200) && (y > 10))
570 // {
571 // Log.e("Navit", "NavitAndroidOverlay -> onTouchEvent -> touch Rect!!");
572 // return true;
573 // }
574 // else
575 // {
576 // return false;
577 // }
578
579 // false -> we dont use this event, give it to other layers
580 return false;
581 }
582
583 @Override
584 public void onSizeChanged(int w, int h, int oldw, int oldh)
585 {
586 // super.onSizeChanged(w, h, oldw, oldh);
587 this.mCanvasWidth = w;
588 this.mCanvasHeight = h;
589
590 draw_factor = 1.0f;
591 if (Navit.my_display_density.compareTo("mdpi") == 0)
592 {
593 draw_factor = 1.0f;
594 }
595 else if (Navit.my_display_density.compareTo("ldpi") == 0)
596 {
597 draw_factor = 0.7f;
598 }
599 else if (Navit.my_display_density.compareTo("hdpi") == 0)
600 {
601 draw_factor = 1.5f;
602 }
603
604 int w_1 = (int) ((10f / 1.5f) * draw_factor);
605 int h_1 = (int) ((200f / 1.5f) * draw_factor);
606 this.follow_button_rect = new RectF(this.mCanvasWidth - Navit.follow_current.getWidth() - w_1, this.mCanvasHeight - Navit.follow_current.getHeight() - h_1, this.mCanvasWidth - w_1, this.mCanvasHeight - h_1);
607
608 /*
609 * int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
610 * int h_2 = (int) ((0f / 1.5f) * draw_factor) + 5;
611 * int h_button_zoom = Navit.zoomin.getHeight();
612 * zoomin_ltx = w_2;
613 * zoomin_lty = h_2;
614 * this.zoomin_button_rect = new RectF(w_2, h_2, Navit.zoomin.getWidth() + w_2, h_button_zoom + h_2);
615 */
616
617 int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
618 int h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25;
619 int h_button_zoom = Navit.zoomin.getHeight();
620 zoomin_ltx = w_2;
621 zoomin_lty = h_2;
622 this.zoomin_button_rect = new RectF(w_2, h_2, Navit.zoomin.getWidth() + w_2, h_button_zoom + h_2);
623
624 w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
625 h_2 = (int) ((2 * 70f / 1.5f) * draw_factor) + 5 + 25 + 25;
626 zoomout_ltx = w_2;
627 zoomout_lty = h_2;
628 this.zoomout_button_rect = new RectF(w_2, h_2, Navit.zoomout.getWidth() + w_2, h_button_zoom + h_2);
629
630 int mapdrawing_width = (int) ((75f / 1.5f) * draw_factor);
631 int mapdrawing_height = (int) ((75f / 1.5f) * draw_factor);
632 w_2 = (int) ((this.mCanvasWidth - mapdrawing_width) - 5);
633 h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25;
634 mapdrawing_ltx = w_2;
635 mapdrawing_lty = h_2;
636 this.mapdrawing_button_rect = new RectF(w_2, h_2, mapdrawing_width + w_2, mapdrawing_height + h_2);
637 }
638
639 public void onDraw(Canvas c)
640 {
641 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
642 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
643 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
644 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
645 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
646 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
647
648 //Log.e("NavitGraphics", "NavitAndroidOverlay -> onDraw");
649 //System.out.println("NavitAndroidOverlay -> onDraw");
650
651 if (this.draw_bubble)
652 {
653 if ((System.currentTimeMillis() - this.bubble_showing_since) > bubble_max_showing_timespan)
654 {
655 // bubble has been showing too log, hide it
656 this.hide_bubble();
657
658 // next lines are a hack, without it screen will not get updated anymore!
659 // next lines are a hack, without it screen will not get updated anymore!
660 // down
661 // Message msg = new Message();
662 // Bundle b = new Bundle();
663 // b.putInt("Callback", 21);
664 // b.putInt("x", 1);
665 // b.putInt("y", 1);
666 // msg.setData(b);
667 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
668 //
669 // // move
670 // msg = new Message();
671 // b = new Bundle();
672 // b.putInt("Callback", 23);
673 // b.putInt("x", 1 + 10);
674 // b.putInt("y", 1);
675 // msg.setData(b);
676 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
677 //
678 // // move
679 // msg = new Message();
680 // b = new Bundle();
681 // b.putInt("Callback", 23);
682 // b.putInt("x", 1 - 10);
683 // b.putInt("y", 1);
684 // msg.setData(b);
685 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
686 //
687 // // up
688 // msg = new Message();
689 // b = new Bundle();
690 // b.putInt("Callback", 22);
691 // b.putInt("x", 1);
692 // b.putInt("y", 1);
693 // msg.setData(b);
694 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
695 // next lines are a hack, without it screen will not get updated anymore!
696 // next lines are a hack, without it screen will not get updated anymore!
697 }
698 }
699
700 if (this.draw_bubble)
701 {
702 //Log.e("Navit", "NavitAndroidOverlay -> onDraw -> bubble");
703
704 int dx = (int) ((20 / 1.5f) * draw_factor);
705 int dy = (int) ((-100 / 1.5f) * draw_factor);
706 Paint bubble_paint = new Paint(0);
707
708 int bubble_size_x = (int) ((150 / 1.5f) * draw_factor);
709 int bubble_size_y = (int) ((60 / 1.5f) * draw_factor);
710
711 // yellow-ish funny lines
712 int lx = (int) ((15 / 1.5f) * draw_factor);
713 int ly = (int) ((15 / 1.5f) * draw_factor);
714 bubble_paint.setStyle(Style.FILL);
715 bubble_paint.setAntiAlias(true);
716 bubble_paint.setStrokeWidth(8 / 1.5f * draw_factor);
717 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
718 c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + bubble_size_y - ly, this.bubble_001.x, this.bubble_001.y, bubble_paint);
719 c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + bubble_size_y, this.bubble_001.x, this.bubble_001.y, bubble_paint);
720
721 // draw black funny lines to target
722 bubble_paint.setStyle(Style.STROKE);
723 bubble_paint.setAntiAlias(true);
724 bubble_paint.setStrokeWidth(3);
725 bubble_paint.setColor(Color.parseColor("#000000"));
726 c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + bubble_size_y - ly, this.bubble_001.x, this.bubble_001.y, bubble_paint);
727 c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + bubble_size_y, this.bubble_001.x, this.bubble_001.y, bubble_paint);
728
729 // filled rect yellow-ish (left side) (fill it all)
730 bubble_paint.setStyle(Style.FILL);
731 bubble_paint.setStrokeWidth(0);
732 bubble_paint.setAntiAlias(false);
733 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
734 RectF box_rect = new RectF(this.bubble_001.x + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy);
735 int rx = (int) (20 / 1.5f * draw_factor);
736 int ry = (int) (20 / 1.5f * draw_factor);
737 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
738
739 // filled rect green-ish (right side)
740 bubble_paint.setStyle(Style.FILL);
741 bubble_paint.setStrokeWidth(0);
742 bubble_paint.setAntiAlias(false);
743 bubble_paint.setColor(Color.parseColor("#74DF00"));
744 RectF box_rect_right_half = new RectF(this.bubble_001.x + dx + (bubble_size_x / 2) - rx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy);
745 c.drawRoundRect(box_rect_right_half, rx, ry, bubble_paint);
746
747 // correct the overlap
748 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
749 RectF box_rect_left_half_correction = new RectF(this.bubble_001.x + dx + (bubble_size_x / 2) - rx - 1, this.bubble_001.y + dy, this.bubble_001.x + dx + (bubble_size_x / 2), this.bubble_001.y + bubble_size_y + dy);
750 c.drawRect(box_rect_left_half_correction, bubble_paint);
751
752 // black outlined rect
753 bubble_paint.setStyle(Style.STROKE);
754 bubble_paint.setStrokeWidth(3);
755 bubble_paint.setAntiAlias(true);
756 bubble_paint.setColor(Color.parseColor("#000000"));
757 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
758
759 // black separator lines (outer)
760 bubble_paint.setStyle(Style.STROKE);
761 bubble_paint.setStrokeWidth(8);
762 bubble_paint.setAntiAlias(true);
763 bubble_paint.setColor(Color.parseColor("#000000"));
764 c.drawLine(box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.top, box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.bottom, bubble_paint);
765
766 // black separator lines (inner)
767 bubble_paint.setStyle(Style.STROKE);
768 bubble_paint.setStrokeWidth(2);
769 bubble_paint.setAntiAlias(true);
770 bubble_paint.setColor(Color.parseColor("#D8D8D8"));
771 c.drawLine(box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.top, box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.bottom, bubble_paint);
772
773 if (NavitAndroidOverlay.confirmed_bubble)
774 {
775 // red outline (for confirmed bubble)
776 bubble_paint.setStyle(Style.STROKE);
777 bubble_paint.setStrokeWidth(5);
778 bubble_paint.setAntiAlias(true);
779 bubble_paint.setColor(Color.parseColor("#EC294D"));
780 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
781 }
782
783 int inner_dx = (int) (30 / 1.5f * draw_factor);
784 int inner_dx_left = (int) (30 / 1.5f * draw_factor);
785 int inner_dx_right = (int) (30 / 1.5f * draw_factor) + (bubble_size_x / 2);
786 int inner_dy = (int) (36 / 1.5f * draw_factor);
787 bubble_paint.setAntiAlias(true);
788 bubble_paint.setStyle(Style.FILL);
789 bubble_paint.setTextSize((int) (20 / 1.5f * draw_factor));
790 bubble_paint.setStrokeWidth(3);
791 bubble_paint.setColor(Color.parseColor("#3b3131"));
792 // c.drawText(Navit.get_text("drive here"), this.bubble_001.x + dx + inner_dx, this.bubble_001.y + dy + inner_dy, bubble_paint);
793 c.drawText("X", this.bubble_001.x + dx + inner_dx_left, this.bubble_001.y + dy + inner_dy, bubble_paint);
794 c.drawText("?", this.bubble_001.x + dx + inner_dx_right, this.bubble_001.y + dy + inner_dy, bubble_paint);
795
796 }
797
798 if (NavitGraphics.in_map)
799 {
800 // draw follow
801 if (Navit.follow_current != null)
802 {
803 c.drawBitmap(Navit.follow_current, this.follow_button_rect.left, this.follow_button_rect.top, null);
804 }
805 }
806
807 if (NavitGraphics.in_map)
808 {
809 c.drawBitmap(Navit.zoomin, zoomin_ltx, zoomin_lty, null);
810 c.drawBitmap(Navit.zoomout, zoomout_ltx, zoomout_lty, null);
811 Paint paint = new Paint();
812 paint.setAntiAlias(true);
813 paint.setStyle(Style.STROKE);
814 paint.setColor(Color.GRAY);
815 paint.setAlpha(30);
816 paint.setStrokeWidth(2);
817 c.drawRoundRect(this.zoomin_button_rect, 10, 10, paint);
818 //paint.setStyle(Style.STROKE);
819 //paint.setColor(Color.GRAY);
820 //paint.setAlpha(30);
821 c.drawRoundRect(this.zoomout_button_rect, 10, 10, paint);
822 c.drawRoundRect(this.mapdrawing_button_rect, 10, 10, paint);
823 if ((draw_factor == 0.7f) || (draw_factor == 1.0f))
824 {
825 paint.setStrokeWidth(6);
826 }
827 else
828 {
829 paint.setStrokeWidth(10);
830 }
831 paint.setAlpha(80);
832 c.drawLine(this.mapdrawing_button_rect.left + 10, this.mapdrawing_button_rect.bottom - 10, this.mapdrawing_button_rect.right - 10, this.mapdrawing_button_rect.top + 10, paint);
833 }
834
835 if (NavitGraphics.in_map)
836 {
837 //Log.e("NavitGraphics", "NavitAndroidOverlay -> draw2");
838 //if (NavitGraphics.wait_for_redraw_map)
839 //{
840 // //Log.e("NavitGraphics", "NavitAndroidOverlay -> draw wait rect");
841 // Paint paint = new Paint(0);
842 // paint.setAntiAlias(true);
843 // paint.setStyle(Style.FILL);
844 // paint.setColor(Color.LTGRAY);
845 // paint.setAlpha(70);
846 //
847 // RectF r1 = new RectF(20 * draw_factor, 20 * draw_factor, this.mCanvasWidth - 20 * draw_factor, this.mCanvasHeight - 20 * draw_factor);
848 // c.drawRoundRect(r1, 20, 20, paint);
849 // paint.setColor(Color.parseColor("#888888"));
850 // paint.setAlpha(230);
851 // paint.setTextAlign(Paint.Align.CENTER);
852 // paint.setStrokeWidth(2);
853 // paint.setTextSize(30);
854 // c.drawText(Navit.get_text("wait ..."), this.mCanvasWidth / 2, this.mCanvasHeight / 2, paint); //TRANS
855 //}
856 }
857
858 if (Navit.PREF_item_dump)
859 {
860 if (!Navit.debug_item_dump.equals(""))
861 {
862 Paint paint = new Paint(0);
863 paint.setAntiAlias(true);
864 paint.setColor(Color.BLUE);
865 // paint.setAlpha(240);
866 // paint.setColor(Color.parseColor("#888888"));
867 paint.setStrokeWidth(2);
868 paint.setTextSize(22);
869
870 String[] s = Navit.debug_item_dump.split("\n");
871 int i3;
872 int i4 = 0;
873 int max_char = 38;
874 for (i3 = 0; i3 < s.length; i3++)
875 {
876 if (s[i3].length() > max_char)
877 {
878 int j3;
879 int indent = 0;
880 for (j3 = 0; j3 < (int) (s[i3].length() / max_char); j3++)
881 {
882 if (j3 > 0)
883 {
884 indent = 8;
885 }
886 c.drawText(s[i3].substring(j3 * max_char, ((j3 + 1) * max_char) - 0), 20 + indent, 110 + (i4 * 32), paint);
887 i4++;
888 }
889 if ((((int) (s[i3].length() / max_char)) * max_char) < s[i3].length())
890 {
891 indent = 8;
892 c.drawText(s[i3].substring(j3 * max_char), 20 + indent, 110 + (i4 * 32), paint);
893 i4++;
894 }
895 }
896 else
897 {
898 c.drawText(s[i3], 20, 110 + (i4 * 32), paint);
899 i4++;
900 }
901 }
902 }
903 }
904
905 // // test, draw rectangles on top layer!
906 // Paint paint = new Paint(0);
907 // paint.setAntiAlias(false);
908 // paint.setStyle(Style.STROKE);
909 // paint.setColor(Color.GREEN);
910 // c.drawRect(0 * draw_factor, 0 * draw_factor, 64 * draw_factor, 64 * draw_factor, paint);
911 // paint.setColor(Color.RED);
912 // c.drawRect(0 * draw_factor, (0 + 70) * draw_factor, 64 * draw_factor,
913 // (64 + 70) * draw_factor, paint);
914 }
915 }

   
Visit the ZANavi Wiki