Hey Dumby is now the one app: the wake-word listener (with the
pre-roll + double-check trick from Hey Claude, so a stray word
doesn't trigger it) branches into three things depending on what
it hears.
- The full phrase ("hey dummy take a note" by default) drops
straight into dictation, unchanged from before.
- The bare phrase alone ("hey dummy"/"hey dumby"/"okay dummy")
beeps and listens for one command: open an app, call, text,
directions, or falls through to the Claude app. This is Hey
Claude's CommandRouter/AppMatcher/ContactMatcher/Comms, ported
over basically unchanged (package renamed, Hey Claude branding
swapped for Hey Dumby).
- Driving mode (DrivingMode.kt, new): speaks command results out
loud with TextToSpeech instead of only showing them. Can be
switched on by voice ("hey dummy, driving mode on") or, if
Bluetooth permission is granted, auto-arms when the phone
connects to something that reports itself as an audio/video
Bluetooth device (the closest thing Android has to "this is a
car"), and disarms on disconnect.
Kept Hey Dumby's bundled-in-the-apk speech model (ModelFiles) over
Hey Claude's download-on-first-run one, so the no-network claim on
the landing page stays true and the INTERNET permission goes away.
Still TODO, not done in this pass:
- Settings screen doesn't expose the new toggles yet (driving
mode, auto-arm, call/text direct, aliases, strict wake). They
all have working Prefs getters/setters, just no UI.
Quick Settings tile and the Claude-app fallback aren't wired
into a Settings toggle either, though they work.
- Not build-tested. No Android SDK in this workspace to compile
against; needs a real build on Elessar before it installs.
78 lines
2.5 KiB
Kotlin
78 lines
2.5 KiB
Kotlin
package space.bloggin.scribe
|
|
|
|
import android.app.Activity
|
|
import android.app.KeyguardManager
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.os.Build
|
|
import android.os.Bundle
|
|
import android.widget.Toast
|
|
|
|
/**
|
|
* Invisible go-between. The listening service can't open apps directly from the background,
|
|
* so it opens this, which wakes the screen, asks you to unlock if needed, opens the target
|
|
* and disappears. Also used by the Quick Settings tile to start listening.
|
|
*/
|
|
class LaunchActivity : Activity() {
|
|
|
|
companion object {
|
|
private const val EXTRA_TARGET = "target"
|
|
const val ACTION_START_LISTENING = "space.bloggin.scribe.START_LISTENING"
|
|
|
|
fun go(ctx: Context, target: Intent) {
|
|
val i = Intent(ctx, LaunchActivity::class.java)
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION)
|
|
.putExtra(EXTRA_TARGET, target)
|
|
try {
|
|
ctx.startActivity(i)
|
|
} catch (e: Exception) {
|
|
EventLog.add("Couldn't open: ${e.message}")
|
|
}
|
|
}
|
|
}
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setShowWhenLocked(true)
|
|
setTurnScreenOn(true)
|
|
|
|
if (intent?.action == ACTION_START_LISTENING) {
|
|
ListenService.start(this)
|
|
finish()
|
|
return
|
|
}
|
|
|
|
val target: Intent? = if (Build.VERSION.SDK_INT >= 33) {
|
|
intent?.getParcelableExtra(EXTRA_TARGET, Intent::class.java)
|
|
} else {
|
|
@Suppress("DEPRECATION")
|
|
intent?.getParcelableExtra(EXTRA_TARGET)
|
|
}
|
|
if (target == null) {
|
|
finish()
|
|
return
|
|
}
|
|
|
|
val km = getSystemService(KeyguardManager::class.java)
|
|
if (km != null && km.isKeyguardLocked) {
|
|
km.requestDismissKeyguard(this, object : KeyguardManager.KeyguardDismissCallback() {
|
|
override fun onDismissSucceeded() = open(target)
|
|
override fun onDismissCancelled() = finish()
|
|
override fun onDismissError() = finish()
|
|
})
|
|
} else {
|
|
open(target)
|
|
}
|
|
}
|
|
|
|
private fun open(target: Intent) {
|
|
try {
|
|
startActivity(target.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
|
} catch (e: Exception) {
|
|
Toast.makeText(this, "Hey Dumby couldn't open that", Toast.LENGTH_SHORT).show()
|
|
EventLog.add("Couldn't open: ${e.message}")
|
|
}
|
|
finish()
|
|
}
|
|
}
|