aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien
diff options
context:
space:
mode:
authorpacien2018-03-04 19:54:08 +0100
committerpacien2018-03-04 19:54:08 +0100
commit9c987682bde9f532f53f3f1ac3ade7e96a5e2293 (patch)
tree8d1681ff2ecf27d768bec005aec41c9264ec6df9 /app/src/main/java/org/pacien
parent1f30a8838d787f31dbc0af83458d73afef104927 (diff)
downloadtincapp-9c987682bde9f532f53f3f1ac3ade7e96a5e2293.tar.gz
Add share button on log view
Diffstat (limited to 'app/src/main/java/org/pacien')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/ViewLogActivity.kt18
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 @@
1package org.pacien.tincapp.activities 1package org.pacien.tincapp.activities
2 2
3import android.content.Intent
3import android.os.Bundle 4import android.os.Bundle
4import android.view.Menu 5import android.view.Menu
5import android.view.MenuItem 6import 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) }