Skip to content

Commit

Permalink
build:更新包名
Browse files Browse the repository at this point in the history
  • Loading branch information
Petterpx committed Jul 21, 2024
1 parent 107c8c7 commit cd75ca7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 86 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

## 👏 特性

- 支持 **JetPack Compose**
- 支持 **浮窗半隐藏模式**
- 支持 **自定义隐藏显示动画**;
- 支持 **多指触摸**,精准决策触摸手势;
- 支持 自定义是否保存历史位置及还原;
Expand All @@ -35,7 +37,7 @@

```groovy
dependencies {
implementation 'io.github.petterpx:floatingx:2.1.1'
implementation 'io.github.petterpx:floatingx:2.2.1'
}
```

Expand Down
171 changes: 87 additions & 84 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,71 @@
# FloatingX


# FloatingX

![image-20210810161316095](https://tva1.sinaimg.cn/large/008i3skNly1gtbrg85hlhj61040k80ui02.jpg)

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a9edd107b5444b7ca31738f5a96b3cb9)](https://app.codacy.com/gh/Petterpx/FloatingX?utm_source=github.com&utm_medium=referral&utm_content=Petterpx/FloatingX&utm_campaign=Badge_Grade_Settings)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.petterpx/floatingx)](https://search.maven.org/search?q=g:io.github.petterpx%20AND%20a:floatingx)
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)

[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)

**FloatingX** A flexible and powerful ``permission-free`` hover window solution.
**FloatingX** is a flexible and powerful floating window solution.

