Redesign watch navigation with a shared icon menu
No files matched your search
@@ -55,7 +55,7 @@ The UI uses native Android views and custom drawing, without Compose or a runtim
|
|||||||
|
|
||||||
- Preserve the dark olive/lime appearance and original rounded vector numeral behind foreground controls. The numeral represents measured whole minutes, with gentle floating motion; the semicircle represents seconds within the minute. Do not add a caption beneath the numeral or labels beside the edge lines without a requested design change.
|
- Preserve the dark olive/lime appearance and original rounded vector numeral behind foreground controls. The numeral represents measured whole minutes, with gentle floating motion; the semicircle represents seconds within the minute. Do not add a caption beneath the numeral or labels beside the edge lines without a requested design change.
|
||||||
- Keep the edge lines functional: microphone level/free space/playback state on the left and bookmarks/navigation/seeking on the right. Retain native button and slider alternatives, rotary access, and spoken descriptions for custom visuals.
|
- Keep the edge lines functional: microphone level/free space/playback state on the left and bookmarks/navigation/seeking on the right. Retain native button and slider alternatives, rotary access, and spoken descriptions for custom visuals.
|
||||||
- Settings entry labels are `Storage` and `Recording limit`. The storage chart fills most of the first viewport; readings and buttons can sit below it and remain reachable by scrolling. Keep the page visually readable at a glance.
|
- `MainActivity` owns one three-column icon menu; `BackupActivity.EXTRA_PAGE` opens backup sections directly. Preserve a floating, transparent, icon-only Menu shortcut (with its spoken label) over a full-screen scroll viewport. Keep the shortcut at the bottom center, hidden initially and after three idle seconds. Touch and rotary input reveal it without intercepting content gestures or opening the menu on the reveal tap. Keep it visible for touch exploration or keyboard focus, respect accessibility timeouts, and cancel idle callbacks when paused or rebuilt. Preserve consistent parent/back behavior, and the menu's scroll position. `WatchDesign.kt` supplies native controls, vector icons, cards, and static status dials without added UI dependencies. Menu entry labels include `Storage` and `Recording limit`. The storage chart fills most of the first viewport; readings and buttons can sit below it and remain reachable by scrolling. Keep the page visually readable at a glance.
|
||||||
- Storage reads use Android's device capacity/available accounting and Remember's own app usage. `dataBytes` already includes cache: do not add `cacheBytes` again. Mark fallback app accounting as approximate. Show proportional chart slices; a small visibility marker must not inflate the app's actual share.
|
- Storage reads use Android's device capacity/available accounting and Remember's own app usage. `dataBytes` already includes cache: do not add `cacheBytes` again. Mark fallback app accounting as approximate. Show proportional chart slices; a small visibility marker must not inflate the app's actual share.
|
||||||
- Preserve five-second storage refresh while that page is open, manual Refresh, and stale-result guards. Do not request usage access to other apps for this feature.
|
- Preserve five-second storage refresh while that page is open, manual Refresh, and stale-result guards. Do not request usage access to other apps for this feature.
|
||||||
- Stop decorative motion when animations are disabled, battery saver is active, the activity is backgrounded, or capture is paused. Avoid extra background polling or animation work.
|
- Stop decorative motion when animations are disabled, battery saver is active, the activity is backgrounded, or capture is paused. Avoid extra background polling or animation work.
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ Screenshots from a Wear OS round-screen emulator:
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<img src="docs/home.png" width="240" alt="Remember home screen with a floating minute number and recording controls" />
|
<img src="docs/home.png" width="240" alt="Remember home screen with a floating minute number and recording controls" />
|
||||||
<img src="docs/settings.png" width="240" alt="Settings with Storage and Recording limit sections" />
|
<img src="docs/home-menu-visible.png" width="240" alt="Home with the bottom-center menu icon revealed by touch" />
|
||||||
|
<img src="docs/menu.png" width="240" alt="Single menu with a grid of icons for every section" />
|
||||||
|
<img src="docs/recording-limit.png" width="240" alt="Recording limit dial showing unlimited recording" />
|
||||||
<img src="docs/storage.png" width="240" alt="Large storage ring showing free space and total device capacity" />
|
<img src="docs/storage.png" width="240" alt="Large storage ring showing free space and total device capacity" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -19,6 +21,7 @@ Screenshots from a Wear OS round-screen emulator:
|
|||||||
- Recording continues in a microphone foreground service when the screen turns off or you leave the app.
|
- Recording continues in a microphone foreground service when the screen turns off or you leave the app.
|
||||||
- Floating rounded numerals show captured minutes; the background sweep shows seconds within the current minute.
|
- Floating rounded numerals show captured minutes; the background sweep shows seconds within the current minute.
|
||||||
- A live microphone edge meter and an interactive bookmark/playback edge.
|
- A live microphone edge meter and an interactive bookmark/playback edge.
|
||||||
|
- One shared icon grid opens every section directly, with a fixed Menu shortcut and rotary scrolling.
|
||||||
- Device and app storage monitoring with a large proportional chart.
|
- Device and app storage monitoring with a large proportional chart.
|
||||||
- Optional SFTP backups to your own server, a transfer queue, scheduled uploads, and remote playback.
|
- Optional SFTP backups to your own server, a transfer queue, scheduled uploads, and remote playback.
|
||||||
- Optional minute limits: save and stop, or save each clip and start the next at zero.
|
- Optional minute limits: save and stop, or save each clip and start the next at zero.
|
||||||
@@ -103,9 +106,11 @@ The pairing and connection ports are different. Read each from the watch's Wirel
|
|||||||
|
|
||||||
Audio is stored as mono AAC in M4A files at 44.1 kHz / 128 kbps, approximately 1 MB per minute. The large numeral shows whole minutes in the current recording or playback, and total saved minutes on the home screen. Floating motion stops while capture is paused, the app is in the background, animations are disabled, or battery saver is active.
|
Audio is stored as mono AAC in M4A files at 44.1 kHz / 128 kbps, approximately 1 MB per minute. The large numeral shows whole minutes in the current recording or playback, and total saved minutes on the home screen. Floating motion stops while capture is paused, the app is in the background, animations are disabled, or battery saver is active.
|
||||||
|
|
||||||
## Settings
|
## Menu and preferences
|
||||||
|
|
||||||
Open **Settings** beside Moments. During capture, scroll below Save to reach it; recording continues while you browse.
|
Open the transparent four-dot **Menu** icon at the bottom center of the home or recording screen. A three-column icon grid opens Recorder, Moments, Storage, Recording limit, Backup, Server, Transfers, Server recordings, Automatic backup, and Advanced directly. Scroll or use rotary input for the lower rows. The transparent Menu shortcut floats over full-screen pages without a reserved footer bar. Touch the screen to reveal it; it hides after three seconds without interaction. Rotary input also reveals it. It stays visible for touch exploration and keyboard focus, and respects the system accessibility timeout. Returning preserves your grid position. Back returns to the grid, or to the parent page for a clip, picker, or approval step. Recording continues while you browse.
|
||||||
|
|
||||||
|
The library uses recording cards, Backup shows a completion dial, Recording limit shows the configured minutes or an unlimited dial, and Automatic backup shows its interval and whether checks are off. Interval, retry, and timeout choices use inline selected chips. Setup forms and actions remain scrollable.
|
||||||
|
|
||||||
### Storage
|
### Storage
|
||||||
|
|
||||||
@@ -121,17 +126,18 @@ Under **At the limit**, choose **Save & stop** to end the recording, or **Save &
|
|||||||
|
|
||||||
## Backup
|
## Backup
|
||||||
|
|
||||||
Open **Settings → Backup**. Dedicated pages keep setup, transfer status, remote listening, and scheduling separate.
|
Open **Menu → Backup** for the dashboard. **Server**, **Transfers**, **Server recordings**, **Automatic backup**, and **Advanced** are independent tiles in the same menu.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<img src="docs/backup-overview.png" width="240" alt="Backup overview with backed-up and waiting counts and Back up now" />
|
<img src="docs/backup-overview.png" width="240" alt="Backup overview with backed-up and waiting counts and Back up now" />
|
||||||
<img src="docs/backup-trust.png" width="240" alt="Server approval with Trust server and Cancel buttons, without fingerprint typing" />
|
<img src="docs/backup-trust.png" width="240" alt="Server approval with Trust server and Cancel buttons, without fingerprint typing" />
|
||||||
<img src="docs/backup-server.png" width="240" alt="Server settings with address, port, and username fields" />
|
<img src="docs/backup-server.png" width="240" alt="Server settings with address, port, and username fields" />
|
||||||
<img src="docs/backup-automatic.png" width="240" alt="Automatic backup disabled, with charging and unmetered preferences enabled" />
|
<img src="docs/backup-automatic.png" width="240" alt="Automatic backup interval dial showing that background checks are off" />
|
||||||
|
<img src="docs/advanced.png" width="240" alt="Inline selected chips for retry attempts and connection timeout" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
- **Server:** configure address, port, username, and an existing absolute backup folder. **Connect & trust** fetches the fingerprint without typing; approve the server once to remember it. Create the watch key, export or copy its public key, and authorize it on your server. Test connection before uploading. See [server setup](docs/backup.md).
|
- **Server:** configure address, port, username, and an existing absolute backup folder. **Connect & trust** fetches the fingerprint without typing; approve the server once to remember it. Create the watch key, export or copy its public key, and authorize it on your server. Test connection before uploading. See [server setup](docs/backup.md).
|
||||||
- **Transfers:** shows saved recordings and their status. **Back up / Retry** queues unfinished or changed recordings. **Pause all backups** cancels transfers and turns automatic backup off. Local recordings are never deleted by backup; local deletion does not delete server copies.
|
- **Transfers:** shows saved recordings and their status. **Back up / Retry** queues unfinished or changed recordings. **Pause all** cancels transfers and turns automatic backup off. Local recordings are never deleted by backup; local deletion does not delete server copies.
|
||||||
- **Server recordings:** Refresh lists completed Remember backups (up to 1,000 per folder). Select a recording to download a verified temporary copy and play it with seeking and bookmark buttons. This is cached playback, not live streaming; sufficient watch storage is required. Leaving the activity pauses playback.
|
- **Server recordings:** Refresh lists completed Remember backups (up to 1,000 per folder). Select a recording to download a verified temporary copy and play it with seeking and bookmark buttons. This is cached playback, not live streaming; sufficient watch storage is required. Leaving the activity pauses playback.
|
||||||
- **Automatic backup:** opt in to checks every hour, every six hours, or daily. Charging and unmetered connections are required by default and can be changed. Unmetered does not necessarily mean Wi-Fi. Android schedules work when conditions allow, rather than at an exact clock time; jobs persist across reboot.
|
- **Automatic backup:** opt in to checks every hour, every six hours, or daily. Charging and unmetered connections are required by default and can be changed. Unmetered does not necessarily mean Wi-Fi. Android schedules work when conditions allow, rather than at an exact clock time; jobs persist across reboot.
|
||||||
- **Advanced:** choose 1/3/5 retry attempts, a 20/40/60-second connection timeout, or clear the playback cache. Server identity shows the remembered fingerprint; Forget trust pauses backups and allows a verified server-key change to be approved again.
|
- **Advanced:** choose 1/3/5 retry attempts, a 20/40/60-second connection timeout, or clear the playback cache. Server identity shows the remembered fingerprint; Forget trust pauses backups and allows a verified server-key change to be approved again.
|
||||||
@@ -154,7 +160,7 @@ Device tests require a **disposable** emulator with a microphone. They create au
|
|||||||
./gradlew :app:connectedDebugAndroidTest
|
./gradlew :app:connectedDebugAndroidTest
|
||||||
```
|
```
|
||||||
|
|
||||||
Coverage includes backup destination validation, encrypted watch-key persistence, backup-page navigation, manifest safety, and (with an opt-in disposable SFTP fixture) resumable transfers, checksum verification, host-key rejection, actual scheduled uploads, scheduling constraints, and cached remote playback/background pause. Network fixture instructions are in [docs/backup.md](docs/backup.md). Coverage also includes duration formatting, limit boundaries, pause exclusion, real one-minute automatic stop and split rollover, playable file output, bookmarks, settings persistence/navigation, storage accounting, and clip rename/delete behavior.
|
Coverage includes backup destination validation, encrypted watch-key persistence, the shared menu, direct section navigation and back behavior, backup-page navigation, manifest safety, and (with an opt-in disposable SFTP fixture) resumable transfers, checksum verification, host-key rejection, actual scheduled uploads, scheduling constraints, and cached remote playback/background pause. Network fixture instructions are in [docs/backup.md](docs/backup.md). Coverage also includes duration formatting, limit boundaries, pause exclusion, real one-minute automatic stop and split rollover, playable file output, bookmarks, settings persistence/navigation, storage accounting, and clip rename/delete behavior.
|
||||||
|
|
||||||
[Android checks](.github/workflows/android.yml) runs on pushes, pull requests, and manual dispatch. It verifies the wrapper, builds the debug app, runs lint and unit tests, and compiles device tests. It uploads check reports and a debug APK with a 14-day retention period. Device tests are run locally; the workflow does not claim to run them. The workflow uses pinned action commits and read-only repository permissions. Its first hosted run will happen after the repository is pushed to GitHub.
|
[Android checks](.github/workflows/android.yml) runs on pushes, pull requests, and manual dispatch. It verifies the wrapper, builds the debug app, runs lint and unit tests, and compiles device tests. It uploads check reports and a debug APK with a 14-day retention period. Device tests are run locally; the workflow does not claim to run them. The workflow uses pinned action commits and read-only repository permissions. Its first hosted run will happen after the repository is pushed to GitHub.
|
||||||
|
|
||||||
|
|||||||
@@ -39,18 +39,18 @@ class BackupTest {
|
|||||||
editor.commit()
|
editor.commit()
|
||||||
}
|
}
|
||||||
@Test fun backupPagesAreReachableAndAutomaticUploadsDefaultOff() {
|
@Test fun backupPagesAreReachableAndAutomaticUploadsDefaultOff() {
|
||||||
val activity = instrumentation.startActivitySync(Intent(context, BackupActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
listOf("overview", "server", "transfers", "remote", "automatic", "advanced").forEach { page ->
|
||||||
try {
|
val activity = instrumentation.startActivitySync(Intent(context, BackupActivity::class.java)
|
||||||
instrumentation.runOnMainSync {
|
.putExtra(BackupActivity.EXTRA_PAGE, page).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||||
fun descendants(view: View): List<View> = listOf(view) + if (view is ViewGroup)
|
try {
|
||||||
(0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
instrumentation.runOnMainSync {
|
||||||
fun button(label: String) = descendants(activity.window.decorView).filterIsInstance<Button>().first { it.text == label }
|
fun descendants(view: View): List<View> = listOf(view) + if (view is ViewGroup)
|
||||||
listOf("Server", "Transfers", "Server recordings", "Automatic backup", "Advanced").forEach {
|
(0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
||||||
button(it).performClick(); button("Back").performClick()
|
assertTrue(descendants(activity.window.decorView).filterIsInstance<Button>().any { it.contentDescription == "Open all sections" })
|
||||||
}
|
}
|
||||||
}
|
} finally { instrumentation.runOnMainSync { activity.finish() } }
|
||||||
assertFalse(settings.automatic)
|
}
|
||||||
} finally { instrumentation.runOnMainSync { activity.finish() } }
|
assertFalse(settings.automatic)
|
||||||
}
|
}
|
||||||
@Test fun encryptedWatchKeyPersistsWithoutPlaintextPrivateKeyInPreferences() {
|
@Test fun encryptedWatchKeyPersistsWithoutPlaintextPrivateKeyInPreferences() {
|
||||||
val public = settings.generateKey()
|
val public = settings.generateKey()
|
||||||
@@ -107,8 +107,8 @@ class BackupTest {
|
|||||||
try {
|
try {
|
||||||
settings.save(pending)
|
settings.save(pending)
|
||||||
settings.preferences.edit().remove("key").remove("public_key").commit()
|
settings.preferences.edit().remove("key").remove("public_key").commit()
|
||||||
activity = instrumentation.startActivitySync(Intent(context, BackupActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
activity = instrumentation.startActivitySync(Intent(context, BackupActivity::class.java)
|
||||||
press("Server")
|
.putExtra(BackupActivity.EXTRA_PAGE, "server").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||||
instrumentation.runOnMainSync {
|
instrumentation.runOnMainSync {
|
||||||
assertEquals("Fingerprint must not require typing", 4, descendants(activity!!.window.decorView).filterIsInstance<EditText>().size)
|
assertEquals("Fingerprint must not require typing", 4, descendants(activity!!.window.decorView).filterIsInstance<EditText>().size)
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ class BackupTest {
|
|||||||
settings.generateKey()
|
settings.generateKey()
|
||||||
instrumentation.uiAutomation.grantRuntimePermission(context.packageName, Manifest.permission.RECORD_AUDIO)
|
instrumentation.uiAutomation.grantRuntimePermission(context.packageName, Manifest.permission.RECORD_AUDIO)
|
||||||
try {
|
try {
|
||||||
activity = instrumentation.startActivitySync(Intent(context, BackupActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
activity = instrumentation.startActivitySync(Intent(context, BackupActivity::class.java).putExtra(BackupActivity.EXTRA_PAGE, "remote").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||||
val recorder = MediaRecorder(context)
|
val recorder = MediaRecorder(context)
|
||||||
try {
|
try {
|
||||||
recorder.setAudioSource(MediaRecorder.AudioSource.MIC)
|
recorder.setAudioSource(MediaRecorder.AudioSource.MIC)
|
||||||
@@ -239,9 +239,13 @@ class BackupTest {
|
|||||||
}
|
}
|
||||||
assertTrue("Remote playback did not reach expected state", ready)
|
assertTrue("Remote playback did not reach expected state", ready)
|
||||||
}
|
}
|
||||||
click("Server recordings"); click("Refresh")
|
click("Refresh")
|
||||||
await { descendants(activity!!.window.decorView).filterIsInstance<Button>().any { it.text.startsWith(clip.title) } }
|
await { descendants(activity!!.window.decorView).filterIsInstance<android.widget.TextView>().any { it.text == clip.title } }
|
||||||
click(clip.title); click("Download & play")
|
instrumentation.runOnMainSync {
|
||||||
|
descendants(activity!!.window.decorView).filterIsInstance<android.widget.TextView>().first { it.text == clip.title }
|
||||||
|
.let { (it.parent.parent as View).performClick() }
|
||||||
|
}
|
||||||
|
click("Download & play")
|
||||||
val playerField = BackupActivity::class.java.getDeclaredField("player").apply { isAccessible = true }
|
val playerField = BackupActivity::class.java.getDeclaredField("player").apply { isAccessible = true }
|
||||||
val readyField = BackupActivity::class.java.getDeclaredField("playbackReady").apply { isAccessible = true }
|
val readyField = BackupActivity::class.java.getDeclaredField("playbackReady").apply { isAccessible = true }
|
||||||
await { readyField.getBoolean(activity) && (playerField.get(activity) as? MediaPlayer)?.isPlaying == true }
|
await { readyField.getBoolean(activity) && (playerField.get(activity) as? MediaPlayer)?.isPlaying == true }
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.junit.Assert.*
|
|||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class LaunchTest {
|
class LaunchTest {
|
||||||
@Test fun homeLaunchesWithAccessibleRecordAndLibraryControls() {
|
@Test fun homeLaunchesWithRecordAndSharedMenuControls() {
|
||||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||||
val activity = instrumentation.startActivitySync(
|
val activity = instrumentation.startActivitySync(
|
||||||
Intent(instrumentation.targetContext, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
Intent(instrumentation.targetContext, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
@@ -23,7 +23,8 @@ class LaunchTest {
|
|||||||
if (view is ViewGroup) (0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
if (view is ViewGroup) (0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
||||||
val buttons = descendants(activity.window.decorView).filterIsInstance<Button>()
|
val buttons = descendants(activity.window.decorView).filterIsInstance<Button>()
|
||||||
assertTrue(buttons.any { it.contentDescription == "Start recording" && it.isEnabled })
|
assertTrue(buttons.any { it.contentDescription == "Start recording" && it.isEnabled })
|
||||||
assertTrue(buttons.any { it.text.startsWith("Moments") })
|
assertTrue(buttons.any { it.contentDescription == "Open all sections" && it.isEnabled })
|
||||||
|
assertFalse(buttons.any { it.text.startsWith("Moments") })
|
||||||
}
|
}
|
||||||
} finally { instrumentation.runOnMainSync { activity.finish() } }
|
} finally { instrumentation.runOnMainSync { activity.finish() } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package meghdad.remember
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.os.SystemClock
|
||||||
|
import android.view.InputDevice
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.ScrollView
|
||||||
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import org.junit.Assert.*
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class MenuVisibilityTest {
|
||||||
|
@Test fun bottomMenuStartsHiddenRevealsWithoutOpeningAndWaitsUntilTouchEndsToHide() {
|
||||||
|
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||||
|
val context = instrumentation.targetContext
|
||||||
|
fun descendants(view: View): List<View> = listOf(view) + if (view is ViewGroup)
|
||||||
|
(0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
||||||
|
fun send(activity: Activity, action: Int, x: Float, y: Float, downTime: Long) = instrumentation.runOnMainSync {
|
||||||
|
MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), action, x, y, 0).also {
|
||||||
|
it.source = InputDevice.SOURCE_TOUCHSCREEN
|
||||||
|
activity.dispatchTouchEvent(it); it.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (type in listOf(MainActivity::class.java, BackupActivity::class.java)) {
|
||||||
|
val activity = instrumentation.startActivitySync(Intent(context, type).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||||
|
try {
|
||||||
|
onView(isRoot()).check(matches(isDisplayed()))
|
||||||
|
lateinit var menu: Button
|
||||||
|
var x = 0f; var y = 0f
|
||||||
|
instrumentation.runOnMainSync {
|
||||||
|
val root = activity.window.decorView
|
||||||
|
menu = descendants(root).filterIsInstance<Button>().single { it.contentDescription == "Open all sections" }
|
||||||
|
val location = IntArray(2); menu.getLocationInWindow(location)
|
||||||
|
assertEquals(root.width / 2, location[0] + menu.width / 2)
|
||||||
|
assertEquals(root.height, location[1] + menu.height)
|
||||||
|
assertEquals(root.height, descendants(root).filterIsInstance<ScrollView>().single().height)
|
||||||
|
assertEquals(View.INVISIBLE, menu.visibility)
|
||||||
|
x = location[0] + menu.width / 2f; y = location[1] + menu.height / 2f
|
||||||
|
}
|
||||||
|
val down = SystemClock.uptimeMillis()
|
||||||
|
// The reveal tap must reach the old content target, never the newly shown menu.
|
||||||
|
send(activity, MotionEvent.ACTION_DOWN, x, y, down)
|
||||||
|
SystemClock.sleep(3300)
|
||||||
|
instrumentation.runOnMainSync {
|
||||||
|
assertEquals("Do not hide under a held finger", View.VISIBLE, menu.visibility)
|
||||||
|
assertFalse(descendants(activity.window.decorView).filterIsInstance<Button>().any { it.contentDescription == "Recorder" })
|
||||||
|
}
|
||||||
|
send(activity, MotionEvent.ACTION_UP, x, y, down)
|
||||||
|
instrumentation.runOnMainSync {
|
||||||
|
assertTrue("Reveal must not open the menu", menu.isAttachedToWindow)
|
||||||
|
assertFalse(descendants(activity.window.decorView).filterIsInstance<Button>().any { it.contentDescription == "Recorder" })
|
||||||
|
}
|
||||||
|
SystemClock.sleep(2000)
|
||||||
|
instrumentation.runOnMainSync { assertEquals("Leave time to tap the revealed menu", View.VISIBLE, menu.visibility) }
|
||||||
|
var hidden = false
|
||||||
|
val deadline = SystemClock.elapsedRealtime() + 2500
|
||||||
|
while (!hidden && SystemClock.elapsedRealtime() < deadline) {
|
||||||
|
instrumentation.runOnMainSync { hidden = menu.visibility == View.INVISIBLE }
|
||||||
|
if (!hidden) SystemClock.sleep(50)
|
||||||
|
}
|
||||||
|
assertTrue("Menu must hide after idle time", hidden)
|
||||||
|
// Ordinary content touches reveal it too, without swallowing that gesture.
|
||||||
|
val tap = SystemClock.uptimeMillis()
|
||||||
|
send(activity, MotionEvent.ACTION_DOWN, activity.window.decorView.width / 2f, activity.window.decorView.height * .12f, tap)
|
||||||
|
send(activity, MotionEvent.ACTION_UP, activity.window.decorView.width / 2f, activity.window.decorView.height * .12f, tap)
|
||||||
|
instrumentation.runOnMainSync { assertEquals(View.VISIBLE, menu.visibility) }
|
||||||
|
if (type == MainActivity::class.java && InstrumentationRegistry.getArguments().getString("saveDesignScreenshots") == "true") {
|
||||||
|
instrumentation.waitForIdleSync()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
instrumentation.uiAutomation.takeScreenshot()?.let { bitmap ->
|
||||||
|
File(context.cacheDir, "home-menu-visible.png").outputStream().use { bitmap.compress(Bitmap.CompressFormat.PNG, 100, it) }
|
||||||
|
bitmap.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == MainActivity::class.java) {
|
||||||
|
val open = SystemClock.uptimeMillis()
|
||||||
|
send(activity, MotionEvent.ACTION_DOWN, x, y, open)
|
||||||
|
send(activity, MotionEvent.ACTION_UP, x, y, open)
|
||||||
|
instrumentation.runOnMainSync {
|
||||||
|
assertTrue("A second tap opens the visible menu", descendants(activity.window.decorView).filterIsInstance<Button>().any { it.contentDescription == "Recorder" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally { instrumentation.runOnMainSync { activity.finish() } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package meghdad.remember
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Button
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.Espresso.pressBack
|
||||||
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
|
import androidx.test.espresso.action.ViewActions.scrollTo
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.*
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry
|
||||||
|
import androidx.test.runner.lifecycle.Stage
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class NavigationTest {
|
||||||
|
/** Exercise the real activity stack, the fixed menu shortcut, and scrollable grid tiles. */
|
||||||
|
@Test fun oneMenuOpensEverySectionAndBackReturnsWithoutNestedMenus() {
|
||||||
|
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||||
|
val context = instrumentation.targetContext
|
||||||
|
val activity = instrumentation.startActivitySync(Intent(context, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||||
|
fun descendants(view: View): List<View> = listOf(view) + if (view is ViewGroup)
|
||||||
|
(0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
||||||
|
fun revealMenu(open: Boolean = false) {
|
||||||
|
// Run the gesture and assertion together: an idle-waiting test runner must not
|
||||||
|
// wait out the very timeout this control is meant to have.
|
||||||
|
instrumentation.runOnMainSync {
|
||||||
|
val current = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED)
|
||||||
|
.single { it.window.decorView.hasWindowFocus() }
|
||||||
|
val root = current.window.decorView
|
||||||
|
val now = android.os.SystemClock.uptimeMillis()
|
||||||
|
listOf(MotionEvent.ACTION_DOWN, MotionEvent.ACTION_UP).forEach { action ->
|
||||||
|
MotionEvent.obtain(now, now, action, root.width * .5f, root.height * .2f, 0).also {
|
||||||
|
it.source = android.view.InputDevice.SOURCE_TOUCHSCREEN
|
||||||
|
current.dispatchTouchEvent(it); it.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val button = descendants(root).filterIsInstance<Button>().single { it.contentDescription == "Open all sections" }
|
||||||
|
assertEquals(View.VISIBLE, button.visibility)
|
||||||
|
if (open) button.performClick()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun screenshot(name: String) {
|
||||||
|
if (InstrumentationRegistry.getArguments().getString("saveDesignScreenshots") != "true") return
|
||||||
|
onView(isRoot()).check(matches(isDisplayed()))
|
||||||
|
instrumentation.waitForIdleSync()
|
||||||
|
android.os.SystemClock.sleep(350)
|
||||||
|
instrumentation.uiAutomation.takeScreenshot()?.let { bitmap ->
|
||||||
|
File(context.cacheDir, "$name.png").outputStream().use { bitmap.compress(Bitmap.CompressFormat.PNG, 100, it) }
|
||||||
|
bitmap.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
screenshot("home")
|
||||||
|
revealMenu(open = true)
|
||||||
|
screenshot("menu")
|
||||||
|
listOf("Moments", "Storage", "Recording limit", "Backup", "Server", "Transfers", "Server recordings", "Automatic backup", "Advanced").forEach { destination ->
|
||||||
|
android.util.Log.i("RememberNavigation", "Opening $destination")
|
||||||
|
onView(withContentDescription(destination)).perform(scrollTo())
|
||||||
|
instrumentation.waitForIdleSync()
|
||||||
|
android.os.SystemClock.sleep(250)
|
||||||
|
onView(withContentDescription(destination)).perform(click())
|
||||||
|
val expected = if (destination in listOf("Moments", "Storage", "Recording limit")) MainActivity::class.java else BackupActivity::class.java
|
||||||
|
var ready = false
|
||||||
|
val deadline = android.os.SystemClock.elapsedRealtime() + 5000
|
||||||
|
while (!ready && android.os.SystemClock.elapsedRealtime() < deadline) {
|
||||||
|
instrumentation.runOnMainSync {
|
||||||
|
ready = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED)
|
||||||
|
.any { expected.isInstance(it) && it.window.decorView.hasWindowFocus() }
|
||||||
|
}
|
||||||
|
if (!ready) android.os.SystemClock.sleep(50)
|
||||||
|
}
|
||||||
|
assertTrue("Section must be foreground before testing its touch menu", ready)
|
||||||
|
revealMenu()
|
||||||
|
screenshot(when (destination) {
|
||||||
|
"Recording limit" -> "recording-limit"
|
||||||
|
"Backup" -> "backup-overview"
|
||||||
|
"Server" -> "backup-server"
|
||||||
|
"Automatic backup" -> "backup-automatic"
|
||||||
|
else -> destination.lowercase().replace(' ', '-')
|
||||||
|
})
|
||||||
|
// Both ways out must return to the same shared grid across activity boundaries.
|
||||||
|
if (destination in listOf("Storage", "Backup", "Automatic backup")) {
|
||||||
|
revealMenu(open = true)
|
||||||
|
} else pressBack()
|
||||||
|
instrumentation.waitForIdleSync()
|
||||||
|
android.os.SystemClock.sleep(350)
|
||||||
|
onView(withContentDescription("Recorder")).check(matches(isEnabled()))
|
||||||
|
}
|
||||||
|
onView(withContentDescription("Recorder")).perform(scrollTo(), click())
|
||||||
|
onView(withContentDescription("Start recording")).check(matches(isDisplayed()))
|
||||||
|
} finally { instrumentation.runOnMainSync { activity.finish() } }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,13 +25,18 @@ class SettingsTest {
|
|||||||
fun descendants(view: View): List<View> = listOf(view) + if (view is ViewGroup)
|
fun descendants(view: View): List<View> = listOf(view) + if (view is ViewGroup)
|
||||||
(0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
(0 until view.childCount).flatMap { descendants(view.getChildAt(it)) } else emptyList()
|
||||||
fun button(prefix: String) = descendants(activity.window.decorView).filterIsInstance<Button>().first { it.text.startsWith(prefix) }
|
fun button(prefix: String) = descendants(activity.window.decorView).filterIsInstance<Button>().first { it.text.startsWith(prefix) }
|
||||||
button("Settings").performClick()
|
val now = android.os.SystemClock.uptimeMillis()
|
||||||
|
listOf(android.view.MotionEvent.ACTION_DOWN, android.view.MotionEvent.ACTION_UP).forEach { action ->
|
||||||
|
android.view.MotionEvent.obtain(now, now, action, activity.window.decorView.width / 2f,
|
||||||
|
activity.window.decorView.height * .12f, 0).also { event -> activity.dispatchTouchEvent(event); event.recycle() }
|
||||||
|
}
|
||||||
|
descendants(activity.window.decorView).filterIsInstance<Button>().first { it.contentDescription == "Open all sections" }.performClick()
|
||||||
button("Recording limit").performClick()
|
button("Recording limit").performClick()
|
||||||
descendants(activity.window.decorView).filterIsInstance<Switch>().single().isChecked = true
|
descendants(activity.window.decorView).filterIsInstance<Switch>().single().isChecked = true
|
||||||
button("Length").performClick()
|
button("Length").performClick()
|
||||||
descendants(activity.window.decorView).filterIsInstance<NumberPicker>().single().value = 137
|
descendants(activity.window.decorView).filterIsInstance<NumberPicker>().single().value = 137
|
||||||
button("Save").performClick()
|
button("Save").performClick()
|
||||||
button("At the limit").performClick()
|
descendants(activity.window.decorView).filterIsInstance<android.widget.TextView>().first { it.text == "At the limit" }.let { (it.parent.parent as View).performClick() }
|
||||||
button("Save & start next").performClick()
|
button("Save & start next").performClick()
|
||||||
button("Back").performClick()
|
button("Back").performClick()
|
||||||
assertEquals(RecordingLimit(true, 137, LimitAction.NEXT_CLIP), preferences.read())
|
assertEquals(RecordingLimit(true, 137, LimitAction.NEXT_CLIP), preferences.read())
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<service android:name=".RecordingService" android:exported="false" android:foregroundServiceType="microphone" />
|
<service android:name=".RecordingService" android:exported="false" android:foregroundServiceType="microphone" />
|
||||||
<activity android:name=".BackupActivity" android:exported="false" android:taskAffinity="" />
|
<activity android:name=".BackupActivity" android:exported="false" android:taskAffinity="" android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
|
||||||
<service android:name=".BackupWorker" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
|
<service android:name=".BackupWorker" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -28,6 +28,10 @@ class BackupActivity : Activity() {
|
|||||||
private lateinit var body: LinearLayout
|
private lateinit var body: LinearLayout
|
||||||
private lateinit var scroll: ScrollView
|
private lateinit var scroll: ScrollView
|
||||||
private var page = "overview"
|
private var page = "overview"
|
||||||
|
private var floatingMenu: FloatingMenuController? = null
|
||||||
|
companion object { const val EXTRA_PAGE = "backup_page" }
|
||||||
|
private var backupDial: StatusDialView? = null
|
||||||
|
private var waitingCount: TextView? = null
|
||||||
private var busy = false
|
private var busy = false
|
||||||
private val executor = Executors.newSingleThreadExecutor()
|
private val executor = Executors.newSingleThreadExecutor()
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
@@ -48,7 +52,10 @@ class BackupActivity : Activity() {
|
|||||||
private var localClips: List<Clip> = emptyList()
|
private var localClips: List<Clip> = emptyList()
|
||||||
private val tick = object : Runnable {
|
private val tick = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (page == "overview") summary?.text = settings.preferences.getString("summary", "Ready when you are")
|
if (page == "overview") {
|
||||||
|
summary?.text = settings.preferences.getString("summary", "Ready when you are")
|
||||||
|
updateBackupDial()
|
||||||
|
}
|
||||||
if (page == "transfers") rows.forEach { (id, view) ->
|
if (page == "transfers") rows.forEach { (id, view) ->
|
||||||
val clip = localClips.find { it.id == id }
|
val clip = localClips.find { it.id == id }
|
||||||
if (clip != null) view.text = transferState(clip)
|
if (clip != null) view.text = transferState(clip)
|
||||||
@@ -64,23 +71,43 @@ class BackupActivity : Activity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
settings = BackupSettings(this)
|
settings = BackupSettings(this)
|
||||||
|
page = intent.getStringExtra(EXTRA_PAGE)?.takeIf { it in listOf("overview", "server", "transfers", "remote", "automatic", "advanced") } ?: "overview"
|
||||||
if (Build.VERSION.SDK_INT >= 33) onBackInvokedDispatcher.registerOnBackInvokedCallback(0) { back() }
|
if (Build.VERSION.SDK_INT >= 33) onBackInvokedDispatcher.registerOnBackInvokedCallback(0) { back() }
|
||||||
render()
|
render()
|
||||||
}
|
}
|
||||||
override fun onResume() { super.onResume(); resumed = true; handler.post(tick) }
|
override fun onResume() { super.onResume(); resumed = true; floatingMenu?.resume(); handler.post(tick) }
|
||||||
override fun onPause() { resumed = false; handler.removeCallbacks(tick); if (playbackReady) player?.pause(); super.onPause() }
|
override fun onPause() { resumed = false; floatingMenu?.pause(); handler.removeCallbacks(tick); if (playbackReady) player?.pause(); super.onPause() }
|
||||||
override fun onDestroy() { trustProbe?.close(); client?.close(); executor.shutdownNow(); player?.release(); super.onDestroy() }
|
override fun onDestroy() { floatingMenu?.dispose(); trustProbe?.close(); client?.close(); executor.shutdownNow(); player?.release(); super.onDestroy() }
|
||||||
|
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
val handled = super.dispatchTouchEvent(event)
|
||||||
|
floatingMenu?.onTouch(event.actionMasked)
|
||||||
|
return handled
|
||||||
|
}
|
||||||
|
override fun dispatchKeyEvent(event: android.view.KeyEvent): Boolean {
|
||||||
|
val handled = super.dispatchKeyEvent(event)
|
||||||
|
if (event.action == android.view.KeyEvent.ACTION_DOWN && event.keyCode in listOf(
|
||||||
|
android.view.KeyEvent.KEYCODE_DPAD_UP, android.view.KeyEvent.KEYCODE_DPAD_DOWN,
|
||||||
|
android.view.KeyEvent.KEYCODE_DPAD_LEFT, android.view.KeyEvent.KEYCODE_DPAD_RIGHT,
|
||||||
|
android.view.KeyEvent.KEYCODE_DPAD_CENTER, android.view.KeyEvent.KEYCODE_TAB)) floatingMenu?.interact()
|
||||||
|
return handled
|
||||||
|
}
|
||||||
|
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
|
||||||
|
val handled = super.dispatchGenericMotionEvent(event)
|
||||||
|
if (event.action == MotionEvent.ACTION_SCROLL) floatingMenu?.interact()
|
||||||
|
return handled
|
||||||
|
}
|
||||||
private fun dp(value: Int) = (value * resources.displayMetrics.density).roundToInt()
|
private fun dp(value: Int) = (value * resources.displayMetrics.density).roundToInt()
|
||||||
private fun text(value: String, size: Float = 12f, color: Int = Color.WHITE): TextView = TextView(this).apply {
|
private fun text(value: String, size: Float = 12f, color: Int = Color.WHITE): TextView = TextView(this).apply {
|
||||||
text = value; textSize = size; setTextColor(color); gravity = Gravity.CENTER
|
text = value; textSize = size; setTextColor(color); gravity = Gravity.CENTER
|
||||||
setPadding(dp(3), dp(5), dp(3), dp(5)); body.addView(this, LinearLayout.LayoutParams(-1, -2))
|
setPadding(dp(3), dp(5), dp(3), dp(5)); body.addView(this, LinearLayout.LayoutParams(-1, -2))
|
||||||
}
|
}
|
||||||
private fun button(label: String, action: () -> Unit): Button = Button(this).apply {
|
private fun button(label: String, action: () -> Unit): Button = WatchDesign.action(this, label, action = action).also { body.addView(it) }
|
||||||
text = label; textSize = 12f; isAllCaps = false; setTextColor(Color.WHITE)
|
private fun primary(label: String, action: () -> Unit): Button = WatchDesign.action(this, label, true, action).also { body.addView(it) }
|
||||||
background = GradientDrawable().apply { setColor(Color.rgb(43, 52, 32)); cornerRadius = dp(24).toFloat() }
|
private fun menu() {
|
||||||
stateListAnimator = null
|
if (busy) { toast(getString(R.string.backup_wait_for_the_current_action_or_cancel_it)); return }
|
||||||
setOnClickListener { action() }
|
startActivity(Intent(this, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||||
body.addView(this, LinearLayout.LayoutParams(-1, dp(48)).apply { setMargins(0, dp(4), 0, dp(4)) })
|
.putExtra(MainActivity.EXTRA_SCREEN, "menu"))
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
private fun navigate(target: String) {
|
private fun navigate(target: String) {
|
||||||
if (busy) { toast(getString(R.string.backup_wait_for_the_current_action_or_cancel_it)); return }
|
if (busy) { toast(getString(R.string.backup_wait_for_the_current_action_or_cancel_it)); return }
|
||||||
@@ -89,15 +116,29 @@ class BackupActivity : Activity() {
|
|||||||
page = target; render()
|
page = target; render()
|
||||||
}
|
}
|
||||||
private fun render() {
|
private fun render() {
|
||||||
rows.clear(); summary = null; progress = null; playbackButton = null; seek = null
|
val menuWasVisible = floatingMenu?.button?.visibility == View.VISIBLE
|
||||||
|
floatingMenu?.dispose(); floatingMenu = null
|
||||||
|
rows.clear(); summary = null; progress = null; playbackButton = null; seek = null; backupDial = null; waitingCount = null
|
||||||
scroll = ScrollView(this).apply { isFillViewport = true; isVerticalScrollBarEnabled = false; setBackgroundColor(Color.rgb(13, 17, 11)) }
|
scroll = ScrollView(this).apply { isFillViewport = true; isVerticalScrollBarEnabled = false; setBackgroundColor(Color.rgb(13, 17, 11)) }
|
||||||
body = LinearLayout(this).apply {
|
body = LinearLayout(this).apply {
|
||||||
orientation = LinearLayout.VERTICAL; gravity = Gravity.CENTER_HORIZONTAL
|
orientation = LinearLayout.VERTICAL; gravity = Gravity.CENTER_HORIZONTAL
|
||||||
// Keep controls inside a round watch's usable area even on emulator images
|
// Keep controls inside a round watch's usable area even on emulator images
|
||||||
// that omit the round configuration qualifier.
|
// that omit the round configuration qualifier.
|
||||||
setPadding(dp(28), dp(28), dp(28), dp(36))
|
setPadding(dp(28), dp(14), dp(28), dp(24))
|
||||||
}
|
}
|
||||||
scroll.addView(body); setContentView(scroll)
|
val layers = FrameLayout(this).apply { setBackgroundColor(WatchDesign.ink) }
|
||||||
|
scroll.addView(body); layers.addView(scroll, FrameLayout.LayoutParams(-1, -1))
|
||||||
|
if (page !in listOf("trust", "trust_fingerprint")) {
|
||||||
|
val menuButton = WatchDesign.menuDock(this) { menu() }
|
||||||
|
layers.addView(menuButton, FrameLayout.LayoutParams(dp(48), dp(48), Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL))
|
||||||
|
floatingMenu = FloatingMenuController(menuButton).also {
|
||||||
|
if (resumed) { it.resume(); if (menuWasVisible) it.interact() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setContentView(layers)
|
||||||
|
window.decorView.windowInsetsController?.hide(android.view.WindowInsets.Type.systemBars())
|
||||||
|
scroll.descendantFocusability = android.view.ViewGroup.FOCUS_BEFORE_DESCENDANTS
|
||||||
|
scroll.isFocusableInTouchMode = true
|
||||||
scroll.setOnGenericMotionListener { _, event ->
|
scroll.setOnGenericMotionListener { _, event ->
|
||||||
if (event.action == MotionEvent.ACTION_SCROLL) {
|
if (event.action == MotionEvent.ACTION_SCROLL) {
|
||||||
scroll.smoothScrollBy(0, (-event.getAxisValue(MotionEvent.AXIS_SCROLL) * dp(35)).toInt()); true
|
scroll.smoothScrollBy(0, (-event.getAxisValue(MotionEvent.AXIS_SCROLL) * dp(35)).toInt()); true
|
||||||
@@ -119,28 +160,27 @@ class BackupActivity : Activity() {
|
|||||||
"licenses" -> { title(getString(R.string.backup_open_source_licenses)); text(listOf("JSch.txt", "Bouncy-Castle.txt").joinToString("\n\n") { name -> assets.open("licenses/$name").bufferedReader().use { it.readText() } }, 10f, muted); button(getString(R.string.backup_back)) { navigate("advanced") } }
|
"licenses" -> { title(getString(R.string.backup_open_source_licenses)); text(listOf("JSch.txt", "Bouncy-Castle.txt").joinToString("\n\n") { name -> assets.open("licenses/$name").bufferedReader().use { it.readText() } }, 10f, muted); button(getString(R.string.backup_back)) { navigate("advanced") } }
|
||||||
else -> overview()
|
else -> overview()
|
||||||
}
|
}
|
||||||
|
scroll.requestFocus()
|
||||||
|
}
|
||||||
|
private fun title(value: String) { WatchDesign.heading(body, value, "Remember") }
|
||||||
|
private fun updateBackupDial() {
|
||||||
|
val backed = localClips.count { settings.receipt(it.id) == backupVersion(it, Recordings(this).audio(it.id)) }
|
||||||
|
backupDial?.update(backed.toString(), "backed up / ${localClips.size}", if (localClips.isEmpty()) 0f else backed.toFloat() / localClips.size)
|
||||||
|
waitingCount?.text = getString(R.string.backup_waiting_count, localClips.size - backed)
|
||||||
}
|
}
|
||||||
private fun title(value: String) { text(value.uppercase(), 10f, lime) }
|
|
||||||
private fun overview() {
|
private fun overview() {
|
||||||
title(getString(R.string.backup_backup))
|
body.addView(WatchDesign.label(this, getString(R.string.backup_backup).uppercase(), 10f, lime).apply { letterSpacing = .16f })
|
||||||
text(getString(R.string.backup_keep_your_moments), 16f)
|
localClips = Recordings(this).list()
|
||||||
val clips = Recordings(this).list()
|
backupDial = StatusDialView(this).also { body.addView(it, LinearLayout.LayoutParams(-1, dp(92))) }
|
||||||
val backed = clips.count { settings.receipt(it.id) == backupVersion(it, Recordings(this).audio(it.id)) }
|
primary(getString(R.string.backup_back_up_now)) { startBackup() }
|
||||||
text("$backed backed up\n${clips.size - backed} waiting", 16f, lime)
|
waitingCount = text("", 11f, lime)
|
||||||
button(getString(R.string.backup_back_up_now)) { startBackup() }.apply {
|
updateBackupDial()
|
||||||
background = GradientDrawable().apply {
|
|
||||||
setColor(Color.rgb(35, 44, 20)); cornerRadius = dp(24).toFloat(); setStroke(dp(1), lime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val time = settings.preferences.getLong("last_success", 0)
|
|
||||||
text(if (time == 0L) "No completed backup yet" else "Last backup\n${DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(Date(time))}", 10f, muted)
|
|
||||||
summary = text(settings.preferences.getString("summary", "Ready when you are")!!, 11f, muted)
|
summary = text(settings.preferences.getString("summary", "Ready when you are")!!, 11f, muted)
|
||||||
button(getString(R.string.backup_server)) { navigate("server") }
|
val time = settings.preferences.getLong("last_success", 0)
|
||||||
button(getString(R.string.backup_transfers)) { navigate("transfers") }
|
WatchDesign.card(body, getString(R.string.backup_last), if (time == 0L) getString(R.string.backup_none_completed) else DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(Date(time)), WatchIcon.BACKUP)
|
||||||
button(getString(R.string.backup_server_recordings)) { navigate("remote") }
|
val server = settings.server()
|
||||||
button(getString(R.string.backup_automatic_backup)) { navigate("automatic") }
|
WatchDesign.card(body, getString(R.string.backup_destination), server.host.ifBlank { getString(R.string.backup_no_destination) }, WatchIcon.SERVER)
|
||||||
button(getString(R.string.backup_advanced)) { navigate("advanced") }
|
text(getString(if (settings.automatic) R.string.backup_automatic_on else R.string.backup_automatic_off), 10f, muted)
|
||||||
button(getString(R.string.backup_back)) { finish() }
|
|
||||||
}
|
}
|
||||||
private fun field(label: String, value: String, type: Int = InputType.TYPE_CLASS_TEXT): EditText {
|
private fun field(label: String, value: String, type: Int = InputType.TYPE_CLASS_TEXT): EditText {
|
||||||
text(label, 11f, muted)
|
text(label, 11f, muted)
|
||||||
@@ -152,6 +192,7 @@ class BackupActivity : Activity() {
|
|||||||
}
|
}
|
||||||
private fun serverPage() {
|
private fun serverPage() {
|
||||||
title(getString(R.string.backup_server))
|
title(getString(R.string.backup_server))
|
||||||
|
text("01 / CONNECTION", 9f, lime)
|
||||||
val server = serverDraft?.withRememberedTrust(settings.server()) ?: settings.server()
|
val server = serverDraft?.withRememberedTrust(settings.server()) ?: settings.server()
|
||||||
val host = field(getString(R.string.backup_address), server.host, InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
val host = field(getString(R.string.backup_address), server.host, InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
val port = field(getString(R.string.backup_port), server.port.toString(), InputType.TYPE_CLASS_NUMBER)
|
val port = field(getString(R.string.backup_port), server.port.toString(), InputType.TYPE_CLASS_NUMBER)
|
||||||
@@ -169,7 +210,7 @@ class BackupActivity : Activity() {
|
|||||||
host.addTextChangedListener(endpointWatcher); port.addTextChangedListener(endpointWatcher)
|
host.addTextChangedListener(endpointWatcher); port.addTextChangedListener(endpointWatcher)
|
||||||
fun save(candidate: BackupServer): Boolean = persistServer(candidate).also { if (it) updateTrustStatus() }
|
fun save(candidate: BackupServer): Boolean = persistServer(candidate).also { if (it) updateTrustStatus() }
|
||||||
fun testConnection() { runRemote("Connecting…") { it.test(); "Connected. Backup folder is accessible." } }
|
fun testConnection() { runRemote("Connecting…") { it.test(); "Connected. Backup folder is accessible." } }
|
||||||
button(getString(R.string.backup_connect_trust)) {
|
primary(getString(R.string.backup_connect_trust)) {
|
||||||
val candidate = draft()
|
val candidate = draft()
|
||||||
runCatching { candidate.validateConfiguration() }.onSuccess {
|
runCatching { candidate.validateConfiguration() }.onSuccess {
|
||||||
serverDraft = candidate
|
serverDraft = candidate
|
||||||
@@ -197,7 +238,7 @@ class BackupActivity : Activity() {
|
|||||||
button(getString(R.string.backup_save_server)) {
|
button(getString(R.string.backup_save_server)) {
|
||||||
if (save(draft())) {
|
if (save(draft())) {
|
||||||
if (settings.server().fingerprint.isNotEmpty()) BackupWork.schedule(this)
|
if (settings.server().fingerprint.isNotEmpty()) BackupWork.schedule(this)
|
||||||
navigate("overview")
|
menu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
button(getString(R.string.backup_test_connection)) {
|
button(getString(R.string.backup_test_connection)) {
|
||||||
@@ -205,6 +246,7 @@ class BackupActivity : Activity() {
|
|||||||
runCatching { candidate.validate() }.onSuccess { if (save(candidate)) testConnection() }
|
runCatching { candidate.validate() }.onSuccess { if (save(candidate)) testConnection() }
|
||||||
.onFailure { toast(it.message ?: "Use Connect & trust first") }
|
.onFailure { toast(it.message ?: "Use Connect & trust first") }
|
||||||
}
|
}
|
||||||
|
text("02 / WATCH IDENTITY", 9f, lime)
|
||||||
button(if (settings.publicKey() == null) "Create watch key" else "Show watch key") {
|
button(if (settings.publicKey() == null) "Create watch key" else "Show watch key") {
|
||||||
runTask("Preparing key…", { settings.generateKey() }) { key ->
|
runTask("Preparing key…", { settings.generateKey() }) { key ->
|
||||||
showPublicKey(key)
|
showPublicKey(key)
|
||||||
@@ -223,7 +265,7 @@ class BackupActivity : Activity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
progress = text("", 10f, muted)
|
progress = text("", 10f, muted)
|
||||||
button(getString(R.string.backup_back)) { navigate("overview") }
|
button(getString(R.string.backup_back)) { back() }
|
||||||
}
|
}
|
||||||
private fun persistServer(candidate: BackupServer): Boolean = try {
|
private fun persistServer(candidate: BackupServer): Boolean = try {
|
||||||
candidate.validateConfiguration()
|
candidate.validateConfiguration()
|
||||||
@@ -277,48 +319,51 @@ class BackupActivity : Activity() {
|
|||||||
title(getString(R.string.backup_transfers))
|
title(getString(R.string.backup_transfers))
|
||||||
val clips = Recordings(this).list()
|
val clips = Recordings(this).list()
|
||||||
localClips = clips
|
localClips = clips
|
||||||
if (clips.isEmpty()) text(getString(R.string.backup_save_a_recording_to_begin), 14f)
|
text("${clips.size} moments · one safe copy at a time", 10f, muted)
|
||||||
clips.forEach { clip ->
|
WatchDesign.pair(body,
|
||||||
text(clip.title, 14f)
|
WatchDesign.action(this, getString(R.string.backup_back_up_retry), true) { startBackup() },
|
||||||
rows[clip.id] = text(transferState(clip), 11f, lime)
|
WatchDesign.action(this, getString(R.string.pause_all)) {
|
||||||
}
|
BackupWork.cancel(this)
|
||||||
button(getString(R.string.backup_back_up_retry)) { startBackup() }
|
clips.forEach { if (transferState(it) != "Backed up") settings.status(it.id, "Waiting") }
|
||||||
button(getString(R.string.backup_pause_all_backups)) {
|
toast(getString(R.string.backup_backups_paused_automatic_backup_is_off))
|
||||||
BackupWork.cancel(this)
|
})
|
||||||
clips.forEach { if (transferState(it) != "Backed up") settings.status(it.id, "Waiting") }
|
if (clips.isEmpty()) {
|
||||||
toast(getString(R.string.backup_backups_paused_automatic_backup_is_off))
|
body.addView(ImageView(this).apply { setImageDrawable(WatchGlyph(WatchIcon.TRANSFERS, lime)); importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO }, LinearLayout.LayoutParams(dp(60), dp(72)))
|
||||||
|
text(getString(R.string.backup_save_a_recording_to_begin), 14f)
|
||||||
}
|
}
|
||||||
|
clips.forEach { clip -> rows[clip.id] = WatchDesign.card(body, clip.title, transferState(clip), WatchIcon.TRANSFERS) }
|
||||||
text(getString(R.string.backup_copies_stay_on_the_server_when_you_delete_local_recordings), 10f, muted)
|
text(getString(R.string.backup_copies_stay_on_the_server_when_you_delete_local_recordings), 10f, muted)
|
||||||
button(getString(R.string.backup_back)) { navigate("overview") }
|
button(getString(R.string.backup_back)) { back() }
|
||||||
}
|
}
|
||||||
private fun startBackup() {
|
private fun startBackup() {
|
||||||
runCatching { BackupWork.start(this) }.onSuccess { toast(getString(R.string.backup_backup_queued_opens_when_connected)) }
|
runCatching { BackupWork.start(this) }.onSuccess { toast(getString(R.string.backup_backup_queued_opens_when_connected)) }
|
||||||
.onFailure { toast(it.message ?: "Configure the server first") }
|
.onFailure { toast(it.message ?: "Configure the server first") }
|
||||||
}
|
}
|
||||||
private fun remotePage() {
|
private fun remotePage() {
|
||||||
title(getString(R.string.backup_server_recordings))
|
WatchDesign.heading(body, getString(R.string.on_your_server), getString(R.string.backup_server_recordings))
|
||||||
button(getString(R.string.backup_refresh)) {
|
button(getString(R.string.backup_refresh)) {
|
||||||
runTask("Loading recordings…", { withRemote { it.list() } }) { remoteClips = it; render() }
|
runTask("Loading recordings…", { withRemote { it.list() } }) { remoteClips = it; render() }
|
||||||
}
|
}
|
||||||
if (remoteClips.isEmpty()) text(getString(R.string.backup_tap_refresh_to_browse_your_backups), 12f, muted)
|
if (remoteClips.isEmpty()) {
|
||||||
|
body.addView(ImageView(this).apply { setImageDrawable(WatchGlyph(WatchIcon.REMOTE, Color.rgb(143, 204, 217))); importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO }, LinearLayout.LayoutParams(dp(72), dp(88)))
|
||||||
|
text(getString(R.string.backup_tap_refresh_to_browse_your_backups), 12f, muted)
|
||||||
|
}
|
||||||
remoteClips.forEach { remote ->
|
remoteClips.forEach { remote ->
|
||||||
val date = DateFormat.getDateInstance(DateFormat.SHORT).format(Date(remote.clip.created))
|
val date = DateFormat.getDateInstance(DateFormat.SHORT).format(Date(remote.clip.created))
|
||||||
button("${remote.clip.title}\n$date · ${timeLabel(remote.clip.duration)}") { selected = remote; navigate("playback") }.apply {
|
WatchDesign.card(body, remote.clip.title, "$date · ${timeLabel(remote.clip.duration)}", WatchIcon.PLAY) { selected = remote; navigate("playback") }
|
||||||
maxLines = 2; ellipsize = android.text.TextUtils.TruncateAt.END
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
progress = text("", 10f, muted)
|
progress = text("", 10f, muted)
|
||||||
button(getString(R.string.backup_back)) { navigate("overview") }
|
button(getString(R.string.backup_back)) { back() }
|
||||||
}
|
}
|
||||||
private fun playbackPage() {
|
private fun playbackPage() {
|
||||||
val remote = selected ?: return
|
val remote = selected ?: return
|
||||||
title(getString(R.string.backup_server_playback))
|
title(getString(R.string.backup_server_playback))
|
||||||
text(remote.clip.title, 17f)
|
text(remote.clip.title, 17f)
|
||||||
text("${timeLabel(remote.clip.duration)} · ${remote.clip.marks.size} bookmarks", 11f, muted)
|
text("${timeLabel(remote.clip.duration)} · ${remote.clip.marks.size} bookmarks", 11f, muted)
|
||||||
text(getString(R.string.backup_audio_downloads_to_a_temporary_watch_cache_before_playing), 10f, muted)
|
body.addView(StatusDialView(this).apply { update((remote.clip.duration / 60_000).toString(), "minutes on server", 1f) }, LinearLayout.LayoutParams(-1, dp(104)))
|
||||||
progress = text(getString(R.string.backup_ready_to_download), 11f, lime)
|
progress = text(getString(R.string.backup_ready_to_download), 11f, lime)
|
||||||
playbackButton = button(getString(R.string.backup_download_play)) {
|
playbackButton = primary(getString(R.string.backup_download_play)) {
|
||||||
if (player != null) { if (playbackReady) player!!.let { if (it.isPlaying) it.pause() else it.start() }; return@button }
|
if (player != null) { if (playbackReady) player!!.let { if (it.isPlaying) it.pause() else it.start() }; return@primary }
|
||||||
val file = File(cacheDir, "server-playback.m4a")
|
val file = File(cacheDir, "server-playback.m4a")
|
||||||
runTask("Preparing audio…", {
|
runTask("Preparing audio…", {
|
||||||
require(StatFs(cacheDir.absolutePath).availableBytes > remote.bytes + 16 * 1024 * 1024) { "Not enough free space for playback" }
|
require(StatFs(cacheDir.absolutePath).availableBytes > remote.bytes + 16 * 1024 * 1024) { "Not enough free space for playback" }
|
||||||
@@ -351,43 +396,50 @@ class BackupActivity : Activity() {
|
|||||||
}); body.addView(this, LinearLayout.LayoutParams(-1, dp(40)))
|
}); body.addView(this, LinearLayout.LayoutParams(-1, dp(40)))
|
||||||
}
|
}
|
||||||
remote.clip.marks.forEach { mark -> button("Bookmark · ${timeLabel(mark)}") { runCatching { player?.seekTo(mark.coerceAtMost(Int.MAX_VALUE.toLong()).toInt()) } } }
|
remote.clip.marks.forEach { mark -> button("Bookmark · ${timeLabel(mark)}") { runCatching { player?.seekTo(mark.coerceAtMost(Int.MAX_VALUE.toLong()).toInt()) } } }
|
||||||
|
text(getString(R.string.backup_audio_downloads_to_a_temporary_watch_cache_before_playing), 10f, muted)
|
||||||
button(getString(R.string.backup_cancel_download)) { client?.close() }
|
button(getString(R.string.backup_cancel_download)) { client?.close() }
|
||||||
button(getString(R.string.backup_back)) { navigate("remote") }
|
button(getString(R.string.backup_back)) { navigate("remote") }
|
||||||
}
|
}
|
||||||
private fun toggle(label: String, value: Boolean, change: (Boolean) -> Unit) {
|
private fun toggle(label: String, value: Boolean, change: (Boolean) -> Unit) {
|
||||||
Switch(this).apply {
|
Switch(this).apply {
|
||||||
|
background = WatchDesign.shape(this@BackupActivity)
|
||||||
|
setPadding(dp(12), 0, dp(12), 0)
|
||||||
|
thumbTintList = WatchDesign.switchTint()
|
||||||
text = label; textSize = 12f; setTextColor(Color.WHITE); isChecked = value
|
text = label; textSize = 12f; setTextColor(Color.WHITE); isChecked = value
|
||||||
setOnCheckedChangeListener { _, checked -> change(checked) }
|
setOnCheckedChangeListener { _, checked -> change(checked) }
|
||||||
body.addView(this, LinearLayout.LayoutParams(-1, dp(52)))
|
body.addView(this, LinearLayout.LayoutParams(-1, dp(52)).apply { topMargin = dp(4); bottomMargin = dp(4) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun automaticPage() {
|
private fun automaticPage() {
|
||||||
title(getString(R.string.backup_automatic_backup))
|
WatchDesign.heading(body, getString(R.string.autopilot), getString(R.string.backup_automatic_backup))
|
||||||
|
body.addView(StatusDialView(this).apply { update(settings.hours.toString(), if (settings.automatic) "hours / check" else "hours · off", if (settings.automatic) 1f else 0f) }, LinearLayout.LayoutParams(-1, dp(112)))
|
||||||
toggle("Enable", settings.automatic) {
|
toggle("Enable", settings.automatic) {
|
||||||
settings.preferences.edit().putBoolean("automatic", it).apply()
|
settings.preferences.edit().putBoolean("automatic", it).apply()
|
||||||
runCatching { BackupWork.schedule(this) }.onFailure { error ->
|
runCatching { BackupWork.schedule(this) }.onSuccess { render() }.onFailure { error ->
|
||||||
settings.preferences.edit().putBoolean("automatic", false).apply(); toast(error.message ?: "Configure server first"); render()
|
settings.preferences.edit().putBoolean("automatic", false).apply(); toast(error.message ?: "Configure server first"); render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toggle("While charging", settings.charging) { updateOption("charging", it) }
|
toggle("While charging", settings.charging) { updateOption("charging", it) }
|
||||||
toggle("Unmetered only", settings.unmetered) { updateOption("unmetered", it) }
|
toggle("Unmetered only", settings.unmetered) { updateOption("unmetered", it) }
|
||||||
button("Check every ${settings.hours} hours") {
|
text(getString(R.string.check_interval), 9f, lime)
|
||||||
choose("Backup interval", arrayOf("Every hour", "Every 6 hours", "Daily")) { index ->
|
optionStrip(listOf(1, 6, 24), settings.hours, { if (it == 24) "Daily" else "${it}h" }) {
|
||||||
settings.preferences.edit().putInt("hours", intArrayOf(1, 6, 24)[index]).apply(); BackupWork.schedule(this); render()
|
settings.preferences.edit().putInt("hours", it).apply(); BackupWork.schedule(this); render()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
text(getString(R.string.backup_runs_when_conditions_allow_the_watch_may_delay_background), 10f, muted)
|
text(getString(R.string.backup_runs_when_conditions_allow_the_watch_may_delay_background), 10f, muted)
|
||||||
button(getString(R.string.backup_back)) { navigate("overview") }
|
button(getString(R.string.backup_back)) { back() }
|
||||||
}
|
}
|
||||||
private fun updateOption(key: String, value: Boolean) { settings.preferences.edit().putBoolean(key, value).apply(); BackupWork.schedule(this) }
|
private fun updateOption(key: String, value: Boolean) { settings.preferences.edit().putBoolean(key, value).apply(); BackupWork.schedule(this) }
|
||||||
private fun advancedPage() {
|
private fun advancedPage() {
|
||||||
title(getString(R.string.backup_advanced))
|
WatchDesign.heading(body, getString(R.string.fine_tune), getString(R.string.backup_advanced))
|
||||||
button("Retry attempts · ${settings.attempts}") { choose("Retry attempts", arrayOf("1", "3", "5")) { index ->
|
text(getString(R.string.retry_attempts), 9f, lime)
|
||||||
settings.preferences.edit().putInt("attempts", intArrayOf(1, 3, 5)[index]).apply(); render()
|
optionStrip(listOf(1, 3, 5), settings.attempts, { it.toString() }) {
|
||||||
} }
|
settings.preferences.edit().putInt("attempts", it).apply(); render()
|
||||||
button("Connection timeout · ${settings.timeout}s") { choose("Connection timeout", arrayOf("20 seconds", "40 seconds", "60 seconds")) { index ->
|
}
|
||||||
settings.preferences.edit().putInt("timeout", intArrayOf(20, 40, 60)[index]).apply(); render()
|
text(getString(R.string.connection_timeout), 9f, lime)
|
||||||
} }
|
optionStrip(listOf(20, 40, 60), settings.timeout, { "${it}s" }) {
|
||||||
|
settings.preferences.edit().putInt("timeout", it).apply(); render()
|
||||||
|
}
|
||||||
|
text(getString(R.string.on_this_watch), 9f, lime)
|
||||||
button(getString(R.string.backup_clear_playback_cache)) {
|
button(getString(R.string.backup_clear_playback_cache)) {
|
||||||
player?.release(); player = null; playbackReady = false
|
player?.release(); player = null; playbackReady = false
|
||||||
File(cacheDir, "server-playback.m4a").delete(); File(cacheDir, "server-playback.m4a.download").delete()
|
File(cacheDir, "server-playback.m4a").delete(); File(cacheDir, "server-playback.m4a.download").delete()
|
||||||
@@ -411,9 +463,18 @@ class BackupActivity : Activity() {
|
|||||||
}.setNegativeButton(android.R.string.cancel, null).show()
|
}.setNegativeButton(android.R.string.cancel, null).show()
|
||||||
}
|
}
|
||||||
button(getString(R.string.backup_open_source_licenses)) { navigate("licenses") }
|
button(getString(R.string.backup_open_source_licenses)) { navigate("licenses") }
|
||||||
button(getString(R.string.backup_back)) { navigate("overview") }
|
button(getString(R.string.backup_back)) { back() }
|
||||||
|
}
|
||||||
|
private fun optionStrip(values: List<Int>, selected: Int, label: (Int) -> String, action: (Int) -> Unit) {
|
||||||
|
val row = LinearLayout(this).apply { orientation = LinearLayout.HORIZONTAL }
|
||||||
|
values.forEach { value ->
|
||||||
|
row.addView(WatchDesign.action(this, label(value), value == selected) { action(value) }.apply {
|
||||||
|
isSelected = value == selected
|
||||||
|
if (Build.VERSION.SDK_INT >= 30) stateDescription = if (isSelected) "Selected" else "Not selected"
|
||||||
|
}, LinearLayout.LayoutParams(0, dp(48), 1f).apply { setMargins(dp(2), dp(4), dp(2), dp(8)) })
|
||||||
|
}
|
||||||
|
body.addView(row)
|
||||||
}
|
}
|
||||||
private fun choose(title: String, values: Array<String>, action: (Int) -> Unit) { AlertDialog.Builder(this).setTitle(title).setItems(values) { _, index -> action(index) }.show() }
|
|
||||||
private fun <T> runTask(message: String, task: () -> T, done: (T) -> Unit) {
|
private fun <T> runTask(message: String, task: () -> T, done: (T) -> Unit) {
|
||||||
if (busy) { toast(getString(R.string.backup_an_action_is_already_running)); return }
|
if (busy) { toast(getString(R.string.backup_an_action_is_already_running)); return }
|
||||||
busy = true; progress?.text = message
|
busy = true; progress?.text = message
|
||||||
@@ -450,7 +511,9 @@ class BackupActivity : Activity() {
|
|||||||
private fun toast(message: String) { Toast.makeText(this, message, Toast.LENGTH_LONG).show() }
|
private fun toast(message: String) { Toast.makeText(this, message, Toast.LENGTH_LONG).show() }
|
||||||
private fun back() {
|
private fun back() {
|
||||||
when (page) {
|
when (page) {
|
||||||
"overview" -> finish()
|
"overview", "server", "transfers", "remote", "automatic", "advanced" -> {
|
||||||
|
if (busy) toast(getString(R.string.backup_wait_for_the_current_action_or_cancel_it)) else finish()
|
||||||
|
}
|
||||||
"trust" -> cancelTrust()
|
"trust" -> cancelTrust()
|
||||||
"trust_fingerprint" -> navigate("trust")
|
"trust_fingerprint" -> navigate("trust")
|
||||||
else -> navigate(when (page) { "playback" -> "remote"; "licenses" -> "advanced"; else -> "overview" })
|
else -> navigate(when (page) { "playback" -> "remote"; "licenses" -> "advanced"; else -> "overview" })
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package meghdad.remember
|
||||||
|
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import android.view.accessibility.AccessibilityManager
|
||||||
|
import android.widget.Button
|
||||||
|
|
||||||
|
/** One idle callback per visible menu; never polls or intercepts the content's gestures. */
|
||||||
|
class FloatingMenuController(val button: Button) {
|
||||||
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
private val accessibility = button.context.getSystemService(AccessibilityManager::class.java)
|
||||||
|
private var active = false
|
||||||
|
private var touching = false
|
||||||
|
private val hide = Runnable {
|
||||||
|
if (active && !touching && !keepVisible()) button.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
private val explorationListener = AccessibilityManager.TouchExplorationStateChangeListener {
|
||||||
|
if (active) {
|
||||||
|
if (accessibility.isTouchExplorationEnabled) reveal() else scheduleHide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
init {
|
||||||
|
button.visibility = View.INVISIBLE
|
||||||
|
button.onFocusChangeListener = View.OnFocusChangeListener { _, focused ->
|
||||||
|
if (active) { if (focused) reveal() else scheduleHide() }
|
||||||
|
}
|
||||||
|
accessibility.addTouchExplorationStateChangeListener(explorationListener, handler)
|
||||||
|
}
|
||||||
|
fun resume() {
|
||||||
|
active = true; touching = false
|
||||||
|
if (keepVisible()) reveal() else button.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
fun pause() {
|
||||||
|
active = false; touching = false
|
||||||
|
handler.removeCallbacks(hide)
|
||||||
|
button.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
fun dispose() {
|
||||||
|
pause()
|
||||||
|
button.onFocusChangeListener = null
|
||||||
|
accessibility.removeTouchExplorationStateChangeListener(explorationListener)
|
||||||
|
}
|
||||||
|
/** Called AFTER normal dispatch so a reveal cannot become a menu click in the same gesture. */
|
||||||
|
fun onTouch(action: Int) {
|
||||||
|
if (!active) return
|
||||||
|
when (action) {
|
||||||
|
MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> { touching = true; reveal() }
|
||||||
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { touching = false; interact() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun interact() {
|
||||||
|
if (!active) return
|
||||||
|
reveal(); scheduleHide()
|
||||||
|
}
|
||||||
|
private fun keepVisible() = accessibility.isTouchExplorationEnabled || button.hasFocus()
|
||||||
|
private fun reveal() {
|
||||||
|
handler.removeCallbacks(hide)
|
||||||
|
button.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
private fun scheduleHide() {
|
||||||
|
handler.removeCallbacks(hide)
|
||||||
|
if (active && !touching && !keepVisible()) {
|
||||||
|
val timeout = accessibility.getRecommendedTimeoutMillis(3000, AccessibilityManager.FLAG_CONTENT_CONTROLS)
|
||||||
|
handler.postDelayed(hide, timeout.toLong())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,10 @@ class MainActivity : Activity() {
|
|||||||
private lateinit var scroll: ScrollView
|
private lateinit var scroll: ScrollView
|
||||||
private lateinit var store: Recordings
|
private lateinit var store: Recordings
|
||||||
private var screen = "home"
|
private var screen = "home"
|
||||||
|
private var menuOffset = 0
|
||||||
|
private var foreground = false
|
||||||
|
private var floatingMenu: FloatingMenuController? = null
|
||||||
|
companion object { const val EXTRA_SCREEN = "screen" }
|
||||||
private var clip: Clip? = null
|
private var clip: Clip? = null
|
||||||
private var player: MediaPlayer? = null
|
private var player: MediaPlayer? = null
|
||||||
private var minutes: MinuteCounterView? = null
|
private var minutes: MinuteCounterView? = null
|
||||||
@@ -73,16 +77,40 @@ class MainActivity : Activity() {
|
|||||||
store = Recordings(this)
|
store = Recordings(this)
|
||||||
store.recover()
|
store.recover()
|
||||||
active = RecordingService.activeId != null
|
active = RecordingService.activeId != null
|
||||||
|
if (intent.getStringExtra(EXTRA_SCREEN) == "menu") screen = "menu"
|
||||||
render()
|
render()
|
||||||
}
|
}
|
||||||
|
override fun onNewIntent(intent: Intent) {
|
||||||
|
super.onNewIntent(intent)
|
||||||
|
if (intent.getStringExtra(EXTRA_SCREEN) == "menu") { releasePlayer(); screen = "menu"; render() }
|
||||||
|
}
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
foreground = true; floatingMenu?.resume()
|
||||||
motionAllowed = android.animation.ValueAnimator.areAnimatorsEnabled() && !getSystemService(PowerManager::class.java).isPowerSaveMode
|
motionAllowed = android.animation.ValueAnimator.areAnimatorsEnabled() && !getSystemService(PowerManager::class.java).isPowerSaveMode
|
||||||
minutes?.setFloating(motionAllowed && !RecordingService.paused && minutes?.visibility == View.VISIBLE)
|
minutes?.setFloating(motionAllowed && !RecordingService.paused && minutes?.visibility == View.VISIBLE)
|
||||||
handler.post(ticker)
|
handler.post(ticker)
|
||||||
}
|
}
|
||||||
override fun onPause() { handler.removeCallbacks(ticker); minutes?.setFloating(false); player?.pause(); super.onPause() }
|
override fun onPause() { foreground = false; floatingMenu?.pause(); handler.removeCallbacks(ticker); minutes?.setFloating(false); player?.pause(); super.onPause() }
|
||||||
override fun onDestroy() { releasePlayer(); storageWorker.shutdown(); super.onDestroy() }
|
override fun onDestroy() { floatingMenu?.dispose(); releasePlayer(); storageWorker.shutdown(); super.onDestroy() }
|
||||||
|
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
val handled = super.dispatchTouchEvent(event)
|
||||||
|
floatingMenu?.onTouch(event.actionMasked)
|
||||||
|
return handled
|
||||||
|
}
|
||||||
|
override fun dispatchKeyEvent(event: android.view.KeyEvent): Boolean {
|
||||||
|
val handled = super.dispatchKeyEvent(event)
|
||||||
|
if (event.action == android.view.KeyEvent.ACTION_DOWN && event.keyCode in listOf(
|
||||||
|
android.view.KeyEvent.KEYCODE_DPAD_UP, android.view.KeyEvent.KEYCODE_DPAD_DOWN,
|
||||||
|
android.view.KeyEvent.KEYCODE_DPAD_LEFT, android.view.KeyEvent.KEYCODE_DPAD_RIGHT,
|
||||||
|
android.view.KeyEvent.KEYCODE_DPAD_CENTER, android.view.KeyEvent.KEYCODE_TAB)) floatingMenu?.interact()
|
||||||
|
return handled
|
||||||
|
}
|
||||||
|
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
|
||||||
|
val handled = super.dispatchGenericMotionEvent(event)
|
||||||
|
if (event.action == MotionEvent.ACTION_SCROLL) floatingMenu?.interact()
|
||||||
|
return handled
|
||||||
|
}
|
||||||
private fun dp(value: Int) = (value * resources.displayMetrics.density).roundToInt()
|
private fun dp(value: Int) = (value * resources.displayMetrics.density).roundToInt()
|
||||||
private fun background(color: Int, radius: Float = 28f) = GradientDrawable().apply { setColor(color); cornerRadius = dp(radius.toInt()).toFloat() }
|
private fun background(color: Int, radius: Float = 28f) = GradientDrawable().apply { setColor(color); cornerRadius = dp(radius.toInt()).toFloat() }
|
||||||
private fun text(value: String, size: Float, color: Int = Color.WHITE): TextView {
|
private fun text(value: String, size: Float, color: Int = Color.WHITE): TextView {
|
||||||
@@ -108,6 +136,8 @@ class MainActivity : Activity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun render() {
|
private fun render() {
|
||||||
|
val menuWasVisible = floatingMenu?.button?.visibility == View.VISIBLE
|
||||||
|
floatingMenu?.dispose(); floatingMenu = null
|
||||||
minutes?.setFloating(false)
|
minutes?.setFloating(false)
|
||||||
minutes = null; status = null; pause = null; play = null; seek = null; limitPicker = null
|
minutes = null; status = null; pause = null; play = null; seek = null; limitPicker = null
|
||||||
storageRequest++; storageChart = null; storageAvailable = null; storageApp = null
|
storageRequest++; storageChart = null; storageAvailable = null; storageApp = null
|
||||||
@@ -118,10 +148,17 @@ class MainActivity : Activity() {
|
|||||||
body = LinearLayout(this).apply {
|
body = LinearLayout(this).apply {
|
||||||
orientation = LinearLayout.VERTICAL; gravity = Gravity.CENTER_HORIZONTAL
|
orientation = LinearLayout.VERTICAL; gravity = Gravity.CENTER_HORIZONTAL
|
||||||
val round = resources.configuration.isScreenRound
|
val round = resources.configuration.isScreenRound
|
||||||
setPadding(dp(if (round) 30 else 20), dp(16), dp(if (round) 30 else 20), dp(20))
|
setPadding(dp(if (round) 30 else 28), dp(if (screen == "home") 16 else 14), dp(if (round) 30 else 28), dp(24))
|
||||||
}
|
}
|
||||||
scroll.addView(body)
|
scroll.addView(body)
|
||||||
layers.addView(scroll, FrameLayout.LayoutParams(-1, -1))
|
layers.addView(scroll, FrameLayout.LayoutParams(-1, -1))
|
||||||
|
if (screen != "menu") {
|
||||||
|
val menuButton = WatchDesign.menuDock(this) { releasePlayer(); screen = "menu"; render() }
|
||||||
|
layers.addView(menuButton, FrameLayout.LayoutParams(dp(48), dp(48), Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL))
|
||||||
|
floatingMenu = FloatingMenuController(menuButton).also {
|
||||||
|
if (foreground) { it.resume(); if (menuWasVisible) it.interact() }
|
||||||
|
}
|
||||||
|
}
|
||||||
setContentView(layers)
|
setContentView(layers)
|
||||||
window.decorView.windowInsetsController?.hide(WindowInsets.Type.systemBars())
|
window.decorView.windowInsetsController?.hide(WindowInsets.Type.systemBars())
|
||||||
window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
@@ -158,7 +195,7 @@ class MainActivity : Activity() {
|
|||||||
} else false
|
} else false
|
||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
screen == "settings" -> settings()
|
screen == "menu" -> menu()
|
||||||
screen == "storage" -> storage()
|
screen == "storage" -> storage()
|
||||||
screen == "limits" -> limits()
|
screen == "limits" -> limits()
|
||||||
screen == "limit_minutes" -> limitMinutes()
|
screen == "limit_minutes" -> limitMinutes()
|
||||||
@@ -212,13 +249,6 @@ class MainActivity : Activity() {
|
|||||||
// Saved total has no running seconds; the sweep starts when capture starts.
|
// Saved total has no running seconds; the sweep starts when capture starts.
|
||||||
dial.elapsed = 0
|
dial.elapsed = 0
|
||||||
button("● Record", mint) { startRecording() }.contentDescription = "Start recording"
|
button("● Record", mint) { startRecording() }.contentDescription = "Start recording"
|
||||||
val row = LinearLayout(this).apply { orientation = LinearLayout.HORIZONTAL }
|
|
||||||
val moments = button("Moments · ${clips.size}") { screen = "library"; render() }.apply { textSize = 11f }
|
|
||||||
val settings = button("Settings") { screen = "settings"; render() }.apply { textSize = 11f }
|
|
||||||
body.removeView(moments); body.removeView(settings)
|
|
||||||
row.addView(moments, LinearLayout.LayoutParams(0, dp(44), 1f).apply { marginEnd = dp(3) })
|
|
||||||
row.addView(settings, LinearLayout.LayoutParams(dp(64), dp(44)).apply { marginStart = dp(3) })
|
|
||||||
body.addView(row, LinearLayout.LayoutParams(-1, dp(44)).apply { topMargin = dp(3) })
|
|
||||||
}
|
}
|
||||||
private fun recording() {
|
private fun recording() {
|
||||||
status = text(if (RecordingService.paused) "PAUSED" else "● RECORDING", 10f, mint)
|
status = text(if (RecordingService.paused) "PAUSED" else "● RECORDING", 10f, mint)
|
||||||
@@ -235,20 +265,60 @@ class MainActivity : Activity() {
|
|||||||
row.addView(mark, LinearLayout.LayoutParams(0, dp(44), 1f).apply { marginStart = dp(3) })
|
row.addView(mark, LinearLayout.LayoutParams(0, dp(44), 1f).apply { marginStart = dp(3) })
|
||||||
body.addView(row)
|
body.addView(row)
|
||||||
button("■ Save", mint) { command(RecordingService.SAVE) }
|
button("■ Save", mint) { command(RecordingService.SAVE) }
|
||||||
button("Settings") { screen = "settings"; render() }
|
|
||||||
}
|
}
|
||||||
private fun settings() {
|
private fun menu() {
|
||||||
updateDial(0)
|
updateDial(0)
|
||||||
text("SETTINGS", 10f, mint)
|
text("REMEMBER", 9f, mint).apply { letterSpacing = .16f }
|
||||||
text("Make it yours.", 17f)
|
text(getString(R.string.menu), 18f)
|
||||||
button("Storage") { screen = "storage"; render() }.apply { layoutParams.height = dp(56) }
|
data class Destination(val label: String, val icon: WatchIcon, val target: String, val backup: Boolean = false)
|
||||||
button("Recording limit") { screen = "limits"; render() }.apply { layoutParams.height = dp(56) }
|
val destinations = listOf(
|
||||||
button("Backup") { startActivity(Intent(this, BackupActivity::class.java)) }.apply { layoutParams.height = dp(56) }
|
Destination(getString(R.string.recorder), WatchIcon.RECORD, "home"),
|
||||||
|
Destination(getString(R.string.moments), WatchIcon.MOMENTS, "library"),
|
||||||
|
Destination(getString(R.string.storage), WatchIcon.STORAGE, "storage"),
|
||||||
|
Destination(getString(R.string.recording_limit), WatchIcon.LIMIT, "limits"),
|
||||||
|
Destination(getString(R.string.backup_backup), WatchIcon.BACKUP, "overview", true),
|
||||||
|
Destination(getString(R.string.backup_server), WatchIcon.SERVER, "server", true),
|
||||||
|
Destination(getString(R.string.backup_transfers), WatchIcon.TRANSFERS, "transfers", true),
|
||||||
|
Destination(getString(R.string.backup_server_recordings), WatchIcon.REMOTE, "remote", true),
|
||||||
|
Destination(getString(R.string.backup_automatic_backup), WatchIcon.AUTOMATIC, "automatic", true),
|
||||||
|
Destination(getString(R.string.backup_advanced), WatchIcon.ADVANCED, "advanced", true)
|
||||||
|
)
|
||||||
|
destinations.chunked(3).forEach { pair ->
|
||||||
|
val row = LinearLayout(this).apply { orientation = LinearLayout.HORIZONTAL }
|
||||||
|
pair.forEach { destination ->
|
||||||
|
val tile = WatchDesign.action(this, destination.label) {
|
||||||
|
menuOffset = scroll.scrollY
|
||||||
|
if (destination.backup) startActivity(Intent(this, BackupActivity::class.java).putExtra(BackupActivity.EXTRA_PAGE, destination.target))
|
||||||
|
else { screen = destination.target; render() }
|
||||||
|
}.apply {
|
||||||
|
background = WatchDesign.touch(this@MainActivity, Color.TRANSPARENT, 16)
|
||||||
|
textSize = 9f; gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
||||||
|
setPadding(dp(3), dp(4), dp(3), 0); maxLines = 2
|
||||||
|
val colors = when (destination.icon) {
|
||||||
|
WatchIcon.MOMENTS, WatchIcon.REMOTE -> Color.rgb(143, 204, 217)
|
||||||
|
WatchIcon.SERVER, WatchIcon.ADVANCED -> Color.rgb(197, 190, 234)
|
||||||
|
else -> mint
|
||||||
|
}
|
||||||
|
val icon = WatchGlyph(destination.icon, colors, true).apply { setBounds(0, 0, dp(44), dp(44)) }
|
||||||
|
setCompoundDrawables(null, icon, null, null); compoundDrawablePadding = dp(4)
|
||||||
|
contentDescription = destination.label
|
||||||
|
}
|
||||||
|
row.addView(tile, LinearLayout.LayoutParams(0, dp(84), 1f))
|
||||||
|
}
|
||||||
|
repeat(3 - pair.size) { row.addView(Space(this), LinearLayout.LayoutParams(0, dp(84), 1f)) }
|
||||||
|
body.addView(row, LinearLayout.LayoutParams(-1, -2))
|
||||||
|
}
|
||||||
button(if (active) "Back to recording" else "Back") { screen = "home"; render() }
|
button(if (active) "Back to recording" else "Back") { screen = "home"; render() }
|
||||||
|
scroll.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
override fun onGlobalLayout() {
|
||||||
|
scroll.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
|
scroll.scrollTo(0, menuOffset)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
private fun storage() {
|
private fun storage() {
|
||||||
updateDial(0)
|
updateDial(0)
|
||||||
body.setPadding(dp(12), dp(8), dp(12), dp(20))
|
body.setPadding(dp(12), dp(8), dp(12), dp(24))
|
||||||
text("STORAGE", 10f, mint)
|
text("STORAGE", 10f, mint)
|
||||||
storageChart = StorageChartView(this).also {
|
storageChart = StorageChartView(this).also {
|
||||||
// Center a large chart in the initial viewport; details and actions follow below it.
|
// Center a large chart in the initial viewport; details and actions follow below it.
|
||||||
@@ -258,7 +328,7 @@ class MainActivity : Activity() {
|
|||||||
storageAvailable = text("● Available · …", 11f, mint)
|
storageAvailable = text("● Available · …", 11f, mint)
|
||||||
storageApp = text("● Remember · …", 11f)
|
storageApp = text("● Remember · …", 11f)
|
||||||
button("Refresh") { loadStorage() }
|
button("Refresh") { loadStorage() }
|
||||||
button("Back") { screen = "settings"; render() }
|
button("Back") { screen = "menu"; render() }
|
||||||
loadStorage()
|
loadStorage()
|
||||||
}
|
}
|
||||||
private fun loadStorage() {
|
private fun loadStorage() {
|
||||||
@@ -286,30 +356,30 @@ class MainActivity : Activity() {
|
|||||||
private fun limits() {
|
private fun limits() {
|
||||||
updateDial(0)
|
updateDial(0)
|
||||||
val limit = preferences.read()
|
val limit = preferences.read()
|
||||||
text("RECORDING LIMIT", 10f, mint)
|
WatchDesign.heading(body, getString(R.string.your_pace), getString(R.string.recording_limit))
|
||||||
val toggle = Switch(this).apply {
|
val face = StatusDialView(this).apply {
|
||||||
|
update(if (limit.enabled) limit.minutes.toString() else "∞", if (limit.enabled) "minutes / clip" else "unlimited", if (limit.enabled) 1f else 0f)
|
||||||
|
}
|
||||||
|
body.addView(face, LinearLayout.LayoutParams(-1, dp(116)))
|
||||||
|
Switch(this).apply {
|
||||||
text = "Minute limit"; textSize = 12f; setTextColor(Color.WHITE)
|
text = "Minute limit"; textSize = 12f; setTextColor(Color.WHITE)
|
||||||
isChecked = limit.enabled
|
isChecked = limit.enabled
|
||||||
thumbTintList = android.content.res.ColorStateList(
|
thumbTintList = WatchDesign.switchTint()
|
||||||
arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()),
|
background = WatchDesign.shape(this@MainActivity)
|
||||||
intArrayOf(mint, Color.rgb(116, 129, 96))
|
setPadding(dp(12), 0, dp(12), 0)
|
||||||
)
|
body.addView(this, LinearLayout.LayoutParams(-1, dp(48)))
|
||||||
setPadding(dp(5), 0, dp(5), 0)
|
|
||||||
body.addView(this, LinearLayout.LayoutParams(-1, dp(44)))
|
|
||||||
setOnCheckedChangeListener { _, checked -> preferences.write(preferences.read().copy(enabled = checked)); render() }
|
setOnCheckedChangeListener { _, checked -> preferences.write(preferences.read().copy(enabled = checked)); render() }
|
||||||
}
|
}
|
||||||
text(if (toggle.isChecked) "Enabled" else "Unlimited recording", 10f, muted)
|
|
||||||
button("Length · ${limit.minutes} min") { screen = "limit_minutes"; render() }
|
button("Length · ${limit.minutes} min") { screen = "limit_minutes"; render() }
|
||||||
button("At the limit\n${if (limit.action == LimitAction.STOP) "Save & stop" else "Save & start next"}") {
|
WatchDesign.card(body, "At the limit", if (limit.action == LimitAction.STOP) "Save & stop" else "Save & start next", WatchIcon.LIMIT) {
|
||||||
screen = "limit_action"; render()
|
screen = "limit_action"; render()
|
||||||
}.apply { layoutParams.height = dp(54); textSize = 11f }
|
}
|
||||||
text("Applies to your next recording session.\nPaused time doesn't count.", 10f, muted)
|
text("Applies to your next session.\nPaused time doesn't count.", 10f, muted)
|
||||||
button("Back") { screen = "settings"; render() }
|
button("Back") { screen = "menu"; render() }
|
||||||
}
|
}
|
||||||
private fun limitMinutes() {
|
private fun limitMinutes() {
|
||||||
updateDial(0)
|
updateDial(0)
|
||||||
text("CLIP LENGTH", 10f, mint)
|
WatchDesign.heading(body, "Minutes", "Clip length")
|
||||||
text("Minutes", 13f)
|
|
||||||
limitPicker = NumberPicker(this).apply {
|
limitPicker = NumberPicker(this).apply {
|
||||||
minValue = 1; maxValue = 1440; value = preferences.read().minutes; wrapSelectorWheel = false
|
minValue = 1; maxValue = 1440; value = preferences.read().minutes; wrapSelectorWheel = false
|
||||||
contentDescription = "Recording limit in minutes"
|
contentDescription = "Recording limit in minutes"
|
||||||
@@ -325,7 +395,7 @@ class MainActivity : Activity() {
|
|||||||
}
|
}
|
||||||
private fun limitAction() {
|
private fun limitAction() {
|
||||||
updateDial(0)
|
updateDial(0)
|
||||||
text("AT THE LIMIT", 10f, mint)
|
WatchDesign.heading(body, "At the limit", "Recording limit")
|
||||||
val action = preferences.read().action
|
val action = preferences.read().action
|
||||||
button("${if (action == LimitAction.STOP) "✓ " else ""}Save & stop", if (action == LimitAction.STOP) mint else Color.rgb(43, 52, 32)) {
|
button("${if (action == LimitAction.STOP) "✓ " else ""}Save & stop", if (action == LimitAction.STOP) mint else Color.rgb(43, 52, 32)) {
|
||||||
preferences.write(preferences.read().copy(action = LimitAction.STOP)); render()
|
preferences.write(preferences.read().copy(action = LimitAction.STOP)); render()
|
||||||
@@ -338,7 +408,7 @@ class MainActivity : Activity() {
|
|||||||
}
|
}
|
||||||
private fun library() {
|
private fun library() {
|
||||||
updateDial(0)
|
updateDial(0)
|
||||||
text("YOUR MOMENTS", 10f, mint)
|
WatchDesign.heading(body, getString(R.string.moments), getString(R.string.on_your_wrist))
|
||||||
val clips = store.list()
|
val clips = store.list()
|
||||||
if (clips.isEmpty()) {
|
if (clips.isEmpty()) {
|
||||||
text("A little space\nfor big ideas.", 20f)
|
text("A little space\nfor big ideas.", 20f)
|
||||||
@@ -347,16 +417,13 @@ class MainActivity : Activity() {
|
|||||||
} else {
|
} else {
|
||||||
text("${clips.size} saved", 12f, muted)
|
text("${clips.size} saved", 12f, muted)
|
||||||
clips.forEach { item ->
|
clips.forEach { item ->
|
||||||
button("${item.title}\n${SimpleDateFormat("MMM d", Locale.getDefault()).format(Date(item.created))} · ${timeLabel(item.duration)}") {
|
WatchDesign.card(body, item.title,
|
||||||
|
"${SimpleDateFormat("MMM d", Locale.getDefault()).format(Date(item.created))} · ${timeLabel(item.duration)}", WatchIcon.PLAY) {
|
||||||
clip = item; screen = "detail"; render()
|
clip = item; screen = "detail"; render()
|
||||||
}.apply {
|
|
||||||
textSize = 11f
|
|
||||||
layoutParams.height = dp(54)
|
|
||||||
maxLines = 2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
button("Back") { screen = "home"; render() }
|
button("Back") { screen = "menu"; render() }
|
||||||
}
|
}
|
||||||
private fun detail() {
|
private fun detail() {
|
||||||
val item = clip ?: run { screen = "library"; render(); return }
|
val item = clip ?: run { screen = "library"; render(); return }
|
||||||
@@ -454,7 +521,7 @@ class MainActivity : Activity() {
|
|||||||
releasePlayer()
|
releasePlayer()
|
||||||
screen = when (screen) {
|
screen = when (screen) {
|
||||||
"detail" -> "library"
|
"detail" -> "library"
|
||||||
"storage", "limits" -> "settings"
|
"storage", "limits", "library" -> "menu"
|
||||||
"limit_minutes", "limit_action" -> "limits"
|
"limit_minutes", "limit_action" -> "limits"
|
||||||
else -> "home"
|
else -> "home"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
package meghdad.remember
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.*
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.graphics.drawable.GradientDrawable
|
||||||
|
import android.graphics.drawable.RippleDrawable
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.view.HapticFeedbackConstants
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.*
|
||||||
|
import kotlin.math.*
|
||||||
|
|
||||||
|
/** Shared watch controls: native focus and spoken labels, with original vector artwork. */
|
||||||
|
object WatchDesign {
|
||||||
|
val ink = Color.rgb(13, 17, 11)
|
||||||
|
val lime = Color.rgb(199, 234, 24)
|
||||||
|
val muted = Color.rgb(164, 175, 143)
|
||||||
|
val surface = Color.rgb(30, 39, 25)
|
||||||
|
fun dp(context: Context, value: Int) = (context.resources.displayMetrics.density * value).roundToInt()
|
||||||
|
fun switchTint() = ColorStateList(arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()), intArrayOf(lime, muted))
|
||||||
|
fun shape(context: Context, color: Int = surface, radius: Int = 22, stroke: Int? = null) = GradientDrawable().apply {
|
||||||
|
setColor(color); cornerRadius = dp(context, radius).toFloat()
|
||||||
|
stroke?.let { setStroke(dp(context, 1), it) }
|
||||||
|
}
|
||||||
|
fun touch(context: Context, color: Int = surface, radius: Int = 22) = RippleDrawable(
|
||||||
|
ColorStateList.valueOf(Color.argb(60, 199, 234, 24)), shape(context, color, radius), shape(context, Color.WHITE, radius))
|
||||||
|
fun label(context: Context, value: String, size: Float = 12f, color: Int = Color.WHITE) = TextView(context).apply {
|
||||||
|
text = value; textSize = size; setTextColor(color); gravity = Gravity.CENTER
|
||||||
|
includeFontPadding = false
|
||||||
|
layoutParams = LinearLayout.LayoutParams(-1, -2)
|
||||||
|
}
|
||||||
|
fun heading(body: LinearLayout, title: String, eyebrow: String) {
|
||||||
|
body.addView(label(body.context, eyebrow.uppercase(), 9f, lime).apply { letterSpacing = .16f })
|
||||||
|
body.addView(label(body.context, title, 21f).apply {
|
||||||
|
typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
|
||||||
|
setPadding(0, dp(context, 4), 0, dp(context, 8))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fun action(context: Context, label: String, primary: Boolean = false, action: () -> Unit) = Button(context).apply {
|
||||||
|
text = label; textSize = 12f; isAllCaps = false; setTextColor(if (primary) ink else Color.WHITE)
|
||||||
|
background = touch(context, if (primary) lime else surface)
|
||||||
|
minHeight = 0; minimumHeight = 0; stateListAnimator = null
|
||||||
|
setPadding(dp(context, 8), 0, dp(context, 8), 0)
|
||||||
|
layoutParams = LinearLayout.LayoutParams(-1, dp(context, 48)).apply { setMargins(0, dp(context, 4), 0, dp(context, 4)) }
|
||||||
|
setOnClickListener { performHapticFeedback(HapticFeedbackConstants.CONFIRM); action() }
|
||||||
|
}
|
||||||
|
fun pair(body: LinearLayout, first: Button, second: Button) {
|
||||||
|
val row = LinearLayout(body.context).apply { orientation = LinearLayout.HORIZONTAL }
|
||||||
|
row.addView(first, LinearLayout.LayoutParams(0, dp(body.context, 48), 1f).apply { marginEnd = dp(body.context, 3) })
|
||||||
|
row.addView(second, LinearLayout.LayoutParams(0, dp(body.context, 48), 1f).apply { marginStart = dp(body.context, 3) })
|
||||||
|
body.addView(row, LinearLayout.LayoutParams(-1, -2).apply { topMargin = dp(body.context, 6); bottomMargin = dp(body.context, 6) })
|
||||||
|
}
|
||||||
|
fun card(body: LinearLayout, title: String, subtitle: String, icon: WatchIcon, action: (() -> Unit)? = null): TextView {
|
||||||
|
val context = body.context
|
||||||
|
val row = LinearLayout(context).apply {
|
||||||
|
orientation = LinearLayout.HORIZONTAL; gravity = Gravity.CENTER_VERTICAL
|
||||||
|
background = touch(context); setPadding(dp(context, 12), dp(context, 12), dp(context, 10), dp(context, 12))
|
||||||
|
minimumHeight = dp(context, 60)
|
||||||
|
}
|
||||||
|
val image = ImageView(context).apply { setImageDrawable(WatchGlyph(icon, lime)); importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO }
|
||||||
|
row.addView(image, LinearLayout.LayoutParams(dp(context, 24), dp(context, 24)).apply { marginEnd = dp(context, 10) })
|
||||||
|
val copy = LinearLayout(context).apply { orientation = LinearLayout.VERTICAL }
|
||||||
|
copy.addView(label(context, title, 13f).apply { gravity = Gravity.START; maxLines = 2; ellipsize = android.text.TextUtils.TruncateAt.END })
|
||||||
|
val detail = label(context, subtitle, 10f, muted).apply { gravity = Gravity.START; setPadding(0, dp(context, 4), 0, 0) }
|
||||||
|
copy.addView(detail); row.addView(copy, LinearLayout.LayoutParams(0, -2, 1f))
|
||||||
|
if (action != null) {
|
||||||
|
row.contentDescription = "$title. $subtitle"
|
||||||
|
image.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
||||||
|
copy.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
||||||
|
row.isFocusable = true; row.setOnClickListener { row.performHapticFeedback(HapticFeedbackConstants.CONFIRM); action() }
|
||||||
|
row.accessibilityDelegate = object : View.AccessibilityDelegate() {
|
||||||
|
override fun onInitializeAccessibilityNodeInfo(host: View, info: android.view.accessibility.AccessibilityNodeInfo) {
|
||||||
|
super.onInitializeAccessibilityNodeInfo(host, info); info.className = Button::class.java.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body.addView(row, LinearLayout.LayoutParams(-1, -2).apply { topMargin = dp(context, 4); bottomMargin = dp(context, 4) })
|
||||||
|
return detail
|
||||||
|
}
|
||||||
|
fun menuDock(context: Context, action: () -> Unit) = action(context, "", false, action).apply {
|
||||||
|
background = touch(context, Color.TRANSPARENT, 24)
|
||||||
|
setPadding(dp(context, 10), dp(context, 10), dp(context, 10), dp(context, 10))
|
||||||
|
val icon = WatchGlyph(WatchIcon.MENU, lime).apply { setBounds(0, 0, dp(context, 28), dp(context, 28)) }
|
||||||
|
setCompoundDrawables(icon, null, null, null); compoundDrawablePadding = 0
|
||||||
|
contentDescription = context.getString(R.string.open_menu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class WatchIcon { RECORD, MOMENTS, STORAGE, LIMIT, BACKUP, SERVER, TRANSFERS, REMOTE, AUTOMATIC, ADVANCED, MENU, PLAY }
|
||||||
|
|
||||||
|
/** Each destination has an identifiable silhouette, without fonts or bitmap assets. */
|
||||||
|
class WatchGlyph(private val icon: WatchIcon, private val tint: Int, private val orb: Boolean = false) : Drawable() {
|
||||||
|
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
override fun draw(canvas: Canvas) {
|
||||||
|
canvas.save(); canvas.translate(bounds.left.toFloat(), bounds.top.toFloat()); canvas.scale(bounds.width() / 48f, bounds.height() / 48f)
|
||||||
|
if (orb) {
|
||||||
|
paint.style = Paint.Style.FILL
|
||||||
|
paint.shader = LinearGradient(5f, 3f, 40f, 48f, Color.rgb(47, 61, 34), Color.rgb(21, 29, 17), Shader.TileMode.CLAMP)
|
||||||
|
canvas.drawCircle(24f, 24f, 23f, paint); paint.shader = null
|
||||||
|
paint.color = Color.argb(90, Color.red(tint), Color.green(tint), Color.blue(tint)); paint.style = Paint.Style.STROKE; paint.strokeWidth = .7f
|
||||||
|
canvas.drawArc(RectF(1f, 1f, 47f, 47f), 210f, 130f, false, paint)
|
||||||
|
canvas.translate(9f, 9f); canvas.scale(.625f, .625f)
|
||||||
|
}
|
||||||
|
paint.color = tint; paint.style = Paint.Style.STROKE; paint.strokeWidth = 2.5f; paint.strokeCap = Paint.Cap.ROUND; paint.strokeJoin = Paint.Join.ROUND
|
||||||
|
fun line(x: Float, y: Float, xx: Float, yy: Float) = canvas.drawLine(x, y, xx, yy, paint)
|
||||||
|
fun box(x: Float, y: Float, xx: Float, yy: Float, r: Float = 4f) = canvas.drawRoundRect(RectF(x, y, xx, yy), r, r, paint)
|
||||||
|
fun arrow() { line(24f, 33f, 24f, 15f); line(18f, 21f, 24f, 15f); line(24f, 15f, 30f, 21f) }
|
||||||
|
when (icon) {
|
||||||
|
WatchIcon.RECORD -> { box(18f, 7f, 30f, 29f, 6f); canvas.drawArc(RectF(12f, 15f, 36f, 36f), 0f, 180f, false, paint); line(24f, 36f, 24f, 42f); line(18f, 42f, 30f, 42f) }
|
||||||
|
WatchIcon.MOMENTS -> { line(10f, 20f, 10f, 28f); line(17f, 12f, 17f, 36f); line(24f, 6f, 24f, 42f); line(31f, 15f, 31f, 33f); line(38f, 20f, 38f, 28f) }
|
||||||
|
WatchIcon.STORAGE -> { canvas.drawCircle(24f, 24f, 16f, paint); paint.strokeWidth = 6f; canvas.drawArc(RectF(8f, 8f, 40f, 40f), -90f, 235f, false, paint); paint.style = Paint.Style.FILL; canvas.drawCircle(24f, 24f, 3f, paint) }
|
||||||
|
WatchIcon.LIMIT -> { canvas.drawCircle(24f, 26f, 16f, paint); line(24f, 26f, 24f, 16f); line(24f, 26f, 31f, 30f); line(20f, 5f, 28f, 5f); line(24f, 5f, 24f, 10f) }
|
||||||
|
WatchIcon.BACKUP, WatchIcon.REMOTE -> {
|
||||||
|
val path = Path().apply { moveTo(12f, 35f); cubicTo(-1f, 31f, 5f, 15f, 15f, 18f); cubicTo(17f, 3f, 37f, 5f, 37f, 20f); cubicTo(48f, 20f, 48f, 35f, 37f, 35f) }
|
||||||
|
canvas.drawPath(path, paint)
|
||||||
|
if (icon == WatchIcon.BACKUP) arrow() else { val play = Path().apply { moveTo(21f, 24f); lineTo(29f, 29f); lineTo(21f, 34f); close() }; canvas.drawPath(play, paint) }
|
||||||
|
}
|
||||||
|
WatchIcon.SERVER -> { box(8f, 7f, 40f, 22f); box(8f, 27f, 40f, 42f); line(14f, 14f, 15f, 14f); line(14f, 34f, 15f, 34f); line(27f, 14f, 34f, 14f); line(27f, 34f, 34f, 34f) }
|
||||||
|
WatchIcon.TRANSFERS -> { line(15f, 37f, 15f, 10f); line(9f, 16f, 15f, 10f); line(15f, 10f, 21f, 16f); line(33f, 11f, 33f, 38f); line(27f, 32f, 33f, 38f); line(33f, 38f, 39f, 32f) }
|
||||||
|
WatchIcon.AUTOMATIC -> { canvas.drawArc(RectF(7f, 7f, 41f, 41f), -60f, 290f, false, paint); line(35f, 5f, 40f, 12f); line(40f, 12f, 31f, 13f); line(24f, 14f, 24f, 24f); line(24f, 24f, 31f, 29f) }
|
||||||
|
WatchIcon.ADVANCED -> { for (i in 0..2) { val y = 12f + i * 12; line(7f, y, 41f, y); box(if (i == 1) 26f else 12f, y - 4, if (i == 1) 32f else 18f, y + 4, 2f) } }
|
||||||
|
WatchIcon.MENU -> { paint.style = Paint.Style.FILL; for (x in listOf(15f, 33f)) for (y in listOf(15f, 33f)) canvas.drawCircle(x, y, 5f, paint) }
|
||||||
|
WatchIcon.PLAY -> { val path = Path().apply { moveTo(17f, 9f); lineTo(38f, 24f); lineTo(17f, 39f); close() }; canvas.drawPath(path, paint) }
|
||||||
|
}
|
||||||
|
canvas.restore()
|
||||||
|
}
|
||||||
|
override fun setAlpha(alpha: Int) { paint.alpha = alpha; invalidateSelf() }
|
||||||
|
override fun setColorFilter(colorFilter: ColorFilter?) { paint.colorFilter = colorFilter; invalidateSelf() }
|
||||||
|
@Deprecated("Drawable opacity") override fun getOpacity() = PixelFormat.TRANSLUCENT
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A quiet, static dial: progress for backups, or tick marks for a configured duration. */
|
||||||
|
class StatusDialView(context: Context) : View(context) {
|
||||||
|
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
private var value = "0"
|
||||||
|
private var caption = ""
|
||||||
|
private var fraction = 0f
|
||||||
|
private val ring = RectF()
|
||||||
|
fun update(number: String, label: String, progress: Float) {
|
||||||
|
value = number; caption = label; fraction = progress.coerceIn(0f, 1f)
|
||||||
|
contentDescription = "$number $label"; invalidate()
|
||||||
|
}
|
||||||
|
override fun onDraw(canvas: Canvas) {
|
||||||
|
val size = min(width, height).toFloat(); val cx = width / 2f; val cy = height / 2f; val r = size * .42f
|
||||||
|
paint.style = Paint.Style.STROKE; paint.strokeWidth = size * .035f; paint.strokeCap = Paint.Cap.ROUND; paint.color = WatchDesign.surface
|
||||||
|
ring.set(cx - r, cy - r, cx + r, cy + r)
|
||||||
|
canvas.drawArc(ring, 135f, 270f, false, paint)
|
||||||
|
paint.color = WatchDesign.lime
|
||||||
|
if (fraction > 0) canvas.drawArc(ring, 135f, 270f * fraction, false, paint)
|
||||||
|
paint.strokeWidth = size * .008f
|
||||||
|
for (i in 0..24) {
|
||||||
|
val angle = Math.toRadians(135.0 + i * 270.0 / 24)
|
||||||
|
val outer = r - size * .05f; val inner = outer - if (i % 6 == 0) size * .05f else size * .024f
|
||||||
|
paint.color = if (i / 24f <= fraction && fraction > 0) WatchDesign.lime else Color.rgb(67, 80, 54)
|
||||||
|
canvas.drawLine(cx + cos(angle).toFloat() * inner, cy + sin(angle).toFloat() * inner, cx + cos(angle).toFloat() * outer, cy + sin(angle).toFloat() * outer, paint)
|
||||||
|
}
|
||||||
|
paint.style = Paint.Style.FILL; paint.color = Color.WHITE; paint.textAlign = Paint.Align.CENTER
|
||||||
|
paint.typeface = Typeface.create("sans-serif-condensed", Typeface.BOLD)
|
||||||
|
paint.textSize = size * if (value.length > 3) .26f else .36f
|
||||||
|
canvas.drawText(value, cx, cy + size * .09f, paint)
|
||||||
|
paint.color = WatchDesign.muted; paint.typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL); paint.textSize = size * .075f
|
||||||
|
val displayCaption = caption.uppercase()
|
||||||
|
val captionWidth = paint.measureText(displayCaption)
|
||||||
|
if (captionWidth > size * .68f) paint.textSize *= size * .68f / captionWidth
|
||||||
|
canvas.drawText(displayCaption, cx, cy + size * .23f, paint)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,27 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
<string name="menu">Menu</string>
|
||||||
|
<string name="open_menu">Open all sections</string>
|
||||||
|
<string name="recorder">Recorder</string>
|
||||||
|
<string name="moments">Moments</string>
|
||||||
|
<string name="storage">Storage</string>
|
||||||
|
<string name="recording_limit">Recording limit</string>
|
||||||
|
<string name="autopilot">Autopilot</string>
|
||||||
|
<string name="on_your_server">On your server</string>
|
||||||
|
<string name="fine_tune">Fine tune</string>
|
||||||
|
<string name="your_pace">Your pace</string>
|
||||||
|
<string name="on_your_wrist">On your wrist</string>
|
||||||
|
<string name="retry_attempts">RETRY ATTEMPTS</string>
|
||||||
|
<string name="connection_timeout">CONNECTION TIMEOUT</string>
|
||||||
|
<string name="on_this_watch">ON THIS WATCH</string>
|
||||||
|
<string name="check_interval">CHECK INTERVAL</string>
|
||||||
|
<string name="pause_all">Pause all</string>
|
||||||
|
<string name="backup_waiting_count">%1$d waiting on your wrist</string>
|
||||||
|
<string name="backup_last">Last backup</string>
|
||||||
|
<string name="backup_destination">Destination</string>
|
||||||
|
<string name="backup_no_destination">Choose Server in the menu</string>
|
||||||
|
<string name="backup_none_completed">No completed backup yet</string>
|
||||||
|
<string name="backup_automatic_on">Automatic backups are on</string>
|
||||||
|
<string name="backup_automatic_off">Automatic backups are off</string>
|
||||||
<string name="app_name">Remember</string>
|
<string name="app_name">Remember</string>
|
||||||
<string name="backup_download_progress">Downloading · %1$d%%</string>
|
<string name="backup_download_progress">Downloading · %1$d%%</string>
|
||||||
<string name="backup_address">Address</string>
|
<string name="backup_address">Address</string>
|
||||||
|
|||||||
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -12,8 +12,8 @@ Remember needs an existing SSH server with SFTP enabled. No database or custom a
|
|||||||
ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key.pub -E sha256
|
ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key.pub -E sha256
|
||||||
```
|
```
|
||||||
|
|
||||||
Compare the `SHA256:...` value with the watch's read-only display if desired. Subsequent fingerprint mismatches block authentication and transfers. For a legitimate server-key change, verify it first, then use **Backup → Advanced → Server identity → Forget trust** and approve the new identity. Forgetting trust pauses backups and turns automatic backup off.
|
Compare the `SHA256:...` value with the watch's read-only display if desired. Subsequent fingerprint mismatches block authentication and transfers. For a legitimate server-key change, verify it first, then use **Menu → Advanced → Server identity → Forget trust** and approve the new identity. Forgetting trust pauses backups and turns automatic backup off.
|
||||||
4. In Remember, open **Settings → Backup → Server**, then **Create watch key**. Export or copy the public key and add its single line to the dedicated account's `~/.ssh/authorized_keys`. Keep normal OpenSSH ownership and permissions: the account owns `.ssh` and its files, `.ssh` is mode 700, and `authorized_keys` is mode 600.
|
4. In Remember, open **Menu → Server**, then **Create watch key**. Export or copy the public key and add its single line to the dedicated account's `~/.ssh/authorized_keys`. Keep normal OpenSSH ownership and permissions: the account owns `.ssh` and its files, `.ssh` is mode 700, and `authorized_keys` is mode 600.
|
||||||
5. Restrict the account to SFTP and its intended storage area using your server's supported configuration. For OpenSSH, a dedicated-user `Match` block can disable shell use and forwarding:
|
5. Restrict the account to SFTP and its intended storage area using your server's supported configuration. For OpenSSH, a dedicated-user `Match` block can disable shell use and forwarding:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|||||||
|
After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 36 KiB |