|
@@ -1,17 +1,19 @@
|
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
-import android.app.Fragment;
|
|
|
import android.os.Bundle;
|
|
|
+import android.text.format.DateFormat;
|
|
|
+import android.text.method.ScrollingMovementMethod;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuInflater;
|
|
|
+import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.ScrollView;
|
|
|
import android.widget.TextView;
|
|
|
-
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
@@ -62,6 +64,15 @@ public class RecordDetailFragment extends UpNavigatibleFragment {
|
|
|
private Record record;
|
|
|
private UglyDbHelper dbh;
|
|
|
private View rootView;
|
|
|
+ private LayoutInflater mInflater;
|
|
|
+
|
|
|
+
|
|
|
+ private ScrollView mScrollView;
|
|
|
+ private LinearLayout mRecordOverviewConversation;
|
|
|
+ private TextView mRecordDetailsTextSsid;
|
|
|
+ private TextView mRecordDetailsTextBssid;
|
|
|
+ private TextView mRecordDetailsTextRemoteip;
|
|
|
+ private TextView mRecordDetailsTextProtocol;
|
|
|
|
|
|
public void setRecord(Record rec){
|
|
|
this.record = rec;
|
|
@@ -71,7 +82,8 @@ public class RecordDetailFragment extends UpNavigatibleFragment {
|
|
|
}
|
|
|
|
|
|
public int getLayoutId(){
|
|
|
- return R.layout.fragment_record_detail;
|
|
|
+ //return R.layout.fragment_record_detail;
|
|
|
+ return R.layout.fragment_record_overview;
|
|
|
}
|
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
@@ -83,11 +95,15 @@ public class RecordDetailFragment extends UpNavigatibleFragment {
|
|
|
Bundle savedInstanceState) {
|
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
|
+ mInflater = inflater;
|
|
|
+ getActivity().setTitle(record.getSsid());
|
|
|
+
|
|
|
this.dbh = new UglyDbHelper(this.getActivity().getBaseContext());
|
|
|
|
|
|
this.rootView = inflater.inflate(this.getLayoutId(), container, false);
|
|
|
+ this.assignViews(rootView);
|
|
|
this.configurateRootView(rootView);
|
|
|
- System.out.println("ATT: " + dbh.getConversationForAttackID(record.getAttack_id()));
|
|
|
+
|
|
|
|
|
|
return rootView;
|
|
|
}
|
|
@@ -97,37 +113,64 @@ public class RecordDetailFragment extends UpNavigatibleFragment {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void configurateRootView(View rootView) {
|
|
|
- /*
|
|
|
- String protocol = this.record.getProtocol();
|
|
|
- String type = "" + this.record.getType();
|
|
|
- String externalIP = this.record.getExternalIP();
|
|
|
- String localIP = this.record.getLocalIP();
|
|
|
- String localPort = "" + this.record.getLocalPort();
|
|
|
- String remoteIP = this.record.getRemoteIP();
|
|
|
- String bssid = this.record.getBssid() ;
|
|
|
- String essid = this.record.getSsid();
|
|
|
- double latitude = this.record.getLatitude();
|
|
|
- double longitude = this.record.getLongitude();
|
|
|
- float accuracy =this.record.getAccuracy();
|
|
|
-
|
|
|
- Location location = new Location(latitude, longitude, accuracy);
|
|
|
-
|
|
|
- String packet = this.record.getPacket();
|
|
|
- String timeStamp = this.getDateAsString(this.record.getTimestamp());
|
|
|
- */
|
|
|
-
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_ssid_value)).setText(record.getSsid());
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_bssid_value)).setText(record.getBssid());
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_protocol_value)).setText(record.getProtocol());
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_timestamp_value)).setText(getDateAsString(record.getTimestamp()));
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_location_value)).setText(record.getLatitude() + ", " + record.getLongitude());
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_externalip_value)).setText(record.getExternalIP());
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_internalip_value)).setText(record.getLocalIP() + ":" + record.getLocalPort());
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_remoteip_value)).setText(record.getRemoteIP() + ":" + record.getRemotePort());
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_packettype_value)).setText(
|
|
|
- record.getType() == Record.TYPE.SEND ? "SEND" : "RECV");
|
|
|
- ((TextView)rootView.findViewById(R.id.record_detail_packetcontent_value)).setText(record.getPacket());
|
|
|
+ private void assignViews(View view) {
|
|
|
+ mScrollView = (ScrollView) view.findViewById(R.id.scrollView);
|
|
|
+ mRecordOverviewConversation = (LinearLayout) view.findViewById(R.id.record_overview_conversation);
|
|
|
+ mRecordDetailsTextSsid = (TextView) view.findViewById(R.id.record_details_text_ssid);
|
|
|
+ mRecordDetailsTextBssid = (TextView) view.findViewById(R.id.record_details_text_bssid);
|
|
|
+ mRecordDetailsTextRemoteip = (TextView) view.findViewById(R.id.record_details_text_remoteip);
|
|
|
+ mRecordDetailsTextProtocol = (TextView) view.findViewById(R.id.record_details_text_protocol);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void configurateRootView(View rootView) {
|
|
|
+
|
|
|
+ mRecordDetailsTextBssid.setText(record.getBssid());
|
|
|
+ mRecordDetailsTextSsid.setText(record.getSsid());
|
|
|
+ if(record.getRemoteIP() != null) mRecordDetailsTextRemoteip.setText(record.getRemoteIP() + ":" + record.getRemotePort());
|
|
|
+ mRecordDetailsTextProtocol.setText(record.getProtocol());
|
|
|
+
|
|
|
+ ArrayList<Record> conversation = this.dbh.getConversationForAttackID(record.getAttack_id());
|
|
|
+
|
|
|
+ for(Record r: conversation){
|
|
|
+ View row;
|
|
|
+
|
|
|
+ String from = r.getLocalIP() == null ? "-" : r.getLocalIP() + ":" + r.getLocalPort();
|
|
|
+ String to = r.getRemoteIP() == null ? "-" : r.getRemoteIP() + ":" + r.getRemotePort();
|
|
|
+
|
|
|
+ if(r.getType() == Record.TYPE.SEND){
|
|
|
+ row = mInflater.inflate(R.layout.fragment_record_conversation_sent, null);
|
|
|
+ } else {
|
|
|
+ row = mInflater.inflate(R.layout.fragment_record_conversation_received, null);
|
|
|
+
|
|
|
+ String tmp = from;
|
|
|
+ from = to;
|
|
|
+ to = tmp;
|
|
|
+ }
|
|
|
+
|
|
|
+ TextView conversationInfo = (TextView) row.findViewById(R.id.record_conversation_info);
|
|
|
+ TextView conversationContent = (TextView) row.findViewById(R.id.record_conversation_content);
|
|
|
+ conversationContent.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(final View v, final MotionEvent motionEvent) {
|
|
|
+ if (v.getId() == R.id.record_conversation_content) {
|
|
|
+ v.getParent().requestDisallowInterceptTouchEvent(true);
|
|
|
+ switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
|
|
|
+ case MotionEvent.ACTION_UP:
|
|
|
+ v.getParent().requestDisallowInterceptTouchEvent(
|
|
|
+ false);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Date date = new Date(r.getTimestamp());
|
|
|
+ conversationInfo.setText(String.format(getString(R.string.record_details_info), from, to, getDateAsString(date), getTimeAsString(date)));
|
|
|
+ if(r.getPacket() != null) conversationContent.setText(r.getPacket());
|
|
|
+
|
|
|
+ mRecordOverviewConversation.addView(row);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -136,20 +179,14 @@ public class RecordDetailFragment extends UpNavigatibleFragment {
|
|
|
* Date Transform
|
|
|
*
|
|
|
* ***************************/
|
|
|
-
|
|
|
-
|
|
|
- @SuppressLint("SimpleDateFormat")
|
|
|
- private String getDateAsString(long timeStamp) {
|
|
|
-
|
|
|
- try {
|
|
|
- DateFormat sdf = new SimpleDateFormat("H:mm d.M.yy");
|
|
|
- Date netDate = (new Date(timeStamp));
|
|
|
- return sdf.format(netDate);
|
|
|
- } catch (Exception ex) {
|
|
|
- return "xx";
|
|
|
- }
|
|
|
+ private String getDateAsString(Date date) {
|
|
|
+ return DateFormat.getDateFormat(getActivity()).format(date);
|
|
|
}
|
|
|
|
|
|
+ private String getTimeAsString(Date date){
|
|
|
+ return DateFormat.getTimeFormat(getActivity()).format(date);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|