From edd2347ffbb9de0abed920e6abc6eec4099e66e3 Mon Sep 17 00:00:00 2001 From: goweii Date: Sat, 12 Mar 2022 12:30:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=BF=E6=8D=A2visualeffect?= =?UTF-8?q?=E5=92=8Cshadowlayout=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 75 +- build.gradle | 4 +- layer-core-ktx/src/main/AndroidManifest.xml | 3 +- .../java/per/goweii/layer/core/ktx/Layer.kt | 40 +- layer-core/src/main/AndroidManifest.xml | 4 +- .../per/goweii/layer/core/ActivityHolder.java | 2 +- .../per/goweii/layer/core/FrameLayer.java | 2 - .../per/goweii/layer/core/utils/Utils.java | 4 - layer-core/src/main/res/values/styles.xml | 1 + layer-design-cupertino/build.gradle | 1 + .../src/main/AndroidManifest.xml | 3 +- .../design/cupertino/CupertinoAlertLayer.java | 2 +- .../cupertino/CupertinoNotificationLayer.java | 2 +- .../cupertino/CupertinoPopoverLayer.java | 4 +- .../src/main/AndroidManifest.xml | 3 +- .../design/material/MaterialDialogLayer.java | 1 - .../src/main/res/values-night/colors.xml | 3 +- .../src/main/res/values/colors.xml | 3 +- layer-design-res/src/main/AndroidManifest.xml | 3 +- layer-dialog-ktx/src/main/AndroidManifest.xml | 3 +- .../goweii/layer/dialog/ktx/DialogLayer.kt | 43 +- layer-dialog/src/main/AndroidManifest.xml | 1 + layer-guide-ktx/src/main/AndroidManifest.xml | 3 +- .../per/goweii/layer/guide/ktx/GuideLayer.kt | 5 +- layer-guide/src/main/AndroidManifest.xml | 3 +- .../src/main/AndroidManifest.xml | 3 +- layer-keyboard/src/main/AndroidManifest.xml | 1 + .../DefaultBindingActionListener.java | 2 +- .../per/goweii/layer/keyboard/KeyCodes.java | 439 +++++++---- .../layer_keyboard_ic_arrow_down.xml | 6 +- .../layer_keyboard_ic_caps.xml | 6 +- .../layer_keyboard_ic_caps_lock.xml | 6 +- .../drawable-anydpi/layer_keyboard_ic_del.xml | 6 +- .../layer_keyboard_ic_enter.xml | 6 +- .../layer_keyboard_ic_space.xml | 6 +- .../drawable/layer_keyboard_btn_bg_normal.xml | 4 +- .../layer_keyboard_btn_bg_pressed.xml | 4 +- .../src/main/AndroidManifest.xml | 3 +- .../notification/ktx/NotificationLayer.kt | 40 +- .../src/main/AndroidManifest.xml | 3 +- .../src/main/AndroidManifest.xml | 3 +- .../goweii/layer/overlay/ktx/OverlayLayer.kt | 14 +- layer-overlay/src/main/AndroidManifest.xml | 3 +- layer-popup-ktx/src/main/AndroidManifest.xml | 3 +- .../per/goweii/layer/popup/ktx/PopupLayer.kt | 15 +- layer-popup/src/main/AndroidManifest.xml | 3 +- .../per/goweii/layer/popup/PopupLayer.java | 6 +- layer-startup/src/main/AndroidManifest.xml | 1 + layer-toast-ktx/src/main/AndroidManifest.xml | 3 +- .../per/goweii/layer/toast/ktx/ToastLayer.kt | 2 +- layer-toast/src/main/AndroidManifest.xml | 3 +- layer-visualeffectview/build.gradle | 6 +- .../src/main/AndroidManifest.xml | 3 +- .../visualeffectview/PopupShadowLayout.java | 704 ------------------ .../visualeffectview/RoundedShadowLayout.java | 260 ------- .../layer/visualeffectview/ShadowLayout.java | 328 -------- .../layer/simple/CupertinoSimpleActivity.kt | 66 +- .../layer/simple/LayersSimpleActivity.kt | 151 ++-- .../layer/simple/MaterialSimpleActivity.kt | 39 +- simple/src/main/res/layout/bottom_sheet.xml | 6 +- simple/src/main/res/layout/dialog_normal.xml | 6 +- simple/src/main/res/layout/guide_content.xml | 6 +- simple/src/main/res/layout/overlay.xml | 6 +- simple/src/main/res/layout/toast.xml | 6 +- 64 files changed, 637 insertions(+), 1759 deletions(-) delete mode 100644 layer-visualeffectview/src/main/java/per/goweii/layer/visualeffectview/PopupShadowLayout.java delete mode 100644 layer-visualeffectview/src/main/java/per/goweii/layer/visualeffectview/RoundedShadowLayout.java delete mode 100644 layer-visualeffectview/src/main/java/per/goweii/layer/visualeffectview/ShadowLayout.java diff --git a/README.md b/README.md index 4c524dd..5be401f 100644 --- a/README.md +++ b/README.md @@ -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的完美替代。而且可以实现悬浮按钮和引导层等一些列功能。 @@ -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:通知 + - 支持滑动关闭 # 截图 @@ -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) @@ -83,6 +73,7 @@ allprojects { - ### 添加依赖 [点击查看最新版本号](https://github.com/goweii/Layer/releases) + ```groovy // build.gradle(Module:) dependencies { @@ -101,18 +92,14 @@ dependencies { - ### 一些问题/建议 - - 建议按需引入 - - - layer-startup依赖于Jetpack Startup(需要自行引入)。 - + - 建议按需引入 + - layer-startup依赖于Jetpack Startup(需要自行引入)。 ## 更新说明 [点击查看](https://github.com/goweii/Layer/releases) - - # 如果你觉得还不错,就请我喝杯咖啡吧~ | 微信 | 支付宝 | QQ | diff --git a/build.gradle b/build.gradle index 3ae2b50..247cb4a 100644 --- a/build.gradle +++ b/build.gradle @@ -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" @@ -37,7 +38,6 @@ allprojects { jcenter() mavenCentral() maven { url "https://jitpack.io" } - maven { url "https://gitee.com/goweii/maven-repository/raw/master/releases/" } } } diff --git a/layer-core-ktx/src/main/AndroidManifest.xml b/layer-core-ktx/src/main/AndroidManifest.xml index 3527f08..bc7276a 100644 --- a/layer-core-ktx/src/main/AndroidManifest.xml +++ b/layer-core-ktx/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + \ No newline at end of file diff --git a/layer-core-ktx/src/main/java/per/goweii/layer/core/ktx/Layer.kt b/layer-core-ktx/src/main/java/per/goweii/layer/core/ktx/Layer.kt index 080ec3a..a203ee1 100644 --- a/layer-core-ktx/src/main/java/per/goweii/layer/core/ktx/Layer.kt +++ b/layer-core-ktx/src/main/java/per/goweii/layer/core/ktx/Layer.kt @@ -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.onClick(@IdRes viewId: Int, onClickListener: T.(view: View) -> Unit) = this.apply { - this.addOnClickListener(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId) -} - -fun T.onClickToDismiss(@IdRes viewId: Int, onClickListener: (T.(view: View) -> Unit)? = null) = this.apply { +fun T.onClick(@IdRes viewId: Int, onClickListener: T.(view: View) -> Unit) = + this.apply { + this.addOnClickListener(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId) + } + +fun 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.onLongClick(@IdRes viewId: Int, onLongClickListener: T.(view: View) -> Boolean) = this.apply { - this.addOnLongClickListener(Layer.OnLongClickListener { _, v -> this.onLongClickListener(v) }, viewId) -} - -fun T.onLongClickToDismiss(@IdRes viewId: Int, onLongClickListener: (T.(view: View) -> Boolean)? = null) = this.apply { +fun T.onLongClick(@IdRes viewId: Int, onLongClickListener: T.(view: View) -> Boolean) = + this.apply { + this.addOnLongClickListener( + Layer.OnLongClickListener { _, v -> this.onLongClickListener(v) }, + viewId + ) + } + +fun 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) } @@ -85,8 +99,8 @@ fun T.onPostDismiss(onPostDismiss: T.() -> Unit) = this.apply { } fun 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? { diff --git a/layer-core/src/main/AndroidManifest.xml b/layer-core/src/main/AndroidManifest.xml index 48b9ab7..1f4ea99 100644 --- a/layer-core/src/main/AndroidManifest.xml +++ b/layer-core/src/main/AndroidManifest.xml @@ -1,4 +1,2 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/layer-core/src/main/java/per/goweii/layer/core/ActivityHolder.java b/layer-core/src/main/java/per/goweii/layer/core/ActivityHolder.java index 29ddc3a..2ab1d62 100644 --- a/layer-core/src/main/java/per/goweii/layer/core/ActivityHolder.java +++ b/layer-core/src/main/java/per/goweii/layer/core/ActivityHolder.java @@ -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)); diff --git a/layer-core/src/main/java/per/goweii/layer/core/FrameLayer.java b/layer-core/src/main/java/per/goweii/layer/core/FrameLayer.java index 6eeead8..f5a6a64 100644 --- a/layer-core/src/main/java/per/goweii/layer/core/FrameLayer.java +++ b/layer-core/src/main/java/per/goweii/layer/core/FrameLayer.java @@ -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; diff --git a/layer-core/src/main/java/per/goweii/layer/core/utils/Utils.java b/layer-core/src/main/java/per/goweii/layer/core/utils/Utils.java index fa922a3..581531d 100644 --- a/layer-core/src/main/java/per/goweii/layer/core/utils/Utils.java +++ b/layer-core/src/main/java/per/goweii/layer/core/utils/Utils.java @@ -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 { diff --git a/layer-core/src/main/res/values/styles.xml b/layer-core/src/main/res/values/styles.xml index 4f68eb3..697977a 100644 --- a/layer-core/src/main/res/values/styles.xml +++ b/layer-core/src/main/res/values/styles.xml @@ -1,5 +1,6 @@ +