diff --git a/app-common/src/main/AndroidManifest.xml b/app-common/src/main/AndroidManifest.xml
index f53e6ff..728febb 100644
--- a/app-common/src/main/AndroidManifest.xml
+++ b/app-common/src/main/AndroidManifest.xml
@@ -46,5 +46,15 @@
android:name="im.angry.openeuicc.service.EuiccChannelManagerService"
android:foregroundServiceType="shortService"
android:exported="false" />
+
+
+
+
diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/LogsActivity.kt b/app-common/src/main/java/im/angry/openeuicc/ui/LogsActivity.kt
index 49bfa0f..cfb97d9 100644
--- a/app-common/src/main/java/im/angry/openeuicc/ui/LogsActivity.kt
+++ b/app-common/src/main/java/im/angry/openeuicc/ui/LogsActivity.kt
@@ -10,6 +10,8 @@ import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.app.ShareCompat
+import androidx.core.content.FileProvider
import androidx.lifecycle.lifecycleScope
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import im.angry.openeuicc.common.R
@@ -17,15 +19,22 @@ import im.angry.openeuicc.util.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
+import java.io.File
import java.io.FileOutputStream
import java.util.Date
+
class LogsActivity : AppCompatActivity() {
private lateinit var swipeRefresh: SwipeRefreshLayout
private lateinit var scrollView: ScrollView
private lateinit var logText: TextView
private lateinit var logStr: String
+ private val fileName by lazy {
+ val now = SimpleDateFormat.getDateTimeInstance().format(Date())
+ getString(R.string.logs_filename_template, now)
+ }
+
private val saveLogs =
registerForActivityResult(ActivityResultContracts.CreateDocument("text/plain")) { uri ->
if (uri == null) return@registerForActivityResult
@@ -76,9 +85,19 @@ class LogsActivity : AppCompatActivity() {
true
}
R.id.save -> {
- saveLogs.launch(getString(R.string.logs_filename_template,
- SimpleDateFormat.getDateTimeInstance().format(Date())
- ))
+ saveLogs.launch(fileName)
+ true
+ }
+ R.id.share -> {
+ val authority = "$packageName.provider"
+ val displayName = "$fileName.txt"
+ val file = File.createTempFile("logs", ".txt", cacheDir)
+ .apply { writeText(logStr) }
+ ShareCompat.IntentBuilder(this)
+ .setType("image/plain")
+ .setChooserTitle(fileName)
+ .addStream(FileProvider.getUriForFile(this, authority, file, displayName))
+ .startChooser()
true
}
else -> super.onOptionsItemSelected(item)
diff --git a/app-common/src/main/res/menu/activity_logs.xml b/app-common/src/main/res/menu/activity_logs.xml
index 4fa3aeb..7095be2 100644
--- a/app-common/src/main/res/menu/activity_logs.xml
+++ b/app-common/src/main/res/menu/activity_logs.xml
@@ -6,4 +6,7 @@
android:icon="@drawable/ic_save_as_black"
android:title="@string/logs_save"
app:showAsAction="always" />
+
\ No newline at end of file
diff --git a/app-common/src/main/res/values/strings.xml b/app-common/src/main/res/values/strings.xml
index 4a9f529..800a473 100644
--- a/app-common/src/main/res/values/strings.xml
+++ b/app-common/src/main/res/values/strings.xml
@@ -130,6 +130,7 @@
No
Save
+ Share
Logs at %s
You are %d steps away from being a developer.
diff --git a/app-common/src/main/res/xml/file_provider_paths.xml b/app-common/src/main/res/xml/file_provider_paths.xml
new file mode 100644
index 0000000..26062c7
--- /dev/null
+++ b/app-common/src/main/res/xml/file_provider_paths.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file