summaryrefslogtreecommitdiff
path: root/android/app/src/main/kotlin/org/buetow
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-08 00:05:39 +0300
committerPaul Buetow <paul@buetow.org>2026-05-08 00:05:39 +0300
commit3e4bacb7b939b1de98a2fb07115f638750637357 (patch)
tree0897a6854d1c3ca3b1d0252657e992abbba061ba /android/app/src/main/kotlin/org/buetow
parent665b150727ee7259e398d38d1f6bc51b4c2d4a1c (diff)
Rewrite as Flutter app and rename to Quicklogmain
Drop the Go/Fyne implementation and replace it with a native Flutter app targeting Android (primary) and Linux desktop (development). Rename quicklogger -> quicklog throughout (project, applicationId, MethodChannel, cache filename, AppBar title, Linux binary). Storage on Android moves to /Android/data/org.buetow.quicklog/files/ so MANAGE_EXTERNAL_STORAGE is no longer required. Share-intent receive is preserved via a Kotlin ShareActivity that writes shared text to the app cache, which Dart reads through a MethodChannel on app resume; MainActivity also accepts SEND directly so launchers that prefer the main target work. New since the Fyne version: an entry browser screen with read-only viewer and long-press delete. Cross-compiling to Android ARM from amd64 Linux no longer needs Docker / fyne-cross / NDK -- flutter build apk emits ARM binaries directly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'android/app/src/main/kotlin/org/buetow')
-rw-r--r--android/app/src/main/kotlin/org/buetow/quicklog/MainActivity.kt56
-rw-r--r--android/app/src/main/kotlin/org/buetow/quicklog/ShareActivity.kt54
2 files changed, 110 insertions, 0 deletions
diff --git a/android/app/src/main/kotlin/org/buetow/quicklog/MainActivity.kt b/android/app/src/main/kotlin/org/buetow/quicklog/MainActivity.kt
new file mode 100644
index 0000000..426589f
--- /dev/null
+++ b/android/app/src/main/kotlin/org/buetow/quicklog/MainActivity.kt
@@ -0,0 +1,56 @@
+package org.buetow.quicklog
+
+import android.content.Intent
+import android.os.Bundle
+import io.flutter.embedding.android.FlutterActivity
+import io.flutter.embedding.engine.FlutterEngine
+import io.flutter.plugin.common.MethodChannel
+import java.io.File
+
+class MainActivity : FlutterActivity() {
+ private val channelName = "org.buetow.quicklog/share"
+ private val cacheFilename = "quicklog-shared.txt"
+
+ override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
+ super.configureFlutterEngine(flutterEngine)
+ MethodChannel(flutterEngine.dartExecutor.binaryMessenger, channelName)
+ .setMethodCallHandler { call, result ->
+ when (call.method) {
+ "readSharedTextFromCache" -> result.success(readCache())
+ "clearSharedTextCache" -> {
+ clearCache()
+ result.success(null)
+ }
+ else -> result.notImplemented()
+ }
+ }
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ captureSendIntent(intent)
+ }
+
+ override fun onNewIntent(intent: Intent) {
+ super.onNewIntent(intent)
+ captureSendIntent(intent)
+ }
+
+ private fun captureSendIntent(intent: Intent?) {
+ if (intent?.action == Intent.ACTION_SEND && intent.type?.startsWith("text/") == true) {
+ intent.getStringExtra(Intent.EXTRA_TEXT)?.let { text ->
+ File(cacheDir, cacheFilename).writeText(text)
+ }
+ }
+ }
+
+ private fun readCache(): String? {
+ val f = File(cacheDir, cacheFilename)
+ return if (f.exists()) f.readText() else null
+ }
+
+ private fun clearCache() {
+ val f = File(cacheDir, cacheFilename)
+ if (f.exists()) f.delete()
+ }
+}
diff --git a/android/app/src/main/kotlin/org/buetow/quicklog/ShareActivity.kt b/android/app/src/main/kotlin/org/buetow/quicklog/ShareActivity.kt
new file mode 100644
index 0000000..15261e6
--- /dev/null
+++ b/android/app/src/main/kotlin/org/buetow/quicklog/ShareActivity.kt
@@ -0,0 +1,54 @@
+package org.buetow.quicklog
+
+import android.app.Activity
+import android.content.Intent
+import android.os.Bundle
+import android.util.Log
+import java.io.File
+
+class ShareActivity : Activity() {
+ companion object {
+ private const val TAG = "QuicklogShare"
+ private const val CACHE_FILENAME = "quicklog-shared.txt"
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ handleShare(intent)
+ launchMain()
+ finish()
+ }
+
+ private fun handleShare(intent: Intent?) {
+ if (intent == null) return
+ val type = intent.type
+ if (intent.action == Intent.ACTION_SEND && type != null && type.startsWith("text/")) {
+ val sharedText = intent.getStringExtra(Intent.EXTRA_TEXT)
+ if (sharedText != null) {
+ try {
+ val f = File(cacheDir, CACHE_FILENAME)
+ f.writeText(sharedText)
+ Log.i(TAG, "Wrote shared text to ${f.absolutePath}")
+ } catch (e: Exception) {
+ Log.e(TAG, "Error writing shared text", e)
+ }
+ }
+ }
+ }
+
+ private fun launchMain() {
+ try {
+ val launch = Intent(this, MainActivity::class.java).apply {
+ action = Intent.ACTION_MAIN
+ addCategory(Intent.CATEGORY_LAUNCHER)
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK or
+ Intent.FLAG_ACTIVITY_SINGLE_TOP or
+ Intent.FLAG_ACTIVITY_CLEAR_TOP or
+ Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
+ }
+ startActivity(launch)
+ } catch (t: Throwable) {
+ Log.e(TAG, "Failed to launch main activity", t)
+ }
+ }
+}