File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed
commons/src/main/kotlin/org/fossify/commons/helpers Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 11package org.fossify.commons.helpers
22
33import android.app.Activity
4- import android.telephony.PhoneNumberUtils
54import org.fossify.commons.extensions.addBlockedNumber
6- import org.fossify.commons.extensions.isPhoneNumber
75import org.fossify.commons.extensions.showErrorToast
86import 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 ) {
You can’t perform that action at this time.
0 commit comments