Skip to content

Commit

Permalink
2.0.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewis committed Feb 25, 2021

Verified

This commit was signed with the committer’s verified signature.
ilkhem Ilyes Khemakhem
1 parent a2a4dce commit de51565
Showing 84 changed files with 2,617 additions and 1,547 deletions.
136 changes: 58 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,16 +15,16 @@
- **支持出入动画的设定,有默认动画,可自行替换(策略模式)**
- **使用简单、链式调用、可轻松修改浮窗View**
- **支持Kotlin DSL,可按需回调状态,摆脱Java的繁琐**
- **支持xml直接使用,满足拖拽控件的需求**
- **支持状态栏沉浸,侧滑打开、拖拽关闭**
- **支持解锁更多姿势,如:拖拽缩放、通知弹窗...**

|权限申请|系统浮窗|前台和过滤|
|:---:|:---:|:---:|
|![](https://github.com/princekin-f/EasyFloat/blob/master/gif/%E6%9D%83%E9%99%90%E7%94%B3%E8%AF%B7.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/gif/%E7%B3%BB%E7%BB%9F%E6%B5%AE%E7%AA%97.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/gif/%E6%B5%AE%E7%AA%97%E7%BC%A9%E6%94%BE.gif)|
|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%9D%83%E9%99%90%E7%94%B3%E8%AF%B7.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E7%B3%BB%E7%BB%9F%E6%B5%AE%E7%AA%97.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%B5%AE%E7%AA%97%E7%BC%A9%E6%94%BE.gif)|

|状态回调|View修改|拓展使用|
|:---:|:---:|:---:|
|![](https://github.com/princekin-f/EasyFloat/blob/master/gif/%E6%B5%AE%E7%AA%97Callbacks.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/gif/%E6%96%B9%E4%BE%BF%E7%9A%84view%E4%BF%AE%E6%94%B9.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/gif/dialog%E5%92%8Cxml%E4%BD%BF%E7%94%A8.gif)|
|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%B5%AE%E7%AA%97Callbacks.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%96%B9%E4%BE%BF%E7%9A%84view%E4%BF%AE%E6%94%B9.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/dialog%E5%92%8Cxml%E4%BD%BF%E7%94%A8.gif)|

