package de.tudarmstadt.informatik.hostage.ui;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.TextView;
import de.tudarmstadt.informatik.hostage.logging.Record;
import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;

/**
 * Creates a simple log view. Shows the Information for every attack. The format
 * ist defined in {@link Record#toString(int)}.
 * 
 * @author Lars Pandikow
 * 
 */
public class ViewLogTable extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		UglyDbHelper dbh = new UglyDbHelper(getBaseContext());
		StringBuffer log = new StringBuffer();
		// Create a log entry for every attack in the Database
		for (Record record : dbh.getAllRecords()) {
			log.append(record.toString());
		}

		ScrollView scroll = new ScrollView(this);
		TextView text = new TextView(getApplicationContext());
		text.setText(log);
		text.setTextAppearance(this, android.R.style.TextAppearance_Medium);
		scroll.addView(text);
		setContentView(scroll);
	}

}
