|
@@ -1,5 +1,6 @@
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
|
|
|
|
|
|
+import android.app.Activity;
|
|
import android.app.AlertDialog;
|
|
import android.app.AlertDialog;
|
|
import android.app.Dialog;
|
|
import android.app.Dialog;
|
|
import android.app.DialogFragment;
|
|
import android.app.DialogFragment;
|
|
@@ -20,15 +21,25 @@ import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by Fabio Arnold on 03.03.14.
|
|
* Created by Fabio Arnold on 03.03.14.
|
|
|
|
+ * displays details about the current connection
|
|
*/
|
|
*/
|
|
public class ConnectionInfoDialogFragment extends DialogFragment {
|
|
public class ConnectionInfoDialogFragment extends DialogFragment {
|
|
public Dialog onCreateDialog(Bundle savedInstance) {
|
|
public Dialog onCreateDialog(Bundle savedInstance) {
|
|
- // get connection infos
|
|
|
|
- SharedPreferences sharedPreferences = getActivity().getSharedPreferences(getString(R.string.connection_info), Context.MODE_PRIVATE);
|
|
|
|
- final String ssid = sharedPreferences.getString(getString(R.string.connection_info_ssid), "");
|
|
|
|
- String bssid = sharedPreferences.getString(getString(R.string.connection_info_bssid), "");
|
|
|
|
- String internalIP = sharedPreferences.getString(getString(R.string.connection_info_internal_ip), "");
|
|
|
|
- String externalIP = sharedPreferences.getString(getString(R.string.connection_info_external_ip), "");
|
|
|
|
|
|
+ // the data we want to display
|
|
|
|
+ String ssid = "undefined";
|
|
|
|
+ String bssid = "undefined";
|
|
|
|
+ String internalIP = "undefined";
|
|
|
|
+ String externalIP = "undefined";
|
|
|
|
+
|
|
|
|
+ // get infos about the current connection using SharedPreferences
|
|
|
|
+ final Activity activity = getActivity();
|
|
|
|
+ if (activity != null) {
|
|
|
|
+ SharedPreferences sharedPreferences = activity.getSharedPreferences(getString(R.string.connection_info), Context.MODE_PRIVATE);
|
|
|
|
+ ssid = sharedPreferences.getString(getString(R.string.connection_info_ssid), "");
|
|
|
|
+ bssid = sharedPreferences.getString(getString(R.string.connection_info_bssid), "");
|
|
|
|
+ internalIP = sharedPreferences.getString(getString(R.string.connection_info_internal_ip), "");
|
|
|
|
+ externalIP = sharedPreferences.getString(getString(R.string.connection_info_external_ip), "");
|
|
|
|
+ }
|
|
|
|
|
|
// inflate the layout with a dark theme
|
|
// inflate the layout with a dark theme
|
|
Context context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo);
|
|
Context context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo);
|
|
@@ -36,12 +47,17 @@ public class ConnectionInfoDialogFragment extends DialogFragment {
|
|
View view = localInflater.inflate(R.layout.fragment_connectioninfo_dialog, null);
|
|
View view = localInflater.inflate(R.layout.fragment_connectioninfo_dialog, null);
|
|
|
|
|
|
// assign values in layout
|
|
// assign values in layout
|
|
- ((TextView)view.findViewById(R.id.connectioninfo_ssid_value)).setText(ssid);
|
|
|
|
- ((TextView)view.findViewById(R.id.connectioninfo_bssid_value)).setText(bssid);
|
|
|
|
- ((TextView)view.findViewById(R.id.connectioninfo_internalip_value)).setText(internalIP);
|
|
|
|
- ((TextView)view.findViewById(R.id.connectioninfo_externalip_value)).setText(externalIP);
|
|
|
|
|
|
+ if (view != null) {
|
|
|
|
+ ((TextView)view.findViewById(R.id.connectioninfo_ssid_value)).setText(ssid);
|
|
|
|
+ ((TextView)view.findViewById(R.id.connectioninfo_bssid_value)).setText(bssid);
|
|
|
|
+ ((TextView)view.findViewById(R.id.connectioninfo_internalip_value)).setText(internalIP);
|
|
|
|
+ ((TextView)view.findViewById(R.id.connectioninfo_externalip_value)).setText(externalIP);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // capture the SSID for the button action
|
|
|
|
+ final String filterSSID = ssid;
|
|
|
|
|
|
- // build the dialog
|
|
|
|
|
|
+ // build the actual dialog
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_HOLO_DARK);
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_HOLO_DARK);
|
|
builder.setView(view);
|
|
builder.setView(view);
|
|
builder.setTitle(R.string.title_connection_info);
|
|
builder.setTitle(R.string.title_connection_info);
|
|
@@ -50,7 +66,7 @@ public class ConnectionInfoDialogFragment extends DialogFragment {
|
|
@Override
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
ArrayList<String> ssids = new ArrayList<String>();
|
|
ArrayList<String> ssids = new ArrayList<String>();
|
|
- ssids.add(ssid);
|
|
|
|
|
|
+ ssids.add(filterSSID);
|
|
|
|
|
|
LogFilter filter = new LogFilter();
|
|
LogFilter filter = new LogFilter();
|
|
filter.setESSIDs(ssids);
|
|
filter.setESSIDs(ssids);
|