From 6d2cbdae51c0cc2a1e2c898dcfc73df49e87682c Mon Sep 17 00:00:00 2001 From: sjtufs Date: Wed, 28 Aug 2013 17:32:17 +0800 Subject: Markers (Other Users) are now "touchable" --- client/Piztor/.project | 33 ----------- client/Piztor/.settings/org.eclipse.jdt.core.prefs | 4 -- client/Piztor/ic_launcher-web.png | Bin 130248 -> 0 bytes client/Piztor/proguard-project.txt | 20 ------- client/Piztor/project.properties | 14 ----- client/Piztor/res/drawable/pop.png | Bin 0 -> 1312 bytes client/Piztor/res/drawable/popup_down.png | Bin 0 -> 2998 bytes client/Piztor/res/drawable/popup_left.png | Bin 0 -> 2902 bytes client/Piztor/res/drawable/popup_middle.png | Bin 0 -> 3100 bytes client/Piztor/res/drawable/popup_right.png | Bin 0 -> 2917 bytes client/Piztor/res/drawable/popup_side.png | Bin 0 -> 3040 bytes client/Piztor/res/layout/custom_text_view.xml | 61 +++++++++++++++++++++ .../Piztor/src/com/macaroon/piztor/BMapUtil.java | 5 -- client/Piztor/src/com/macaroon/piztor/Main.java | 32 +++-------- .../Piztor/src/com/macaroon/piztor/MapMaker.java | 60 ++++++++++++++++++-- client/README.rst | 1 - 16 files changed, 125 insertions(+), 105 deletions(-) delete mode 100644 client/Piztor/.project delete mode 100644 client/Piztor/.settings/org.eclipse.jdt.core.prefs delete mode 100644 client/Piztor/ic_launcher-web.png delete mode 100644 client/Piztor/proguard-project.txt delete mode 100644 client/Piztor/project.properties create mode 100644 client/Piztor/res/drawable/pop.png create mode 100644 client/Piztor/res/drawable/popup_down.png create mode 100644 client/Piztor/res/drawable/popup_left.png create mode 100644 client/Piztor/res/drawable/popup_middle.png create mode 100644 client/Piztor/res/drawable/popup_right.png create mode 100644 client/Piztor/res/drawable/popup_side.png create mode 100644 client/Piztor/res/layout/custom_text_view.xml delete mode 100644 client/README.rst diff --git a/client/Piztor/.project b/client/Piztor/.project deleted file mode 100644 index 97100ec..0000000 --- a/client/Piztor/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - Piztor - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/client/Piztor/.settings/org.eclipse.jdt.core.prefs b/client/Piztor/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b080d2d..0000000 --- a/client/Piztor/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/client/Piztor/ic_launcher-web.png b/client/Piztor/ic_launcher-web.png deleted file mode 100644 index 3cd0ac2..0000000 Binary files a/client/Piztor/ic_launcher-web.png and /dev/null differ diff --git a/client/Piztor/proguard-project.txt b/client/Piztor/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/client/Piztor/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/client/Piztor/project.properties b/client/Piztor/project.properties deleted file mode 100644 index ce39f2d..0000000 --- a/client/Piztor/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-18 diff --git a/client/Piztor/res/drawable/pop.png b/client/Piztor/res/drawable/pop.png new file mode 100644 index 0000000..07e897a Binary files /dev/null and b/client/Piztor/res/drawable/pop.png differ diff --git a/client/Piztor/res/drawable/popup_down.png b/client/Piztor/res/drawable/popup_down.png new file mode 100644 index 0000000..8dad382 Binary files /dev/null and b/client/Piztor/res/drawable/popup_down.png differ diff --git a/client/Piztor/res/drawable/popup_left.png b/client/Piztor/res/drawable/popup_left.png new file mode 100644 index 0000000..98c81b6 Binary files /dev/null and b/client/Piztor/res/drawable/popup_left.png differ diff --git a/client/Piztor/res/drawable/popup_middle.png b/client/Piztor/res/drawable/popup_middle.png new file mode 100644 index 0000000..750b455 Binary files /dev/null and b/client/Piztor/res/drawable/popup_middle.png differ diff --git a/client/Piztor/res/drawable/popup_right.png b/client/Piztor/res/drawable/popup_right.png new file mode 100644 index 0000000..84745ff Binary files /dev/null and b/client/Piztor/res/drawable/popup_right.png differ diff --git a/client/Piztor/res/drawable/popup_side.png b/client/Piztor/res/drawable/popup_side.png new file mode 100644 index 0000000..49135ca Binary files /dev/null and b/client/Piztor/res/drawable/popup_side.png differ diff --git a/client/Piztor/res/layout/custom_text_view.xml b/client/Piztor/res/layout/custom_text_view.xml new file mode 100644 index 0000000..5ef1c9f --- /dev/null +++ b/client/Piztor/res/layout/custom_text_view.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/client/Piztor/src/com/macaroon/piztor/BMapUtil.java b/client/Piztor/src/com/macaroon/piztor/BMapUtil.java index 04e2e71..38d9f7d 100644 --- a/client/Piztor/src/com/macaroon/piztor/BMapUtil.java +++ b/client/Piztor/src/com/macaroon/piztor/BMapUtil.java @@ -5,11 +5,6 @@ import android.view.View; public class BMapUtil { - /** - * 从view 得到图片 - * @param view - * @return - */ public static Bitmap getBitmapFromView(View view) { view.destroyDrawingCache(); view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java index c3f6047..952b7f2 100644 --- a/client/Piztor/src/com/macaroon/piztor/Main.java +++ b/client/Piztor/src/com/macaroon/piztor/Main.java @@ -4,6 +4,8 @@ import java.util.Timer; import java.util.TimerTask; import android.annotation.SuppressLint; +import android.graphics.Bitmap; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -19,10 +21,15 @@ import com.baidu.location.BDLocation; import com.baidu.location.BDLocationListener; import com.baidu.location.LocationClient; import com.baidu.location.LocationClientOption; +import com.baidu.mapapi.map.ItemizedOverlay; import com.baidu.mapapi.map.LocationData; import com.baidu.mapapi.map.MapView; import com.baidu.mapapi.map.OverlayItem; +import com.baidu.mapapi.map.PopupClickListener; import com.baidu.mapapi.map.PopupOverlay; +import com.baidu.platform.comapi.basestruct.GeoPoint; + +import com.macaroon.piztor.BMapUtil; public class Main extends PiztorAct { final static int SearchButtonPress = 1; @@ -32,19 +39,6 @@ public class Main extends PiztorAct { final static int Fetch = 6; final static int mapViewtouched = 7; - /** - * popups - */ - private PopupOverlay pop = null; - private TextView popupText = null; - private View viewCache = null; - private View popupInfo = null; - private View popupLeft = null; - private View popupRight = null; - private MapView.LayoutParams layoutParam = null; - private OverlayItem mCurItem = null; - - MapMaker mapMaker = null; MapView mMapView; @@ -156,7 +150,6 @@ public class Main extends PiztorAct { void flushMap() { if (mapMaker != null) mapMaker.UpdateMap(AppMgr.mapInfo); - else System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); } public class MyLocationListener implements BDLocationListener { @@ -300,8 +293,6 @@ public class Main extends PiztorAct { actMgr.add(focusStatus, Fetch, focusStatus); //autodate = new Timer(); flushMap(); - // ImageView view = (ImageView) findViewById(R.id.main_mapview); - // view.setOnTouchListener(new MultiTouchListener()); setContentView(R.layout.activity_main); mMapView = (MapView) findViewById(R.id.bmapView); mapMaker = new MapMaker(mMapView, getApplicationContext()); @@ -316,15 +307,8 @@ public class Main extends PiztorAct { mLocClient.setLocOption(option); mLocClient.start(); mapMaker.UpdateLocationOverlay(locData, false); - - } - /* - public boolean onTap(int index) { - OverlayItem item = getItem(index); - mCurItem = item; - if () } - */ + @Override protected void onStart() { super.onStart(); diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java index 89f29fc..0c1a7d0 100644 --- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java +++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java @@ -12,14 +12,17 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.KeyEvent; +import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; +import android.widget.TextView; import android.app.Activity; import android.content.Context; import android.content.res.Configuration; +import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.widget.FrameLayout; import android.widget.Toast; @@ -42,6 +45,7 @@ import com.baidu.mapapi.map.MapPoi; import com.baidu.mapapi.map.MapView; import com.baidu.mapapi.map.MyLocationOverlay; import com.baidu.mapapi.map.OverlayItem; +import com.baidu.mapapi.map.PopupClickListener; import com.baidu.mapapi.map.PopupOverlay; import com.baidu.platform.comapi.basestruct.GeoPoint; @@ -56,6 +60,13 @@ public class MapMaker extends Activity{ private ArrayList mItems = null; private LocationOverlay mLocationOverlay; private Context context; + /** + * popups + */ + private PopupOverlay popLay = null; + private TextView popupText = null; + private View viewCache = null; + private View popupInfo = null; public MapMaker(MapView mapView, Context c) { mMapView = mapView; @@ -75,11 +86,31 @@ public class MapMaker extends Activity{ } } - public class MyOverlay extends ItemizedOverlay { + public class MyOverlay extends ItemizedOverlay{ public MyOverlay(Drawable defaultMarker, MapView mapView) { super(defaultMarker, mapView); } - } + + @Override + public boolean onTap(int index){ + Log.d("123", "Marker tap"); + OverlayItem item = getItem(index); + popupText.setText("^ _ ^"); + Bitmap bitmap = BMapUtil.getBitmapFromView(popupInfo); + popLay.showPopup(bitmap,item.getPoint(),32); + return true; + } + + @Override + public boolean onTap(GeoPoint pt, MapView mMapView){ + Log.d("123", "Marker tap disappear"); + + if (popLay != null){ + popLay.hidePop(); + } + return false; + } + } public void UpdateLocationOverlay(LocationData locationData, boolean hasAnimation) { /** @@ -102,6 +133,29 @@ public class MapMaker extends Activity{ mLocationOverlay.enableCompass(); mMapView.refresh(); mOverlay = new MyOverlay(context.getResources().getDrawable(R.drawable.circle_red), mMapView); + Log.d("123", "MapView initialized"); + + /** + * Initialize pop up + */ + LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); + Log.d("123", "OK 0"); + viewCache = inflater.inflate(R.layout.custom_text_view, null); + Log.d("123", "OK 1"); + popupInfo = (View) viewCache.findViewById(R.id.popinfo); + Log.d("123", "OK 2"); + popupText = (TextView) viewCache.findViewById(R.id.textcache); + Log.d("123", "OK 3"); + Log.d("123", "Popup initialized"); + + + PopupClickListener popListener = new PopupClickListener() { + @Override + public void onClickedPopup(int index) { + // + } + }; + popLay = new PopupOverlay(mMapView, popListener); } public void UpdateMap(MapInfo mapInfo) { @@ -109,9 +163,7 @@ public class MapMaker extends Activity{ * Update location of others */ if (mOverlay != null && mOverlay.getAllItem().size() != 0) { - System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); clearOverlay(mMapView); - System.out.println("+++++++++++++++++++++++------------------------------------------"); } mOverlay = new MyOverlay(context.getResources().getDrawable(R.drawable.circle_red), mMapView); //mMapView.refresh(); diff --git a/client/README.rst b/client/README.rst deleted file mode 100644 index 0527e6b..0000000 --- a/client/README.rst +++ /dev/null @@ -1 +0,0 @@ -This is a test -- cgit v1.2.3-70-g09d2