Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2013-02-15 19:34:25 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:50:56 +0300
commited871401989b44705858f5343b948fa77e8b7a00 (patch)
tree1dd4e7e3be0a9a46a4fd88db96cfb765ce5015f9 /android
parent739a92e67be59f5e4905ef24f6e838425837055c (diff)
[android] [bookmarks] Remove obsolete native pin sources.
Diffstat (limited to 'android')
-rw-r--r--android/jni/Android.mk3
-rw-r--r--android/jni/com/mapswithme/maps/bookmarks/PopupLayout.cpp25
-rw-r--r--android/res/layout/map.xml5
-rw-r--r--android/src/com/mapswithme/maps/bookmarks/PopupLayout.java257
4 files changed, 1 insertions, 289 deletions
diff --git a/android/jni/Android.mk b/android/jni/Android.mk
index 1d34021641..40fc99e7ab 100644
--- a/android/jni/Android.mk
+++ b/android/jni/Android.mk
@@ -37,7 +37,6 @@ LOCAL_SRC_FILES := \
com/mapswithme/core/logging.cpp \
com/mapswithme/core/render_context.cpp \
com/mapswithme/maps/Framework.cpp \
- com/mapswithme/maps/bookmarks/PopupLayout.cpp \
com/mapswithme/maps/bookmarks/data/Bookmark.cpp \
com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp \
com/mapswithme/maps/bookmarks/data/BookmarkCategory.cpp \
@@ -54,7 +53,7 @@ LOCAL_SRC_FILES := \
com/mapswithme/platform/Platform.cpp \
com/mapswithme/platform/HttpThread.cpp \
com/mapswithme/platform/Language.cpp \
- com/mapswithme/platform/PThreadImpl.cpp \
+ com/mapswithme/platform/PThreadImpl.cpp \
nv_thread/nv_thread.cpp \
nv_event/nv_event_queue.cpp \
nv_event/nv_event.cpp \
diff --git a/android/jni/com/mapswithme/maps/bookmarks/PopupLayout.cpp b/android/jni/com/mapswithme/maps/bookmarks/PopupLayout.cpp
deleted file mode 100644
index 902c2c71cf..0000000000
--- a/android/jni/com/mapswithme/maps/bookmarks/PopupLayout.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "../Framework.hpp"
-
-#include "../../core/jni_helper.hpp"
-
-namespace
-{
- ::Framework * frm() { return g_framework->NativeFramework(); }
-}
-
-extern "C"
-{
- JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_bookmarks_PopupLayout_nDrawBookmark(JNIEnv * env, jobject thiz, jdouble px, jdouble py)
- {
- frm()->DrawPlacemark(frm()->PtoG(m2::PointD(px, py)));
- frm()->Invalidate();
- }
-
- JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_bookmarks_PopupLayout_nRemoveBookmark(JNIEnv * env, jobject thiz)
- {
- frm()->DisablePlacemark();
- frm()->Invalidate();
- }
-}
diff --git a/android/res/layout/map.xml b/android/res/layout/map.xml
index 9e2b3e9487..3ae5e41e1a 100644
--- a/android/res/layout/map.xml
+++ b/android/res/layout/map.xml
@@ -6,11 +6,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
- <com.mapswithme.maps.bookmarks.PopupLayout
- android:id="@+id/map_popup"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"/>
-
<LinearLayout
android:id="@+id/navigation_buttons_container"
android:layout_width="wrap_content"
diff --git a/android/src/com/mapswithme/maps/bookmarks/PopupLayout.java b/android/src/com/mapswithme/maps/bookmarks/PopupLayout.java
deleted file mode 100644
index ae76d2d1e2..0000000000
--- a/android/src/com/mapswithme/maps/bookmarks/PopupLayout.java
+++ /dev/null
@@ -1,257 +0,0 @@
-package com.mapswithme.maps.bookmarks;
-
-import com.mapswithme.maps.R;
-import com.mapswithme.maps.bookmarks.data.Bookmark;
-import com.mapswithme.maps.bookmarks.data.BookmarkManager;
-import com.mapswithme.maps.bookmarks.data.ParcelablePoint;
-
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.Path;
-import android.graphics.Point;
-import android.graphics.PorterDuff.Mode;
-import android.graphics.Rect;
-import android.text.TextPaint;
-import android.text.TextUtils;
-import android.text.TextUtils.TruncateAt;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.view.WindowManager;
-
-public class PopupLayout extends View
-{
- private static final String DEACTIVATION = "deactivation";
- private static final int VERTICAL_MARGIN = 10;
- private final int mThriangleHeight;
- private Bitmap mAddButton;
- private Bitmap mEditButton;
- private Bitmap mPin;
- private Bitmap mPopup;
-
- volatile private Bookmark mBmk;
- private Paint mBackgroundPaint;
- private Paint mBorderPaint;
- private Paint mButtonPaint = new Paint();
- private Path mPopupPath;
- private TextPaint mTextPaint;
- private Rect mTextBounds = new Rect();
- private Rect mPopupRect = new Rect();
- private Point mPopupAnchor = new Point();
-
- private int mWidth;
- private int mHeight;
-
- public PopupLayout(Context context)
- {
- this(context, null, 0);
- }
-
- public PopupLayout(Context context, AttributeSet attrs)
- {
- this(context, attrs, 0);
- }
-
- public PopupLayout(Context context, AttributeSet attrs, int defStyle)
- {
- super(context, attrs, defStyle);
- mAddButton = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.add);
- mEditButton = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.arrow);
- mPin = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.placemark_red);
-
- mThriangleHeight = (int) (10 * getResources().getDisplayMetrics().density);
- mBackgroundPaint = new Paint();
- mBackgroundPaint.setColor(Color.BLACK);
- mBackgroundPaint.setStyle(Paint.Style.FILL);
- mBorderPaint = new Paint();
- mBorderPaint.setStyle(Style.STROKE);
- mBorderPaint.setColor(Color.GRAY);
- mBorderPaint.setStrokeWidth(2);
- mBorderPaint.setAntiAlias(true);
- mPopupPath = new Path();
-
- mTextPaint = new TextPaint();
- mTextPaint.setTextSize(20 * getResources().getDisplayMetrics().density);
- mTextPaint.setAntiAlias(true);
- mTextPaint.setColor(Color.WHITE);
- }
-
- public synchronized void activate(final Bookmark bmk, WindowManager manager)
- {
- mBmk = bmk;
- if (bmk.isPreviewBookmark())
- {
- nDrawBookmark(bmk.getPosition().x, bmk.getPosition().y);
- }
- mPopup = prepareBitmap(mBmk, manager);
- postInvalidate();
- }
-
- public synchronized void deactivate()
- {
- mBmk = null;
- nRemoveBookmark();
- if(mPopup != null)
- {
- Bitmap b = mPopup;
- mPopup = null;
- b.recycle();
- }
- postInvalidate();
- }
-
- public synchronized boolean isActive()
- {
- return mBmk != null;
- }
-
- private Point anchor;
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh)
- {
- super.onSizeChanged(w, h, oldw, oldh);
- anchor = new Point(w / 2, h / 2);
- }
-
- public void requestInvalidation()
- {
- if (isActive())
- postInvalidate();
- }
-
- private Bitmap prepareBitmap(Bookmark bmk, WindowManager manager)
- {
- anchor = bmk.getPosition().getRoundedPoint();
-
- Bitmap btn;
- if (bmk.isPreviewBookmark())
- {
- btn = mAddButton;
- }
- else
- {
- btn = mEditButton;
- BookmarkManager.getBookmarkManager(getContext()).getCategoryById(bmk.getCategoryId()).setVisibility(true);
- }
-
- String bmkName = bmk.getName();
- int pWidth = Math.min(manager.getDefaultDisplay().getWidth(), manager.getDefaultDisplay().getHeight()) - VERTICAL_MARGIN;
- int pHeight = mHeight = btn.getHeight() + 10;
- int maxTextWidth = pWidth - btn.getWidth() - 10;
- int currentTextWidth = Math.round(mTextPaint.measureText(bmkName));
- String text;
- if (currentTextWidth > maxTextWidth)
- {
- text = TextUtils.ellipsize(bmkName, mTextPaint, maxTextWidth, TruncateAt.END).toString();
- currentTextWidth = Math.round(mTextPaint.measureText(text));;
- }
- else
- {
- text = bmkName;
- }
- pWidth = mWidth = currentTextWidth + btn.getWidth() + 10;
-
-
- mPopupPath.reset();
- mPopupPath.moveTo(0, 0);
- mPopupPath.lineTo(pWidth, 0);
- mPopupPath.lineTo(pWidth, 0 + pHeight);
- mPopupPath.lineTo(mWidth/2 + mThriangleHeight, pHeight);
- mPopupPath.lineTo(mWidth/2, pHeight + mThriangleHeight);
- mPopupPath.lineTo(mWidth/2 - mThriangleHeight, pHeight);
- mPopupPath.lineTo(0, pHeight);
- mPopupPath.lineTo(0, 0);
-
- Bitmap b = Bitmap.createBitmap(pWidth, pHeight + mThriangleHeight, Config.ARGB_8888);
- Canvas canvas = new Canvas(b);
- canvas.drawPath(mPopupPath, mBackgroundPaint);
- canvas.drawBitmap(btn, pWidth - btn.getWidth()-5, + 5, mButtonPaint);
- canvas.drawPath(mPopupPath, mBorderPaint);
- mTextPaint.getTextBounds(text, 0, text.length(), mTextBounds);
-
- int textHeight = mTextBounds.bottom - mTextBounds.top;
- canvas.drawText(text, 2,
- - (pHeight - textHeight) / 2 + pHeight,
- mTextPaint);
-
- return b;
- }
-
- @Override
- protected void onDraw(Canvas canvas)
- {
- Bookmark bmk = mBmk;
- if (bmk != null)
- {
- int pinHeight = Math.round(35/1.5f * getResources().getDisplayMetrics().density);
- mPopupAnchor.x = bmk.getPosition().getRoundX() - mWidth / 2;
- mPopupAnchor.y = bmk.getPosition().getRoundY() - pinHeight - mThriangleHeight - mHeight;
-
- mPopupRect.left = mPopupAnchor.x;
- mPopupRect.top = mPopupAnchor.y;
- mPopupRect.right = mPopupAnchor.x + mWidth;
- mPopupRect.bottom = mPopupAnchor.y + mHeight;
-
- if (mPopup != null)
- {
- canvas.drawBitmap(mPopup, mPopupAnchor.x, mPopupAnchor.y, mButtonPaint);
- }
- }
- else
- {
- super.onDraw(canvas);
- }
-
- }
-
- private native void nDrawBookmark(double x, double y);
- private native void nRemoveBookmark();
-
- /**
- *
- * @param x
- * @param y
- * @return true if we start {@link BookmarkActivity}, false otherwise
- */
- public synchronized boolean handleClick(int x, int y, boolean ispro)
- {
- if (mBmk != null)
- {
- if ( mPopupRect.contains(x, y) )
- {
- if (ispro)
- {
- if (mBmk.isPreviewBookmark())
- {
- getContext().startActivity(new Intent(getContext(), BookmarkActivity.class).
- putExtra(BookmarkActivity.BOOKMARK_POSITION, (mBmk.getPosition())).
- putExtra(BookmarkActivity.BOOKMARK_NAME, mBmk.getName()));
- }
- else
- {
- getContext().startActivity(
- new Intent(getContext(), BookmarkActivity.class)
- .putExtra(
- BookmarkActivity.PIN,
- new ParcelablePoint(mBmk.getCategoryId(), mBmk.getBookmarkId()
- )
- ));
- }
- }
- return true;
- }
- deactivate();
- }
- return false;
- }
-
-
-}