## 下载体验:
- [直接下载测试APK](https://raw.githubusercontent.com/princekin-f/EasyFloat/master/example/release/EasyFloat.apk),或者扫码下载:
@@ -44,7 +44,7 @@ allprojects {
- **在应用模块的`build.gradle`添加:**
```
dependencies {
implementation 'com.github.princekin-f:EasyFloat:1.3.4'
implementation 'com.github.princekin-f:EasyFloat:2.0.0-beta'
}
```

@@ -54,12 +54,8 @@ EasyFloat.with(this).setLayout(R.layout.float_test).show()
```

## 关于初始化:
- 全局初始化为非必须;
- **当浮窗为仅前台、仅后台显示,或者设置了浮窗过滤页面;**
- 需要在项目的`Application`中进行全局初始化,进行页面生命周期检测。
```
EasyFloat.init(this, isDebug)
```
> 2.0.0开始,无需初始化

## 关于权限声明:
- 权限声明为非必须;
@@ -73,31 +69,29 @@ EasyFloat.init(this, isDebug)
```
EasyFloat.with(this)
// 设置浮窗xml布局文件,并可设置详细信息
.setLayout(R.layout.float_app, OnInvokeView { })
// 设置浮窗显示类型,默认只在当前Activity显示,可选一直显示、仅前台显示、仅后台显示
.setLayout(R.layout.float_app) { }
// 设置浮窗显示类型,默认只在当前Activity显示,可选一直显示、仅前台显示
.setShowPattern(ShowPattern.ALL_TIME)
// 设置吸附方式,共15种模式,详情参考SidePattern
.setSidePattern(SidePattern.RESULT_HORIZONTAL)
// 设置浮窗的标签,用于区分多个浮窗
.setTag("testFloat")
// 设置浮窗是否可拖拽,默认可拖拽
// 设置浮窗是否可拖拽
.setDragEnable(true)
// 系统浮窗是否包含EditText,仅针对系统浮窗,默认不包含
// 浮窗是否包含EditText,默认不包含
.hasEditText(false)
// 设置浮窗固定坐标,ps:设置固定坐标,Gravity属性和offset属性将无效
.setLocation(100, 200)
// 设置浮窗的对齐方式和坐标偏移量
.setGravity(Gravity.END or Gravity.CENTER_VERTICAL, 0, 200)
// 设置宽高是否充满父布局,直接在xml设置match_parent属性无效
.setMatchParent(widthMatch = false, heightMatch = false)
// 设置Activity浮窗的出入动画,可自定义,实现相应接口即可(策略模式),无需动画直接设置为null
// 设置浮窗的出入动画,可自定义,实现相应接口即可(策略模式),无需动画直接设置为null
.setAnimator(DefaultAnimator())
// 设置系统浮窗的出入动画,使用同上
.setAppFloatAnimator(AppFloatDefaultAnimator())
// 设置系统浮窗的不需要显示的页面
.setFilter(MainActivity::class.java, SecondActivity::class.java)
// 设置系统浮窗的有效显示高度(不包含虚拟导航栏的高度),基本用不到,除非有虚拟导航栏适配问题
.setDisplayHeight(OnDisplayHeight { context -> DisplayUtils.rejectedNavHeight(context) })
.setDisplayHeight { context -> DisplayUtils.rejectedNavHeight(context) }
// 浮窗的一些状态回调,如:创建结果、显示、隐藏、销毁、touchEvent、拖拽过程、拖拽结束。
// ps:通过Kotlin DSL实现的回调,可以按需复写方法,用到哪个写哪个
.registerCallback {
@@ -112,7 +106,9 @@ EasyFloat.with(this)
// 创建浮窗(这是关键哦😂)
.show()
```

**在Java中使用Kotlin DSL不是很方便,状态回调还有一种常规的接口方式:**

```
.registerCallbacks(new OnFloatCallbacks() {
@Override
@@ -137,10 +133,12 @@ EasyFloat.with(this)
public void dragEnd(@NotNull View view) { }
})
```

如果想要在Java是使用Kotlin DSL,可以参考Demo。

### 悬浮窗权限的检测、申请:
- **无需主动进行权限申请,创建结果、申请结果可在`OnFloatCallbacks``createdResult`获取。**

```
// 权限检测
PermissionUtils.checkPermission(this)
@@ -149,49 +147,27 @@ PermissionUtils.checkPermission(this)
PermissionUtils.requestPermission(this,OnPermissionResult)
```

### Activity浮窗的相关API:
```
// 关闭浮窗
dismiss(activity: Activity? = null, floatTag: String? = null)
// 隐藏浮窗
hide(activity: Activity? = null, floatTag: String? = null)
// 显示浮窗
show(activity: Activity? = null, floatTag: String? = null)
// 设置是否可拖拽
setDragEnable(activity: Activity? = null, dragEnable: Boolean, floatTag: String? = null )
// 浮窗是否显示
isShow(activity: Activity? = null, floatTag: String? = null)
// 获取我们设置的浮窗View
getFloatView(activity: Activity? = null, tag: String? = null)
```

**PS:`? = null` 代表可选参数,不填也行,默认值为null。下同。**

### 系统浮窗的相关API:
### 浮窗的相关API:
```
// 关闭浮窗
dismissAppFloat(tag: String? = null)
// 关闭浮窗,force为强制关闭,有退出动画也不执行
dismiss(tag: String? = null, force: Boolean = false)
// 隐藏浮窗
hideAppFloat(tag: String? = null)
hide(tag: String? = null)
// 显示浮窗
showAppFloat(tag: String? = null)
show(tag: String? = null)
// 设置是否可拖拽
appFloatDragEnable(dragEnable: Boolean, tag: String? = null)
dragEnable(dragEnable: Boolean, tag: String? = null)
// 浮窗是否显示
appFloatIsShow(tag: String? = null)
isShow(tag: String? = null)
// 获取我们设置的浮窗View
getAppFloatView(tag: String? = null)
getFloatView(tag: String? = null)
// ******************* 系统浮窗独有 *******************
// 添加单个浮窗过滤页面
filterActivity(activity: Activity, tag: String? = null)
@@ -206,39 +182,43 @@ removeFilters(tag: String? = null, vararg clazz: Class<*>)
// 清空过滤页面
clearFilters(tag: String? = null)
```
### 系统浮窗中使用`EditText`
- **首先设置`.hasEditText(true)`,用于内部监听返回键;**
- **当点击`EditText`时,主动调用`openInputMethod`方法:**
```
InputMethodUtils.openInputMethod(editText, tag)
```
软键盘关闭时调用`closedInputMethod`方法(`1.1.1`开始无需再调用):
```
InputMethodUtils.closedInputMethod(tag)
```
**PS:`? = null` 代表可选参数,不填也行,默认值为null。**

### 直接在xml布局使用拖拽控件:

## 拖拽关闭、侧滑创建:
```
<com.lzf.easyfloat.widget.activityfloat.FloatingView
android:id="@+id/floatingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@mipmap/ic_launcher_round" />
</com.lzf.easyfloat.widget.activityfloat.FloatingView>
// 在拖拽回调中,注册拖拽关闭
drag { view, motionEvent ->
DragUtils.registerDragClose(motionEvent, object : OnTouchRangeListener {
override fun touchInRange(inRange: Boolean, view: BaseSwitchView) {
// 震动、视图调整等...
}
override fun touchUpInRange() {
// 关闭浮窗等...
EasyFloat.dismiss(tag, true)
}
})
}
// 在Activity的dispatchTouchEvent中,注册侧滑创建
DragUtils.registerSwipeAdd(ev, object : OnTouchRangeListener {
override fun touchInRange(inRange: Boolean, view: BaseSwitchView) {
// 震动、视图调整等...
}
override fun touchUpInRange() {
// 浮窗创建等,详情参考:SwipeTestActivity
showFloat()
}
})
```


## 关于混淆:
```
-keep class com.lzf.easyfloat.** {*;}
```
> 自带混淆规则,正常情况下无需手动导入。
## 关于感谢:
- **权限适配:[FloatWindowPermission](https://github.com/zhaozepeng/FloatWindowPermission)**
@@ -251,9 +231,9 @@ InputMethodUtils.closedInputMethod(tag)
- 如果该库对你提供了帮助,你可以小小的赏赞一下作者,同样作者也会非常感谢你!我们一起众筹云测😘

<div align="center">
<img src="https://github.com/princekin-f/EasyFloat/blob/master/gif/EasyFloatGroup.jpeg" width="266">
<img src="https://github.com/princekin-f/EasyFloat/blob/master/gif/Alipay.jpeg" width="266">
<img src="https://github.com/princekin-f/EasyFloat/blob/master/gif/WeChatPay.jpeg" width="266" >
<img src="https://github.com/princekin-f/EasyFloat/blob/master/readme/EasyFloatGroup.jpeg" width="266">
<img src="https://github.com/princekin-f/EasyFloat/blob/master/readme/Alipay.jpeg" width="266">
<img src="https://github.com/princekin-f/EasyFloat/blob/master/readme/WeChatPay.jpeg" width="266" >
</div>


5 changes: 5 additions & 0 deletions UpdateDoc.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## 版本更新日志
#### v 2.0.0-beta:
- 新增拖拽关闭、侧滑创建、状态栏沉浸等功能;
- 重构单页面浮窗(创建和PopupWindow同类型的子窗口),减少了API数目,提高利用率;
- 优化使用体验,无需手动init,无需手动调起软键盘。

#### v 1.3.4:
- 优化细节。

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.71'
ext.kotlin_version = '1.4.20'
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
16 changes: 16 additions & 0 deletions easyfloat/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -19,3 +19,19 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# 保持配置类 config 不被混淆
-keep class com.lzf.easyfloat.data.FloatConfig {*;}

# 保持自定义控件、ContentProvider 不被混淆
-keep public class * extends android.view.View
-keep public class * extends android.content.ContentProvider

# 保持枚举 enum 类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

# 保持反射不被混淆
-keepattributes EnclosingMethod
12 changes: 11 additions & 1 deletion easyfloat/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lzf.easyfloat"/>
package="com.lzf.easyfloat">

<application>
<provider
android:name="com.lzf.easyfloat.EasyFloatInitializer"
android:authorities="${applicationId}.EasyFloatInitializer"
android:exported="false"
android:multiprocess="true" />
</application>

</manifest>
Loading

0 comments on commit de51565

Please sign in to comment.