diff options
Diffstat (limited to 'app/src/main/java/org')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/ViewLogActivity.kt | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/ViewLogActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/ViewLogActivity.kt index 673dedb..2a56ceb 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/ViewLogActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/ViewLogActivity.kt | |||
@@ -1,5 +1,6 @@ | |||
1 | package org.pacien.tincapp.activities | 1 | package org.pacien.tincapp.activities |
2 | 2 | ||
3 | import android.content.Intent | ||
3 | import android.os.Bundle | 4 | import android.os.Bundle |
4 | import android.view.Menu | 5 | import android.view.Menu |
5 | import android.view.MenuItem | 6 | import android.view.MenuItem |
@@ -21,8 +22,10 @@ class ViewLogActivity : BaseActivity() { | |||
21 | companion object { | 22 | companion object { |
22 | private const val LOG_LINES = 250 | 23 | private const val LOG_LINES = 250 |
23 | private const val LOG_LEVEL = 5 | 24 | private const val LOG_LEVEL = 5 |
24 | private const val NEW_LINE = "\n\n" | 25 | private const val NEW_LINE = "\n" |
26 | private const val SPACED_NEW_LINE = "\n\n" | ||
25 | private const val UPDATE_INTERVAL = 250L // ms | 27 | private const val UPDATE_INTERVAL = 250L // ms |
28 | private const val MIME_TYPE = "text/plain" | ||
26 | } | 29 | } |
27 | 30 | ||
28 | private val log = LinkedList<String>() | 31 | private val log = LinkedList<String>() |
@@ -61,6 +64,17 @@ class ViewLogActivity : BaseActivity() { | |||
61 | } | 64 | } |
62 | } | 65 | } |
63 | 66 | ||
67 | fun share(@Suppress("UNUSED_PARAMETER") menuItem: MenuItem) { | ||
68 | synchronized(this) { | ||
69 | val logFragment = log.joinToString(NEW_LINE) | ||
70 | val shareIntent = Intent(Intent.ACTION_SEND) | ||
71 | .setType(MIME_TYPE) | ||
72 | .putExtra(Intent.EXTRA_TEXT, logFragment) | ||
73 | |||
74 | startActivity(Intent.createChooser(shareIntent, resources.getString(R.string.menu_share_log))) | ||
75 | } | ||
76 | } | ||
77 | |||
64 | private fun startLogging(level: Int = LOG_LEVEL) { | 78 | private fun startLogging(level: Int = LOG_LEVEL) { |
65 | disableUserScroll() | 79 | disableUserScroll() |
66 | appendLog(resources.getString(R.string.message_log_level_set, level)) | 80 | appendLog(resources.getString(R.string.message_log_level_set, level)) |
@@ -96,7 +110,7 @@ class ViewLogActivity : BaseActivity() { | |||
96 | } | 110 | } |
97 | 111 | ||
98 | private fun printLog() = synchronized(this) { | 112 | private fun printLog() = synchronized(this) { |
99 | log.joinToString(NEW_LINE).let { | 113 | log.joinToString(SPACED_NEW_LINE).let { |
100 | logview_text.post { | 114 | logview_text.post { |
101 | logview_text.text = it | 115 | logview_text.text = it |
102 | logview_frame.post { logview_frame.fullScroll(View.FOCUS_DOWN) } | 116 | logview_frame.post { logview_frame.fullScroll(View.FOCUS_DOWN) } |