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 @@ +