Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

refactor(i18n): notifications and the last UI text in string resources

Durganshu3d2c1448eb59
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.kt
index b0fc4d1..7d96126 100644
--- a/app/src/main/java/com/gotcha/MainActivity.kt
+++ b/app/src/main/java/com/gotcha/MainActivity.kt
@@ -48,6 +48,7 @@ import com.gotcha.data.LEGAL_VERSION
import com.gotcha.data.Settings
import com.gotcha.data.SettingsRepository
import com.gotcha.data.computeFeedbackStats
+import com.gotcha.i18n.stringLookup
import com.gotcha.llm.ChatMessage
import com.gotcha.llm.LLMClient
import com.gotcha.notifications.ChatCompletionNotifier
@@ -83,7 +84,6 @@ import com.gotcha.ui.SharePosterSheet
import com.gotcha.ui.SharePosterState
import com.gotcha.ui.rememberChatTransfer
import com.gotcha.ui.runtimePermissionAsk
-import com.gotcha.ui.stringLookup
import com.gotcha.ui.theme.GotchaTheme
import com.gotcha.ui.theme.SkinBackdrop
import com.gotcha.ui.theme.Skins
diff --git a/app/src/main/java/com/gotcha/agent/ChatRunner.kt b/app/src/main/java/com/gotcha/agent/ChatRunner.kt
index f1cfac0..5754c25 100644
--- a/app/src/main/java/com/gotcha/agent/ChatRunner.kt
+++ b/app/src/main/java/com/gotcha/agent/ChatRunner.kt
@@ -12,6 +12,7 @@ import com.gotcha.data.ChatSession
import com.gotcha.data.LlmProvider
import com.gotcha.data.Settings
import com.gotcha.data.SettingsRepository
+import com.gotcha.i18n.stringLookup
import com.gotcha.llm.ChatMessage
import com.gotcha.llm.DocumentPart
import com.gotcha.llm.LLMClient
@@ -1035,14 +1036,14 @@ class ChatRunner(private val app: Application) : AgentEvents {
// at all, get a notification that says only that a task finished.
val named = mayNameChat(sessionId)
val title = if (named) {
- ChatCompletionNotifier.notificationTitle(engine.currentTitle(), outcome)
+ ChatCompletionNotifier.notificationTitle(engine.currentTitle(), outcome, app.stringLookup())
} else {
- ChatCompletionNotifier.anonymousTitle(outcome)
+ app.getString(ChatCompletionNotifier.anonymousTitle(outcome))
}
val entryId = localNotificationStore.addEntry(
category = NotificationCategory.TASK_FINISHED,
title = title,
- body = ChatCompletionNotifier.defaultBody(outcome),
+ body = app.getString(ChatCompletionNotifier.defaultBody(outcome)),
target = NotificationTarget.Chat(sessionId)
)
return completionNotifier.build(
diff --git a/app/src/main/java/com/gotcha/ui/StringLookup.kt b/app/src/main/java/com/gotcha/i18n/StringLookup.kt
similarity index 96%
rename from app/src/main/java/com/gotcha/ui/StringLookup.kt
rename to app/src/main/java/com/gotcha/i18n/StringLookup.kt
index 6c62897..e6f5fe9 100644
--- a/app/src/main/java/com/gotcha/ui/StringLookup.kt
+++ b/app/src/main/java/com/gotcha/i18n/StringLookup.kt
@@ -1,4 +1,4 @@
-package com.gotcha.ui
+package com.gotcha.i18n
import android.content.Context
import androidx.annotation.StringRes
diff --git a/app/src/main/java/com/gotcha/notifications/AttentionNotifier.kt b/app/src/main/java/com/gotcha/notifications/AttentionNotifier.kt
index 9701055..c37627b 100644
--- a/app/src/main/java/com/gotcha/notifications/AttentionNotifier.kt
+++ b/app/src/main/java/com/gotcha/notifications/AttentionNotifier.kt
@@ -5,8 +5,10 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
+import androidx.annotation.StringRes
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
+import com.gotcha.R
import com.gotcha.data.CompletionPreview
/** What a paused run is waiting on. */
@@ -45,11 +47,11 @@ class AttentionNotifier(private val context: Context) {
if (!canPost()) return false
ensureChannel()
val shown = if (named && kind == AttentionKind.QUESTION) preview else CompletionPreview.NONE
- val body = questionPreview(question, shown) ?: defaultBody(kind)
+ val body = questionPreview(question, shown) ?: context.getString(defaultBody(kind))
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(com.gotcha.R.drawable.ic_notification)
- .setContentTitle(title(kind))
+ .setContentTitle(context.getString(title(kind)))
.setContentText(body)
.setCategory(NotificationCompat.CATEGORY_REMINDER)
.setPriority(NotificationCompat.PRIORITY_HIGH)
@@ -58,7 +60,7 @@ class AttentionNotifier(private val context: Context) {
.setPublicVersion(
NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(com.gotcha.R.drawable.ic_notification)
- .setContentTitle(PUBLIC_TITLE)
+ .setContentTitle(context.getString(R.string.attention_public_title))
.build()
)
.setOnlyAlertOnce(true)
@@ -95,8 +97,12 @@ class AttentionNotifier(private val context: Context) {
val mgr = context.getSystemService(NotificationManager::class.java) ?: return
if (mgr.getNotificationChannel(CHANNEL_ID) != null) return
mgr.createNotificationChannel(
- NotificationChannel(CHANNEL_ID, "Waiting for your answer", NotificationManager.IMPORTANCE_HIGH).apply {
- description = "When Gotcha has paused a task to ask you something while you are in another app"
+ NotificationChannel(
+ CHANNEL_ID,
+ context.getString(R.string.channel_attention),
+ NotificationManager.IMPORTANCE_HIGH
+ ).apply {
+ description = context.getString(R.string.channel_attention_description)
}
)
}
@@ -104,17 +110,18 @@ class AttentionNotifier(private val context: Context) {
companion object {
const val CHANNEL_ID = "gotcha_needs_input"
private const val NOTIFICATION_ID = 0x4A77_E7
- private const val PUBLIC_TITLE = "Gotcha is waiting for you"
private val FENCE_LINE = Regex("^\\s*(```|~~~).*$")
- internal fun title(kind: AttentionKind): String = when (kind) {
- AttentionKind.QUESTION -> "Gotcha has a question"
- AttentionKind.CONFIRMATION -> "Gotcha is waiting for your OK"
+ @StringRes
+ internal fun title(kind: AttentionKind): Int = when (kind) {
+ AttentionKind.QUESTION -> R.string.attention_question_title
+ AttentionKind.CONFIRMATION -> R.string.attention_confirmation_title
}
- internal fun defaultBody(kind: AttentionKind): String = when (kind) {
- AttentionKind.QUESTION -> "Your task is paused until you answer. Tap to open it."
- AttentionKind.CONFIRMATION -> "Your task is paused until you allow or deny its next step. Tap to open it."
+ @StringRes
+ internal fun defaultBody(kind: AttentionKind): Int = when (kind) {
+ AttentionKind.QUESTION -> R.string.attention_question_body
+ AttentionKind.CONFIRMATION -> R.string.attention_confirmation_body
}
/**
diff --git a/app/src/main/java/com/gotcha/notifications/ChatCompletionNotifier.kt b/app/src/main/java/com/gotcha/notifications/ChatCompletionNotifier.kt
index aefbb14..861aaae 100644
--- a/app/src/main/java/com/gotcha/notifications/ChatCompletionNotifier.kt
+++ b/app/src/main/java/com/gotcha/notifications/ChatCompletionNotifier.kt
@@ -9,11 +9,14 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
+import androidx.annotation.StringRes
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import com.gotcha.R
import com.gotcha.data.CompletionPreview
+import com.gotcha.i18n.StringLookup
+import com.gotcha.i18n.stringLookup
import com.gotcha.service.ChatRunService
/** How a chat run ended, as the task-finished notification reports it. */
@@ -79,9 +82,13 @@ class ChatCompletionNotifier(private val context: Context) {
if (!canPost()) return null
ensureChannel()
val notifyId = notificationId(sessionId)
- val title = if (named) notificationTitle(chatTitle, outcome) else anonymousTitle(outcome)
+ val title = if (named) {
+ notificationTitle(chatTitle, outcome, context.stringLookup())
+ } else {
+ context.getString(anonymousTitle(outcome))
+ }
val shown = if (named) preview else CompletionPreview.NONE
- val body = previewText(reply, shown) ?: defaultBody(outcome)
+ val body = previewText(reply, shown) ?: context.getString(defaultBody(outcome))
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(smallIcon(outcome))
@@ -93,7 +100,7 @@ class ChatCompletionNotifier(private val context: Context) {
.setPublicVersion(
NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(smallIcon(outcome))
- .setContentTitle(PUBLIC_TITLE)
+ .setContentTitle(context.getString(R.string.completion_public_title))
.build()
)
.setAutoCancel(true)
@@ -133,8 +140,12 @@ class ChatCompletionNotifier(private val context: Context) {
val mgr = context.getSystemService(NotificationManager::class.java) ?: return
if (mgr.getNotificationChannel(CHANNEL_ID) != null) return
mgr.createNotificationChannel(
- NotificationChannel(CHANNEL_ID, "Task finished", NotificationManager.IMPORTANCE_DEFAULT).apply {
- description = "When a chat task finishes while you are in another app"
+ NotificationChannel(
+ CHANNEL_ID,
+ context.getString(R.string.channel_completion),
+ NotificationManager.IMPORTANCE_DEFAULT
+ ).apply {
+ description = context.getString(R.string.channel_completion_description)
}
)
}
@@ -143,7 +154,6 @@ class ChatCompletionNotifier(private val context: Context) {
const val CHANNEL_ID = "gotcha_chat_completion"
const val ACTION_OPEN_CHAT_SESSION = "com.gotcha.ACTION_OPEN_CHAT_SESSION"
const val EXTRA_OPEN_SESSION_ID = "com.gotcha.OPEN_SESSION_ID"
- private const val PUBLIC_TITLE = "Gotcha finished a task"
private const val SHORT_PREVIEW_CHARS = 140
/**
@@ -152,12 +162,12 @@ class ChatCompletionNotifier(private val context: Context) {
*/
internal fun notificationId(sessionId: String): Int = "chat:$sessionId".hashCode() and 0x7FFF_FFFF
- internal fun notificationTitle(chatTitle: String, outcome: RunOutcome): String {
- val chat = chatTitle.ifBlank { "Chat" }
+ internal fun notificationTitle(chatTitle: String, outcome: RunOutcome, text: StringLookup): String {
+ val chat = chatTitle.ifBlank { text(R.string.completion_untitled_chat) }
return when (outcome) {
- RunOutcome.DONE -> "Done: $chat"
- RunOutcome.FAILED -> "Failed: $chat"
- RunOutcome.STOPPED -> "Stopped: $chat"
+ RunOutcome.DONE -> text(R.string.completion_done_title, chat)
+ RunOutcome.FAILED -> text(R.string.completion_failed_title, chat)
+ RunOutcome.STOPPED -> text(R.string.completion_stopped_title, chat)
}
}
@@ -169,16 +179,18 @@ class ChatCompletionNotifier(private val context: Context) {
}
/** The title when the chat may not be named. */
- internal fun anonymousTitle(outcome: RunOutcome): String = when (outcome) {
- RunOutcome.DONE -> "Task finished"
- RunOutcome.FAILED -> "Task failed"
- RunOutcome.STOPPED -> "Task stopped"
+ @StringRes
+ internal fun anonymousTitle(outcome: RunOutcome): Int = when (outcome) {
+ RunOutcome.DONE -> R.string.completion_done_anonymous
+ RunOutcome.FAILED -> R.string.completion_failed_anonymous
+ RunOutcome.STOPPED -> R.string.completion_stopped_anonymous
}
- internal fun defaultBody(outcome: RunOutcome): String = when (outcome) {
- RunOutcome.DONE -> "Gotcha finished your task. Tap to see the reply."
- RunOutcome.FAILED -> "Gotcha couldn't finish your task. Tap to see what happened."
- RunOutcome.STOPPED -> "The task was stopped. Tap to open the chat."
+ @StringRes
+ internal fun defaultBody(outcome: RunOutcome): Int = when (outcome) {
+ RunOutcome.DONE -> R.string.completion_done_body
+ RunOutcome.FAILED -> R.string.completion_failed_body
+ RunOutcome.STOPPED -> R.string.completion_stopped_body
}
/**
diff --git a/app/src/main/java/com/gotcha/notifications/DailyTip.kt b/app/src/main/java/com/gotcha/notifications/DailyTip.kt
index 39c8bd9..30b89bf 100644
--- a/app/src/main/java/com/gotcha/notifications/DailyTip.kt
+++ b/app/src/main/java/com/gotcha/notifications/DailyTip.kt
@@ -1,5 +1,7 @@
package com.gotcha.notifications
+import androidx.annotation.StringRes
+import com.gotcha.R
import com.gotcha.tools.AgentMode
import java.time.LocalDate
import java.time.LocalTime
@@ -22,9 +24,9 @@ import kotlin.random.Random
*/
data class DailyTip(
val id: String,
- val title: String,
- val body: String,
- val prompt: String,
+ @StringRes val title: Int,
+ @StringRes val body: Int,
+ @StringRes val prompt: Int,
val tools: Set<String>,
val agent: AgentMode = AgentMode.MONITOR
)
@@ -33,127 +35,127 @@ data class DailyTip(
val DAILY_TIPS = listOf(
DailyTip(
id = "read_screen",
- title = "Ask about your screen",
- body = "Stuck on something? Gotcha can read your screen and explain it.",
- prompt = "What's on my screen?",
+ title = R.string.daily_tip_read_screen_title,
+ body = R.string.daily_tip_read_screen_body,
+ prompt = R.string.daily_tip_read_screen_prompt,
tools = setOf("read_screen")
),
DailyTip(
id = "catch_up",
- title = "Catch up in seconds",
- body = "Let Gotcha sum up your unread notifications.",
- prompt = "Catch me up on my unread notifications",
+ title = R.string.daily_tip_catch_up_title,
+ body = R.string.daily_tip_catch_up_body,
+ prompt = R.string.daily_tip_catch_up_prompt,
tools = setOf("read_notifications")
),
DailyTip(
id = "big_files",
- title = "Free up some space",
- body = "Gotcha can find your largest files and tell you what's safe to delete.",
- prompt = "Find the largest files in my Downloads folder and tell me what's safe to delete",
+ title = R.string.daily_tip_big_files_title,
+ body = R.string.daily_tip_big_files_body,
+ prompt = R.string.daily_tip_big_files_prompt,
tools = setOf("list_files", "get_storage_info")
),
DailyTip(
id = "summarise_pdf",
- title = "Summarise a PDF",
- body = "No time to read it? Gotcha can summarise your latest PDF.",
- prompt = "Read the most recent PDF in my Downloads and summarise it",
+ title = R.string.daily_tip_summarise_pdf_title,
+ body = R.string.daily_tip_summarise_pdf_body,
+ prompt = R.string.daily_tip_summarise_pdf_prompt,
tools = setOf("read_file")
),
DailyTip(
id = "calendar_today",
- title = "Plan your day",
- body = "Ask Gotcha what's on your calendar today.",
- prompt = "What's on my calendar today?",
+ title = R.string.daily_tip_calendar_today_title,
+ body = R.string.daily_tip_calendar_today_body,
+ prompt = R.string.daily_tip_calendar_today_prompt,
tools = setOf("list_calendar_events")
),
DailyTip(
id = "calendar_add",
- title = "Add to your calendar",
- body = "Tell Gotcha about a plan and it goes straight into your calendar.",
- prompt = "Add lunch with … on Friday at 1pm to my calendar",
+ title = R.string.daily_tip_calendar_add_title,
+ body = R.string.daily_tip_calendar_add_body,
+ prompt = R.string.daily_tip_calendar_add_prompt,
tools = setOf("create_calendar_event"),
agent = AgentMode.OPERATOR
),
DailyTip(
id = "set_alarm",
- title = "Set an alarm by asking",
- body = "Gotcha can set alarms and timers for you.",
- prompt = "Set an alarm for 7am tomorrow",
+ title = R.string.daily_tip_set_alarm_title,
+ body = R.string.daily_tip_set_alarm_body,
+ prompt = R.string.daily_tip_set_alarm_prompt,
tools = setOf("set_alarm", "set_timer"),
agent = AgentMode.OPERATOR
),
DailyTip(
id = "send_whatsapp",
- title = "Send a WhatsApp hands-free",
- body = "Gotcha can open WhatsApp and send the message for you.",
- prompt = "Send a WhatsApp to … saying …",
+ title = R.string.daily_tip_send_whatsapp_title,
+ body = R.string.daily_tip_send_whatsapp_body,
+ prompt = R.string.daily_tip_send_whatsapp_prompt,
tools = setOf("navigate_app"),
agent = AgentMode.OPERATOR
),
DailyTip(
id = "send_sms",
- title = "Running late?",
- body = "Gotcha can text someone for you.",
- prompt = "Text … that I'm running 10 minutes late",
+ title = R.string.daily_tip_send_sms_title,
+ body = R.string.daily_tip_send_sms_body,
+ prompt = R.string.daily_tip_send_sms_prompt,
tools = setOf("send_sms"),
agent = AgentMode.OPERATOR
),
DailyTip(
id = "recent_sms",
- title = "Skim your messages",
- body = "Gotcha can summarise your latest texts.",
- prompt = "Summarise my latest text messages",
+ title = R.string.daily_tip_recent_sms_title,
+ body = R.string.daily_tip_recent_sms_body,
+ prompt = R.string.daily_tip_recent_sms_prompt,
tools = setOf("read_recent_sms")
),
DailyTip(
id = "missed_calls",
- title = "Who called?",
- body = "Ask Gotcha to go through your call log.",
- prompt = "Who called me today?",
+ title = R.string.daily_tip_missed_calls_title,
+ body = R.string.daily_tip_missed_calls_body,
+ prompt = R.string.daily_tip_missed_calls_prompt,
tools = setOf("read_call_log")
),
DailyTip(
id = "battery",
- title = "What's draining your battery?",
- body = "Gotcha can check your battery and which apps use it most.",
- prompt = "Check my battery and tell me which apps have been using the most",
+ title = R.string.daily_tip_battery_title,
+ body = R.string.daily_tip_battery_body,
+ prompt = R.string.daily_tip_battery_prompt,
tools = setOf("get_battery_info", "get_app_usage")
),
DailyTip(
id = "screen_time",
- title = "Check your screen time",
- body = "Ask Gotcha how long you spent on your phone, and where.",
- prompt = "How much time did I spend on my phone today, and on which apps?",
+ title = R.string.daily_tip_screen_time_title,
+ body = R.string.daily_tip_screen_time_body,
+ prompt = R.string.daily_tip_screen_time_prompt,
tools = setOf("get_app_usage")
),
DailyTip(
id = "web_search",
- title = "Research anything",
- body = "Gotcha can search the web and sum up what it finds.",
- prompt = "Search the web for … and summarise what you find",
+ title = R.string.daily_tip_web_search_title,
+ body = R.string.daily_tip_web_search_body,
+ prompt = R.string.daily_tip_web_search_prompt,
tools = setOf("websearch", "webfetch")
),
DailyTip(
id = "do_not_disturb",
- title = "Need to focus?",
- body = "Gotcha can turn on Do Not Disturb for you.",
- prompt = "Turn on Do Not Disturb for the next hour",
+ title = R.string.daily_tip_do_not_disturb_title,
+ body = R.string.daily_tip_do_not_disturb_body,
+ prompt = R.string.daily_tip_do_not_disturb_prompt,
tools = setOf("set_dnd"),
agent = AgentMode.OPERATOR
),
DailyTip(
id = "wifi",
- title = "Change settings by asking",
- body = "Gotcha can find and flip settings for you, like Wi-Fi.",
- prompt = "Open settings and turn on Wi-Fi",
+ title = R.string.daily_tip_wifi_title,
+ body = R.string.daily_tip_wifi_body,
+ prompt = R.string.daily_tip_wifi_prompt,
tools = setOf("toggle_wifi", "open_setting"),
agent = AgentMode.OPERATOR
),
DailyTip(
id = "podcast",
- title = "Listen instead of reading",
- body = "Gotcha can turn a document into a short podcast.",
- prompt = "Turn the most recent PDF in my Downloads into a short podcast",
+ title = R.string.daily_tip_podcast_title,
+ body = R.string.daily_tip_podcast_body,
+ prompt = R.string.daily_tip_podcast_prompt,
tools = setOf("synthesize_podcast", "synthesize_podcast_dialogue"),
agent = AgentMode.OPERATOR
)
diff --git a/app/src/main/java/com/gotcha/notifications/LocalNotificationScheduler.kt b/app/src/main/java/com/gotcha/notifications/LocalNotificationScheduler.kt
index 47f41cc..9c81628 100644
--- a/app/src/main/java/com/gotcha/notifications/LocalNotificationScheduler.kt
+++ b/app/src/main/java/com/gotcha/notifications/LocalNotificationScheduler.kt
@@ -8,6 +8,7 @@ import android.content.Intent
import android.util.Log
import com.gotcha.data.ChatHistoryRepository
import com.gotcha.data.SettingsRepository
+import com.gotcha.i18n.stringLookup
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -172,7 +173,8 @@ internal suspend fun runLocalNotificationCheck(
settings.inactivityDays,
settings.notificationsMentionChats,
now,
- zone
+ zone,
+ context.stringLookup()
)
)
}
@@ -181,7 +183,7 @@ internal suspend fun runLocalNotificationCheck(
if (includeTip && !usedToday(lastRun, now, zone)) {
val usedTools = chats.flatMap { c -> c.runs.flatMap { run -> run.toolCalls.map { it.name } } }
tip = pickDailyTip(DAILY_TIPS, recentTips(repo), usedTools.toSet())
- tip?.let { add(tipCandidate(it, now, zone)) }
+ tip?.let { add(tipCandidate(it, now, zone, context.stringLookup())) }
}
}
diff --git a/app/src/main/java/com/gotcha/notifications/LocalNotifications.kt b/app/src/main/java/com/gotcha/notifications/LocalNotifications.kt
index 01441d7..425f6e6 100644
--- a/app/src/main/java/com/gotcha/notifications/LocalNotifications.kt
+++ b/app/src/main/java/com/gotcha/notifications/LocalNotifications.kt
@@ -4,6 +4,7 @@ import androidx.annotation.StringRes
import com.gotcha.R
import com.gotcha.data.RunSummary
import com.gotcha.data.Settings
+import com.gotcha.i18n.StringLookup
import com.gotcha.tools.AgentMode
import java.time.Instant
import java.time.LocalDate
@@ -146,13 +147,14 @@ internal fun behaviorCandidates(
inactivityDays: Int,
mention: Boolean,
now: Long,
- zone: ZoneId
+ zone: ZoneId,
+ text: StringLookup
): List<LocalCandidate> {
val usable = chats.filterNot { it.sensitive }
return listOfNotNull(
- unfinishedChat(usable, mention, now),
- dueRoutine(usable, mention, now, zone),
- inactivityReminder(usable, lastOpenedAt, inactivityDays, mention, now)
+ unfinishedChat(usable, mention, now, text),
+ dueRoutine(usable, mention, now, zone, text),
+ inactivityReminder(usable, lastOpenedAt, inactivityDays, mention, now, text)
)
}
@@ -161,7 +163,12 @@ internal fun behaviorCandidates(
* question to the user — between [UNFINISHED_MIN_AGE_MS] and
* [UNFINISHED_MAX_AGE_MS] ago.
*/
-internal fun unfinishedChat(chats: List<ChatDigest>, mention: Boolean, now: Long): LocalCandidate? {
+internal fun unfinishedChat(
+ chats: List<ChatDigest>,
+ mention: Boolean,
+ now: Long,
+ text: StringLookup
+): LocalCandidate? {
val (chat, run) = chats
.mapNotNull { chat -> chat.runs.maxByOrNull { it.endedAt }?.let { chat to it } }
.filter { (_, run) -> now - run.endedAt in UNFINISHED_MIN_AGE_MS..UNFINISHED_MAX_AGE_MS }
@@ -170,14 +177,14 @@ internal fun unfinishedChat(chats: List<ChatDigest>, mention: Boolean, now: Long
?: return null
val asked = run.succeeded
val body = when {
- !mention -> "A chat was left unfinished. Tap to pick it up."
- asked -> "Gotcha asked you something in “${chat.title}”. Tap to answer."
- else -> "“${chat.title}” stopped before it was done. Tap to pick it up."
+ !mention -> text(R.string.local_unfinished_generic)
+ asked -> text(R.string.local_unfinished_asked, chat.title)
+ else -> text(R.string.local_unfinished_stopped, chat.title)
}
return LocalCandidate(
category = NotificationCategory.UNFINISHED_CHAT,
dedupKey = "unfinished:${chat.id}:${run.endedAt}",
- title = if (asked) "Gotcha is waiting for you" else "Finish what you started",
+ title = text(if (asked) R.string.local_unfinished_title_asked else R.string.local_unfinished_title),
body = body,
target = NotificationTarget.Chat(chat.id)
)
@@ -189,7 +196,13 @@ internal fun unfinishedChat(chats: List<ChatDigest>, mention: Boolean, now: Long
* last time as usually do (the median gap), but no more than two beyond it —
* a routine long abandoned is not nagged about.
*/
-internal fun dueRoutine(chats: List<ChatDigest>, mention: Boolean, now: Long, zone: ZoneId): LocalCandidate? {
+internal fun dueRoutine(
+ chats: List<ChatDigest>,
+ mention: Boolean,
+ now: Long,
+ zone: ZoneId,
+ text: StringLookup
+): LocalCandidate? {
val today = Instant.ofEpochMilli(now).atZone(zone).toLocalDate()
fun day(millis: Long): LocalDate = Instant.ofEpochMilli(millis).atZone(zone).toLocalDate()
val runs = chats.flatMap { it.runs }.filter { it.succeeded && routineKey(it.userPrompt).isNotEmpty() }
@@ -216,11 +229,11 @@ internal fun dueRoutine(chats: List<ChatDigest>, mention: Boolean, now: Long, zo
LocalCandidate(
category = NotificationCategory.ROUTINE,
dedupKey = "routine:${key.hashCode()}:${day(latest.endedAt)}",
- title = "Time for your usual?",
+ title = text(R.string.local_routine_title),
body = if (mention) {
- "You often ask: “$preview”. Tap to ask again."
+ text(R.string.local_routine_body, preview)
} else {
- "One of your regular requests may be due. Tap to see it."
+ text(R.string.local_routine_body_generic)
},
target = NotificationTarget.Draft(
prompt = prompt,
@@ -260,7 +273,8 @@ internal fun inactivityReminder(
lastOpenedAt: Long,
inactivityDays: Int,
mention: Boolean,
- now: Long
+ now: Long,
+ text: StringLookup
): LocalCandidate? {
if (lastOpenedAt <= 0L || now - lastOpenedAt < inactivityDays * DAY_MS) return null
val recent = chats
@@ -271,23 +285,23 @@ internal fun inactivityReminder(
return LocalCandidate(
category = NotificationCategory.INACTIVITY,
dedupKey = "inactive:$lastOpenedAt",
- title = if (recent != null) "Pick up where you left off" else "Anything Gotcha can do for you?",
+ title = text(if (recent != null) R.string.local_inactive_title_recent else R.string.local_inactive_title),
body = if (recent != null) {
- "Your last chat was “${recent.title}”. Tap to open it."
+ text(R.string.local_inactive_body_recent, recent.title)
} else {
- "Ask Gotcha to handle something on your phone. Tap to open."
+ text(R.string.local_inactive_body)
},
target = recent?.let { NotificationTarget.Chat(it.id) } ?: NotificationTarget.Home
)
}
/** The daily tip as a candidate: at most one a day. */
-internal fun tipCandidate(tip: DailyTip, now: Long, zone: ZoneId): LocalCandidate = LocalCandidate(
+internal fun tipCandidate(tip: DailyTip, now: Long, zone: ZoneId, text: StringLookup): LocalCandidate = LocalCandidate(
category = NotificationCategory.DAILY_TIP,
dedupKey = "tip:${Instant.ofEpochMilli(now).atZone(zone).toLocalDate()}",
- title = tip.title,
- body = tip.body,
- target = NotificationTarget.Draft(tip.prompt, tip.agent)
+ title = text(tip.title),
+ body = text(tip.body),
+ target = NotificationTarget.Draft(text(tip.prompt), tip.agent)
)
/**
diff --git a/app/src/main/java/com/gotcha/notifications/LocalNotifier.kt b/app/src/main/java/com/gotcha/notifications/LocalNotifier.kt
index 5a6f110..8ccb945 100644
--- a/app/src/main/java/com/gotcha/notifications/LocalNotifier.kt
+++ b/app/src/main/java/com/gotcha/notifications/LocalNotifier.kt
@@ -7,6 +7,7 @@ import android.content.Context
import android.content.Intent
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
+import com.gotcha.R
/**
* Posts Gotcha's proactive notifications (issues #100, #101) and files each in
@@ -44,7 +45,7 @@ class LocalNotifier(private val context: Context) {
.setPublicVersion(
NotificationCompat.Builder(context, channel)
.setSmallIcon(com.gotcha.R.drawable.ic_notification)
- .setContentTitle(PUBLIC_TITLE)
+ .setContentTitle(context.getString(R.string.local_public_title))
.build()
)
}
@@ -71,15 +72,23 @@ class LocalNotifier(private val context: Context) {
val mgr = context.getSystemService(NotificationManager::class.java) ?: return
if (mgr.getNotificationChannel(TIP_CHANNEL_ID) == null) {
mgr.createNotificationChannel(
- NotificationChannel(TIP_CHANNEL_ID, "Daily tips", NotificationManager.IMPORTANCE_LOW).apply {
- description = "One thing to try with Gotcha each day"
+ NotificationChannel(
+ TIP_CHANNEL_ID,
+ context.getString(R.string.channel_daily_tips),
+ NotificationManager.IMPORTANCE_LOW
+ ).apply {
+ description = context.getString(R.string.channel_daily_tips_description)
}
)
}
if (mgr.getNotificationChannel(REMINDER_CHANNEL_ID) == null) {
mgr.createNotificationChannel(
- NotificationChannel(REMINDER_CHANNEL_ID, "Reminders", NotificationManager.IMPORTANCE_DEFAULT).apply {
- description = "Unfinished chats, routines that are due, and a nudge after a quiet spell"
+ NotificationChannel(
+ REMINDER_CHANNEL_ID,
+ context.getString(R.string.channel_reminders),
+ NotificationManager.IMPORTANCE_DEFAULT
+ ).apply {
+ description = context.getString(R.string.channel_reminders_description)
}
)
}
@@ -91,7 +100,6 @@ class LocalNotifier(private val context: Context) {
const val ACTION_OPEN_LOCAL_NOTIFICATION = "com.gotcha.ACTION_OPEN_LOCAL_NOTIFICATION"
const val EXTRA_DRAFT_PROMPT = "com.gotcha.DRAFT_PROMPT"
const val EXTRA_DRAFT_MODE = "com.gotcha.DRAFT_MODE"
- private const val PUBLIC_TITLE = "Gotcha has a suggestion"
internal fun notificationId(category: NotificationCategory): Int = 0x7100 + category.ordinal
diff --git a/app/src/main/java/com/gotcha/notifications/NotificationDispatcher.kt b/app/src/main/java/com/gotcha/notifications/NotificationDispatcher.kt
index bb45f80..e82d2d7 100644
--- a/app/src/main/java/com/gotcha/notifications/NotificationDispatcher.kt
+++ b/app/src/main/java/com/gotcha/notifications/NotificationDispatcher.kt
@@ -13,6 +13,7 @@ import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
+import com.gotcha.R
/**
* Pulls the latest envelope from [NotificationApi], filters/dedupes against
@@ -186,10 +187,10 @@ class NotificationDispatcher(
return try {
val channel = NotificationChannel(
CHANNEL_ID,
- "Server messages",
+ context.getString(R.string.channel_server),
NotificationManager.IMPORTANCE_DEFAULT
).apply {
- description = "Updates, tips, and maintenance notices from Gotcha"
+ description = context.getString(R.string.channel_server_description)
}
mgr.createNotificationChannel(channel)
true
diff --git a/app/src/main/java/com/gotcha/service/ChatRunService.kt b/app/src/main/java/com/gotcha/service/ChatRunService.kt
index e41dd72..494c3c0 100644
--- a/app/src/main/java/com/gotcha/service/ChatRunService.kt
+++ b/app/src/main/java/com/gotcha/service/ChatRunService.kt
@@ -16,6 +16,9 @@ import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
+import com.gotcha.R
+import com.gotcha.i18n.StringLookup
+import com.gotcha.i18n.stringLookup
import com.gotcha.notifications.ChatCompletionNotifier
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
@@ -139,7 +142,6 @@ class ChatRunService : Service() {
const val CHANNEL_ID = "gotcha_chat_running"
const val ACTION_STOP_RUN = "com.gotcha.ACTION_STOP_CHAT_RUN"
internal const val NOTIFICATION_ID = 0x4A77_E8
- private const val PUBLIC_TITLE = "Gotcha is working on a task…"
private val _running = MutableStateFlow<RunningChat?>(null)
@@ -245,17 +247,17 @@ class ChatRunService : Service() {
stop()
}
- internal fun title(chat: RunningChat?): String {
- val name = chat?.chatTitle?.takeIf { it.isNotBlank() } ?: return PUBLIC_TITLE
+ internal fun title(chat: RunningChat?, text: StringLookup): String {
+ val name = chat?.chatTitle?.takeIf { it.isNotBlank() } ?: return text(R.string.run_public_title)
// A name already cut short with "…" doesn't need a second one.
- return if (name.endsWith("…")) "Gotcha is working on “$name”" else "Gotcha is working on “$name”…"
+ return text(if (name.endsWith("…")) R.string.run_title_cut else R.string.run_title, name)
}
internal fun buildNotification(context: Context, chat: RunningChat?): Notification {
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(com.gotcha.R.drawable.ic_notification_running)
- .setContentTitle(title(chat))
- .setContentText("Tap to follow along. You can keep using your phone.")
+ .setContentTitle(title(chat, context.stringLookup()))
+ .setContentText(context.getString(R.string.run_body))
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
.setProgress(0, 0, true)
.setOngoing(true)
@@ -266,10 +268,10 @@ class ChatRunService : Service() {
.setPublicVersion(
NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(com.gotcha.R.drawable.ic_notification_running)
- .setContentTitle(PUBLIC_TITLE)
+ .setContentTitle(context.getString(R.string.run_public_title))
.build()
)
- .addAction(0, "Stop", stopIntent(context))
+ .addAction(0, context.getString(R.string.action_stop), stopIntent(context))
chat?.let { builder.setContentIntent(openChatIntent(context, it.sessionId)) }
return builder.build()
}
@@ -299,9 +301,12 @@ class ChatRunService : Service() {
val mgr = context.getSystemService(NotificationManager::class.java) ?: return
if (mgr.getNotificationChannel(CHANNEL_ID) != null) return
mgr.createNotificationChannel(
- NotificationChannel(CHANNEL_ID, "Task in progress", NotificationManager.IMPORTANCE_LOW).apply {
- description = "Shown while Gotcha works on a task, so Android keeps it running " +
- "when you switch to another app"
+ NotificationChannel(
+ CHANNEL_ID,
+ context.getString(R.string.channel_run),
+ NotificationManager.IMPORTANCE_LOW
+ ).apply {
+ description = context.getString(R.string.channel_run_description)
setShowBadge(false)
}
)
diff --git a/app/src/main/java/com/gotcha/ui/ConnectorsScreen.kt b/app/src/main/java/com/gotcha/ui/ConnectorsScreen.kt
index bb11f7a..42390dc 100644
--- a/app/src/main/java/com/gotcha/ui/ConnectorsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/ConnectorsScreen.kt
@@ -14,7 +14,9 @@ import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
+import com.gotcha.R
/**
* Top-level Connectors screen, reached from the drawer alongside Settings.
@@ -27,8 +29,8 @@ fun ConnectorsScreen(onBack: () -> Unit) {
Scaffold(
topBar = {
TopAppBar(
- title = { Text("Connectors") },
- navigationIcon = { TextButton(onClick = onBack) { Text("← Back") } }
+ title = { Text(stringResource(R.string.connectors_title)) },
+ navigationIcon = { TextButton(onClick = onBack) { Text(stringResource(R.string.action_back)) } }
)
}
) { padding ->
@@ -41,8 +43,7 @@ fun ConnectorsScreen(onBack: () -> Unit) {
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Text(
- "Connect your accounts so the assistant can read and act on your mail, " +
- "calendars, tasks and notes.",
+ stringResource(R.string.connectors_intro),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
diff --git a/app/src/main/java/com/gotcha/ui/PermissionAsk.kt b/app/src/main/java/com/gotcha/ui/PermissionAsk.kt
index 92d52ee..d92961c 100644
--- a/app/src/main/java/com/gotcha/ui/PermissionAsk.kt
+++ b/app/src/main/java/com/gotcha/ui/PermissionAsk.kt
@@ -8,6 +8,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.gotcha.R
+import com.gotcha.i18n.StringLookup
import com.gotcha.ui.theme.SkinAlertDialog
import android.provider.Settings as AndroidSettings
diff --git a/app/src/main/java/com/gotcha/ui/ReleaseNotes.kt b/app/src/main/java/com/gotcha/ui/ReleaseNotes.kt
index 513ba0b..167a1ac 100644
--- a/app/src/main/java/com/gotcha/ui/ReleaseNotes.kt
+++ b/app/src/main/java/com/gotcha/ui/ReleaseNotes.kt
@@ -12,7 +12,9 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
+import com.gotcha.R
import com.halilibo.richtext.ui.RichTextStyle
private val LIST_ITEM = Regex("^[-*+] ")
@@ -61,7 +63,9 @@ fun ReleaseNotes(markdown: String, modifier: Modifier = Modifier) {
}
if (headlines != null) {
TextButton(onClick = { expanded = !expanded }) {
- Text(if (expanded) "Show less" else "Show all release notes")
+ Text(
+ stringResource(if (expanded) R.string.release_notes_show_less else R.string.release_notes_show_all)
+ )
}
}
}
diff --git a/app/src/main/java/com/gotcha/ui/ScreenCropOverlayView.kt b/app/src/main/java/com/gotcha/ui/ScreenCropOverlayView.kt
index e5b3840..9029216 100644
--- a/app/src/main/java/com/gotcha/ui/ScreenCropOverlayView.kt
+++ b/app/src/main/java/com/gotcha/ui/ScreenCropOverlayView.kt
@@ -14,6 +14,7 @@ import android.graphics.Shader
import android.view.MotionEvent
import android.view.View
import androidx.core.graphics.ColorUtils
+import com.gotcha.R
import com.gotcha.service.AnnotatedEntity
import com.gotcha.service.SmartActionDetector
import com.gotcha.ui.theme.OverlaySkin
@@ -322,7 +323,7 @@ class ScreenCropOverlayView(
frozen != null -> drawSelectionBox(canvas, frozen)
else -> if (annotatedEntities.isEmpty()) {
canvas.drawText(
- "Draw around anything • tap to cancel",
+ context.getString(R.string.crop_hint),
width / 2f,
height * 0.12f,
hintPaint
diff --git a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
index 10c2eb8..c1d5577 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
@@ -74,6 +74,7 @@ import com.gotcha.R
import com.gotcha.auth.ReferralClipboardHelper
import com.gotcha.auth.SamosaTier
import com.gotcha.auth.SamosaUser
+import com.gotcha.i18n.StringLookup
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.launch
diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
index 8d6805d..f50457c 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
@@ -40,6 +40,7 @@ import com.gotcha.audio.AudioModel
import com.gotcha.data.FeedbackChannel
import com.gotcha.data.Settings
import com.gotcha.i18n.Language
+import com.gotcha.i18n.stringLookup
import com.gotcha.ui.tour.TourAnchor
import com.gotcha.ui.tour.tourAnchor
import kotlinx.coroutines.delay
diff --git a/app/src/main/java/com/gotcha/ui/SettingsSearchEntry.kt b/app/src/main/java/com/gotcha/ui/SettingsSearchEntry.kt
index 20bad6a..cf4097b 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsSearchEntry.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsSearchEntry.kt
@@ -2,6 +2,7 @@ package com.gotcha.ui
import androidx.annotation.StringRes
import com.gotcha.R
+import com.gotcha.i18n.StringLookup
/**
* The search index behind the field at the top of the settings home list.
diff --git a/app/src/main/java/com/gotcha/ui/SharePosterState.kt b/app/src/main/java/com/gotcha/ui/SharePosterState.kt
index c8ce151..cb3e215 100644
--- a/app/src/main/java/com/gotcha/ui/SharePosterState.kt
+++ b/app/src/main/java/com/gotcha/ui/SharePosterState.kt
@@ -9,6 +9,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.core.content.FileProvider
import androidx.lifecycle.viewModelScope
+import com.gotcha.R
import com.gotcha.agent.ChatViewModel
import com.gotcha.data.GotchaStorage
import com.gotcha.data.RunSummary
@@ -39,7 +40,7 @@ class SharePosterState(
/** Opens the poster sheet for [runs] (single latest run or whole chat). */
fun open(runs: List<RunSummary>) {
if (runs.isEmpty()) {
- Toast.makeText(context, "Nothing to share yet.", Toast.LENGTH_SHORT).show()
+ Toast.makeText(context, context.getString(R.string.share_nothing_yet), Toast.LENGTH_SHORT).show()
return
}
this.runs = runs
@@ -60,7 +61,7 @@ class SharePosterState(
result.fold(
onSuccess = { preview = it },
onFailure = { e ->
- error = e.message ?: "Could not generate the poster."
+ error = e.message ?: context.getString(R.string.share_generate_failed)
}
)
}
@@ -81,12 +82,16 @@ class SharePosterState(
val intent = Intent(Intent.ACTION_SEND).apply {
type = "image/png"
putExtra(Intent.EXTRA_STREAM, uri)
- putExtra(Intent.EXTRA_SUBJECT, "Gotcha just did this for me")
+ putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.share_subject))
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
- context.startActivity(Intent.createChooser(intent, "Share your Gotcha moment"))
+ context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_chooser_title)))
} catch (e: Exception) {
- Toast.makeText(context, "Could not share: ${e.message}", Toast.LENGTH_SHORT).show()
+ Toast.makeText(
+ context,
+ context.getString(R.string.share_failed, e.message.orEmpty()),
+ Toast.LENGTH_SHORT
+ ).show()
}
}
@@ -98,9 +103,13 @@ class SharePosterState(
"gotcha_moment_${System.currentTimeMillis()}.png",
bitmap
)
- Toast.makeText(context, "Saved to $location", Toast.LENGTH_SHORT).show()
+ Toast.makeText(context, context.getString(R.string.share_saved_to, location), Toast.LENGTH_SHORT).show()
} catch (e: Exception) {
- Toast.makeText(context, "Could not save: ${e.message}", Toast.LENGTH_SHORT).show()
+ Toast.makeText(
+ context,
+ context.getString(R.string.share_save_failed, e.message.orEmpty()),
+ Toast.LENGTH_SHORT
+ ).show()
}
}
diff --git a/app/src/main/java/com/gotcha/ui/SkillsScreen.kt b/app/src/main/java/com/gotcha/ui/SkillsScreen.kt
index fefbf08..736bdc4 100644
--- a/app/src/main/java/com/gotcha/ui/SkillsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SkillsScreen.kt
@@ -40,6 +40,7 @@ import com.gotcha.R
import com.gotcha.agent.skills.Skill
import com.gotcha.agent.skills.SkillRegistry
import com.gotcha.data.Settings
+import com.gotcha.i18n.stringLookup
import com.gotcha.ui.theme.SkinAlertDialog
import kotlinx.coroutines.launch
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0f70892..a11ff92 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1108,4 +1108,121 @@
<!-- Feature tour: finish -->
<string name="tour_start_using">Start using Gotcha</string>
+
+ <!-- Share poster, connectors, crop, release notes -->
+ <string name="share_nothing_yet">Nothing to share yet.</string>
+ <string name="share_generate_failed">Could not generate the poster.</string>
+ <string name="share_subject">Gotcha just did this for me</string>
+ <string name="share_chooser_title">Share your Gotcha moment</string>
+ <string name="share_failed">Could not share: %1$s</string>
+ <string name="share_saved_to">Saved to %1$s</string>
+ <string name="share_save_failed">Could not save: %1$s</string>
+ <string name="connectors_title">Connectors</string>
+ <string name="connectors_intro">Connect your accounts so the assistant can read and act on your mail, calendars, tasks and notes.</string>
+ <string name="crop_hint">Draw around anything • tap to cancel</string>
+ <string name="release_notes_show_less">Show less</string>
+ <string name="release_notes_show_all">Show all release notes</string>
+
+ <!-- Daily tips -->
+ <string name="daily_tip_read_screen_title">Ask about your screen</string>
+ <string name="daily_tip_read_screen_body">Stuck on something? Gotcha can read your screen and explain it.</string>
+ <string name="daily_tip_read_screen_prompt">What\'s on my screen?</string>
+ <string name="daily_tip_catch_up_title">Catch up in seconds</string>
+ <string name="daily_tip_catch_up_body">Let Gotcha sum up your unread notifications.</string>
+ <string name="daily_tip_catch_up_prompt">Catch me up on my unread notifications</string>
+ <string name="daily_tip_big_files_title">Free up some space</string>
+ <string name="daily_tip_big_files_body">Gotcha can find your largest files and tell you what\'s safe to delete.</string>
+ <string name="daily_tip_big_files_prompt">Find the largest files in my Downloads folder and tell me what\'s safe to delete</string>
+ <string name="daily_tip_summarise_pdf_title">Summarise a PDF</string>
+ <string name="daily_tip_summarise_pdf_body">No time to read it? Gotcha can summarise your latest PDF.</string>
+ <string name="daily_tip_summarise_pdf_prompt">Read the most recent PDF in my Downloads and summarise it</string>
+ <string name="daily_tip_calendar_today_title">Plan your day</string>
+ <string name="daily_tip_calendar_today_body">Ask Gotcha what\'s on your calendar today.</string>
+ <string name="daily_tip_calendar_today_prompt">What\'s on my calendar today?</string>
+ <string name="daily_tip_calendar_add_title">Add to your calendar</string>
+ <string name="daily_tip_calendar_add_body">Tell Gotcha about a plan and it goes straight into your calendar.</string>
+ <string name="daily_tip_calendar_add_prompt">Add lunch with … on Friday at 1pm to my calendar</string>
+ <string name="daily_tip_set_alarm_title">Set an alarm by asking</string>
+ <string name="daily_tip_set_alarm_body">Gotcha can set alarms and timers for you.</string>
+ <string name="daily_tip_set_alarm_prompt">Set an alarm for 7am tomorrow</string>
+ <string name="daily_tip_send_whatsapp_title">Send a WhatsApp hands-free</string>
+ <string name="daily_tip_send_whatsapp_body">Gotcha can open WhatsApp and send the message for you.</string>
+ <string name="daily_tip_send_whatsapp_prompt">Send a WhatsApp to … saying …</string>
+ <string name="daily_tip_send_sms_title">Running late?</string>
+ <string name="daily_tip_send_sms_body">Gotcha can text someone for you.</string>
+ <string name="daily_tip_send_sms_prompt">Text … that I\'m running 10 minutes late</string>
+ <string name="daily_tip_recent_sms_title">Skim your messages</string>
+ <string name="daily_tip_recent_sms_body">Gotcha can summarise your latest texts.</string>
+ <string name="daily_tip_recent_sms_prompt">Summarise my latest text messages</string>
+ <string name="daily_tip_missed_calls_title">Who called?</string>
+ <string name="daily_tip_missed_calls_body">Ask Gotcha to go through your call log.</string>
+ <string name="daily_tip_missed_calls_prompt">Who called me today?</string>
+ <string name="daily_tip_battery_title">What\'s draining your battery?</string>
+ <string name="daily_tip_battery_body">Gotcha can check your battery and which apps use it most.</string>
+ <string name="daily_tip_battery_prompt">Check my battery and tell me which apps have been using the most</string>
+ <string name="daily_tip_screen_time_title">Check your screen time</string>
+ <string name="daily_tip_screen_time_body">Ask Gotcha how long you spent on your phone, and where.</string>
+ <string name="daily_tip_screen_time_prompt">How much time did I spend on my phone today, and on which apps?</string>
+ <string name="daily_tip_web_search_title">Research anything</string>
+ <string name="daily_tip_web_search_body">Gotcha can search the web and sum up what it finds.</string>
+ <string name="daily_tip_web_search_prompt">Search the web for … and summarise what you find</string>
+ <string name="daily_tip_do_not_disturb_title">Need to focus?</string>
+ <string name="daily_tip_do_not_disturb_body">Gotcha can turn on Do Not Disturb for you.</string>
+ <string name="daily_tip_do_not_disturb_prompt">Turn on Do Not Disturb for the next hour</string>
+ <string name="daily_tip_wifi_title">Change settings by asking</string>
+ <string name="daily_tip_wifi_body">Gotcha can find and flip settings for you, like Wi-Fi.</string>
+ <string name="daily_tip_wifi_prompt">Open settings and turn on Wi-Fi</string>
+ <string name="daily_tip_podcast_title">Listen instead of reading</string>
+ <string name="daily_tip_podcast_body">Gotcha can turn a document into a short podcast.</string>
+ <string name="daily_tip_podcast_prompt">Turn the most recent PDF in my Downloads into a short podcast</string>
+
+ <!-- Local notifications -->
+ <string name="local_unfinished_generic">A chat was left unfinished. Tap to pick it up.</string>
+ <string name="local_unfinished_asked">Gotcha asked you something in “%1$s”. Tap to answer.</string>
+ <string name="local_unfinished_stopped">“%1$s” stopped before it was done. Tap to pick it up.</string>
+ <string name="local_unfinished_title_asked">Gotcha is waiting for you</string>
+ <string name="local_unfinished_title">Finish what you started</string>
+ <string name="local_routine_title">Time for your usual?</string>
+ <string name="local_routine_body">You often ask: “%1$s”. Tap to ask again.</string>
+ <string name="local_routine_body_generic">One of your regular requests may be due. Tap to see it.</string>
+ <string name="local_inactive_title_recent">Pick up where you left off</string>
+ <string name="local_inactive_title">Anything Gotcha can do for you?</string>
+ <string name="local_inactive_body_recent">Your last chat was “%1$s”. Tap to open it.</string>
+ <string name="local_inactive_body">Ask Gotcha to handle something on your phone. Tap to open.</string>
+
+ <!-- Notifications: channels and titles -->
+ <string name="channel_attention">Waiting for your answer</string>
+ <string name="channel_attention_description">When Gotcha has paused a task to ask you something while you are in another app</string>
+ <string name="attention_public_title">Gotcha is waiting for you</string>
+ <string name="attention_question_title">Gotcha has a question</string>
+ <string name="attention_confirmation_title">Gotcha is waiting for your OK</string>
+ <string name="attention_question_body">Your task is paused until you answer. Tap to open it.</string>
+ <string name="attention_confirmation_body">Your task is paused until you allow or deny its next step. Tap to open it.</string>
+ <string name="channel_completion">Task finished</string>
+ <string name="channel_completion_description">When a chat task finishes while you are in another app</string>
+ <string name="completion_public_title">Gotcha finished a task</string>
+ <string name="completion_untitled_chat">Chat</string>
+ <string name="completion_done_title">Done: %1$s</string>
+ <string name="completion_failed_title">Failed: %1$s</string>
+ <string name="completion_stopped_title">Stopped: %1$s</string>
+ <string name="completion_done_anonymous">Task finished</string>
+ <string name="completion_failed_anonymous">Task failed</string>
+ <string name="completion_stopped_anonymous">Task stopped</string>
+ <string name="completion_done_body">Gotcha finished your task. Tap to see the reply.</string>
+ <string name="completion_failed_body">Gotcha couldn\'t finish your task. Tap to see what happened.</string>
+ <string name="completion_stopped_body">The task was stopped. Tap to open the chat.</string>
+ <string name="channel_daily_tips">Daily tips</string>
+ <string name="channel_daily_tips_description">One thing to try with Gotcha each day</string>
+ <string name="channel_reminders">Reminders</string>
+ <string name="channel_reminders_description">Unfinished chats, routines that are due, and a nudge after a quiet spell</string>
+ <string name="local_public_title">Gotcha has a suggestion</string>
+ <string name="channel_server">Server messages</string>
+ <string name="channel_server_description">Updates, tips, and maintenance notices from Gotcha</string>
+ <string name="run_public_title">Gotcha is working on a task…</string>
+ <string name="run_title">Gotcha is working on “%1$s”…</string>
+ <string name="run_title_cut">Gotcha is working on “%1$s”</string>
+ <string name="run_body">Tap to follow along. You can keep using your phone.</string>
+ <string name="action_stop">Stop</string>
+ <string name="channel_run">Task in progress</string>
+ <string name="channel_run_description">Shown while Gotcha works on a task, so Android keeps it running when you switch to another app</string>
</resources>
diff --git a/app/src/test/java/com/gotcha/notifications/AttentionNotifierTest.kt b/app/src/test/java/com/gotcha/notifications/AttentionNotifierTest.kt
index 18a80f9..47493e9 100644
--- a/app/src/test/java/com/gotcha/notifications/AttentionNotifierTest.kt
+++ b/app/src/test/java/com/gotcha/notifications/AttentionNotifierTest.kt
@@ -80,7 +80,7 @@ class AttentionNotifierTest {
)
val notification = posted().single()
- assertEquals(AttentionNotifier.defaultBody(AttentionKind.QUESTION), text(notification))
+ assertEquals(application.getString(AttentionNotifier.defaultBody(AttentionKind.QUESTION)), text(notification))
assertNull(notification.extras.getString(NotificationCompat.EXTRA_SUB_TEXT))
}
@@ -88,7 +88,10 @@ class AttentionNotifierTest {
fun `a confirmation never shows the actions, only that it is waiting`() {
notifier.notify("s1", AttentionKind.CONFIRMATION, "Chat", "Delete 3 files", CompletionPreview.FULL)
- assertEquals(AttentionNotifier.defaultBody(AttentionKind.CONFIRMATION), text(posted().single()))
+ assertEquals(
+ application.getString(AttentionNotifier.defaultBody(AttentionKind.CONFIRMATION)),
+ text(posted().single())
+ )
}
@Test
diff --git a/app/src/test/java/com/gotcha/notifications/ChatCompletionNotifierTest.kt b/app/src/test/java/com/gotcha/notifications/ChatCompletionNotifierTest.kt
index 3500904..756275f 100644
--- a/app/src/test/java/com/gotcha/notifications/ChatCompletionNotifierTest.kt
+++ b/app/src/test/java/com/gotcha/notifications/ChatCompletionNotifierTest.kt
@@ -7,6 +7,7 @@ import androidx.core.app.NotificationCompat
import androidx.test.core.app.ApplicationProvider
import com.gotcha.R
import com.gotcha.data.CompletionPreview
+import com.gotcha.i18n.stringLookup
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
@@ -72,10 +73,22 @@ class ChatCompletionNotifierTest {
@Test
fun `title says how the run ended`() {
- assertEquals("Done: Chat", ChatCompletionNotifier.notificationTitle("Chat", RunOutcome.DONE))
- assertEquals("Failed: Chat", ChatCompletionNotifier.notificationTitle("Chat", RunOutcome.FAILED))
- assertEquals("Stopped: Chat", ChatCompletionNotifier.notificationTitle("Chat", RunOutcome.STOPPED))
- assertEquals("Done: Chat", ChatCompletionNotifier.notificationTitle(" ", RunOutcome.DONE))
+ assertEquals(
+ "Done: Chat",
+ ChatCompletionNotifier.notificationTitle("Chat", RunOutcome.DONE, application.stringLookup())
+ )
+ assertEquals(
+ "Failed: Chat",
+ ChatCompletionNotifier.notificationTitle("Chat", RunOutcome.FAILED, application.stringLookup())
+ )
+ assertEquals(
+ "Stopped: Chat",
+ ChatCompletionNotifier.notificationTitle("Chat", RunOutcome.STOPPED, application.stringLookup())
+ )
+ assertEquals(
+ "Done: Chat",
+ ChatCompletionNotifier.notificationTitle(" ", RunOutcome.DONE, application.stringLookup())
+ )
}
@Test
@@ -111,7 +124,7 @@ class ChatCompletionNotifierTest {
notifier.notify("s1", "Chat", RunOutcome.FAILED, "secret reply", CompletionPreview.NONE)
val text = posted().single().extras.getCharSequence(NotificationCompat.EXTRA_TEXT).toString()
- assertEquals(ChatCompletionNotifier.defaultBody(RunOutcome.FAILED), text)
+ assertEquals(application.getString(ChatCompletionNotifier.defaultBody(RunOutcome.FAILED)), text)
}
@Test
@@ -123,7 +136,10 @@ class ChatCompletionNotifierTest {
val notification = posted().single()
assertEquals(R.drawable.ic_notification_failed, notification.smallIcon.resId)
assertEquals(R.drawable.ic_notification_failed, notification.publicVersion.smallIcon.resId)
- assertEquals("Gotcha finished a task", notification.publicVersion.extras.getString(NotificationCompat.EXTRA_TITLE))
+ assertEquals(
+ "Gotcha finished a task",
+ notification.publicVersion.extras.getString(NotificationCompat.EXTRA_TITLE)
+ )
}
@Test
diff --git a/app/src/test/java/com/gotcha/notifications/DailyTipsTest.kt b/app/src/test/java/com/gotcha/notifications/DailyTipsTest.kt
index 7cc583f..bcf05b2 100644
--- a/app/src/test/java/com/gotcha/notifications/DailyTipsTest.kt
+++ b/app/src/test/java/com/gotcha/notifications/DailyTipsTest.kt
@@ -22,7 +22,7 @@ class DailyTipsTest {
ZonedDateTime.of(y, mo, d, h, mi, 0, 0, zone).toInstant().toEpochMilli()
private fun tip(id: String, vararg tools: String) =
- DailyTip(id = id, title = id, body = id, prompt = id, tools = tools.toSet())
+ DailyTip(id = id, title = 0, body = 0, prompt = 0, tools = tools.toSet())
// ---- catalog ----
@@ -44,7 +44,7 @@ class DailyTipsTest {
val known = ToolDefinitions.all.map { it.function.name }.toSet()
DAILY_TIPS.forEach { tip ->
val texts = listOf(tip.title, tip.body, tip.prompt)
- assertTrue("Blank text in ${tip.id}", texts.all { it.isNotBlank() })
+ assertTrue("Missing text in ${tip.id}", texts.all { it != 0 })
assertTrue("${tip.id} lists no tools", tip.tools.isNotEmpty())
tip.tools.forEach { assertTrue("${tip.id} names unknown tool $it", it in known) }
}
diff --git a/app/src/test/java/com/gotcha/notifications/LocalNotificationCheckTest.kt b/app/src/test/java/com/gotcha/notifications/LocalNotificationCheckTest.kt
index 4df5d03..8551163 100644
--- a/app/src/test/java/com/gotcha/notifications/LocalNotificationCheckTest.kt
+++ b/app/src/test/java/com/gotcha/notifications/LocalNotificationCheckTest.kt
@@ -146,6 +146,6 @@ class LocalNotificationCheckTest {
val tried = DAILY_TIPS.filter { it.id != "podcast" }.flatMap { it.tools }
chat("old", endedAt = noon - 3 * DAY_MS, tools = tried)
val podcast = DAILY_TIPS.single { it.id == "podcast" }
- assertEquals(podcast.title, check()?.title)
+ assertEquals(application.getString(podcast.title), check()?.title)
}
}
diff --git a/app/src/test/java/com/gotcha/notifications/LocalNotificationsTest.kt b/app/src/test/java/com/gotcha/notifications/LocalNotificationsTest.kt
index 7f89853..bc88abd 100644
--- a/app/src/test/java/com/gotcha/notifications/LocalNotificationsTest.kt
+++ b/app/src/test/java/com/gotcha/notifications/LocalNotificationsTest.kt
@@ -1,19 +1,28 @@
package com.gotcha.notifications
+import android.content.Context
+import androidx.test.core.app.ApplicationProvider
import com.gotcha.data.RunSummary
import com.gotcha.data.Settings
+import com.gotcha.i18n.stringLookup
import com.gotcha.tools.AgentMode
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
import java.time.ZoneId
import java.time.ZonedDateTime
/** The pure rules behind Gotcha's proactive notifications (issue #100). */
+@RunWith(RobolectricTestRunner::class)
class LocalNotificationsTest {
+ /** The notification text, read from Robolectric's (English) resources. */
+ private val text = ApplicationProvider.getApplicationContext<Context>().stringLookup()
+
private val zone = ZoneId.of("Europe/Berlin")
private val now = at(2026, 9, 24, 12)
@@ -117,7 +126,12 @@ class LocalNotificationsTest {
@Test
fun `a failed run from a few hours ago is unfinished`() {
- val c = unfinishedChat(listOf(chat("a", run(now - 3 * HOUR_MS, succeeded = false))), mention = true, now)!!
+ val c = unfinishedChat(
+ listOf(chat("a", run(now - 3 * HOUR_MS, succeeded = false))),
+ mention = true,
+ now,
+ text
+ )!!
assertEquals(NotificationCategory.UNFINISHED_CHAT, c.category)
assertEquals(NotificationTarget.Chat("a"), c.target)
assertTrue(c.body.contains("Chat a"))
@@ -125,23 +139,28 @@ class LocalNotificationsTest {
@Test
fun `a reply ending on a question is unfinished`() {
- val c = unfinishedChat(listOf(chat("a", run(now - 3 * HOUR_MS, reply = "Which Priya?"))), true, now)!!
+ val c = unfinishedChat(listOf(chat("a", run(now - 3 * HOUR_MS, reply = "Which Priya?"))), true, now, text)!!
assertEquals("Gotcha is waiting for you", c.title)
}
@Test
fun `too fresh, too old, finished or superseded is not unfinished`() {
- assertNull(unfinishedChat(listOf(chat("a", run(now - HOUR_MS, succeeded = false))), true, now))
- assertNull(unfinishedChat(listOf(chat("a", run(now - 4 * DAY_MS, succeeded = false))), true, now))
- assertNull(unfinishedChat(listOf(chat("a", run(now - 3 * HOUR_MS))), true, now))
+ assertNull(unfinishedChat(listOf(chat("a", run(now - HOUR_MS, succeeded = false))), true, now, text))
+ assertNull(unfinishedChat(listOf(chat("a", run(now - 4 * DAY_MS, succeeded = false))), true, now, text))
+ assertNull(unfinishedChat(listOf(chat("a", run(now - 3 * HOUR_MS))), true, now, text))
// Only the chat's last run counts: a later success finished it.
val later = chat("a", run(now - 5 * HOUR_MS, succeeded = false), run(now - 3 * HOUR_MS))
- assertNull(unfinishedChat(listOf(later), true, now))
+ assertNull(unfinishedChat(listOf(later), true, now, text))
}
@Test
fun `without mentions the text names no chat`() {
- val c = unfinishedChat(listOf(chat("a", run(now - 3 * HOUR_MS, succeeded = false))), mention = false, now)!!
+ val c = unfinishedChat(
+ listOf(chat("a", run(now - 3 * HOUR_MS, succeeded = false))),
+ mention = false,
+ now,
+ text
+ )!!
assertFalse(c.body.contains("Chat a"))
assertEquals(NotificationTarget.Chat("a"), c.target)
}
@@ -154,7 +173,7 @@ class LocalNotificationsTest {
@Test
fun `a weekly request is due a week after the last`() {
val runs = weekly("Summarise my unread emails from 9 to 5", listOf(1, 2, 3), mode = "OPERATOR")
- val c = dueRoutine(listOf(chat("a", *runs.toTypedArray())), mention = true, now, zone)!!
+ val c = dueRoutine(listOf(chat("a", *runs.toTypedArray())), mention = true, now, zone, text)!!
assertEquals(NotificationCategory.ROUTINE, c.category)
assertEquals(
NotificationTarget.Draft("Summarise my unread emails from 9 to 5", AgentMode.OPERATOR),
@@ -170,18 +189,18 @@ class LocalNotificationsTest {
run(now - 14 * DAY_MS, prompt = "set an alarm for 6am!"),
run(now - 21 * DAY_MS, prompt = "Set an alarm for 7:30am")
)
- assertTrue(dueRoutine(listOf(chat("a", *runs.toTypedArray())), true, now, zone) != null)
+ assertTrue(dueRoutine(listOf(chat("a", *runs.toTypedArray())), true, now, zone, text) != null)
}
@Test
fun `not due early, not nagged when long abandoned, not from two days`() {
// Weekly, but the last time was only four days ago.
val early = listOf(4, 11, 18).map { run(now - it * DAY_MS, prompt = "Summarise my unread emails") }
- assertNull(dueRoutine(listOf(chat("a", *early.toTypedArray())), true, now, zone))
+ assertNull(dueRoutine(listOf(chat("a", *early.toTypedArray())), true, now, zone, text))
val stale = weekly("Summarise my unread emails", listOf(4, 5, 6))
- assertNull(dueRoutine(listOf(chat("a", *stale.toTypedArray())), true, now, zone))
+ assertNull(dueRoutine(listOf(chat("a", *stale.toTypedArray())), true, now, zone, text))
val twice = weekly("Summarise my unread emails", listOf(1, 2))
- assertNull(dueRoutine(listOf(chat("a", *twice.toTypedArray())), true, now, zone))
+ assertNull(dueRoutine(listOf(chat("a", *twice.toTypedArray())), true, now, zone, text))
}
@Test
@@ -195,17 +214,17 @@ class LocalNotificationsTest {
@Test
fun `a reminder after the chosen number of days, once per spell`() {
val opened = now - 5 * DAY_MS
- val c = inactivityReminder(listOf(chat("a", run(opened))), opened, 4, mention = true, now)!!
+ val c = inactivityReminder(listOf(chat("a", run(opened))), opened, 4, mention = true, now, text)!!
assertEquals("inactive:$opened", c.dedupKey)
assertEquals(NotificationTarget.Chat("a"), c.target)
- assertNull(inactivityReminder(emptyList(), now - 3 * DAY_MS, 4, true, now))
- assertNull(inactivityReminder(emptyList(), 0L, 4, true, now))
+ assertNull(inactivityReminder(emptyList(), now - 3 * DAY_MS, 4, true, now, text))
+ assertNull(inactivityReminder(emptyList(), 0L, 4, true, now, text))
}
@Test
fun `without mentions the reminder goes home`() {
val opened = now - 5 * DAY_MS
- val c = inactivityReminder(listOf(chat("a", run(opened))), opened, 4, mention = false, now)!!
+ val c = inactivityReminder(listOf(chat("a", run(opened))), opened, 4, mention = false, now, text)!!
assertEquals(NotificationTarget.Home, c.target)
assertFalse(c.body.contains("Chat a"))
}
@@ -219,7 +238,7 @@ class LocalNotificationsTest {
chat("u", run(now - 3 * HOUR_MS, succeeded = false)),
chat("r", *weekly("Summarise my unread emails", listOf(1, 2, 3)).toTypedArray())
)
- val all = behaviorCandidates(chats, opened, 4, true, now, zone)
+ val all = behaviorCandidates(chats, opened, 4, true, now, zone, text)
assertEquals(
listOf(NotificationCategory.UNFINISHED_CHAT, NotificationCategory.ROUTINE, NotificationCategory.INACTIVITY),
all.map { it.category }
@@ -233,7 +252,7 @@ class LocalNotificationsTest {
chat("u", run(now - 3 * HOUR_MS, succeeded = false), sensitive = true),
chat("r", *weekly("Summarise my unread emails", listOf(1, 2, 3)).toTypedArray(), sensitive = true)
)
- val all = behaviorCandidates(chats, opened, 4, true, now, zone)
+ val all = behaviorCandidates(chats, opened, 4, true, now, zone, text)
assertEquals(listOf(NotificationCategory.INACTIVITY), all.map { it.category })
assertEquals(NotificationTarget.Home, all.single().target)
}
diff --git a/app/src/test/java/com/gotcha/notifications/LocalNotifierTest.kt b/app/src/test/java/com/gotcha/notifications/LocalNotifierTest.kt
index 34c1295..d282c89 100644
--- a/app/src/test/java/com/gotcha/notifications/LocalNotifierTest.kt
+++ b/app/src/test/java/com/gotcha/notifications/LocalNotifierTest.kt
@@ -6,6 +6,7 @@ import android.app.Notification
import android.app.NotificationManager
import androidx.core.app.NotificationCompat
import androidx.test.core.app.ApplicationProvider
+import com.gotcha.i18n.stringLookup
import com.gotcha.testsupport.FakeAndroidKeyStore
import com.gotcha.tools.AgentMode
import org.junit.Assert.assertEquals
@@ -39,13 +40,17 @@ class LocalNotifierTest {
fun `a tip opens a drafted chat and marks its inbox entry read`() {
grant()
val tip = DAILY_TIPS.single { it.id == "do_not_disturb" }
- assertTrue(LocalNotifier(application).post(tipCandidate(tip, 0L, java.time.ZoneOffset.UTC), store))
+ assertTrue(
+ LocalNotifier(
+ application
+ ).post(tipCandidate(tip, 0L, java.time.ZoneOffset.UTC, application.stringLookup()), store)
+ )
val notification = shadowOf(manager).allNotifications.single()
assertEquals(LocalNotifier.TIP_CHANNEL_ID, notification.channelId)
- assertEquals(tip.title, notification.extras.getString(NotificationCompat.EXTRA_TITLE))
+ assertEquals(application.getString(tip.title), notification.extras.getString(NotificationCompat.EXTRA_TITLE))
val intent = shadowOf(notification.contentIntent).savedIntent
- assertEquals(tip.prompt, intent.getStringExtra(LocalNotifier.EXTRA_DRAFT_PROMPT))
+ assertEquals(application.getString(tip.prompt), intent.getStringExtra(LocalNotifier.EXTRA_DRAFT_PROMPT))
assertEquals(AgentMode.OPERATOR.name, intent.getStringExtra(LocalNotifier.EXTRA_DRAFT_MODE))
assertEquals(store.entries().single().id, intent.getStringExtra(LocalNotificationStore.EXTRA_INBOX_ENTRY_ID))
}
@@ -71,7 +76,7 @@ class LocalNotifierTest {
@Test
fun `nothing is posted or filed without the permission`() {
shadowOf(application).denyPermissions(Manifest.permission.POST_NOTIFICATIONS)
- val tip = tipCandidate(DAILY_TIPS.first(), 0L, java.time.ZoneOffset.UTC)
+ val tip = tipCandidate(DAILY_TIPS.first(), 0L, java.time.ZoneOffset.UTC, application.stringLookup())
assertFalse(LocalNotifier(application).post(tip, store))
assertTrue(shadowOf(manager).allNotifications.isEmpty())
assertTrue(store.entries().isEmpty())
diff --git a/app/src/test/java/com/gotcha/service/ChatRunServiceTest.kt b/app/src/test/java/com/gotcha/service/ChatRunServiceTest.kt
index d397101..29a9a0a 100644
--- a/app/src/test/java/com/gotcha/service/ChatRunServiceTest.kt
+++ b/app/src/test/java/com/gotcha/service/ChatRunServiceTest.kt
@@ -7,8 +7,8 @@ import android.content.Intent
import androidx.core.app.NotificationCompat
import androidx.test.core.app.ApplicationProvider
import com.gotcha.R
+import com.gotcha.i18n.stringLookup
import com.gotcha.notifications.ChatCompletionNotifier
-import java.util.concurrent.TimeUnit
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.first
@@ -27,6 +27,7 @@ import org.robolectric.Shadows.shadowOf
import org.robolectric.android.controller.ServiceController
import org.robolectric.annotation.Config
import org.robolectric.shadows.ShadowLooper
+import java.util.concurrent.TimeUnit
/** The keep-alive service for a chat run (issue #105). */
@RunWith(RobolectricTestRunner::class)
@@ -89,7 +90,10 @@ class ChatRunServiceTest {
@Test
fun `a chat that may not be named is not`() {
- assertEquals("Gotcha is working on a task…", ChatRunService.title(chat.copy(chatTitle = null)))
+ assertEquals(
+ "Gotcha is working on a task…",
+ ChatRunService.title(chat.copy(chatTitle = null), application.stringLookup())
+ )
}
@Test
@@ -210,7 +214,9 @@ class ChatRunServiceTest {
assertEquals(
"Done: Plan my trip",
- posted(ChatCompletionNotifier.notificationId("session-1"))?.extras?.getString(NotificationCompat.EXTRA_TITLE)
+ posted(
+ ChatCompletionNotifier.notificationId("session-1")
+ )?.extras?.getString(NotificationCompat.EXTRA_TITLE)
)
}
@@ -222,7 +228,9 @@ class ChatRunServiceTest {
assertEquals(
"Failed: Plan my trip",
- posted(ChatCompletionNotifier.notificationId("session-1"))?.extras?.getString(NotificationCompat.EXTRA_TITLE)
+ posted(
+ ChatCompletionNotifier.notificationId("session-1")
+ )?.extras?.getString(NotificationCompat.EXTRA_TITLE)
)
assertNull(ChatRunService.running.value)
}
@@ -240,9 +248,14 @@ class ChatRunServiceTest {
assertEquals(
"Done: Plan my trip",
- posted(ChatCompletionNotifier.notificationId("session-1"))?.extras?.getString(NotificationCompat.EXTRA_TITLE)
+ posted(
+ ChatCompletionNotifier.notificationId("session-1")
+ )?.extras?.getString(NotificationCompat.EXTRA_TITLE)
+ )
+ assertEquals(
+ ChatCompletionNotifier.notificationId("session-2"),
+ shadowOf(controller.get()).lastForegroundNotificationId
)
- assertEquals(ChatCompletionNotifier.notificationId("session-2"), shadowOf(controller.get()).lastForegroundNotificationId)
assertFalse(shadowOf(controller.get()).isStoppedBySelf)
}
@@ -275,7 +288,7 @@ class ChatRunServiceTest {
fun `a name cut short keeps a single ellipsis`() {
assertEquals(
"Gotcha is working on “Find the largest files in my…”",
- ChatRunService.title(chat.copy(chatTitle = "Find the largest files in my…"))
+ ChatRunService.title(chat.copy(chatTitle = "Find the largest files in my…"), application.stringLookup())
)
}
}
diff --git a/app/src/test/java/com/gotcha/ui/PermissionAskTest.kt b/app/src/test/java/com/gotcha/ui/PermissionAskTest.kt
index aedf6d2..5ab1203 100644
--- a/app/src/test/java/com/gotcha/ui/PermissionAskTest.kt
+++ b/app/src/test/java/com/gotcha/ui/PermissionAskTest.kt
@@ -3,6 +3,7 @@ package com.gotcha.ui
import android.content.Context
import android.content.Intent
import androidx.test.core.app.ApplicationProvider
+import com.gotcha.i18n.stringLookup
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
diff --git a/app/src/test/java/com/gotcha/ui/SettingsSearchEntryTest.kt b/app/src/test/java/com/gotcha/ui/SettingsSearchEntryTest.kt
index 8caa662..14eb833 100644
--- a/app/src/test/java/com/gotcha/ui/SettingsSearchEntryTest.kt
+++ b/app/src/test/java/com/gotcha/ui/SettingsSearchEntryTest.kt
@@ -2,6 +2,7 @@ package com.gotcha.ui
import android.content.Context
import androidx.test.core.app.ApplicationProvider
+import com.gotcha.i18n.stringLookup
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue