|
@@ -8,7 +8,12 @@ import java.util.HashMap;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.annotation.SuppressLint;
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
|
+import android.content.Context;
|
|
|
|
+import android.content.SharedPreferences;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.view.Menu;
|
|
|
|
+import android.view.MenuInflater;
|
|
|
|
+import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.widget.AdapterView;
|
|
import android.widget.AdapterView;
|
|
import android.widget.ListAdapter;
|
|
import android.widget.ListAdapter;
|
|
@@ -27,9 +32,18 @@ import de.tudarmstadt.informatik.hostage.logging.Record;
|
|
public class ViewLogTable extends Activity{
|
|
public class ViewLogTable extends Activity{
|
|
DatabaseHandler dbh;
|
|
DatabaseHandler dbh;
|
|
|
|
|
|
|
|
+ private ArrayList<String> selectedProtocols;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
|
+
|
|
|
|
+ this.selectedProtocols = new ArrayList<String>();
|
|
|
|
+
|
|
|
|
+ for (String protocol : this.getResources().getStringArray( R.array.protocols)){
|
|
|
|
+ this.selectedProtocols.add(protocol);
|
|
|
|
+ }
|
|
|
|
+
|
|
dbh = new DatabaseHandler(getBaseContext());
|
|
dbh = new DatabaseHandler(getBaseContext());
|
|
setContentView(R.layout.activity_loglist);
|
|
setContentView(R.layout.activity_loglist);
|
|
// StringBuffer log = new StringBuffer();
|
|
// StringBuffer log = new StringBuffer();
|
|
@@ -60,24 +74,27 @@ public class ViewLogTable extends Activity{
|
|
ArrayList<Record> data = dbh.getAllRecords();
|
|
ArrayList<Record> data = dbh.getAllRecords();
|
|
|
|
|
|
for (Record val : data) {
|
|
for (Record val : data) {
|
|
- HashMap<String, String> map = new HashMap<String, String>();
|
|
|
|
- map.put(this.getString(R.string.RecordBSSID), val.getBSSID() );
|
|
|
|
- map.put(this.getString(R.string.RecordSSID), val.getSSID());
|
|
|
|
- map.put(this.getString(R.string.RecordProtocol), val.getProtocol());
|
|
|
|
- map.put(this.getString(R.string.RecordTimestamp), this.getDateAsString(val.getTimestamp()));
|
|
|
|
- Items.add(map);
|
|
|
|
|
|
+ String protocol = val.getProtocol();
|
|
|
|
+ if (this.selectedProtocols.contains(protocol)){
|
|
|
|
+ HashMap<String, String> map = new HashMap<String, String>();
|
|
|
|
+ map.put(this.getString(R.string.RecordBSSID), val.getBSSID() );
|
|
|
|
+ map.put(this.getString(R.string.RecordSSID), val.getSSID());
|
|
|
|
+ map.put(this.getString(R.string.RecordProtocol), val.getProtocol());
|
|
|
|
+ map.put(this.getString(R.string.RecordTimestamp), this.getDateAsString(val.getTimestamp()));
|
|
|
|
+ Items.add(map);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Adding Items to ListView
|
|
// Adding Items to ListView
|
|
- ListAdapter adapter = new SimpleAdapter(this, Items,
|
|
|
|
- R.layout.loglist_row,new String[] { this.getString(R.string.RecordBSSID), this.getString(R.string.RecordSSID), this.getString(R.string.RecordProtocol), this.getString(R.string.RecordTimestamp) },
|
|
|
|
- new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp });
|
|
|
|
|
|
+ String keys[] = new String[] { this.getString(R.string.RecordBSSID), this.getString(R.string.RecordSSID), this.getString(R.string.RecordProtocol), this.getString(R.string.RecordTimestamp)};
|
|
|
|
+ int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
|
|
|
|
+
|
|
|
|
+ ListAdapter adapter = new SimpleAdapter(this, Items, R.layout.loglist_row, keys, ids);
|
|
|
|
|
|
mylist.setAdapter(adapter);
|
|
mylist.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
@SuppressLint("SimpleDateFormat")
|
|
@@ -143,33 +160,55 @@ public class ViewLogTable extends Activity{
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// @Override
|
|
|
|
-// public boolean onCreateOptionsMenu(Menu menu)
|
|
|
|
-// {
|
|
|
|
-// MenuInflater inflater = getMenuInflater();
|
|
|
|
-// inflater.inflate(R.menu.main_menu, menu);
|
|
|
|
-// return true;
|
|
|
|
-// }
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu)
|
|
|
|
+ {
|
|
|
|
+ super.onCreateOptionsMenu(menu);
|
|
|
|
+
|
|
|
|
+ for (String protocol : this.getResources().getStringArray( R.array.protocols)){
|
|
|
|
+ MenuItem item = menu.add(protocol);
|
|
|
|
+ item.setCheckable(true);
|
|
|
|
+ boolean isChecked = this.selectedProtocols.contains(item.getTitle());
|
|
|
|
+ item.setChecked(isChecked);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// MenuInflater inflater = getMenuInflater();
|
|
|
|
+// inflater.inflate(R.menu.listview_detail_menu, menu);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item)
|
|
|
|
+ {
|
|
|
|
+ boolean isChecked = this.selectedProtocols.contains(item.getTitle());
|
|
|
|
|
|
-// @Override
|
|
|
|
-// public boolean onOptionsItemSelected(MenuItem item)
|
|
|
|
-// {
|
|
|
|
-// switch (item.getItemId())
|
|
|
|
-// {
|
|
|
|
-// case R.id.home:
|
|
|
|
-// ListviewActivity.this.finish();
|
|
|
|
-// return true;
|
|
|
|
-// case R.id.about:
|
|
|
|
-// Toast.makeText(getApplicationContext(), "This is collection and is created by amdel corporation",
|
|
|
|
-// Toast.LENGTH_LONG).show();
|
|
|
|
-// return true;
|
|
|
|
-// case R.id.exit:
|
|
|
|
-// finish();
|
|
|
|
-// System.exit(0);
|
|
|
|
-// return true;
|
|
|
|
-// default:
|
|
|
|
-// return super.onOptionsItemSelected(item);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
|
|
+ if (isChecked){
|
|
|
|
+ this.selectedProtocols.remove(item.getTitle());
|
|
|
|
+ } else {
|
|
|
|
+ this.selectedProtocols.add(item.getTitle().toString());
|
|
|
|
+ }
|
|
|
|
+ item.setChecked(!isChecked);
|
|
|
|
+
|
|
|
|
+ this.populateListViewFromDB();
|
|
|
|
+
|
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void saveInSharedPreferences(String key, boolean value){
|
|
|
|
+ //--SAVE Data
|
|
|
|
+ SharedPreferences preferences = this.getSharedPreferences();
|
|
|
|
+ SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
+ editor.putBoolean(key, value);
|
|
|
|
+ editor.commit();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean getBooleanInSharedPreferences(String key){
|
|
|
|
+ SharedPreferences preferences = this.getSharedPreferences();
|
|
|
|
+ return preferences.getBoolean(key, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private SharedPreferences getSharedPreferences(){
|
|
|
|
+ return this.getSharedPreferences("HostagePreferences", Context.MODE_PRIVATE);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|