Skip to content

Commit 2cd6114

Browse files
committed
fix(detail): don't report a looked-up number as "Seen 0 times"
The Report button fills a GitHub issue with how many calls and texts from the number CallShield has logged. A number looked up by hand has none, and issues #24 and #27 both arrived saying "Seen 0 times", which reads as if the reporter had never seen the number. That case now says the number isn't in the app's log yet. The issue title and body go to the English-language tracker, so they are marked translatable="false". The Chinese locale had translated the title to "[垃圾]", which broke the tracker's "[SPAM]" convention. Refs #24, #27.
1 parent 1121381 commit 2cd6114

6 files changed

Lines changed: 72 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ All notable changes to CallShield will be documented in this file.
238238

239239
- Tapping the "blocked recently" notification opens the Blocked log now. It
240240
used to do nothing at all.
241+
- The Report button on a number's detail page no longer opens a GitHub issue
242+
saying the number was "Seen 0 times" when you looked it up by hand. It says
243+
the number isn't in the app's log yet. The issue title and body also stay
244+
in English whatever language the app runs in, since they go to the
245+
English-language tracker (issues #24 and #27 arrived this way).
241246
- Blocking a number with the Block button at the bottom of Lookup saved the
242247
name of the check that flagged it ("prefix", "database") as the block's
243248
note, and Lookup then showed that under Details. It saves the result's

‎app/src/main/java/com/sysadmindoc/callshield/ui/screens/details/NumberDetailScreen.kt‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ fun NumberDetailScreen(
9494
}
9595
}
9696
val reportIssueTitle = stringResource(R.string.detail_report_issue_title, number)
97-
val reportIssueBody =
98-
pluralStringResource(
99-
R.plurals.detail_report_issue_body,
100-
numberCalls.size,
101-
number,
102-
numberCalls.size,
103-
)
97+
val reportIssueBody = reportIssueBody(context.resources, number, numberCalls.size)
10498

10599
// Contact name resolution
106100
var contactName by remember(number) { mutableStateOf<String?>(null) }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.sysadmindoc.callshield.ui.screens.details
2+
3+
import android.content.res.Resources
4+
import com.sysadmindoc.callshield.R
5+
6+
/**
7+
* Body of the GitHub issue the Report button opens. The count is how many
8+
* calls and texts from the number CallShield has logged. A number looked up
9+
* by hand has none, and "Seen 0 times" read as if the reporter had never
10+
* seen it, so that case says what it is instead.
11+
*/
12+
fun reportIssueBody(
13+
resources: Resources,
14+
number: String,
15+
loggedEntries: Int,
16+
): String =
17+
if (loggedEntries == 0) {
18+
resources.getString(R.string.detail_report_issue_body_unseen, number)
19+
} else {
20+
resources.getQuantityString(R.plurals.detail_report_issue_body, loggedEntries, number, loggedEntries)
21+
}

‎app/src/main/res/values-zh-rCN/strings.xml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,6 @@
844844
<string name="detail_block_area_code_description_location">拦截区号 %1$s(%2$s)</string>
845845
<string name="detail_blocked_from_detail">从详情拦截</string>
846846
<string name="detail_whitelisted_from_detail">从详情加入白名单</string>
847-
<string name="detail_report_issue_title">[垃圾] %s</string>
848847
<string name="confidence_suffix">(%d%%)</string>
849848
<string name="nav_home">主页</string>
850849
<string name="nav_lookup">查询</string>

‎app/src/main/res/values/strings.xml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,11 +1210,13 @@
12101210
<string name="detail_unknown_location">Unknown region</string>
12111211
<string name="detail_blocked_from_detail">Blocked from detail</string>
12121212
<string name="detail_whitelisted_from_detail">Trusted from detail screen</string>
1213-
<string name="detail_report_issue_title">[SPAM] %s</string>
1213+
<!-- The report title and body open a GitHub issue on the English-language tracker, so they stay in English in every locale. -->
1214+
<string name="detail_report_issue_title" translatable="false">[SPAM] %s</string>
12141215
<plurals name="detail_report_issue_body">
12151216
<item quantity="one">## Phone Number\n%1$s\n\n## Type\nReported from CallShield\n\n## Description\nSeen %2$d time</item>
12161217
<item quantity="other">## Phone Number\n%1$s\n\n## Type\nReported from CallShield\n\n## Description\nSeen %2$d times</item>
12171218
</plurals>
1219+
<string name="detail_report_issue_body_unseen" translatable="false">## Phone Number\n%1$s\n\n## Type\nReported from CallShield\n\n## Description\nLooked up in CallShield. No calls or texts from this number are in the app\'s log yet.</string>
12181220
<string name="confidence_suffix"> (%d%%)</string>
12191221
<plurals name="detail_reports_count_plural">
12201222
<item quantity="one">%d report</item>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.sysadmindoc.callshield.ui.screens.details
2+
3+
import android.content.Context
4+
import androidx.test.core.app.ApplicationProvider
5+
import org.junit.Assert.assertFalse
6+
import org.junit.Assert.assertTrue
7+
import org.junit.Test
8+
import org.junit.runner.RunWith
9+
import org.robolectric.RobolectricTestRunner
10+
import org.robolectric.annotation.Config
11+
12+
@RunWith(RobolectricTestRunner::class)
13+
@Config(sdk = [34])
14+
class ReportIssueBodyTest {
15+
private val resources = ApplicationProvider.getApplicationContext<Context>().resources
16+
17+
@Test
18+
fun `a number with nothing in the log isn't reported as seen zero times`() {
19+
// Issues #24 and #27 both arrived as "Seen 0 times": the reporter had
20+
// looked the number up by hand, so nothing from it was in the log.
21+
val body = reportIssueBody(resources, "+18056377456", 0)
22+
23+
assertTrue(body, body.contains("+18056377456"))
24+
assertTrue(body, body.contains("No calls or texts"))
25+
assertFalse(body, body.contains("Seen 0"))
26+
}
27+
28+
@Test
29+
fun `logged calls and texts are counted`() {
30+
assertTrue(reportIssueBody(resources, "+18056377456", 1).endsWith("Seen 1 time"))
31+
assertTrue(reportIssueBody(resources, "+18056377456", 3).endsWith("Seen 3 times"))
32+
}
33+
34+
@Test
35+
fun `the body keeps the tracker's headings whatever the count`() {
36+
for (count in listOf(0, 2)) {
37+
val body = reportIssueBody(resources, "+18056377456", count)
38+
assertTrue(body, body.startsWith("## Phone Number\n+18056377456\n\n## Type\n"))
39+
assertTrue(body, body.contains("\n\n## Description\n"))
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)