pangli / SuspendedBall

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SuspendedBall Android系统悬浮窗支持横竖屏切换

关于集成:

  • 在应用模块的build.gradle添加:
dependencies {
    implementation 'com.zorro.easyfloat:EasyFloat:0.0.11'
}

关于初始化:

  • 全局初始化为非必须;
  • 当浮窗为仅前台;
  • 需要在项目的Application中进行全局初始化,进行页面生命周期检测。
EasyFloat.init(this)

关于权限声明:

  • 权限声明为非必须;
  • 当使用到系统浮窗(ShowPattern.FOREGROUND);
  • 需要在AndroidManifest.xml进行权限声明。
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

一行代码搞定Android浮窗,浮窗从未如此简单:

EasyFloat.with(this).show()

点击回调

.registerCallbacks(new OnFloatViewClick() {
    @Override
    public void onClick(View v) {
       Toast.makeText(MainActivity.this, "我被点击了", Toast.LENGTH_LONG).show();
    }
})

悬浮窗权限的检测、申请

  • 无需主动进行权限申请
// 权限检测
PermissionUtils.checkPermission(this)

// 权限申请,参数2为权限回调接口
PermissionUtils.requestPermission(this,OnPermissionResult)

系统浮窗的相关API:

// 关闭浮窗
dismissAppFloat(String tag)

// 隐藏浮窗
hideAppFloat(String tag)

// 显示浮窗
showAppFloat(String tag)

关于混淆:

-keep class com.zorro.easyfloat.** {*;}

关于感谢:

License

Copyright 2020 Pang Li

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

License:Apache License 2.0


Languages

Language:Java 99.9%Language:Batchfile 0.1%