Skip to content

Commit

Permalink
Merge branch 'master' into support
Browse files Browse the repository at this point in the history
# Conflicts:
#	anylayer/src/main/java/per/goweii/anylayer/floats/FloatLayer.java
#	anylayer/src/main/java/per/goweii/anylayer/toast/ToastLayer.java
#	anylayer/src/main/java/per/goweii/anylayer/utils/Utils.java
  • Loading branch information
goweii committed Nov 22, 2020
2 parents 5ea8f22 + d26b892 commit 7c04dad
Show file tree
Hide file tree
Showing 21 changed files with 468 additions and 137 deletions.
66 changes: 51 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ AnyLayer

Android稳定高效的浮层创建管理框架。

可取代系统自带Dialog/Popup/BottomSheet等弹窗,可实现单Activity架构的Toast提示,可定制任意样式的Guide引导层,可实现依附Activity的Float悬浮按钮
可实现Dialog/Popup/BottomSheet等弹窗,引导层,悬浮按钮,浮动通知,吐司等效果

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

[Demo下载](https://github.com/goweii/AnyLayer/raw/master/app/release/app-release.apk)
[Demo下载](https://gitee.com/goweii/AnyLayer/raw/master/app/demo/demo.apk)



Expand Down Expand Up @@ -39,9 +39,13 @@ Android稳定高效的浮层创建管理框架。
- 支持自定义透明度
- 支持自定义进出场动画
- Guide效果
- 引导层效果待开发
- 详见demo
- Float效果
- 悬浮按钮效果待开发
- 支持自定义吸附边
- 支持自定义正常和低姿态2中模式
- 支持自定义低姿态显示效果
- Notification效果
- 支持滑动关闭



Expand Down Expand Up @@ -79,9 +83,9 @@ Android稳定高效的浮层创建管理框架。

# 截图

截图效果较差且版本较老,建议[下载Demo](https://github.com/goweii/AnyDialog/raw/master/app/release/app-release.apk)体验最新功能
截图效果较差且版本较老,建议[下载Demo](https://gitee.com/goweii/AnyLayer/raw/master/app/demo/demo.apk)体验最新功能

![anylayer.gif](https://github.com/goweii/AnyLayer/blob/master/picture/demo.gif?raw=true)
![demo](https://gitee.com/goweii/AnyLayer/raw/master/app/demo/demo.gif)



Expand Down Expand Up @@ -133,6 +137,12 @@ dependencies {

[点击查看详细更新说明](https://github.com/goweii/AnyLayer/releases)

### 4.0.0-beta1

- 重构包结构
- 新增通知/悬浮按钮/引导浮层
- 支持自定义浮层层级

### 3.6.0

- 新增ext库,添加常用动画创建器
Expand Down Expand Up @@ -174,12 +184,14 @@ dependencies {
- **[ViewManager]()**(管理View的动态添加移除和KeyEvent事件注册)

- **[Layer]()**(对ViewManager的包装,实现进出场动画逻辑和事件监听,规范接口形式,分离出ViewHolder/ListenerHolder/Config三大内部类)
- **[DecorLayer]()**(规范父布局为DecorView的特殊Layer,引入了Layer层级概念)
- **[DialogLayer]()**(规范子布局层级,加入背景层,分离动画为背景动画和内容动画)
- **[PopupLayer]()**(可依据锚点View定位)
- **[ToastLayer]()**(定时消失,不响应事件的Layer)
- **[GuideLayer]()**(引导层Layer)
- **[FloatLayer]()**(悬浮按钮Layer)
- **[FrameLayer]()**(限定父布局为FrameLayout,引入了Layer层级概念)
- **[DecorLayer]()**(限定父布局为DecorView)
- **[DialogLayer]()**(规范子布局层级,加入背景层,分离动画为背景动画和内容动画)
- **[PopupLayer]()**(可依据锚点View定位)
- **[ToastLayer]()**(吐司)
- **[GuideLayer]()**(引导层)
- **[FloatLayer]()**(悬浮按钮)
- **[NotificationLayer]()**(通知)

- **[AnimatorHelper]()**(创建常用属性动画)

Expand Down Expand Up @@ -245,6 +257,24 @@ public static ToastLayer toast()
* 这个Context不能是ApplicationContext
*/
public static ToastLayer toast(Context context)

/**
* 创建一个FloatLayer
* 这个Context不能是ApplicationContext
*/
public static FloatLayer floats(Context context)

/**
* 创建一个GuideLayer
* 这个Context不能是ApplicationContext
*/
public static GuideLayer guide(Context context)

/**
* 创建一个NotificationLayer
* 这个Context不能是ApplicationContext
*/
public static NotificationLayer notification(Context context)
```


Expand Down Expand Up @@ -619,17 +649,23 @@ AnyLayer.toast()

### GuideLayer

> 待实现
> 已实现,文档待补充


### FloatLayer

> 待实现
> 已实现,文档待补充


### NotificationLayer

> 已实现,文档待补充


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

| ![wx_qrcode](https://gitee.com/goweii/WanAndroidServer/raw/master/about/wx_qrcode.png) |
|---|
|---|
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import per.goweii.anylayer.Layer
import per.goweii.anylayer.ext.DefaultOnSwipeListener
import per.goweii.anylayer.widget.SwipeLayout

/**
* @author CuiZhen
* @date 2020/8/15
*/

fun <T : DialogLayer> T.setCancelableOnTouchOutside(enable: Boolean) = this.apply {
this.cancelableOnTouchOutside(enable)
}
Expand Down Expand Up @@ -124,7 +119,7 @@ fun <T : DialogLayer> T.setBackgroundBlurPercent(@FloatRange(from = 0.0) percent
}

fun <T : DialogLayer> T.setBackgroundBlurScale(@FloatRange(from = 1.0) scale: Float) = this.apply {
this.backgroundBlurScale(scale)
this.backgroundBlurSimple(scale)
}

fun <T : DialogLayer> T.setBackgroundBitmap(bitmap: Bitmap) = this.apply {
Expand Down
101 changes: 101 additions & 0 deletions anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/FloatLayers.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package per.goweii.anylayer.ktx

import android.view.View
import androidx.annotation.LayoutRes
import per.goweii.anylayer.floats.FloatLayer

fun <T : FloatLayer> T.setFloatView(@LayoutRes layoutId: Int) = this.apply {
this.floatView(layoutId)
}

fun <T : FloatLayer> T.setFloatView(floatView: View) = this.apply {
this.floatView(floatView)
}

fun <T : FloatLayer> T.setDefPercentX(p: Float) = this.apply {
this.defPercentX(p)
}

fun <T : FloatLayer> T.setDefPercentY(p: Float) = this.apply {
this.defPercentY(p)
}

fun <T : FloatLayer> T.setDefAlpha(alpha: Float) = this.apply {
this.defAlpha(alpha)
}

fun <T : FloatLayer> T.setDefScale(scale: Float) = this.apply {
this.defScale(scale)
}

fun <T : FloatLayer> T.setNormalAlpha(alpha: Float) = this.apply {
this.normalAlpha(alpha)
}

fun <T : FloatLayer> T.setNormalScale(scale: Float) = this.apply {
this.normalScale(scale)
}

fun <T : FloatLayer> T.setLowProfileAlpha(alpha: Float) = this.apply {
this.lowProfileAlpha(alpha)
}

fun <T : FloatLayer> T.setLowProfileScale(scale: Float) = this.apply {
this.lowProfileScale(scale)
}

fun <T : FloatLayer> T.setLowProfileIndent(indent: Float) = this.apply {
this.lowProfileIndent(indent)
}

fun <T : FloatLayer> T.setLowProfileDelay(delay: Long) = this.apply {
this.lowProfileDelay(delay)
}

fun <T : FloatLayer> T.setSnapEdge(edge: Int) = this.apply {
this.snapEdge(edge)
}

fun <T : FloatLayer> T.setOutside(outside: Boolean) = this.apply {
this.outside(outside)
}

fun <T : FloatLayer> T.setMarginLeft(margin: Int) = this.apply {
this.marginLeft(margin)
}

fun <T : FloatLayer> T.setMarginTop(margin: Int) = this.apply {
this.marginTop(margin)
}

fun <T : FloatLayer> T.setMarginRight(margin: Int) = this.apply {
this.marginRight(margin)
}

fun <T : FloatLayer> T.setMarginBottom(margin: Int) = this.apply {
this.marginBottom(margin)
}

fun <T : FloatLayer> T.setPaddingLeft(padding: Int) = this.apply {
this.paddingLeft(padding)
}

fun <T : FloatLayer> T.setPaddingTop(padding: Int) = this.apply {
this.paddingTop(padding)
}

fun <T : FloatLayer> T.setPaddingRight(padding: Int) = this.apply {
this.paddingRight(padding)
}

fun <T : FloatLayer> T.setPaddingBottom(padding: Int) = this.apply {
this.paddingBottom(padding)
}

fun <T : FloatLayer> T.doOnFloatClick(onFloatClick: T.(view: View) -> Unit) = this.apply {
this.onFloatClick { _, view -> this.onFloatClick(view) }
}

fun <T : FloatLayer> T.doOnFloatLongClick(onFloatClick: T.(view: View) -> Boolean) = this.apply {
this.onFloatLongClick { _, view -> this.onFloatClick(view) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ package per.goweii.anylayer.ktx

import per.goweii.anylayer.FrameLayer

/**
* @author CuiZhen
* @date 2020/9/6
*/

fun <T : FrameLayer> T.setLevel(level: Int) = this.apply {
this.level(level)
}
Expand Down
28 changes: 28 additions & 0 deletions anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/GuideLayers.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package per.goweii.anylayer.ktx

import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.IdRes
import per.goweii.anylayer.Layer
import per.goweii.anylayer.guide.GuideLayer

fun <T : GuideLayer> T.setBackgroundColorInt(@ColorInt colorInt: Int) = this.apply {
this.backgroundColorInt(colorInt)
}

fun <T : GuideLayer> T.setBackgroundColorRes(@ColorRes colorRes: Int) = this.apply {
this.backgroundColorRes(colorRes)
}

fun <T : GuideLayer> T.addMapping(mapping: GuideLayer.Mapping) = this.apply {
this.mapping(mapping)
}

fun <T : GuideLayer> T.addMapping(init: GuideLayer.Mapping.() -> Unit) = this.apply {
this.mapping(GuideLayer.Mapping().apply { init() })
}

fun GuideLayer.Mapping.doOnClick(@IdRes viewId: Int, onClickListener: GuideLayer.Mapping.(view: View) -> Unit) = this.apply {
this.onClick(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId)
}
7 changes: 0 additions & 7 deletions anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/Layers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import per.goweii.anylayer.ext.DefaultOnDismissListener
import per.goweii.anylayer.ext.DefaultOnShowListener
import per.goweii.anylayer.ext.DefaultOnVisibleChangeListener

/**
* @author CuiZhen
* @date 2020/8/15
*/

// Layer

fun <T : Layer> T.doOnClick(@IdRes viewId: Int, onClickListener: T.(view: View) -> Unit) = this.apply {
this.onClick(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package per.goweii.anylayer.ktx

import android.graphics.drawable.Drawable
import android.view.View
import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import per.goweii.anylayer.notification.NotificationLayer


fun <T : NotificationLayer> T.setContentView(contentView: View) = this.apply {
this.contentView(contentView)
}

fun <T : NotificationLayer> T.setContentView(@LayoutRes contentViewId: Int) = this.apply {
this.contentView(contentViewId)
}

fun <T : NotificationLayer> T.setIcon(@DrawableRes icon: Int) = this.apply {
this.icon(icon)
}

fun <T : NotificationLayer> T.setIcon(icon: Drawable) = this.apply {
this.icon(icon)
}

fun <T : NotificationLayer> T.setLabel(label: CharSequence) = this.apply {
this.label(label)
}

fun <T : NotificationLayer> T.setLabel(@StringRes label: Int) = this.apply {
this.label(label)
}

fun <T : NotificationLayer> T.setTime(time: CharSequence) = this.apply {
this.time(time)
}

fun <T : NotificationLayer> T.setTitle(title: CharSequence) = this.apply {
this.title(title)
}

fun <T : NotificationLayer> T.setTitle(@StringRes title: Int) = this.apply {
this.title(title)
}

fun <T : NotificationLayer> T.setDesc(desc: CharSequence) = this.apply {
this.desc(desc)
}

fun <T : NotificationLayer> T.setDesc(@StringRes desc: Int) = this.apply {
this.desc(desc)
}

fun <T : NotificationLayer> T.setDuration(duration: Long) = this.apply {
this.duration(duration)
}

fun <T : NotificationLayer> T.doOnNotificationClick(onNotificationClick: T.(view: View) -> Unit) = this.apply {
this.onNotificationClick { _, view -> this.onNotificationClick(view) }
}

fun <T : NotificationLayer> T.doOnNotificationLongClick(onNotificationClick: T.(view: View) -> Boolean) = this.apply {
this.onNotificationLongClick { _, view -> this.onNotificationClick(view) }
}

fun <T : NotificationLayer> T.setAutoDismiss(autoDismiss: Boolean) = this.apply {
this.autoDismiss(autoDismiss)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import android.view.View
import per.goweii.anylayer.popup.PopupLayer
import per.goweii.anylayer.popup.PopupLayer.Align

/**
* @author CuiZhen
* @date 2020/8/15
*/

fun <T : PopupLayer> T.setUpdateLocationInterceptor(interceptor: PopupLayer.UpdateLocationInterceptor) = this.apply {
this.updateLocationInterceptor(interceptor)
}
Expand Down
Loading

0 comments on commit 7c04dad

Please sign in to comment.