| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
FloatingWidgetCompose is a lightweight Android library for rendering Jetpack Compose UI inside a system overlay window. It is useful for chat-head style widgets, quick actions, assistive floating controls, and small always-on-top Compose surfaces.
The sample app includes:
FloatingWidgetCompose is distributed through JitPack. Use a GitHub release tag as the dependency version, for example v1.0.0.
Add JitPack to settings.gradle.kts:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}Add the dependency to your app module build.gradle.kts:
dependencies {
implementation("com.github.pascaladitia:FloatingWidgetCompose:v1.0.0")
}For local development inside this repository, the sample app uses the local module:
implementation(project(":floating-compose-widget"))System overlays require SYSTEM_ALERT_WINDOW.
Add this permission to your app module AndroidManifest.xml:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />Users must grant overlay permission manually from Android system settings. The library provides openOverlayPermissionSettings(context) to send users to the correct screen when possible.
Some OEM Android builds, especially Xiaomi, Oppo, and Vivo, may place overlay permission and background restrictions in custom settings screens.
Check permission and open settings when needed:
if (!FloatingWidgetCompose.canDrawOverlays(context)) {
FloatingWidgetCompose.openOverlayPermissionSettings(context)
return
}Start a basic floating widget:
val started = FloatingWidgetCompose.start(
context = context,
config = FloatingWidgetConfig(
touchable = true,
sizeMode = SizeMode.WRAP,
startX = 24,
startY = 160
)
) {
Surface(
modifier = Modifier.padding(16.dp),
shape = RoundedCornerShape(16.dp),
color = Color.Black
) {
Text(
text = "Floating Compose",
modifier = Modifier.padding(16.dp),
color = Color.White
)
}
}Stop the floating widget:
FloatingWidgetCompose.stop(context)Use SizeMode.FULL when you want a full-screen transparent gesture layer and draggable floating content:
FloatingWidgetCompose.start(
context = context,
config = FloatingWidgetConfig(
touchable = true,
sizeMode = SizeMode.FULL
)
) {
DraggableFloatingContent()
}FloatingWidgetConfig(
touchable = true,
sizeMode = SizeMode.WRAP,
startX = 0,
startY = 200
)Options:
Wrong:
@Composable
fun Screen() {
FloatingWidgetCompose.start(context, config) {
Text("This can run again during recomposition")
}
}Correct:
Button(
onClick = {
FloatingWidgetCompose.start(context, config) {
Text("Started by user action")
}
}
) {
Text("Start Floating")
}This repository includes a GitHub Actions workflow at .github/workflows/release.yml.
When changes are merged into main, the workflow:
Before merging a release commit into main, update these values in the workflow:
env:
RELEASE_VERSION: v1.1.0
RELEASE_TITLE: FloatingWidgetCompose v1.1.0
RELEASE_NOTES: |
Add your release notes here.JitPack can then consume the new GitHub tag:
implementation("com.github.pascaladitia:FloatingWidgetCompose:v1.1.0")MIT License. See LICENSE.
Pascal Aditia
GitHub: https://github.com/pascaladitia
| Back | FazBrowse Home | New Git URL |