Skip to content

Commit

Permalink
refactor: 替换visualeffect和shadowlayout依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
goweii committed Mar 12, 2022
1 parent 83dbe86 commit edd2347
Show file tree
Hide file tree
Showing 64 changed files with 637 additions and 1,759 deletions.
75 changes: 31 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ Android稳定高效的浮层创建管理框架。

可实现Dialog,PopupWindow,引导层,悬浮按钮,通知,吐司,安全键盘等效果。



[GitHub主页](https://github.com/goweii/Layer)

[Demo下载](https://gitee.com/goweii/Layer/raw/master/app/demo/demo.apk)



# 简介

如果你的App用的是单Activity架构,那么这个就是系统Dialog/PopupWindow/Toast的完美替代。而且可以实现悬浮按钮和引导层等一些列功能。
Expand All @@ -20,36 +16,34 @@ Android稳定高效的浮层创建管理框架。
- 链式调用
- 支持自由扩展
- 实现几种常用效果
- DialogLayer:AlertDialog/BottomSheetDialog
- 占用区域不会超过当前Activity避免导航栏遮挡
- 支持自定义大小和显示位置
- 支持自定义数据绑定
- 支持自定义进出场动画
- 支持自定义背景颜色/图片/高斯模糊
- 支持在Activity的onCreate生命周期弹出
- 支持从ApplicationContext中弹出
- 支持拖拽关闭
- 支持不拦截外部事件
- PopupLayer:PopupWindow
- 拥有Dialog效果特性
- 支持跟随目标View移动
- ToastLayer:吐司
- 支持自定义图标和文字
- 支持自定义显示时长
- 支持自定义位置
- 支持自定义背景资源和颜色
- 支持自定义透明度
- 支持自定义进出场动画
- GuideLayer:引导层
- 支持自定义遮罩颜色和圆角半径
- OverlayLayer:悬浮按钮
- 支持自定义吸附边
- 支持自定义正常和低姿态2中模式
- 支持自定义低姿态显示效果
- NotificationLayer:通知
- 支持滑动关闭


- DialogLayer:AlertDialog/BottomSheetDialog
- 占用区域不会超过当前Activity避免导航栏遮挡
- 支持自定义大小和显示位置
- 支持自定义数据绑定
- 支持自定义进出场动画
- 支持自定义背景颜色/图片/高斯模糊
- 支持在Activity的onCreate生命周期弹出
- 支持从ApplicationContext中弹出
- 支持拖拽关闭
- 支持不拦截外部事件
- PopupLayer:PopupWindow
- 拥有Dialog效果特性
- 支持跟随目标View移动
- ToastLayer:吐司
- 支持自定义图标和文字
- 支持自定义显示时长
- 支持自定义位置
- 支持自定义背景资源和颜色
- 支持自定义透明度
- 支持自定义进出场动画
- GuideLayer:引导层
- 支持自定义遮罩颜色和圆角半径
- OverlayLayer:悬浮按钮
- 支持自定义吸附边
- 支持自定义正常和低姿态2中模式
- 支持自定义低姿态显示效果
- NotificationLayer:通知
- 支持滑动关闭

# 截图

Expand All @@ -59,12 +53,8 @@ Android稳定高效的浮层创建管理框架。
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![20210610_190654.gif](https://i.loli.net/2021/06/10/aVoWBmGqtE1HkUP.gif) | ![20210610_190715.gif](https://i.loli.net/2021/06/10/npHzPjwdqfKBDQt.gif) |



# 使用说明



## 集成

![](https://img.shields.io/badge/Downloads%20Week-1.4k-green) ![](https://img.shields.io/badge/Downloads%20Month-7.3K-blue)
Expand All @@ -83,6 +73,7 @@ allprojects {
- ### 添加依赖

[点击查看最新版本号](https://github.com/goweii/Layer/releases)

```groovy
// build.gradle(Module:)
dependencies {
Expand All @@ -101,18 +92,14 @@ dependencies {

- ### 一些问题/建议

- 建议按需引入

- layer-startup依赖于Jetpack Startup(需要自行引入)。

- 建议按需引入

- layer-startup依赖于Jetpack Startup(需要自行引入)。

## 更新说明

[点击查看](https://github.com/goweii/Layer/releases)



# 如果你觉得还不错,就请我喝杯咖啡吧~

| 微信 | 支付宝 | QQ |
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ buildscript {
androidx_core_ktx_version = "1.6.0"
androidx_startup_version = "1.0.0"
cardview_version = "1.0.0"
visual_effect_version = "1.0.10"
visual_effect_version = "1.0.0"
shadowlayout_version = "1.0.0"
}
ext {
android_application_id = "per.goweii.layer.simple"
Expand Down Expand Up @@ -37,7 +38,6 @@ allprojects {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "https://gitee.com/goweii/maven-repository/raw/master/releases/" }
}
}

Expand Down
3 changes: 1 addition & 2 deletions layer-core-ktx/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="per.goweii.layer.core.ktx">
<manifest package="per.goweii.layer.core.ktx">

</manifest>
40 changes: 27 additions & 13 deletions layer-core-ktx/src/main/java/per/goweii/layer/core/ktx/Layer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,37 @@ import per.goweii.layer.core.listener.DefaultOnDismissListener
import per.goweii.layer.core.listener.DefaultOnShowListener
import per.goweii.layer.core.listener.DefaultOnVisibleChangedListener

fun <T : Layer> T.onClick(@IdRes viewId: Int, onClickListener: T.(view: View) -> Unit) = this.apply {
this.addOnClickListener(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId)
}

fun <T : Layer> T.onClickToDismiss(@IdRes viewId: Int, onClickListener: (T.(view: View) -> Unit)? = null) = this.apply {
fun <T : Layer> T.onClick(@IdRes viewId: Int, onClickListener: T.(view: View) -> Unit) =
this.apply {
this.addOnClickListener(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId)
}

fun <T : Layer> T.onClickToDismiss(
@IdRes viewId: Int,
onClickListener: (T.(view: View) -> Unit)? = null
) = this.apply {
onClickListener?.let {
this.addOnClickToDismissListener(Layer.OnClickListener { _, v -> this.it(v) }, viewId)
} ?: addOnClickToDismissListener(null, viewId)
}

fun <T : Layer> T.onLongClick(@IdRes viewId: Int, onLongClickListener: T.(view: View) -> Boolean) = this.apply {
this.addOnLongClickListener(Layer.OnLongClickListener { _, v -> this.onLongClickListener(v) }, viewId)
}

fun <T : Layer> T.onLongClickToDismiss(@IdRes viewId: Int, onLongClickListener: (T.(view: View) -> Boolean)? = null) = this.apply {
fun <T : Layer> T.onLongClick(@IdRes viewId: Int, onLongClickListener: T.(view: View) -> Boolean) =
this.apply {
this.addOnLongClickListener(
Layer.OnLongClickListener { _, v -> this.onLongClickListener(v) },
viewId
)
}

fun <T : Layer> T.onLongClickToDismiss(
@IdRes viewId: Int,
onLongClickListener: (T.(view: View) -> Boolean)? = null
) = this.apply {
onLongClickListener?.let {
this.addOnLongClickToDismissListener(Layer.OnLongClickListener { _, v -> this.it(v) }, viewId)
this.addOnLongClickToDismissListener(
Layer.OnLongClickListener { _, v -> this.it(v) },
viewId
)
} ?: addOnLongClickToDismissListener(null, viewId)
}

Expand Down Expand Up @@ -85,8 +99,8 @@ fun <T : Layer> T.onPostDismiss(onPostDismiss: T.() -> Unit) = this.apply {
}

fun <T : Layer, R : Animator?> T.animator(
onIn: T.(target: View) -> R,
onOut: T.(target: View) -> R
onIn: T.(target: View) -> R,
onOut: T.(target: View) -> R
) = this.apply {
this.setAnimator(object : Layer.AnimatorCreator {
override fun createInAnimator(target: View): Animator? {
Expand Down
4 changes: 1 addition & 3 deletions layer-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="per.goweii.layer.core">
</manifest>
<manifest package="per.goweii.layer.core"></manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Activity getCurrentActivity() {
return stack.get(stack.size() - 1).get();
}

private class ActivityLifecycleCallbacksImpl implements Application.ActivityLifecycleCallbacks{
private class ActivityLifecycleCallbacksImpl implements Application.ActivityLifecycleCallbacks {
@Override
public void onActivityCreated(@NonNull Activity activity, Bundle savedInstanceState) {
mActivityStack.add(new WeakReference<>(activity));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;

import androidx.annotation.CallSuper;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;

public final class Utils {

Expand Down
1 change: 1 addition & 0 deletions layer-core/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AnyLayerActivityTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
Expand Down
1 change: 1 addition & 0 deletions layer-design-cupertino/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ dependencies {
api project(":layer-keyboard")
api project(":layer-design-res")
api project(":layer-visualeffectview")
api "com.github.goweii:ShadowLayout:$shadowlayout_version"
}
3 changes: 1 addition & 2 deletions layer-design-cupertino/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="per.goweii.layer.design.cupertino">
<manifest package="per.goweii.layer.design.cupertino">

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import per.goweii.layer.dialog.DialogLayer;
import per.goweii.layer.visualeffectview.BackdropBlurView;
import per.goweii.layer.visualeffectview.BackdropIgnoreView;
import per.goweii.layer.visualeffectview.RoundedShadowLayout;
import per.goweii.roundedshadowlayout.RoundedShadowLayout;

public class CupertinoAlertLayer extends DialogLayer {
public CupertinoAlertLayer(@NonNull Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import per.goweii.layer.notification.NotificationLayer;
import per.goweii.layer.visualeffectview.BackdropBlurView;
import per.goweii.layer.visualeffectview.BackdropIgnoreView;
import per.goweii.layer.visualeffectview.RoundedShadowLayout;
import per.goweii.roundedshadowlayout.RoundedShadowLayout;

public class CupertinoNotificationLayer extends NotificationLayer {
public CupertinoNotificationLayer(@NonNull Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import per.goweii.layer.core.anim.AnimatorHelper;
import per.goweii.layer.popup.PopupLayer;
import per.goweii.layer.visualeffectview.PopupShadowLayout;
import per.goweii.popupshadowlayout.PopupShadowLayout;

public class CupertinoPopoverLayer extends PopupLayer {
public CupertinoPopoverLayer(@NonNull Context context) {
Expand Down Expand Up @@ -104,7 +104,7 @@ protected void onInitContent() {
content.setArrowWidth(getConfig().mArrowWidth);
content.setArrowHeight(getConfig().mArrowHeight);
content.setCornerRadius(getConfig().mCornerRadius);
content.setSolidColor(getConfig().mSolidColor);
content.setBackgroundColor(getConfig().mSolidColor);
content.setShadowColor(getActivity().getResources().getColor(R.color.layer_design_cupertino_color_shadow));
content.setShadowRadius(getActivity().getResources().getDimension(R.dimen.layer_design_cupertino_alert_shadow_radius));
content.setShadowOffsetY(getActivity().getResources().getDimension(R.dimen.layer_design_cupertino_alert_shadow_offset_y));
Expand Down
3 changes: 1 addition & 2 deletions layer-design-material/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="per.goweii.layer.design.material">
<manifest package="per.goweii.layer.design.material">

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

Expand Down
3 changes: 2 additions & 1 deletion layer-design-material/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="layer_design_material_dialog_btn_bg_normal">@color/layer_design_res_color_surface</color>
<color name="layer_design_material_dialog_btn_bg_normal">@color/layer_design_res_color_surface
</color>
<color name="layer_design_material_dialog_btn_bg_pressed">#14ffffff</color>
</resources>
3 changes: 2 additions & 1 deletion layer-design-material/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="layer_design_material_dialog_btn_bg_normal">@color/layer_design_res_color_surface</color>
<color name="layer_design_material_dialog_btn_bg_normal">@color/layer_design_res_color_surface
</color>
<color name="layer_design_material_dialog_btn_bg_pressed">#14000000</color>
</resources>
3 changes: 1 addition & 2 deletions layer-design-res/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="per.goweii.layer.design.res">
<manifest package="per.goweii.layer.design.res">

</manifest>
3 changes: 1 addition & 2 deletions layer-dialog-ktx/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="per.goweii.layer.dialog.ktx">
<manifest package="per.goweii.layer.dialog.ktx">

</manifest>
Loading

0 comments on commit edd2347

Please sign in to comment.