diff --git a/build.gradle b/build.gradle
index 96680fb5c2..8d9c2a85bf 100644
--- a/build.gradle
+++ b/build.gradle
@@ -46,6 +46,7 @@ dependencies {
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'org.whispersystems:jobmanager:0.9.0'
+ compile 'org.whispersystems:libpastelog:1.0.2'
androidTestCompile 'com.squareup:fest-android:1.0.8'
androidTestCompile 'com.google.dexmaker:dexmaker:1.1'
@@ -70,6 +71,7 @@ dependencyVerification {
'com.android.support:support-v4:81f2b1c2c94efd5a4ec7fcd97b6cdcd00e87a933905c5c86103c7319eb024572',
'com.madgag.spongycastle:core:8d6240b974b0aca4d3da9c7dd44d42339d8a374358aca5fc98e50a995764511f',
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
+ 'org.whispersystems:libpastelog:9798b3c93a91082c2c68542ce5b5c182e18556aebdcb7c8cebbd89eb48ac4047',
'com.google.protobuf:protobuf-java:e0c1c64575c005601725e7c6a02cebf9e1285e888f756b2a1d73ffa8d725cc74',
'com.googlecode.libphonenumber:libphonenumber:eba17eae81dd622ea89a00a3a8c025b2f25d342e0d9644c5b62e16f15687c3ab',
'org.whispersystems:gson:08f4f7498455d1539c9233e5aac18e9b1805815ef29221572996508eb512fe51',
diff --git a/res/layout/log_submit_activity.xml b/res/layout/log_submit_activity.xml
index 7c0cf5df79..bea73d85dc 100644
--- a/res/layout/log_submit_activity.xml
+++ b/res/layout/log_submit_activity.xml
@@ -1,51 +1,11 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f1bf331920..73f8d7cf92 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -502,18 +502,10 @@
- This log will be posted publicly online for TextSecure contributors to view. Feel free to examine or edit the logs below before hitting submit.
- Don\'t submit
- Submit
Could not grab logs from your device. You can still use ADB to get debug logs instead.
- Success!
- Got it
- Please copy this URL and add it to your issue (long press to put in clipboard):\n\n%1$s
- Copied to clipboard
- Loading logcat…
Thanks for your help!
Submitting
- Posting logs to pastebin…
+ Posting logs to gist…
Would you like to import your existing text messages into TextSecure\'s encrypted database?
diff --git a/src/org/thoughtcrime/securesms/LogSubmitActivity.java b/src/org/thoughtcrime/securesms/LogSubmitActivity.java
index 870c6becb0..df824b1491 100644
--- a/src/org/thoughtcrime/securesms/LogSubmitActivity.java
+++ b/src/org/thoughtcrime/securesms/LogSubmitActivity.java
@@ -1,65 +1,33 @@
package org.thoughtcrime.securesms;
-import android.app.AlertDialog;
-import android.support.v7.app.ActionBarActivity;
-import android.text.ClipboardManager;
-import android.content.DialogInterface;
-import android.os.AsyncTask;
import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.TypedValue;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.TextView;
import android.widget.Toast;
-import com.google.thoughtcrimegson.Gson;
-import com.google.thoughtcrimegson.JsonIOException;
-import com.google.thoughtcrimegson.JsonSyntaxException;
-import com.google.thoughtcrimegson.reflect.TypeToken;
-
-import org.thoughtcrime.securesms.util.ProgressDialogAsyncTask;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.lang.reflect.Type;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Map;
+import org.whispersystems.libpastelog.SubmitLogFragment;
/**
* Activity for submitting logcat logs to a pastebin service.
*/
-public class LogSubmitActivity extends ActionBarActivity {
+public class LogSubmitActivity extends ActionBarActivity implements SubmitLogFragment.OnLogSubmittedListener {
private static final String TAG = LogSubmitActivity.class.getSimpleName();
- private static final String HASTEBIN_ENDPOINT = "http://hastebin.com/documents";
- private static final String HASTEBIN_PREFIX = "http://hastebin.com/";
-
- private EditText logPreview;
- private Button okButton;
- private Button cancelButton;
-
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.log_submit_activity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- initializeResources();
+ SubmitLogFragment fragment = SubmitLogFragment.newInstance();
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.replace(R.id.fragment_container, fragment);
+ transaction.commit();
}
@Override
protected void onResume() {
super.onResume();
- new PopulateLogcatAsyncTask().execute();
}
@Override
@@ -74,161 +42,20 @@ public class LogSubmitActivity extends ActionBarActivity {
return false;
}
- private void initializeResources() {
- logPreview = (EditText) findViewById(R.id.log_preview);
- okButton = (Button) findViewById(R.id.ok);
- cancelButton = (Button) findViewById(R.id.cancel);
-
- okButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- new SubmitToPastebinAsyncTask(logPreview.getText().toString()).execute();
- }
- });
-
- cancelButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- finish();
- }
- });
+ @Override
+ public void onSuccess() {
+ Toast.makeText(getApplicationContext(), R.string.log_submit_activity__thanks, Toast.LENGTH_LONG).show();
+ finish();
}
- private static String grabLogcat() {
- try {
- Process process = Runtime.getRuntime().exec("logcat -d");
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(process.getInputStream()));
-
- StringBuilder log = new StringBuilder();
- String separator = System.getProperty("line.separator");
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- log.append(line);
- log.append(separator);
- }
- return log.toString();
- } catch (IOException ioe) {
- Log.w(TAG, "IOException when trying to read logcat.", ioe);
- return null;
- }
+ @Override
+ public void onFailure() {
+ Toast.makeText(getApplicationContext(), R.string.log_submit_activity__log_fetch_failed, Toast.LENGTH_LONG).show();
+ finish();
}
- private class PopulateLogcatAsyncTask extends AsyncTask {
-
- @Override
- protected String doInBackground(Void... voids) {
- return grabLogcat();
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- logPreview.setText(R.string.log_submit_activity__loading_logcat);
- okButton.setEnabled(false);
- }
-
- @Override
- protected void onPostExecute(String logcat) {
- super.onPostExecute(logcat);
- if (TextUtils.isEmpty(logcat)) {
- Toast.makeText(getApplicationContext(), R.string.log_submit_activity__log_fetch_failed, Toast.LENGTH_LONG).show();
- finish();
- return;
- }
- logPreview.setText(logcat);
- okButton.setEnabled(true);
- }
- }
-
- private class SubmitToPastebinAsyncTask extends ProgressDialogAsyncTask {
- private final String paste;
-
- public SubmitToPastebinAsyncTask(String paste) {
- super(LogSubmitActivity.this, R.string.log_submit_activity__submitting, R.string.log_submit_activity__posting_logs);
- this.paste = paste;
- }
-
- @Override
- protected String doInBackground(Void... voids) {
- HttpURLConnection urlConnection = null;
- try {
- URL url = new URL(HASTEBIN_ENDPOINT);
- urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setDoOutput(true);
- urlConnection.setReadTimeout(10000);
- urlConnection.connect();
-
- OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
- out.write(paste.getBytes());
- out.flush();
- InputStream in = new BufferedInputStream(urlConnection.getInputStream());
-
- Type type = new TypeToken