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

Added share logs functionality

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2013-06-12 09:19:32 +02:00
parent 74d7c4c6a4
commit 1c7977a78d
2 changed files with 22 additions and 2 deletions

View File

@ -23,4 +23,5 @@
<string name="provision">Please enter the URL for remote XML configuration</string>
<string name="back">Back</string>
<string name="refresh">Refresh</string>
<string name="share">Share logs</string>
</resources>

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
@ -17,12 +18,19 @@ public class SSLDroidReadLogs extends Activity {
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem refresh = menu.add(R.string.refresh);
refresh.setIcon(android.R.drawable.ic_menu_rotate);
MenuItem share = menu.add(R.string.share);
share.setIcon(android.R.drawable.ic_menu_share);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
refreshLogs();
if (item.getTitle() == getResources().getString(R.string.refresh))
refreshLogs();
else if ((item.getTitle() == getResources().getString(R.string.share)))
shareLogs();
else
return false;
return true;
}
@ -40,7 +48,7 @@ public class SSLDroidReadLogs extends Activity {
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 AndroidRuntime *:S" });
reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));
@ -63,4 +71,15 @@ public class SSLDroidReadLogs extends Activity {
}
}
public void shareLogs() {
Intent sendIntent = new Intent();
TextView logcontainer = (TextView) findViewById(R.id.logTextView);
CharSequence logdata = logcontainer.getText();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, logdata);
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
}