Refined gradle config
This commit is contained in:
parent
8ecd890bc9
commit
da9f7a6023
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,7 +15,7 @@ DerivedData/
|
|||||||
.swiftpm/configuration/registries.json
|
.swiftpm/configuration/registries.json
|
||||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||||
.netrc
|
.netrc
|
||||||
|
.history
|
||||||
|
|
||||||
# macOS files
|
# macOS files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@ -1,6 +1,11 @@
|
|||||||
package com.dumon.plugin.geolocation
|
package com.dumon.plugin.geolocation
|
||||||
|
|
||||||
import android.Manifest
|
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.*
|
||||||
import com.getcapacitor.annotation.CapacitorPlugin
|
import com.getcapacitor.annotation.CapacitorPlugin
|
||||||
import com.getcapacitor.annotation.Permission
|
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() {
|
private fun emitPositionUpdate() {
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
if (now - lastEmitTimestamp < emitIntervalMs) return
|
if (now - lastEmitTimestamp < emitIntervalMs) return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user