Skip to content

Commit 32434a4

Browse files
jguegelJan Guegel
andauthored
fix: drop isPhoneNumber() check when importing blocked numbers (#266)
Co-authored-by: Jan Guegel <[email protected]>
1 parent 61c8fd8 commit 32434a4

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

commons/src/main/kotlin/org/fossify/commons/helpers/BlockedNumbersImporter.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package org.fossify.commons.helpers
22

33
import android.app.Activity
4-
import android.telephony.PhoneNumberUtils
54
import org.fossify.commons.extensions.addBlockedNumber
6-
import org.fossify.commons.extensions.isPhoneNumber
75
import org.fossify.commons.extensions.showErrorToast
86
import java.io.File
97

@@ -16,18 +14,20 @@ class BlockedNumbersImporter(
1614

1715
fun importBlockedNumbers(path: String): ImportResult {
1816
return try {
19-
val inputStream = File(path).inputStream()
20-
val numbers = inputStream.bufferedReader().use {
21-
val content = it.readText().trimEnd().split(BLOCKED_NUMBERS_EXPORT_DELIMITER)
22-
content.filter { text -> text.isPhoneNumber() }
23-
}
24-
if (numbers.isNotEmpty()) {
25-
numbers.forEach { number ->
26-
activity.addBlockedNumber(number)
17+
val numbers = File(path)
18+
.bufferedReader()
19+
.use { reader ->
20+
reader.readText()
21+
.split(BLOCKED_NUMBERS_EXPORT_DELIMITER)
22+
.map { it.trim() }
23+
.filter { it.isNotEmpty() }
2724
}
28-
ImportResult.IMPORT_OK
29-
} else {
25+
26+
if (numbers.isEmpty()) {
3027
ImportResult.IMPORT_FAIL
28+
} else {
29+
numbers.forEach(activity::addBlockedNumber)
30+
ImportResult.IMPORT_OK
3131
}
3232

3333
} catch (e: Exception) {

0 commit comments

Comments
 (0)