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:
parent
56e9474829
commit
4974177603
@ -7,55 +7,59 @@ 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
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuItem refresh = menu.add("Refresh");
|
||||||
|
refresh.setIcon(android.R.drawable.ic_menu_rotate);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
refreshLogs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.read_logs);
|
setContentView(R.layout.read_logs);
|
||||||
|
refreshLogs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshLogs(){
|
||||||
TextView logcontainer = (TextView) findViewById(R.id.logTextView);
|
TextView logcontainer = (TextView) findViewById(R.id.logTextView);
|
||||||
logcontainer.setText("");
|
logcontainer.setText("");
|
||||||
Process mLogcatProc = null;
|
Process mLogcatProc = null;
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
mLogcatProc = Runtime.getRuntime().exec(new String[]
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
Log.d("SSLDroid", "Logcat problem: "+e.toString());
|
Log.d("SSLDroid", "Logcat problem: "+e.toString());
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (reader != null)
|
if (reader != null)
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
Log.d("SSLDroid", "Logcat problem: "+e.toString());
|
Log.d("SSLDroid", "Logcat problem: "+e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user