… | |
… | |
30 | public class ZANaviOSDNextturn extends View
|
30 | public class ZANaviOSDNextturn extends View
|
31 | {
|
31 | {
|
32 |
|
32 |
|
33 | private Paint paint = new Paint();
|
33 | private Paint paint = new Paint();
|
34 | private RectF f;
|
34 | private RectF f;
|
35 | private RectF f2;
|
|
|
36 | int end_x;
|
|
|
37 | int end_y;
|
|
|
38 | int nt_text_start_x = 0;
|
|
|
39 | int nt_text_start_y = 0;
|
|
|
40 | int nt_font_size = 10;
|
|
|
41 | float draw_factor = 1;
|
|
|
42 | int OSD_element_bg_001 = Color.argb(255, 80, 80, 150); // Color.argb(255, 190, 190, 190); // Color.argb(140, 136, 136, 136);
|
|
|
43 |
|
35 |
|
44 | public ZANaviOSDNextturn(Context context)
|
36 | public ZANaviOSDNextturn(Context context)
|
45 | {
|
37 | {
|
46 | super(context);
|
38 | super(context);
|
|
|
39 |
|
47 | f = new RectF(0, 0, 1, 1);
|
40 | f = new RectF(0, 0, 1, 1);
|
48 | f2 = new RectF(0, 0, 1, 1);
|
41 |
|
|
|
42 | paint.setColor(Navit.OSD_blueish_bg_color);
|
|
|
43 | paint.setStyle(Paint.Style.FILL);
|
|
|
44 | paint.setAntiAlias(false);
|
49 | }
|
45 | }
|
50 |
|
46 |
|
51 | public ZANaviOSDNextturn(Context context, AttributeSet attrs)
|
47 | public ZANaviOSDNextturn(Context context, AttributeSet attrs)
|
52 | {
|
48 | {
|
53 | super(context, attrs);
|
49 | super(context, attrs);
|
|
|
50 |
|
54 | f = new RectF(0, 0, 1, 1);
|
51 | f = new RectF(0, 0, 1, 1);
|
55 | f2 = new RectF(0, 0, 1, 1);
|
|
|
56 | }
|
52 | }
|
57 |
|
53 |
|
58 | @Override
|
54 | @Override
|
59 | public void onSizeChanged(int w, int h, int oldw, int oldh)
|
55 | public void onSizeChanged(int w, int h, int oldw, int oldh)
|
60 | {
|
56 | {
|
61 | super.onSizeChanged(w, h, oldw, oldh);
|
57 | super.onSizeChanged(w, h, oldw, oldh);
|
62 |
|
58 |
|
63 | draw_factor = 1.0f;
|
59 | f = new RectF(0, 0, w, h);
|
64 | if (Navit.my_display_density.compareTo("mdpi") == 0)
|
|
|
65 | {
|
|
|
66 | draw_factor = 1.0f;
|
|
|
67 | }
|
|
|
68 | else if (Navit.my_display_density.compareTo("ldpi") == 0)
|
|
|
69 | {
|
|
|
70 | draw_factor = 0.7f;
|
|
|
71 | }
|
|
|
72 | else if (Navit.my_display_density.compareTo("hdpi") == 0)
|
|
|
73 | {
|
|
|
74 | draw_factor = 1.5f;
|
|
|
75 | }
|
|
|
76 |
|
|
|
77 | // correct for ultra high DPI
|
|
|
78 | if (Navit.metrics.densityDpi >= 320) //&& (Navit.PREF_shrink_on_high_dpi))
|
|
|
79 | {
|
|
|
80 | draw_factor = 1.8f * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other;
|
|
|
81 | }
|
|
|
82 |
|
|
|
83 | float real_factor = draw_factor / 1.5f;
|
|
|
84 |
|
|
|
85 | f = new RectF(0 + 12 * draw_factor, 0 + 12 * draw_factor, w - 12 * draw_factor, h - 12 * draw_factor);
|
|
|
86 | f2 = new RectF(0 + 3 * draw_factor, 0 + 3 * draw_factor, w - 3 * draw_factor, h - 3 * draw_factor);
|
|
|
87 |
|
|
|
88 | nt_text_start_x = (int) (20 * real_factor);
|
|
|
89 | nt_text_start_y = (int) (30 * real_factor);
|
|
|
90 | nt_font_size = (int) (24 * real_factor);
|
|
|
91 | }
|
60 | }
|
92 |
|
61 |
|
93 | public void onDraw(Canvas c)
|
62 | public void onDraw(Canvas c)
|
94 | {
|
63 | {
|
95 | super.onDraw(c);
|
64 | super.onDraw(c);
|
96 | // int dest_valid = NavitGraphics.CallbackDestinationValid2();
|
|
|
97 |
|
65 |
|
98 | try
|
66 | try
|
99 | {
|
67 | {
|
100 | if ((Navit.OSD_nextturn.nextturn_image_valid) && (NavitGraphics.CallbackDestinationValid2() > 0))
|
68 | if ((Navit.OSD_nextturn.nextturn_image_valid) && (NavitGraphics.CallbackDestinationValid2() > 0))
|
101 | {
|
69 | {
|
102 | if (NavitGraphics.MAP_DISPLAY_OFF)
|
|
|
103 | {
|
|
|
104 | paint.setColor(Color.argb(255, 20, 20, 230));
|
|
|
105 | paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
|
|
106 | paint.setStrokeWidth(3 * draw_factor);
|
|
|
107 | paint.setAntiAlias(true);
|
|
|
108 | // c.drawRoundRect(f, 10, 10, paint);
|
|
|
109 | c.drawOval(f2, paint);
|
|
|
110 | paint.setColor(Color.rgb(0, 0, 0));
|
|
|
111 | paint.setStyle(Paint.Style.STROKE);
|
|
|
112 | c.drawOval(f2, paint);
|
|
|
113 | c.drawBitmap(Navit.OSD_nextturn.nextturn_image, null, f, null);
|
70 | c.drawBitmap(Navit.OSD_nextturn.nextturn_image, null, f, null);
|
114 | }
|
|
|
115 | else
|
|
|
116 | {
|
|
|
117 | paint.setColor(OSD_element_bg_001);
|
|
|
118 | paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
|
|
119 | paint.setStrokeWidth(3 * draw_factor);
|
|
|
120 | paint.setAntiAlias(true);
|
|
|
121 | // c.drawRoundRect(f, 10, 10, paint);
|
|
|
122 | c.drawOval(f2, paint);
|
|
|
123 | paint.setColor(Color.rgb(0, 0, 0));
|
|
|
124 | paint.setStyle(Paint.Style.STROKE);
|
|
|
125 | c.drawOval(f2, paint);
|
|
|
126 | c.drawBitmap(Navit.OSD_nextturn.nextturn_image, null, f, null);
|
|
|
127 | }
|
|
|
128 | }
|
71 | }
|
129 | else
|
72 | else
|
130 | {
|
73 | {
|
131 | paint.setColor(Color.argb(0, 0, 0, 0));
|
74 | c.drawColor(Color.TRANSPARENT);
|
132 | paint.setStyle(Paint.Style.FILL);
|
|
|
133 | paint.setStrokeWidth(3);
|
|
|
134 | paint.setAntiAlias(false);
|
|
|
135 | if (NavitGraphics.MAP_DISPLAY_OFF)
|
|
|
136 | {
|
|
|
137 | c.drawRect(f, paint);
|
|
|
138 | }
|
|
|
139 | else
|
|
|
140 | {
|
|
|
141 | c.drawRect(f, paint);
|
|
|
142 | }
|
|
|
143 | }
|
75 | }
|
144 | }
|
76 | }
|
145 | catch (Exception e)
|
77 | catch (Exception e)
|
146 | {
|
78 | {
|
147 | //e.printStackTrace();
|
|
|
148 | }
|
79 | }
|
|
|
80 |
|
|
|
81 | // System.out.println("onDraw:OSDNextturn");
|
149 |
|
82 |
|
150 | }
|
83 | }
|
151 | }
|
84 | }
|