Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,25 @@ object AnkiquestNotifier {
val tag = 5_140_000 + (id % 1_000_000).toInt()
val title = entry.getString("title")
val body = entry.getString("body")
val shownBody =
entry.optJSONObject("reply_to")?.optString("body")?.takeIf { it.isNotBlank() }?.let { original ->
AnkiquestLanguage.context(context).getString(R.string.ankiquest_reply_context, body, original)
} ?: body
val answerable = entry.optString("sender").isNotEmpty() && !entry.optBoolean("replied")
if (fresh &&
notify(
context,
tag,
title,
body,
shownBody,
notificationIntent(context, entry, account),
if (answerable) {
AnkiquestReply.actions(
context,
id,
tag,
title,
body,
shownBody,
account,
scope,
entry.optString("kind", "completion"),
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values-de/ankiquest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="ankiquest_deck_notifications_choose_people">Wähle mindestens eine Person oder schalte das Teilen aus.</string>
<string name="ankiquest_deck_notifications_save">@string/save</string>
<string name="ankiquest_reply">Antwort</string>
<string name="ankiquest_reply_context">%1$s\n\nAls Antwort auf: %2$s</string>
<string name="ankiquest_nudges_title">Anstupser</string>
<string name="ankiquest_nudges_summary">Benachrichtige mich, wenn ein Platz, mein bester Tag oder die nächste Stufe in Reichweite ist</string>
<string name="ankiquest_celebrations_title">Erfolge feiern</string>
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values-es/ankiquest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<string name="ankiquest_deck_notifications_choose_people">Selecciona al menos una persona o desactiva el envío.</string>
<string name="ankiquest_deck_notifications_save">Guardar</string>
<string name="ankiquest_reply">Responder</string>
<string name="ankiquest_reply_context">%1$s\n\nEn respuesta a: %2$s</string>
<string name="ankiquest_nudges_title">Toques</string>
<string name="ankiquest_nudges_summary">Avísame cuando pueda alcanzar un puesto, mi mejor día o el siguiente nivel</string>
<string name="ankiquest_celebrations_title">Celebraciones</string>
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values-fr/ankiquest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="ankiquest_deck_notifications_choose_people">Choisis au moins une personne ou désactive le partage.</string>
<string name="ankiquest_deck_notifications_save">@string/save</string>
<string name="ankiquest_reply">Réponse</string>
<string name="ankiquest_reply_context">%1$s\n\nEn réponse à : %2$s</string>
<string name="ankiquest_nudges_title">Coups de pouce</string>
<string name="ankiquest_nudges_summary">Préviens-moi quand une place, mon meilleur jour ou le prochain niveau est à portée</string>
<string name="ankiquest_celebrations_title">Célébrations</string>
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values-pt/ankiquest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="ankiquest_deck_notifications_choose_people">Escolhe pelo menos uma pessoa ou desativa a partilha.</string>
<string name="ankiquest_deck_notifications_save">@string/save</string>
<string name="ankiquest_reply">Responder</string>
<string name="ankiquest_reply_context">%1$s\n\nEm resposta a: %2$s</string>
<string name="ankiquest_nudges_title">Lembretes</string>
<string name="ankiquest_nudges_summary">Avisa-me quando uma posição, o meu melhor dia ou o próximo nível estiver ao alcance</string>
<string name="ankiquest_celebrations_title">Celebrações</string>
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/ankiquest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<string name="ankiquest_deck_notifications_choose_people">Select at least one person, or switch sharing off.</string>
<string name="ankiquest_deck_notifications_save">@string/save</string>
<string name="ankiquest_reply">Reply</string>
<string name="ankiquest_reply_context">%1$s\n\nIn reply to: %2$s</string>
<string name="ankiquest_nudges_key" translatable="false">ankiquestNudges</string>
<string name="ankiquest_nudges_title" maxLength="41">Nudges</string>
<string name="ankiquest_nudges_summary">Tell me when a place, my best day or the next level is within reach</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ import kotlin.test.assertTrue
@RunWith(AndroidJUnit4::class)
@Config(sdk = [32])
class AnkiquestNotifierTest : RobolectricTest() {
@Test
fun `a reply alert shows the message it answers`() {
val manager = targetContext.getSystemService<NotificationManager>()!!
val account = replyAccount()
val reply =
message(1, 30)
.put("sender", "cerro")
.put("kind", "reply")
.put("body", "Good job!")
.put("reply_to", JSONObject().put("title", "Deck complete").put("body", "Cerro finished Spanish."))
AnkiquestNotifier.onDeckCompletions(targetContext, account.notificationAccount, JSONArray().put(reply), account.scope)
val posted = shadowOf(manager).getNotification(5_140_001)
val shown = posted.extras.getCharSequence(Notification.EXTRA_BIG_TEXT).toString()
assertTrue(shown.contains("Cerro finished Spanish."))
assertTrue(shown.contains("Good job!"))
}

@Test
fun `Spanish contextual replies follow the Anki language and retain notification kind`() {
val manager = targetContext.getSystemService<NotificationManager>()!!
Expand Down
Loading