> "Note: After version 1.3.4, the repository has been migrated to [Maven](https://central.sonatype.com/artifact/io.github.petterpx/floatingx). Make sure to update your dependency accordingly."
[English Introduction](https://github.com/Petterpx/FloatingX/blob/main/README_EN.md)

[中文简介](https://github.com/Petterpx/FloatingX/READDME.md)

[中午使用文档见这里](https://cskf7l0wab.feishu.cn/wiki/wikcnLLBCe3fIDUTAzrEg754tzc)
[See detailed documentation here](https://cskf7l0wab.feishu.cn/wiki/wikcnLLBCe3fIDUTAzrEg754tzc)

## 👏 Features

- Single instance holding floating window view
- Support for various callback listeners
- Chain calls, senseless insertion
- Support customizing whether to save history position and restore
- Support inserting `ViewGroup` , `Fragment` , `Activity`
- Allow custom hover window indicators, custom hidden display animation
- Support cross-border rebound, multi-finger touch, small screen adaptation, screen rotation
- Support custom position direction, with auxiliary positioning display coordinates
- Perfect `kotlin` build extensions, and friendly compatibility with `Java`.
- Support display location [force fix], for special models (need to open separately)
- Perfect logging system, open to see different levels of Fx running process, more convenient to find problems
- ...

## 👨‍💻‍ Dependencies
- Supports **JetPack Compose**
- Supports **semi-hidden floating window mode**
- Supports **custom hide/show animations**;
- Supports **multi-touch**, precise touch gesture recognition;
- Supports custom history position saving and restoration;
- Supports **system floating window**, **in-app floating window**, **local floating window**;
- Supports **boundary rebound**, **edge hovering**, **boundary settings**;
- Supports setting floating window content in **layout** or **View** ways;
- Supports custom floating window display position, **supports auxiliary positioning**;
- Supports **blacklist and whitelist** functions to prevent floating window display on specific pages;
- Supports `kotlin` build extensions and is friendly compatible with `Java`;
- Supports display position [forced fix] to cope with special models (requires separate activation);
- Supports **local floating window**, which can be displayed in `ViewGroup`, `Fragment`, `Activity`;
- Comprehensive logging system, you can see different levels of Fx running processes when turned on, making it easier to find and solve problems.

## 👨‍💻‍ Dependency Method

### Gradle

```groovy
dependencies {
implementation 'io.github.petterpx:floatingx:2.1.1'
implementation 'io.github.petterpx:floatingx:2.2.1'
}
```

## 🏄‍♀️ Demo

## 🏄‍♀️ 效果图

| 全屏,activity,fragment,单view | 小屏展示 | 非正常比例缩放屏幕 |
| Full screen, activity, fragment, single view | Small screen display | Abnormal aspect ratio screen |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![效果-展示1](https://github.com/Petterpx/FloatingX/blob/main/image/fx-api-simple.gif?raw=true) | ![演示-小屏](https://github.com/Petterpx/FloatingX/blob/main/image/fx-small-gif.gif?raw=true) | ![非正常比例缩放](https://github.com/Petterpx/FloatingX/blob/main/image/fx-view-deformed-simple.gif?raw=true) |
| ![Effect-Display1](https://github.com/Petterpx/FloatingX/blob/main/image/fx-api-simple.gif?raw=true) | ![Demo-Small Screen](https://github.com/Petterpx/FloatingX/blob/main/image/fx-small-gif.gif?raw=true) | ![Abnormal Aspect Ratio](https://github.com/Petterpx/FloatingX/blob/main/image/fx-view-deformed-simple.gif?raw=true) |

| 屏幕旋转 | 功能演示 | |
| Screen rotation | Feature demo | |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ---- |
| ![演示-旋转](https://github.com/Petterpx/FloatingX/blob/main/image/fx-rotate-simple.gif?raw=true) | ![演示-局部功能](https://github.com/Petterpx/FloatingX/blob/main/image/fx-api-simple.gif?raw=true) | |



### Complete log-viewer

Open the log viewer, you will see the whole track of Fx, which is easier to find the problem and track the solution. Also support custom log tag。
| ![Demo-Rotation](https://github.com/Petterpx/FloatingX/blob/main/image/fx-rotate-simple.gif?raw=true) | ![Demo-Local Features](https://github.com/Petterpx/FloatingX/blob/main/image/fx-api-simple.gif?raw=true) | |

### Comprehensive Log Viewer

Enable the log viewer to see the entire Fx running track, making it easier to find and track problems. Also supports custom log tags.

| App | Activity | ViewGroup |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![image-20210808123000851](https://tva1.sinaimg.cn/large/008i3skNly1gwgtxtbx5aj31160s8444.jpg) | ![image-20210808123414921](https://tva1.sinaimg.cn/large/008i3skNly1gwgtxu2pkyj313o0r4jwk.jpg) | ![image-20210808123553402](https://tva1.sinaimg.cn/large/008i3skNly1gwgtxunhmwj311y0jctc8.jpg) |


| ![image-20210808123000851](https://tva1.sinaimg.cn/large/008i3skNly1gtbk1ujkqfj31160s8444.jpg) | ![image-20210808123414921](https://tva1.sinaimg.cn/large/008i3skNly1gt99vralyqj313o0r4jwk.jpg) | ![image-20210808123553402](https://tva1.sinaimg.cn/large/008i3skNly1gt99xfpfwgj311y0jctc8.jpg) |

## 👨‍🔧‍ Usage

### Global hover window management
### Global Floating Window Management

**AndroidManifest**
**AndroidManifest (optional)**

```xml
// If not using system floating window, you can ignore this step (skip if FxScopeType.App)
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
```
Expand All @@ -82,28 +74,26 @@ Open the log viewer, you will see the whole track of Fx, which is easier to find

```kotlin
FloatingX.install {
setContext(context)
setLayout(R.layout.item_floating)
setScopeType(FxScopeType.SYSTEM_AUTO)
setContext(context)
setLayout(R.layout.item_floating)
setScopeType(FxScopeType.SYSTEM_AUTO)
}.show()
```

**Java**

```java
AppHelper helper = AppHelper.builder()
.setContext(context)
.setLayout(R.layout.item_floating)
.setScopeType(FxScopeType.SYSTEM_AUTO)
.build();
.setContext(context)
.setLayout(R.layout.item_floating)
.setScopeType(FxScopeType.SYSTEM_AUTO)
.build();
FloatingX.install(helper).show();
```

### Local Floating Window Management


### Local hover window management

#### Generic creation method
#### General Creation Method

**kt**

Expand All @@ -113,66 +103,79 @@ ScopeHelper.builder {
}.toControl(activity)
```

**kt && java**
**kt & java**

```kotlin
ScopeHelper.builder()
.setLayout(R.layout.item_floating)
.build()
.toControl(activity)
.toControl(fragment)
.toControl(viewgroup)
.setLayout(R.layout.item_floating)
.build()
.toControl(activity)
.toControl(fragment)
.toControl(viewgroup)
```

#### extended support for kt
#### Kotlin Extension Support

##### activity create hover window
##### Create floating window in activity

```kotlin
private val activityFx by activityToFx(activity) {
private val scopeFx by createFx {
setLayout(R.layout.item_floating)
build().toControl(this/Activity)
}
```

##### fragment to create a hover window
##### Create floating window in fragment

```kotlin
private val fragment by fragmentToFx(fragment) {
private val activityFx by createFx {
setLayout(R.layout.item_floating)
build().toControl(this/Fragment)
}
```

##### viewGroup creates a hover window
##### Create floating window in viewGroup

```kotlin
private val viewFx by createFx({
init(viewGroup)
}) {
setLayout(R.layout.item_floating)
setEnableLog(true, "main_fx")
}
private val activityFx by createFx {
setLayout(R.layout.item_floating)
build().toControl(this/Viewgroup)
}
```

##### Quickly create an arbitrary scope hover window
## 🤔 Technical Implementation
> **System** level floating window is implemented based on `WindowsManager`. It globally holds a separate floating window `View` and inserts it into `WindowManager` at appropriate times by listening to `Activity` lifecycle through `AppLifecycle`.
```kotlin
private val customCreateFx by createFx {
setLayout(R.layout.item_floating)
build().toControl(activity)
build().toControl(fragment)
build().toControl(viewgroup)
```
> **App** level floating window is implemented based on `DecorView`. It globally holds a separate floating window `View` and inserts it into `DecorView` at appropriate times by listening to `Activity` lifecycle through `AppLifecycle`.
>
> **View** level floating window is based on the given `ViewGroup`.
>
> **Fragment** level floating window is based on its corresponding `rootView`.
>
> **Activity** level floating window is based on `DecorView`'s internal `R.id.content`.
Specific details are as follows:

<img src="https://tva1.sinaimg.cn/large/008i3skNly1gr20ks7780j30rc0i5dim.jpg" alt="Activity-setContentView" />

See my blog for more details: [Source Code Analysis | Activity-setContentView](https://juejin.cn/post/6897453195342610445)

Ps: Why should the app-level floating window be inserted into `DecorView` instead of **R.id.content** -> `FrameLayout`?

> Inserting into `DecorView` maximizes the floating window's freedom of movement, allowing it to be truly [`fullscreen`] draggable.
>
> Inserting into `content` limits its draggable range to **application view range**, affected by **status bar**, **bottom navigation bar**, and default `AppBar`. For example, if the user hides the status bar or navigation bar, the corresponding view size will change, affecting the floating window's position.
## Thanks
## 👍 Thanks

Base **HoverView** sourced from [FloatingMagnetView](https://github.com/leotyndale/EnFloatingView) of [EnFloatingView](EnFloatingView/blob/master/floatingview/src/main/java/com/imuxuan/floatingview/FloatingMagnetView.java) implementation with some improvements on top of it.
The initial implementation idea of the basic **floating window View** comes from [EnFloatingView](https://github.com/leotyndale/EnFloatingView)'s [FloatingMagnetView](https://github.com/leotyndale/EnFloatingView/blob/master/floatingview/src/main/java/com/imuxuan/floatingview/FloatingMagnetView.java), which was thoroughly refactored and evolved.

For the measurement of the navigation bar part of the code from, wenlu, and on top of it added more adaptations, has covered 95% of the market models, can be said to be the only tool that can be searched for accurate measurement.
The measurement code for the navigation bar comes from Wenlu and has been further adapted to cover 95% of the market models. It can be said to be the only tool that can accurately measure the navigation bar.

## About me
## About Me

Welcome to follow my public number, look forward to progress together, if there are any problems in use, you can also add me WeChat.
Welcome to follow my public account and look forward to progressing together. If you have any usage problems, you can also add me on WeChat.

Wechat: **Petterpx**
**WeChat**: **Petterpx**

![Petterp-wechat](https://user-images.githubusercontent.com/41142188/226162520-93796619-81ca-4e61-bfff-4a5b95e4fa0b.png)
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
implementation "androidx.compose.material3:material3"
debugImplementation 'androidx.compose.ui:ui-tooling'
// debugImplementation 'com.squareup.leakcanary:leakcanary-object-watcher-android-startup:2.10'
implementation isDev ? project(path: ':floatingx_compose') : "io.github.petterpx:floatingx-compose:$version_name"
implementation isDev ? project(path: ':floatingx') : "io.github.petterpx:floatingx:$version_name"
debugImplementation "com.bytedance.tools.codelocator:codelocator-core:2.0.3"
}
2 changes: 1 addition & 1 deletion floatingx_compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

mavenPublishing {
coordinates("io.github.petterpx", "floatingx_compose", version_name)
coordinates("io.github.petterpx", "floatingx-compose", version_name)
}

android {
Expand Down

0 comments on commit cd75ca7

Please sign in to comment.