Browse Source

notify if the user isn't connected and tries to use the threatmap

Fabio Arnold 10 years ago
parent
commit
de6098cd6f

+ 2 - 1
res/values/strings.xml

@@ -20,7 +20,8 @@
     <string name="zero_attacks">0 attacks recorded</string>
 
     <string name="information">Information</string>
-    <string name="wifi_not_connected_msg">You are not connected to a WiFi network. \n\nPlease connect to one, before trying to activate HosTaGe.</string>
+	<string name="wifi_not_connected_msg">You are not connected to a WiFi network. \n\nPlease connect to one, before trying to activate HosTaGe.</string>
+	<string name="no_network_connection_threatmap_msg">Currently you are not connected to the Internet.\n\nPlease establish a connection to use the Threatmap.</string>
 	<string name="profile_no_services_msg">The current active protocol does not seem to monitor any services.\n\nPlease activate some services to monitor in the profile.</string>
 
     <string name="monitor_current_connection">Monitor current connection</string>

+ 17 - 0
src/de/tudarmstadt/informatik/hostage/ui2/fragment/ThreatMapFragment.java

@@ -1,8 +1,10 @@
 package de.tudarmstadt.informatik.hostage.ui2.fragment;
 
 import android.app.Activity;
+import android.app.AlertDialog;
 import android.app.Fragment;
 import android.app.FragmentManager;
+import android.content.DialogInterface;
 import android.graphics.Color;
 import android.location.Location;
 import android.os.Bundle;
@@ -29,6 +31,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
 import de.tudarmstadt.informatik.hostage.logging.Record;
 import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
 import de.tudarmstadt.informatik.hostage.ui.LogFilter;
@@ -295,6 +298,20 @@ public class ThreatMapFragment extends Fragment implements GoogleMap.OnInfoWindo
 			sMap.setOnInfoWindowClickListener(this);
 		}
 
+		// tell the user to enable wifi so map data can be streamed
+		if (!HelperUtils.isWifiConnected(activity)) {
+			new AlertDialog.Builder(activity)
+					.setTitle(R.string.information)
+					.setMessage(R.string.no_network_connection_threatmap_msg)
+					.setPositiveButton(android.R.string.ok,
+							new DialogInterface.OnClickListener() {
+								public void onClick(DialogInterface dialog,
+										int which) {
+								}
+							})
+					.setIcon(android.R.drawable.ic_dialog_info).show();
+		}
+
 		return sView;
 	}