aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/invalid/lena
diff options
context:
space:
mode:
authorLena <lena@omega>2026-08-23 00:00:00 +0000
committerLena <lena@omega>2026-08-23 00:00:00 +0000
commit27bce144aa808bad16435f35132bc08da2b05bf4 (patch)
treece90d5e1fe4e510e0c70e493691a863f275a7cf4 /app/src/main/java/invalid/lena
parentca9037ccf3030df287e52b1fa92ab7eb0871eec2 (diff)
downloadrsend-27bce144aa808bad16435f35132bc08da2b05bf4.tar.gz
app: keep editor state across recreation
Browsing restarted at the storage root on every configuration change. The restored path goes through safeDirectory like a typed one, so it still cannot escape the root. A pinned remote wrote its index into both the instance state and the intent. The instance state already survives recreation.
Diffstat (limited to 'app/src/main/java/invalid/lena')
-rw-r--r--app/src/main/java/invalid/lena/rsend/FolderPickerActivity.kt15
-rw-r--r--app/src/main/java/invalid/lena/rsend/RemoteActivity.kt1
2 files changed, 11 insertions, 5 deletions
diff --git a/app/src/main/java/invalid/lena/rsend/FolderPickerActivity.kt b/app/src/main/java/invalid/lena/rsend/FolderPickerActivity.kt
index 0e403e0..b81ce22 100644
--- a/app/src/main/java/invalid/lena/rsend/FolderPickerActivity.kt
+++ b/app/src/main/java/invalid/lena/rsend/FolderPickerActivity.kt
@@ -40,10 +40,12 @@ class FolderPickerActivity : AppCompatActivity() {
root = (getSystemService(StorageManager::class.java).primaryStorageVolume.directory
?: Environment.getExternalStorageDirectory()).canonicalFile
- // Start where the field already points, if that is a directory under the
- // root; otherwise at the root itself.
- val start = intent.getStringExtra("start")?.let { safeDirectory(File(it)) }
- current = start ?: root
+ // Start where the field already points, or where browsing had reached
+ // before a configuration change, if that is a directory under the root;
+ // otherwise at the root itself. Restored paths go through the same check
+ // as typed ones.
+ val start = savedInstanceState?.getString("current") ?: intent.getStringExtra("start")
+ current = start?.let { safeDirectory(File(it)) } ?: root
use = findViewById(R.id.use)
use.setOnClickListener {
@@ -66,6 +68,11 @@ class FolderPickerActivity : AppCompatActivity() {
render()
}
+ override fun onSaveInstanceState(outState: Bundle) {
+ outState.putString("current", current.absolutePath)
+ super.onSaveInstanceState(outState)
+ }
+
private fun render() {
pathView.text = current.absolutePath
list.removeAllViews()
diff --git a/app/src/main/java/invalid/lena/rsend/RemoteActivity.kt b/app/src/main/java/invalid/lena/rsend/RemoteActivity.kt
index 83f499d..b0a94a0 100644
--- a/app/src/main/java/invalid/lena/rsend/RemoteActivity.kt
+++ b/app/src/main/java/invalid/lena/rsend/RemoteActivity.kt
@@ -235,7 +235,6 @@ class RemoteActivity : AppCompatActivity() {
val at = save(r.copy(hostKey = line))
if (at < 0) return
index = at
- intent.putExtra("index", at)
status.text = "Host key pinned. Connection OK."
}