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
dfded887
Commit
dfded887
authored
Sep 04, 2025
by
alep
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle permission android well
parent
74d782e7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
17 deletions
+32
-17
App.tsx
App.tsx
+0
-0
OverlayPermissionModule.kt
...app/src/main/java/com/whoscall/OverlayPermissionModule.kt
+28
-16
StoragePackage.kt
android/app/src/main/java/com/whoscall/StoragePackage.kt
+4
-1
No files found.
App.tsx
View file @
dfded887
This diff is collapsed.
Click to expand it.
android/app/src/main/java/com/whoscall/OverlayPermissionModule.kt
View file @
dfded887
// OverlayPermissionModule.kt
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
android.content.Intent
import
android.net.Uri
import
android.os.Build
import
android.provider.Settings
import
com.facebook.react.bridge.*
class
OverlayPermissionModule
(
reactContext
:
ReactApplicationContext
)
:
ReactContextBaseJavaModule
(
reactContext
)
{
class
OverlayPermissionModule
(
private
val
reactContext
:
ReactApplicationContext
)
:
ReactContextBaseJavaModule
(
reactContext
)
{
override
fun
getName
():
String
{
return
"OverlayPermission"
}
override
fun
getName
():
String
=
"OverlayPermission"
@ReactMethod
fun
hasPermission
(
promise
:
Promise
)
{
val
canDraw
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
Settings
.
canDrawOverlays
(
reactApplicationContext
)
}
else
{
true
fun
hasOverlayPermission
(
promise
:
Promise
)
{
try
{
val
allowed
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
Settings
.
canDrawOverlays
(
reactContext
)
}
else
true
promise
.
resolve
(
allowed
)
}
catch
(
e
:
Exception
)
{
promise
.
reject
(
"OVERLAY_CHECK_ERROR"
,
e
)
}
}
promise
.
resolve
(
canDraw
)
@ReactMethod
fun
openOverlaySettings
()
{
try
{
val
ctx
=
reactContext
.
currentActivity
?:
reactContext
val
intent
=
Intent
(
Settings
.
ACTION_MANAGE_OVERLAY_PERMISSION
,
Uri
.
parse
(
"package:${reactContext.packageName}"
)
).
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
ctx
.
startActivity
(
intent
)
}
catch
(
_
:
Exception
)
{
// best-effort
}
}
}
android/app/src/main/java/com/whoscall/StoragePackage.kt
View file @
dfded887
...
...
@@ -7,7 +7,10 @@ import com.facebook.react.uimanager.ViewManager
class
StoragePackage
:
ReactPackage
{
override
fun
createNativeModules
(
reactContext
:
ReactApplicationContext
):
List
<
NativeModule
>
{
return
listOf
(
StorageModule
(
reactContext
))
return
listOf
(
StorageModule
(
reactContext
),
OverlayPermissionModule
(
reactContext
)
// 👈 add this
)
}
override
fun
createViewManagers
(
reactContext
:
ReactApplicationContext
):
List
<
ViewManager
<*,
*>>
{
...
...
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