ソースを参照

threatmap: show link to records in info windows above markers

Fabio Arnold 10 年 前
コミット
935e352c46

+ 22 - 0
res/layout/fragment_threatmap_infowindow.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+			  android:orientation="vertical"
+			  android:layout_width="match_parent"
+			  android:layout_height="match_parent">
+
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:textAppearance="?android:attr/textAppearanceMedium"
+			android:text="undefined"
+			android:id="@+id/threatmap_infowindow_title" android:layout_gravity="center_horizontal"/>
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:textAppearance="?android:attr/textAppearanceSmall"
+			android:text="@string/threatmap_show_records"
+			android:id="@id/textView" android:layout_gravity="center_horizontal"
+			android:textColor="@color/dark_grey" android:clickable="false"
+			android:textIsSelectable="false"/>
+</LinearLayout>

+ 2 - 0
res/values/strings.xml

@@ -54,6 +54,8 @@
 	<string name="export_dialog_title">Choose Export Format</string>		
 	<string name="delete_dialog_title">Delete data sets by:</string>	
 	<string name="dialog_clear_database_date">Delete all data before:</string>
+
+	<string name="threatmap_show_records"><u>Show records</u></string>
 	
     <string name="RecordBSSID">BSSID</string>
     <string name="RecordSSID">SSID</string>

+ 22 - 2
src/de/tudarmstadt/informatik/hostage/ui2/fragment/ThreatMapFragment.java

@@ -12,6 +12,7 @@ import android.view.InflateException;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.TextView;
 
 import com.google.android.gms.common.ConnectionResult;
 import com.google.android.gms.common.GooglePlayServicesClient;
@@ -262,7 +263,7 @@ public class ThreatMapFragment extends Fragment implements GoogleMap.OnInfoWindo
 	 * @return the view
 	 */
 	@Override
-	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+	public View onCreateView(final LayoutInflater inflater, ViewGroup container,
 	                         Bundle savedInstanceState) {
 		super.onCreateView(inflater, container, savedInstanceState);
 
@@ -296,10 +297,29 @@ public class ThreatMapFragment extends Fragment implements GoogleMap.OnInfoWindo
 		}
 		if (sMap != null) {
 			sMap.setOnInfoWindowClickListener(this);
+			// custom info window layout
+			sMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
+				@Override
+				public View getInfoWindow(Marker marker) {
+					return null;
+				}
+
+				@Override
+				public View getInfoContents(Marker marker) {
+					View view = inflater.inflate(R.layout.fragment_threatmap_infowindow, null);
+					if (view != null) {
+						TextView titleTextView = (TextView)view.findViewById(R.id.threatmap_infowindow_title);
+						if (titleTextView != null) {
+							titleTextView.setText(marker.getTitle());
+						}
+					}
+					return view;
+				}
+			});
 		}
 
 		// tell the user to enable wifi so map data can be streamed
-		if (!HelperUtils.isWifiConnected(activity)) {
+		if (activity != null && !HelperUtils.isWifiConnected(activity)) {
 			new AlertDialog.Builder(activity)
 					.setTitle(R.string.information)
 					.setMessage(R.string.no_network_connection_threatmap_msg)