Skip to content

Commit

Permalink
完善全局配置
Browse files Browse the repository at this point in the history
  • Loading branch information
goweii committed Nov 22, 2020
1 parent 256b8ae commit d26b892
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,4 @@ AnyLayer.toast()
# 如果你觉得还不错,就请我喝杯咖啡吧~

| ![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 @@ -48,7 +48,7 @@ fun <T : FloatLayer> T.setLowProfileIndent(indent: Float) = this.apply {
this.lowProfileIndent(indent)
}

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

Expand Down
34 changes: 34 additions & 0 deletions anylayer/src/main/java/per/goweii/anylayer/GlobalConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;

import per.goweii.anylayer.floats.FloatLayer;

/**
* @author CuiZhen
* @date 2020/8/16
Expand Down Expand Up @@ -64,4 +66,36 @@ public static GlobalConfig get() {
public CharSequence notificationLabel = null;
public Drawable notificationIcon = null;
public String notificationTimePattern = null;

// FloatLayer

public boolean floatOutside = true;
public int floatSnapEdge = FloatLayer.Edge.HORIZONTAL;
@FloatRange(from = -2F, to = 2F)
public float floatDefPercentX = 2F;
@FloatRange(from = -2F, to = 2F)
public float floatDefPercentY = 0.236F;
@FloatRange(from = 0F, to = 1F)
public float floatDefAlpha = 1F;
public float floatDefScale = 1F;
public float floatPivotX = 0.5F;
public float floatPivotY = 0.5F;
@FloatRange(from = 0F, to = 1F)
public float floatNormalAlpha = 1F;
public float floatNormalScale = 1F;
@IntRange(from = 0)
public long floatLowProfileDelay = 3000L;
@FloatRange(from = 0F, to = 1F)
public float floatLowProfileAlpha = 0.8F;
public float floatLowProfileScale = 1F;
@FloatRange(from = 0F, to = 1F)
public float floatLowProfileIndent = 0F;
public int floatMarginLeft = Integer.MIN_VALUE;
public int floatMarginTop = Integer.MIN_VALUE;
public int floatMarginRight = Integer.MIN_VALUE;
public int floatMarginBottom = Integer.MIN_VALUE;
public int floatPaddingLeft = 0;
public int floatPaddingTop = 0;
public int floatPaddingRight = 0;
public int floatPaddingBottom = 0;
}
47 changes: 24 additions & 23 deletions anylayer/src/main/java/per/goweii/anylayer/floats/FloatLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import androidx.annotation.Nullable;

import per.goweii.anylayer.DecorLayer;
import per.goweii.anylayer.GlobalConfig;
import per.goweii.anylayer.R;
import per.goweii.anylayer.utils.AnimatorHelper;
import per.goweii.anylayer.utils.Utils;
Expand Down Expand Up @@ -296,7 +297,7 @@ public FloatLayer lowProfileIndent(float indent) {
return this;
}

public FloatLayer lowProfileDelay(int delay) {
public FloatLayer lowProfileDelay(long delay) {
getConfig().mLowProfileDelay = delay;
return this;
}
Expand Down Expand Up @@ -491,40 +492,40 @@ protected View getNoIdClickView() {
protected static class Config extends DecorLayer.Config {
protected int mFloatViewId = -1;

private boolean mOutside = true;
private int mSnapEdge = Edge.HORIZONTAL;
private boolean mOutside = GlobalConfig.get().floatOutside;
private int mSnapEdge = GlobalConfig.get().floatSnapEdge;

@FloatRange(from = -2F, to = 2F)
private float mDefPercentX = 2F;
private float mDefPercentX = GlobalConfig.get().floatDefPercentX;
@FloatRange(from = -2F, to = 2F)
private float mDefPercentY = 0.236F;
private float mDefPercentY = GlobalConfig.get().floatDefPercentY;
@FloatRange(from = 0F, to = 1F)
private float mDefAlpha = 1F;
private float mDefScale = 1F;
private float mDefAlpha = GlobalConfig.get().floatDefAlpha;
private float mDefScale = GlobalConfig.get().floatDefScale;

private float mPivotX = 0.5F;
private float mPivotY = 0.5F;
private float mPivotX = GlobalConfig.get().floatPivotX;
private float mPivotY = GlobalConfig.get().floatPivotY;

@FloatRange(from = 0F, to = 1F)
private float mNormalAlpha = 1F;
private float mNormalScale = 1F;
private float mNormalAlpha = GlobalConfig.get().floatNormalAlpha;
private float mNormalScale = GlobalConfig.get().floatNormalScale;
@IntRange(from = 0)
private int mLowProfileDelay = 3000;
private long mLowProfileDelay = GlobalConfig.get().floatLowProfileDelay;
@FloatRange(from = 0F, to = 1F)
private float mLowProfileAlpha = 0.8F;
private float mLowProfileScale = 1F;
private float mLowProfileAlpha = GlobalConfig.get().floatLowProfileAlpha;
private float mLowProfileScale = GlobalConfig.get().floatLowProfileScale;
@FloatRange(from = 0F, to = 1F)
private float mLowProfileIndent = 0F;
private float mLowProfileIndent = GlobalConfig.get().floatLowProfileIndent;

private int mMarginLeft = Integer.MIN_VALUE;
private int mMarginTop = Integer.MIN_VALUE;
private int mMarginRight = Integer.MIN_VALUE;
private int mMarginBottom = Integer.MIN_VALUE;
private int mMarginLeft = GlobalConfig.get().floatMarginLeft;
private int mMarginTop = GlobalConfig.get().floatMarginTop;
private int mMarginRight = GlobalConfig.get().floatMarginRight;
private int mMarginBottom = GlobalConfig.get().floatMarginBottom;

private int mPaddingLeft = 0;
private int mPaddingTop = 0;
private int mPaddingRight = 0;
private int mPaddingBottom = 0;
private int mPaddingLeft = GlobalConfig.get().floatPaddingLeft;
private int mPaddingTop = GlobalConfig.get().floatPaddingTop;
private int mPaddingRight = GlobalConfig.get().floatPaddingRight;
private int mPaddingBottom = GlobalConfig.get().floatPaddingBottom;
}

protected static class ListenerHolder extends DecorLayer.ListenerHolder {
Expand Down

0 comments on commit d26b892

Please sign in to comment.