Refined gradle config

This commit is contained in:
wengki81 2025-06-15 01:15:05 +08:00
parent 8ecd890bc9
commit da9f7a6023
2 changed files with 62 additions and 1 deletions

2
.gitignore vendored
View File

@ -15,7 +15,7 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.history
# macOS files
.DS_Store

View File

@ -1,6 +1,11 @@
package com.dumon.plugin.geolocation
import android.Manifest
import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.WindowInsetsController
import android.view.WindowManager
import com.getcapacitor.*
import com.getcapacitor.annotation.CapacitorPlugin
import com.getcapacitor.annotation.Permission
@ -129,6 +134,62 @@ class DumonGeolocation : Plugin() {
}
}
@PluginMethod
fun configureEdgeToEdge(call: PluginCall) {
val bgColorHex = call.getString("bgColor") ?: "#FFFFFF"
val style = call.getString("style") ?: "DARK"
val window = bridge?.activity?.window
if (window == null) {
call.reject("No active window")
return
}
// Background color
val parsedColor = Color.parseColor(bgColorHex)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.statusBarColor = parsedColor
window.navigationBarColor = parsedColor
}
// Edge-to-edge fit
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.setDecorFitsSystemWindows(true)
val controller = window.insetsController
if (controller != null) {
if (style.uppercase() == "DARK") {
controller.setSystemBarsAppearance(
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS or
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS or
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
)
} else {
controller.setSystemBarsAppearance(
0,
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS or
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
)
}
}
} else {
@Suppress("DEPRECATION")
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
@Suppress("DEPRECATION")
val flags = if (style.uppercase() == "DARK") {
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
} else {
0
}
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = flags
}
call.resolve()
}
private fun emitPositionUpdate() {
val now = System.currentTimeMillis()
if (now - lastEmitTimestamp < emitIntervalMs) return