1
0
mirror of https://github.com/moparisthebest/SSLDroid synced 2024-11-27 03:12:18 -05:00

Added refresh menu option to the logview activity

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2011-05-04 12:32:34 +02:00
parent 56e9474829
commit 4974177603

View File

@ -7,56 +7,60 @@ import java.io.InputStreamReader;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView; import android.widget.TextView;
public class SSLDroidReadLogs extends Activity{ public class SSLDroidReadLogs extends Activity{
@Override @Override
public void onCreate(Bundle savedInstanceState) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreate(savedInstanceState); MenuItem refresh = menu.add("Refresh");
setContentView(R.layout.read_logs); refresh.setIcon(android.R.drawable.ic_menu_rotate);
TextView logcontainer = (TextView) findViewById(R.id.logTextView); return true;
logcontainer.setText(""); }
Process mLogcatProc = null;
BufferedReader reader = null; @Override
try public boolean onOptionsItemSelected(MenuItem item) {
{ refreshLogs();
mLogcatProc = Runtime.getRuntime().exec(new String[] return true;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.read_logs);
refreshLogs();
}
public void refreshLogs(){
TextView logcontainer = (TextView) findViewById(R.id.logTextView);
logcontainer.setText("");
Process mLogcatProc = null;
BufferedReader reader = null;
try {
mLogcatProc = Runtime.getRuntime().exec(new String[]
{"logcat", "-d", "-v", "time", "-b", "main", "SSLDroid:D SSLDroidGui:D *:S" }); {"logcat", "-d", "-v", "time", "-b", "main", "SSLDroid:D SSLDroidGui:D *:S" });
reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream())); reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));
String line; String line;
//final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator"); String separator = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null){
{ logcontainer.append(line+separator);
logcontainer.append(line);
logcontainer.append(separator);
} }
} catch (IOException e) {
//logcontainer.setText(log); Log.d("SSLDroid", "Logcat problem: "+e.toString());
} }
finally {
catch (IOException e)
{
Log.d("SSLDroid", "Logcat problem: "+e.toString());
}
finally
{
if (reader != null) if (reader != null)
try try {
{ reader.close();
reader.close(); } catch (IOException e) {
} Log.d("SSLDroid", "Logcat problem: "+e.toString());
catch (IOException e) }
{
Log.d("SSLDroid", "Logcat problem: "+e.toString());
}
} }
} }
} }