Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
whoscall
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wei Han
whoscall
Commits
74d782e7
Commit
74d782e7
authored
Sep 04, 2025
by
alep
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: before pull
parent
501198d0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
ContactModule.kt
android/app/src/main/java/com/whoscall/ContactModule.kt
+37
-0
No files found.
android/app/src/main/java/com/whoscall/ContactModule.kt
0 → 100644
View file @
74d782e7
package
com.whoscall
import
com.facebook.react.bridge.ReactApplicationContext
import
com.facebook.react.bridge.ReactContextBaseJavaModule
import
com.facebook.react.bridge.ReactMethod
import
com.facebook.react.bridge.Promise
import
org.json.JSONArray
class
ContactModule
(
reactContext
:
ReactApplicationContext
)
:
ReactContextBaseJavaModule
(
reactContext
)
{
override
fun
getName
():
String
=
"ContactModule"
@ReactMethod
fun
getDisplayName
(
contactsJson
:
String
,
incomingNumber
:
String
,
promise
:
Promise
)
{
try
{
val
arr
=
JSONArray
(
contactsJson
)
val
normIncoming
=
normalize
(
incomingNumber
)
for
(
i
in
0
until
arr
.
length
())
{
val
obj
=
arr
.
getJSONObject
(
i
)
val
number
=
normalize
(
obj
.
getString
(
"number"
))
val
name
=
obj
.
getString
(
"name"
)
if
(
normIncoming
==
number
)
{
promise
.
resolve
(
name
)
return
}
}
promise
.
resolve
(
null
)
}
catch
(
e
:
Exception
)
{
promise
.
reject
(
"ERR"
,
e
)
}
}
private
fun
normalize
(
n
:
String
):
String
{
return
n
.
replace
(
Regex
(
"[^+0-9]"
),
""
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment