diff --git a/app/src/main/java/org/thoughtcrime/securesms/logging/LogFile.java b/app/src/main/java/org/thoughtcrime/securesms/logging/LogFile.java
index 64702cc988..f0c083ca1d 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/logging/LogFile.java
+++ b/app/src/main/java/org/thoughtcrime/securesms/logging/LogFile.java
@@ -123,7 +123,7 @@ class LogFile {
return builder.toString();
}
- private String readEntry() throws IOException {
+ String readEntry() throws IOException {
try {
Util.readFully(inputStream, ivBuffer);
Util.readFully(inputStream, intBuffer);
diff --git a/app/src/main/java/org/thoughtcrime/securesms/logging/PersistentLogger.java b/app/src/main/java/org/thoughtcrime/securesms/logging/PersistentLogger.java
index ab0b42e210..9fd5968f6a 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/logging/PersistentLogger.java
+++ b/app/src/main/java/org/thoughtcrime/securesms/logging/PersistentLogger.java
@@ -108,13 +108,18 @@ public class PersistentLogger extends Log.Logger {
executor.execute(() -> {
StringBuilder builder = new StringBuilder();
+ long entriesWritten = 0;
try {
File[] logs = getSortedLogFiles();
- for (int i = logs.length - 1; i >= 0; i--) {
+ for (int i = logs.length - 1; i >= 0 && entriesWritten <= MAX_LOG_EXPORT; i--) {
try {
LogFile.Reader reader = new LogFile.Reader(secret, logs[i]);
- builder.append(reader.readAll());
+ String entry;
+ while ((entry = reader.readEntry()) != null) {
+ entriesWritten++;
+ builder.append(entry).append('\n');
+ }
} catch (IOException e) {
android.util.Log.w(TAG, "Failed to read log at index " + i + ". Removing reference.");
logs[i].delete();
diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
index de059b217b..a45efbc290 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
@@ -85,6 +85,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
helpTranslateButton.setOnClickListener { helpTranslate() }
seedButton.setOnClickListener { showSeed() }
clearAllDataButton.setOnClickListener { clearAllData() }
+ supportButton.setOnClickListener { shareLogs() }
val isLightMode = UiModeUtilities.isDayUiMode(this)
oxenLogoImageView.setImageResource(if (isLightMode) R.drawable.oxen_light_mode else R.drawable.oxen_dark_mode)
versionTextView.text = String.format(getString(R.string.version_s), "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})")
@@ -321,6 +322,10 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
ClearAllDataDialog().show(supportFragmentManager, "Clear All Data Dialog")
}
+ private fun shareLogs() {
+ ShareLogsDialog().show(supportFragmentManager,"Share Logs Dialog")
+ }
+
// endregion
private inner class DisplayNameEditActionModeCallback: ActionMode.Callback {
diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt
new file mode 100644
index 0000000000..58e0bc8df4
--- /dev/null
+++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt
@@ -0,0 +1,38 @@
+package org.thoughtcrime.securesms.preferences
+
+import android.view.LayoutInflater
+import androidx.appcompat.app.AlertDialog
+import androidx.lifecycle.lifecycleScope
+import kotlinx.android.synthetic.main.dialog_share_logs.view.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.launch
+import network.loki.messenger.R
+import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
+
+class ShareLogsDialog : BaseDialog() {
+
+ private var shareJob: Job? = null
+
+ override fun setContentView(builder: AlertDialog.Builder) {
+ val contentView =
+ LayoutInflater.from(requireContext()).inflate(R.layout.dialog_share_logs, null)
+ contentView.cancelButton.setOnClickListener {
+ dismiss()
+ }
+ contentView.shareButton.setOnClickListener {
+ // start the export and share
+ shareLogs()
+ }
+ builder.setView(contentView)
+ builder.setCancelable(false)
+ }
+
+ private fun shareLogs() {
+ shareJob?.cancel()
+ shareJob = lifecycleScope.launch(Dispatchers.IO) {
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 39c229df9c..706e4961b0 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -227,6 +227,18 @@
android:gravity="center"
android:text="@string/activity_settings_survey_feedback" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e7c8afc1bb..4f376e3ddb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -899,5 +899,8 @@
Delete for everyone
Delete for me and %s
Feedback/Survey
+ Support
+ Share Logs
+ Would you like to export your application logs to be able to share for troubleshooting?