summaryrefslogtreecommitdiff
path: root/navit/android/src/org/navitproject/navit/NavitGraphics.java
diff options
context:
space:
mode:
Diffstat (limited to 'navit/android/src/org/navitproject/navit/NavitGraphics.java')
-rw-r--r--navit/android/src/org/navitproject/navit/NavitGraphics.java89
1 files changed, 36 insertions, 53 deletions
diff --git a/navit/android/src/org/navitproject/navit/NavitGraphics.java b/navit/android/src/org/navitproject/navit/NavitGraphics.java
index 67fe2615e..6aee53cf5 100644
--- a/navit/android/src/org/navitproject/navit/NavitGraphics.java
+++ b/navit/android/src/org/navitproject/navit/NavitGraphics.java
@@ -66,21 +66,20 @@ class NavitGraphics {
private static final String TAG = "NavitGraphics";
private static final long TIME_FOR_LONG_PRESS = 300L;
private final NavitGraphics mParentGraphics;
- private final ArrayList<NavitGraphics> mOverlays = new ArrayList<>();
+ private final ArrayList<NavitGraphics> mOverlays;
private int mBitmapWidth;
private int mBitmapHeight;
private int mPosX;
private int mPosY;
private int mPosWraparound;
private int mOverlayDisabled;
- private int mBgColor;
private float mTrackballX;
private float mTrackballY;
private int mPaddingLeft;
private int mPaddingRight;
private int mPaddingTop;
private int mPaddingBottom;
- private View mView;
+ private NavitView mView;
static final Handler sCallbackHandler = new CallBackHandler();
private SystemBarTintView mLeftTintView;
private SystemBarTintView mRightTintView;
@@ -91,11 +90,11 @@ class NavitGraphics {
private NavitCamera mCamera;
private Navit mActivity;
private static boolean sInMap;
- private boolean mTinting;
+ private boolean mTinting;
+ @SuppressWarnings("unused")
void setBackgroundColor(int bgcolor) {
- this.mBgColor = bgcolor;
if (mLeftTintView != null) {
mLeftTintView.setBackgroundColor(bgcolor);
}
@@ -113,23 +112,7 @@ class NavitGraphics {
private void setCamera(int useCamera) {
if (useCamera != 0 && mCamera == null) {
// mActivity.requestWindowFeature(Window.FEATURE_NO_TITLE);
- addCamera();
- addCameraView();
- }
- }
-
- /**
- * Adds a camera.
- *
- * <p>This method does not create the view for the camera. This must be done separately by calling
- * {@link #addCameraView()}.</p>
- */
- private void addCamera() {
- mCamera = new NavitCamera(mActivity);
- }
-
- private void addCameraView() {
- if (mCamera != null) {
+ mCamera = new NavitCamera(mActivity);
mRelativeLayout.addView(mCamera);
mRelativeLayout.bringChildToFront(mView);
}
@@ -167,16 +150,20 @@ class NavitGraphics {
static final int DRAG = 1;
static final int ZOOM = 2;
static final int PRESSED = 3;
-
PointF mPressedPosition = null;
NavitView(Context context) {
super(context);
+ // assumption usefull for the KitKat tinting only
+ sInMap = true;
+ }
+
+ boolean isDrag() {
+ return mTouchMode == DRAG;
}
public void onWindowFocusChanged(boolean hasWindowFocus) {
Log.v(TAG,"onWindowFocusChanged = " + hasWindowFocus);
- // beter aanroepen in Navit of appconfig ?
if (Navit.sShowSoftKeyboardShowing && hasWindowFocus) {
InputMethodManager imm = (InputMethodManager) mActivity
.getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -249,6 +236,7 @@ class NavitGraphics {
Uri intentUri = Uri.parse("geo:" + getCoordForPoint((int) mPressedPosition.x,
(int) mPressedPosition.y, true));
Intent mContextMenuMapViewIntent = new Intent(Intent.ACTION_VIEW, intentUri);
+ mContextMenuMapViewIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (mContextMenuMapViewIntent.resolveActivity(this.getContext().getPackageManager()) != null) {
this.getContext().startActivity(mContextMenuMapViewIntent);
} else {
@@ -548,19 +536,21 @@ class NavitGraphics {
public SystemBarTintView(Context context) {
super(context);
- this.setBackgroundColor(mBgColor);
}
}
+ @SuppressWarnings("unused")
NavitGraphics(final Activity navit, NavitGraphics parent, int x, int y, int w, int h,
- int wraparound, int useCamera) {
+ int wraparound, int useCamera) {
if (parent == null) {
+ mOverlays = new ArrayList<>();
if (useCamera != 0) {
- addCamera();
+ setCamera(useCamera);
}
setmActivity((Navit)navit);
} else {
+ mOverlays = null;
mDrawBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
mBitmapWidth = w;
mBitmapHeight = h;
@@ -585,11 +575,9 @@ class NavitGraphics {
mView.setFocusableInTouchMode(true);
mView.setKeepScreenOn(true);
mRelativeLayout = new RelativeLayout(mActivity);
- addCameraView();
mRelativeLayout.addView(mView);
/* The navigational and status bar tinting code is meaningful only on API19+ */
mTinting = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
-
if (mTinting) {
mFrameLayout = new FrameLayout(mActivity);
mFrameLayout.addView(mRelativeLayout);
@@ -656,9 +644,6 @@ class NavitGraphics {
case CLB_DELETE_MAP:
//unload map before deleting it !!!
callbackMessageChannel(7, msg.getData().getString(("title")));
- //remove commentlines below after testing
- //File toDelete = new File(msg.getData().getString(("title")));
- //toDelete.delete();
NavitUtils.removeFileIfExists(msg.getData().getString(("title")));
break;
case CLB_UNLOAD_MAP:
@@ -774,8 +759,6 @@ class NavitGraphics {
* All system bar sizes are device defaults and do not change with rotation, but we have
* to figure out which ones apply.
*
- * Status bar visibility is as on API 20-22.
- *
* The navigation bar is shown on devices that report they have no physical menu button. This seems to
* work even on devices that allow disabling the physical buttons (and use the navigation bar, in which
* case they report no physical menu button is available; tested with a OnePlus One running CyanogenMod)
@@ -833,6 +816,7 @@ class NavitGraphics {
*
* <p>Note that this method is not aware of non-standard mechanisms on some customized builds of Android</p>
*/
+ @SuppressWarnings("unused")
boolean hasMenuButton() {
if (Build.VERSION.SDK_INT <= 10) {
return true;
@@ -845,30 +829,36 @@ class NavitGraphics {
}
}
+ @SuppressWarnings("unused")
void setSizeChangedCallback(long id) {
mSizeChangedCallbackID = id;
}
+ @SuppressWarnings("unused")
void setPaddingChangedCallback(long id) {
mPaddingChangedCallbackID = id;
}
+ @SuppressWarnings("unused")
void setButtonCallback(long id) {
Log.v(TAG,"set Buttononcallback");
mButtonCallbackID = id;
}
+ @SuppressWarnings("unused")
void setMotionCallback(long id) {
mMotionCallbackID = id;
Log.v(TAG,"set Motioncallback");
}
+ @SuppressWarnings("unused")
void setKeypressCallback(long id) {
Log.v(TAG,"set Keypresscallback");
mKeypressCallbackID = id;
}
+ @SuppressWarnings("unused")
protected void draw_polyline(Paint paint, int[] c) {
paint.setStrokeWidth(c[0]);
paint.setARGB(c[1],c[2],c[3],c[4]);
@@ -899,6 +889,7 @@ class NavitGraphics {
paint.setPathEffect(null);
}
+ @SuppressWarnings("unused")
protected void draw_polygon(Paint paint, int[] c) {
paint.setStrokeWidth(c[0]);
paint.setARGB(c[1],c[2],c[3],c[4]);
@@ -914,6 +905,7 @@ class NavitGraphics {
mDrawCanvas.drawPath(path, paint);
}
+ @SuppressWarnings("unused")
protected void draw_rectangle(Paint paint, int x, int y, int w, int h) {
Rect r = new Rect(x, y, x + w, y + h);
paint.setStyle(Paint.Style.FILL);
@@ -922,11 +914,13 @@ class NavitGraphics {
mDrawCanvas.drawRect(r, paint);
}
+ @SuppressWarnings("unused")
protected void draw_circle(Paint paint, int x, int y, int r) {
paint.setStyle(Paint.Style.STROKE);
mDrawCanvas.drawCircle(x, y, r / 2, paint);
}
+ @SuppressWarnings("unused")
protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy, int bgcolor) {
int oldcolor = paint.getColor();
Path path = null;
@@ -977,11 +971,6 @@ class NavitGraphics {
* @param p2x and p2y specifying the bottom left point, not yet used but kept
* for compatibility with the linux port
* @param bitmap Bitmap object holding the image to draw
- *
- * TODO make it work with 4 points specified to make it work for 3D mapview, so it can be used
- * for small but very detailed maps as well as for large maps with very little detail but large
- * coverage.
- * TODO make it work with rectangular tiles as well ?
*/
protected void draw_image_warp(Paint paint, int count, int p0x, int p0y, int p1x, int p1y, int p2x, int p2y,
Bitmap bitmap) {
@@ -1013,6 +1002,7 @@ class NavitGraphics {
/* Used by the pedestrian plugin, draws without a mapbackground */
private static final int DRAW_MODE_BEGIN_CLEAR = 2;
+ @SuppressWarnings("unused")
protected void draw_mode(int mode) {
if (mode == DRAW_MODE_END) {
if (mParentGraphics == null) {
@@ -1027,18 +1017,18 @@ class NavitGraphics {
}
+ @SuppressWarnings("unused")
protected void draw_drag(int x, int y) {
mPosX = x;
mPosY = y;
}
+ @SuppressWarnings("unused")
protected void overlay_disable(int disable) {
Log.v(TAG,"overlay_disable: " + disable + ", Parent: " + (mParentGraphics != null));
- // assume we are NOT in map view mode!
- // but this backfires when dragging the map
if (mParentGraphics == null) {
sInMap = (disable == 0);
- workAroundForGuiInternal(sInMap);
+ workAroundForGuiInternal();
}
if (mOverlayDisabled != disable) {
mOverlayDisabled = disable;
@@ -1048,30 +1038,23 @@ class NavitGraphics {
}
}
- private void workAroundForGuiInternal(Boolean inMap) {
+ private void workAroundForGuiInternal() {
if (!mTinting) {
return;
}
Log.v(TAG,"workaround gui internal");
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !inMap) {
- mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- return;
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- return;
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !inMap) {
+ if (!sInMap && !mView.isDrag() && Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
return;
}
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
}
+ @SuppressWarnings("unused")
protected void overlay_resize(int x, int y, int w, int h, int wraparound) {
mDrawBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
mBitmapWidth = w;