Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1aad772
chore: add devcontainer configuration for Java development
ArthurKun21 Jan 29, 2026
0194913
chore: update devcontainer configuration for Java + Android
ArthurKun21 Jan 29, 2026
2df0f15
chore: add Dockerfile for Java + Android development environment
ArthurKun21 Jan 29, 2026
a40ef3e
chore: update Android Command Line Tools and SDK components in Docker…
ArthurKun21 Jan 29, 2026
12d3ed0
chore: update Dockerfile to improve Android SDK installation process
ArthurKun21 Jan 29, 2026
c4855d0
chore: update Dockerfile and devcontainer.json for improved Android S…
ArthurKun21 Jan 29, 2026
e8b0918
chore: remove yarn repository to avoid GPG key errors in Dockerfile
ArthurKun21 Jan 29, 2026
0209daa
chore: update Gradle wrapper to version 9.3.0
ArthurKun21 Jan 29, 2026
1170c02
chore(deps): bump hilt from 2.58 to 2.59 and ksp from 2.3.4 to 2.3.5
ArthurKun21 Jan 29, 2026
7ed808c
chore(deps): bump compose-bom from 2026.01.00 to 2026.01.01
ArthurKun21 Jan 29, 2026
ff5b9d2
chore(deps): bump agp from 8.13.2 to 9.0.0
ArthurKun21 Jan 29, 2026
a2e4825
chore: initial changes to agp 9.0
ArthurKun21 Jan 29, 2026
94a4bca
chore: add import for LibrariesForLibs in lint configuration
ArthurKun21 Jan 29, 2026
e0e8692
chore: update JavaVersion and JvmTarget to version 17
ArthurKun21 Jan 29, 2026
96ca2df
chore: remove unnecessary blank line in build.gradle.kts
ArthurKun21 Jan 29, 2026
d6c8e99
chore: remove Chinese README file
ArthurKun21 Jan 29, 2026
64c3321
docs: update README with correct repository links and remove outdated…
ArthurKun21 Jan 29, 2026
b924b74
docs: update README to clarify dependency import instructions and imp…
ArthurKun21 Jan 29, 2026
b669b08
ci: update workflows to ignore .devcontainer directory
ArthurKun21 Jan 29, 2026
760a94b
chore(deps): bump spotless from 8.1.0 to 8.2.1
ArthurKun21 Jan 29, 2026
82c2f2c
chore(deps): remove kotlin-metadata dependency due to compatibility i…
ArthurKun21 Jan 29, 2026
cd8f252
chore: remove compose build feature from sample projects
ArthurKun21 Jan 29, 2026
2abb3d4
chore: update packaging configuration to exclude specific resource files
ArthurKun21 Jan 29, 2026
f4af4ae
chore: add library tests plugin and reorganize test dependencies
ArthurKun21 Jan 29, 2026
0fc9a97
chore: add android tests plugin and configure test dependencies
ArthurKun21 Jan 29, 2026
0353d1b
chore: add sample.common.deps plugin and consolidate dependencies in …
ArthurKun21 Jan 29, 2026
95045e2
chore: enable compose build features and update packaging configuration
ArthurKun21 Jan 29, 2026
8192953
chore: remove vscjava.vscode-java-pack extension from devcontainer co…
ArthurKun21 Jan 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM mcr.microsoft.com/devcontainers/java:17-bookworm

# Always start as root for provisioning
USER root
ENV DEBIAN_FRONTEND=noninteractive

# ---- System dependencies ----
# Remove yarn repository to avoid GPG key errors
RUN rm -f /etc/apt/sources.list.d/yarn.list \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
unzip \
zip \
libglu1-mesa \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# ---- Android SDK env ----
ENV ANDROID_SDK_ROOT=/usr/local/android-sdk
ENV ANDROID_HOME=${ANDROID_SDK_ROOT}
ENV PATH=${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools

# ---- Android command line tools ----
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools \
&& curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-14742923_latest.zip -o /tmp/cmdline-tools.zip \
&& unzip /tmp/cmdline-tools.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools \
&& mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest \
&& rm /tmp/cmdline-tools.zip

# ---- SDK packages ----
RUN yes | sdkmanager --licenses \
&& sdkmanager --update \
&& sdkmanager \
"platform-tools" \
"platforms;android-36" \
"build-tools;36.0.0"

# ---- Permissions (CRITICAL) ----
RUN chown -R vscode:vscode ${ANDROID_SDK_ROOT}

# Drop privileges
USER vscode
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Java + Android",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "17",
"installGradle": true
}
},
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot",
"oderwat.indent-rainbow",
"redhat.vscode-yaml"
]
}
},
"remoteUser": "vscode"
}
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '.gitignore'
- 'renovate.json'
- 'FUNDING.yml'
- '.devcontainer/**'
workflow_dispatch:

