import android.graphics.Paint.Style;\r
import android.os.Bundle;\r
import android.os.Message;\r
-import android.util.Log;\r
import android.view.MotionEvent;\r
import android.widget.ImageView;\r
\r
{\r
return this.draw_bubble;\r
}\r
- \r
+\r
public void hide_bubble()\r
{\r
this.draw_bubble = false;\r
{\r
//Log.e("Navit", "NavitAndroidOverlay -> onDraw");\r
\r
- Paint paint = new Paint(0);\r
- paint.setAntiAlias(false);\r
- paint.setColor(Color.GRAY);\r
+ float draw_factor = 1.0f;\r
+ if (Navit.my_display_density.compareTo("mdpi") == 0)\r
+ {\r
+ draw_factor = 1.0f;\r
+ }\r
+ else if (Navit.my_display_density.compareTo("ldpi") == 0)\r
+ {\r
+ draw_factor = 0.7f;\r
+ }\r
+ else if (Navit.my_display_density.compareTo("hdpi") == 0)\r
+ {\r
+ draw_factor = 1.5f;\r
+ }\r
+\r
\r
if (this.draw_bubble)\r
{\r
{\r
//Log.e("Navit", "NavitAndroidOverlay -> onDraw -> bubble");\r
\r
- int dx = 20;\r
- int dy = -100;\r
+ int dx = (int) ((20 / 1.5f) * draw_factor);\r
+ int dy = (int) ((-100 / 1.5f) * draw_factor);\r
Paint bubble_paint = new Paint(0);\r
\r
+ int bubble_size_x = (int) ((150 / 1.5f) * draw_factor);\r
+ int bubble_size_y = (int) ((60 / 1.5f) * draw_factor);\r
+\r
// yellow-ish funny lines\r
- int lx = 15;\r
- int ly = 15;\r
+ int lx = (int) ((15 / 1.5f) * draw_factor);\r
+ int ly = (int) ((15 / 1.5f) * draw_factor);\r
bubble_paint.setStyle(Style.FILL);\r
bubble_paint.setAntiAlias(true);\r
- bubble_paint.setStrokeWidth(8);\r
+ bubble_paint.setStrokeWidth(8 / 1.5f * draw_factor);\r
bubble_paint.setColor(Color.parseColor("#FFF8C6"));\r
- c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + 60 - ly, this.bubble_001.x,\r
- this.bubble_001.y, bubble_paint);\r
- c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + 60, this.bubble_001.x,\r
- this.bubble_001.y, bubble_paint);\r
+ c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + bubble_size_y - ly,\r
+ this.bubble_001.x, this.bubble_001.y, bubble_paint);\r
+ c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + bubble_size_y,\r
+ this.bubble_001.x, this.bubble_001.y, bubble_paint);\r
\r
// draw black funny lines to target\r
bubble_paint.setStyle(Style.STROKE);\r
bubble_paint.setAntiAlias(true);\r
bubble_paint.setStrokeWidth(3);\r
bubble_paint.setColor(Color.parseColor("#000000"));\r
- c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + 60 - ly, this.bubble_001.x,\r
- this.bubble_001.y, bubble_paint);\r
- c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + 60, this.bubble_001.x,\r
- this.bubble_001.y, bubble_paint);\r
+ c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + bubble_size_y - ly,\r
+ this.bubble_001.x, this.bubble_001.y, bubble_paint);\r
+ c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + bubble_size_y,\r
+ this.bubble_001.x, this.bubble_001.y, bubble_paint);\r
\r
\r
// filled rect yellow-ish\r
bubble_paint.setAntiAlias(false);\r
bubble_paint.setColor(Color.parseColor("#FFF8C6"));\r
RectF box_rect = new RectF(this.bubble_001.x + dx, this.bubble_001.y + dy,\r
- this.bubble_001.x + 150 + dx, this.bubble_001.y + 60 + dy);\r
- int rx = 20;\r
- int ry = 20;\r
+ this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy);\r
+ int rx = (int) (20 / 1.5f * draw_factor);\r
+ int ry = (int) (20 / 1.5f * draw_factor);\r
c.drawRoundRect(box_rect, rx, ry, bubble_paint);\r
\r
// black outlined rect\r
bubble_paint.setColor(Color.parseColor("#000000"));\r
c.drawRoundRect(box_rect, rx, ry, bubble_paint);\r
\r
- int inner_dx = 30;\r
- int inner_dy = 36;\r
+ int inner_dx = (int) (30 / 1.5f * draw_factor);\r
+ int inner_dy = (int) (36 / 1.5f * draw_factor);\r
bubble_paint.setAntiAlias(true);\r
bubble_paint.setStyle(Style.FILL);\r
- bubble_paint.setTextSize(20);\r
+ bubble_paint.setTextSize((int) (20 / 1.5f * draw_factor));\r
bubble_paint.setStrokeWidth(3);\r
bubble_paint.setColor(Color.parseColor("#3b3131"));\r
c.drawText("drive here", this.bubble_001.x + dx + inner_dx, this.bubble_001.y + dy\r
+ inner_dy, bubble_paint);\r
}\r
\r
- // test, draw a grey rectangle on top layer!\r
- // c.drawRect(10, 10, 300, 200, paint);\r
+ // // test, draw rectangles on top layer!\r
+ // Paint paint = new Paint(0);\r
+ // paint.setAntiAlias(false);\r
+ // paint.setStyle(Style.STROKE);\r
+ // paint.setColor(Color.GREEN);\r
+ // c.drawRect(0 * draw_factor, 0 * draw_factor, 64 * draw_factor, 64 * draw_factor, paint);\r
+ // paint.setColor(Color.RED);\r
+ // c.drawRect(0 * draw_factor, (0 + 70) * draw_factor, 64 * draw_factor,\r
+ // (64 + 70) * draw_factor, paint);\r
}\r
}\r
import android.graphics.Rect;
import android.os.Handler;
import android.os.Message;
-import android.util.DisplayMetrics;
import android.util.FloatMath;
import android.util.Log;
import android.view.KeyEvent;
public class NavitGraphics
{
- private NavitGraphics parent_graphics;
- private ArrayList overlays = new ArrayList();
- int bitmap_w;
- int bitmap_h;
- int pos_x;
- int pos_y;
- int pos_wraparound;
- int overlay_disabled;
- float trackball_x, trackball_y;
- View view;
- RelativeLayout relativelayout;
- NavitCamera camera;
- Activity activity;
-
- public static Boolean in_map = false;
+ private NavitGraphics parent_graphics;
+ private ArrayList overlays = new ArrayList();
+ int bitmap_w;
+ int bitmap_h;
+ int pos_x;
+ int pos_y;
+ int pos_wraparound;
+ int overlay_disabled;
+ float trackball_x, trackball_y;
+ View view;
+ RelativeLayout relativelayout;
+ NavitCamera camera;
+ Activity activity;
+
+ public static Boolean in_map = false;
// for menu key
- private static long time_for_long_press = 300L;
- private static long interval_for_long_press = 200L;
+ private static long time_for_long_press = 300L;
+ private static long interval_for_long_press = 200L;
// for touch screen
- private long last_touch_on_screen = 0L;
- private static long long_press_on_screen_interval = 1500L;
- private static float long_press_on_screen_max_distance = 8f;
+ private long last_touch_on_screen = 0L;
+ private static long long_press_on_screen_interval = 1500L;
+ private static float long_press_on_screen_max_distance = 8f;
// Overlay View for Android
//
// and get touch events for it (without touching C-code)
public NavitAndroidOverlay NavitAOverlay = null;
-
public void SetCamera(int use_camera)
{
if (use_camera != 0 && camera == null)
last_down_action = System.currentTimeMillis();
Log.e("NavitGraphics", "SensorThread created");
}
-
+
public void down()
{
this.is_still_pressing = true;
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
Log.e("Navit", "NavitGraphics -> onSizeChanged pixels x=" + w + " pixels y=" + h);
- Log.e("Navit", "NavitGraphics -> onSizeChanged dpi="+Navit.metrics.densityDpi);
- Log.e("Navit", "NavitGraphics -> onSizeChanged density="+Navit.metrics.density);
- Log.e("Navit", "NavitGraphics -> onSizeChanged scaledDensity="+Navit.metrics.scaledDensity);
+ Log.e("Navit", "NavitGraphics -> onSizeChanged dpi=" + Navit.metrics.densityDpi);
+ Log.e("Navit", "NavitGraphics -> onSizeChanged density=" + Navit.metrics.density);
+ Log.e("Navit", "NavitGraphics -> onSizeChanged scaledDensity="
+ + Navit.metrics.scaledDensity);
super.onSizeChanged(w, h, oldw, oldh);
draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
draw_canvas = new Canvas(draw_bitmap);
{
}
-
+
// was is a long press? or normal quick touch?
if ((in_map)
&& ((System.currentTimeMillis() - last_touch_on_screen) > long_press_on_screen_interval))
// if we drag, hide the bubble
NavitAOverlay.hide_bubble();
-
+
MotionCallback(MotionCallbackID, x, y);
ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
{
// zoom in
CallbackMessageChannel(1, "");
-
+
// next lines are a hack, without it screen will not get updated anymore!
ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
- MotionCallback(MotionCallbackID, x+15, y);
- MotionCallback(MotionCallbackID, x-15, y);
+ MotionCallback(MotionCallbackID, x + 15, y);
+ MotionCallback(MotionCallbackID, x - 15, y);
ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
this.postInvalidate();
// next lines are a hack, without it screen will not get updated anymore!
ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
- MotionCallback(MotionCallbackID, x+15, y);
- MotionCallback(MotionCallbackID, x-15, y);
+ MotionCallback(MotionCallbackID, x + 15, y);
+ MotionCallback(MotionCallbackID, x - 15, y);
ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
this.postInvalidate();
}
- protected void draw_polyline(Paint paint, int c[])
+ Path global_path = new Path();
+ Rect global_r = new Rect();
+ public static Boolean power_device = false;
+
+
+
+ private class t_draw_polyline extends Thread
{
- paint.setStyle(Paint.Style.STROKE);
- Path path = new Path();
- path.moveTo(c[0], c[1]);
- for (int i = 2; i < c.length; i += 2)
+ private Boolean running;
+ private Paint p = null;
+ private int c[] = null;
+ private Path pf = new Path();
+
+ t_draw_polyline(Paint paint, int cc[])
+ {
+ this.p = paint;
+ this.c = cc;
+ this.running = true;
+ //Log.e("Navit", "t_draw_polyline created");
+ }
+
+ public void run()
{
- path.lineTo(c[i], c[i + 1]);
+ //Log.e("Navit", "t_draw_polyline started");
+ p.setStyle(Paint.Style.STROKE);
+ //pf.reset();
+ pf.moveTo(c[0], c[1]);
+ for (int i = 2; i < c.length; i += 2)
+ {
+ pf.lineTo(c[i], c[i + 1]);
+ }
+ draw_canvas.drawPath(pf, p);
+ //Log.e("Navit", "t_draw_polyline ended");
}
- draw_canvas.drawPath(path, paint);
}
- protected void draw_polygon(Paint paint, int c[])
+ private class t_draw_polygon extends Thread
{
- paint.setStyle(Paint.Style.FILL);
- Path path = new Path();
- path.moveTo(c[0], c[1]);
- for (int i = 2; i < c.length; i += 2)
+ private Boolean running;
+ private Paint p = null;
+ private int c[] = null;
+ private Path pf = new Path();
+
+ t_draw_polygon(Paint paint, int cc[])
{
- path.lineTo(c[i], c[i + 1]);
+ this.p = paint;
+ this.c = cc;
+ this.running = true;
+ }
+
+ public void run()
+ {
+ p.setStyle(Paint.Style.FILL);
+ //pf.reset();
+ pf.moveTo(c[0], c[1]);
+ for (int i = 2; i < c.length; i += 2)
+ {
+ pf.lineTo(c[i], c[i + 1]);
+ }
+ draw_canvas.drawPath(pf, p);
+ }
+ }
+
+ void draw_polyline(Paint paint, int c[])
+ {
+ if (NavitGraphics.power_device)
+ {
+ t_draw_polyline t = new t_draw_polyline(paint, c);
+ t.start();
+ }
+ else
+ {
+// //Log.e("NavitGraphics","draw_polyline");
+ paint.setStyle(Paint.Style.STROKE);
+ global_path.reset();
+ global_path.moveTo(c[0], c[1]);
+ for (int i = 2; i < c.length; i += 2)
+ {
+ global_path.lineTo(c[i], c[i + 1]);
+ }
+ global_path.close();
+ draw_canvas.drawPath(global_path, paint);
+ }
+ }
+
+ void draw_polygon(Paint paint, int c[])
+ {
+ if (NavitGraphics.power_device)
+ {
+ t_draw_polygon t = new t_draw_polygon(paint, c);
+ t.start();
+ }
+ else
+ {
+ //Log.e("NavitGraphics","draw_polygon");
+ paint.setStyle(Paint.Style.FILL);
+ global_path.reset();
+ global_path.moveTo(c[0], c[1]);
+ for (int i = 2; i < c.length; i += 2)
+ {
+ global_path.lineTo(c[i], c[i + 1]);
+ }
+ global_path.close();
+ draw_canvas.drawPath(global_path, paint);
}
- draw_canvas.drawPath(path, paint);
}
protected void draw_rectangle(Paint paint, int x, int y, int w, int h)
{
- Rect r = new Rect(x, y, x + w, y + h);
+ //Log.e("NavitGraphics","draw_rectangle");
+ global_r.set(x, y, x + w, y + h);
paint.setStyle(Paint.Style.FILL);
- draw_canvas.drawRect(r, paint);
+ draw_canvas.drawRect(global_r, paint);
}
protected void draw_circle(Paint paint, int x, int y, int r)
{
- float fx = x;
- float fy = y;
- float fr = r / 2;
+ //Log.e("NavitGraphics","draw_circle");
+ // float fx = x;
+ // float fy = y;
+ // float fr = r / 2;
paint.setStyle(Paint.Style.STROKE);
- draw_canvas.drawCircle(fx, fy, fr, paint);
+ draw_canvas.drawCircle(x, y, r / 2, paint);
}
protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy)
{
- float fx = x;
- float fy = y;
- // Log.e("NavitGraphics","Text size "+size + " vs " + paint.getTextSize());
- paint.setTextSize((float) size / 15);
+ // float fx = x;
+ // float fy = y;
+ //Log.e("NavitGraphics","Text size "+size + " vs " + paint.getTextSize());
+ paint.setTextSize(size / 15);
paint.setStyle(Paint.Style.FILL);
if (dx == 0x10000 && dy == 0)
{
- draw_canvas.drawText(text, fx, fy, paint);
+ draw_canvas.drawText(text, x, y, paint);
}
else
{
}
protected void draw_image(Paint paint, int x, int y, Bitmap bitmap)
{
- // Log.e("NavitGraphics","draw_image");
-
- float fx = x;
- float fy = y;
- draw_canvas.drawBitmap(bitmap, fx, fy, paint);
+ //Log.e("NavitGraphics","draw_image");
+ // float fx = x;
+ // float fy = y;
+ draw_canvas.drawBitmap(bitmap, x, y, paint);
}
protected void draw_mode(int mode)
{