|
@@ -1,28 +1,24 @@
|
|
|
package de.tudarmstadt.informatik.hostage.ui2.adapter;
|
|
|
|
|
|
+
|
|
|
import android.app.AlertDialog;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
+import android.content.SharedPreferences;
|
|
|
import android.os.Build;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ArrayAdapter;
|
|
|
import android.widget.CompoundButton;
|
|
|
-import android.widget.ImageButton;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.ListView;
|
|
|
import android.widget.Switch;
|
|
|
import android.widget.TextView;
|
|
|
-import android.widget.ViewSwitcher;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
|
import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
|
|
|
import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
|
|
|
-import de.tudarmstadt.informatik.hostage.ui2.fragment.ServicesFragment;
|
|
|
import de.tudarmstadt.informatik.hostage.ui2.model.ServicesListItem;
|
|
|
|
|
|
/**
|
|
@@ -30,6 +26,7 @@ import de.tudarmstadt.informatik.hostage.ui2.model.ServicesListItem;
|
|
|
*/
|
|
|
public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
|
|
|
|
+ private SharedPreferences mConnectionInfo;
|
|
|
|
|
|
private class ViewHolder {
|
|
|
public TextView protocolName;
|
|
@@ -78,7 +75,6 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
|
holder.circle = rowView.findViewById(R.id.services_circle);
|
|
|
rowView.setTag(holder);
|
|
|
|
|
|
-
|
|
|
} else {
|
|
|
holder = (ViewHolder) rowView.getTag();
|
|
|
}
|
|
@@ -94,15 +90,15 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
|
ServicesListItem item = (ServicesListItem) buttonView.getTag();
|
|
|
System.out
|
|
|
.println("Protokoll: " + item.protocol);
|
|
|
- System.out.println("Position: " + position);
|
|
|
if(!HelperUtils.isWifiConnected(mActivity)){
|
|
|
new AlertDialog.Builder(mActivity)
|
|
|
.setTitle("Information")
|
|
|
.setMessage("You are not connected to a WiFi network. \n\nPlease connect to one, before trying to activate HosTaGe.")
|
|
|
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
- }
|
|
|
- })
|
|
|
+ .setPositiveButton(android.R.string.ok,
|
|
|
+ new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ }
|
|
|
+ })
|
|
|
.setIcon(android.R.drawable.ic_dialog_info)
|
|
|
.show();
|
|
|
|
|
@@ -126,7 +122,6 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
return rowView;
|
|
|
}
|
|
|
|
|
@@ -149,16 +144,24 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
|
holder.circle.setBackground(MainActivity.getInstance().getResources().getDrawable(R.drawable.services_circle));
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /*private void updateProtocolConnections(int connections, String protocolName, ServicesListAdapter adapter) {
|
|
|
- for (int i = 0; i < adapter.getCount(); ++i) {
|
|
|
- HashMap<String, String> d = ((HashMap<String, String>) adapter
|
|
|
- .getItem(i));
|
|
|
- if (d.get("protocol").equals(protocolName)) {
|
|
|
- d.put("connections", String.valueOf(connections));
|
|
|
+ if((Integer.valueOf(item.attacks) > 0) && (Integer.valueOf(item.attacks) == item.initialValue) && MainActivity.getInstance().getHoneyService().isRunning(item.protocol)) {
|
|
|
+ if(sdk < Build.VERSION_CODES.JELLY_BEAN){
|
|
|
+ holder.circle.setBackgroundDrawable(MainActivity.getInstance().getResources().getDrawable(R.drawable.services_circle_yellow));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ holder.circle.setBackground(MainActivity.getInstance().getResources().getDrawable(R.drawable.services_circle_yellow));
|
|
|
}
|
|
|
}
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
- }*/
|
|
|
+ else if( (item.initialValue < Integer.valueOf(item.attacks)) && MainActivity.getInstance().getHoneyService().isRunning(item.protocol)) {
|
|
|
+ System.out.println(item.initialValue);
|
|
|
+ if(sdk < Build.VERSION_CODES.JELLY_BEAN){
|
|
|
+ holder.circle.setBackgroundDrawable(MainActivity.getInstance().getResources().getDrawable(R.drawable.services_circle_red));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ holder.circle.setBackground(MainActivity.getInstance().getResources().getDrawable(R.drawable.services_circle_red));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ holder.recordedAttacks.setText(item.attacks);
|
|
|
+ }
|
|
|
+
|
|
|
}
|