env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- '.github/**'
- '!.github/workflows/**'
- 'renovate.json'
- '.devcontainer/**'

env:
JAVA_VERSION: 17
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.gradle
/local.properties
.DS_Store
/build
build
.kotlin
/captures
.externalNativeBuild
.cxx
Expand All @@ -11,5 +12,3 @@ local.properties
# Ignore all files in the .idea directory except for name
.idea/*
!.idea/.name

.kotlin/*
93 changes: 25 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# compose-floating-window

[![Release](https://jitpack.io/v/only52607/compose-floating-window.svg)](https://jitpack.io/#User/Repo)
[![Release](https://jitpack.io/v/ArthurKun21/compose-overlay-window.svg)](https://jitpack.io/#ArthurKun21/compose-overlay-window)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Global Floating Window Framework based on Jetpack Compose

[简体中文](README_CN.md)

## Preview

![Preview](/preview/example.gif)
Expand All @@ -22,38 +20,35 @@ Global Floating Window Framework based on Jetpack Compose

### Import Dependencies

- If the Gradle version is less than 7.0, add the Jitpack repository in the `build.gradle` of your app.
- Add on settings.gradle.kts

```groovy
repositories {
maven { url 'https://jitpack.io' }
}
```

- If the Gradle version is greater than or equal to 7.0, add it in the settings.gradle file.
```groovy
```kotlin
dependencyResolutionManagement {
repositories {
maven { url 'https://jitpack.io' }
maven { url = uri("https://jitpack.io") }
}
}
```

- Add `compose-floating-window` Dependency
```groovy

```kotlin
dependencies {
implementation "com.github.only52607:compose-floating-window:1.0"
implementation("com.github.ArthurKun21:compose-overlay-window:<tag>")
}
```

### Grant Floating Window Permission

Add to `AndroidManifest.xml`

```xml
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
```

### Create Floating Window and Show
### Activity

When you want to show the floating window while on the Activity, you can use the following code:

```kotlin
val floatingWindow = ComposeFloatingWindow(applicationContext)
Expand All @@ -69,65 +64,27 @@ floatingWindow.setContent {
floatingWindow.show()
```

> See [Sample App](https://github.com/only52607/compose-floating-window/tree/master/app).

## Advanced Usage

### Make Floating Window Draggable

Use the `Modifier.dragFloatingWindow()` modifier on the component you want to make draggable. Example:

```kotlin
FloatingActionButton(
modifier = Modifier.dragFloatingWindow()
) {
Icon(Icons.Filled.Call, "Call")
}
```

### Get the current instance of `ComposeFloatingWindow`
### Service

Using LocalComposeFloatingWindow to retrieve, here's an example:
When you want to show the floating window while on the Service, you can use the following code:

```kotlin
val floatingWindow = LocalComposeFloatingWindow.current
```

### Show Dialog

When the Context of the floating window is set to Application, using AlertDialog and Dialog in the Compose interface of the floating window may result in a 'token is null' exception. In such cases, you can use the SystemAlertDialog or SystemDialog components, which can be used in the same way as the built-in AlertDialog and Dialog components.

Example:
```kotlin
SystemAlertDialog(
onDismissRequest = { showDialog = false },
confirmButton = {
TextButton(onClick = { showDialog = false }) {
Text(text = "OK")
}
},
text = {
Text(text = "This is a system dialog")
val floatingWindow = ComposeServiceFloatingWindow(applicationContext)
floatingWindow.setContent {
FloatingActionButton(
modifier = Modifier.dragFloatingWindow(),
onClick = {
Log.i("")
}) {
Icon(Icons.Filled.Call, "Call")
}
)
```

### ViewModel

You can access the ViewModel from any Composable by calling the viewModel() function.

```kotlin
class MyViewModel : ViewModel() { /*...*/ }

@Composable
fun MyScreen(
viewModel: MyViewModel = viewModel()
) {
// use viewModel here
}
floatingWindow.show()
```

> See https://developer.android.com/jetpack/compose/libraries#viewmodel
## Advanced Usage

> See [Sample Apps](samples).

## License

Expand Down
132 changes: 0 additions & 132 deletions README_CN.md

This file was deleted.

Loading