summaryrefslogtreecommitdiff
path: root/android_shared_android.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-01 18:10:19 +0200
committerPaul Buetow <paul@buetow.org>2026-03-01 18:10:19 +0200
commit5247a201c8ba77329c7b1ee40da7b8e43a56b567 (patch)
treed5cd331e7bd5040ef3267e7f888a8c4463cd2832 /android_shared_android.go
parent5fcb97aeb4ec1e291e221794df5d40b27ea60197 (diff)
Release v0.1.0: code quality audit — fix dialog bug, refactor, add testsv0.1.0
- Fix per-keystroke dialog storm when text exceeds maxTextLength - Extract logEntry() for testable persistence with filepath.Join - Extract newInputWidget() and deduplicate shared-text loading - Rename appId to appID per Go naming conventions - Delete unused debugSharedPath function - Add error distinction in readSharedFromCache (log real errors) - Fix ANDORID_NDK_HOME typo to ANDRIOD_NDK_HOME in Magefile - Run gofmt, go mod tidy; promote defaultDirectory to const - Add unit tests for logEntry and readSharedFromCache stub Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'android_shared_android.go')
-rw-r--r--android_shared_android.go36
1 files changed, 14 insertions, 22 deletions
diff --git a/android_shared_android.go b/android_shared_android.go
index b736fab..e46fab2 100644
--- a/android_shared_android.go
+++ b/android_shared_android.go
@@ -3,32 +3,24 @@
package main
import (
- "os"
- "path/filepath"
+ "os"
+ "path/filepath"
)
// readSharedFromCache tries to read the shared text written by the Android activity.
// The activity writes into getCacheDir()/quicklogger-shared.txt; on Go, os.TempDir()
// maps to the same location in Android (app cache directory).
func readSharedFromCache() (string, error) {
- dir, derr := os.UserCacheDir()
- if derr != nil || dir == "" {
- dir = os.TempDir()
- }
- path := filepath.Join(dir, "quicklogger-shared.txt")
- b, err := os.ReadFile(path)
- if err != nil {
- return "", err
- }
- // best-effort cleanup; ignore errors
- _ = os.Remove(path)
- return string(b), nil
-}
-
-func debugSharedPath() string {
- dir, _ := os.UserCacheDir()
- if dir == "" {
- dir = os.TempDir()
- }
- return filepath.Join(dir, "quicklogger-shared.txt")
+ dir, derr := os.UserCacheDir()
+ if derr != nil || dir == "" {
+ dir = os.TempDir()
+ }
+ path := filepath.Join(dir, "quicklogger-shared.txt")
+ b, err := os.ReadFile(path)
+ if err != nil {
+ return "", err
+ }
+ // best-effort cleanup; ignore errors
+ _ = os.Remove(path)
+ return string(b), nil
}