diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/CustomViewTokenExt.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/CustomViewTokenExt.kt
index c97c818..5c6997c 100644
--- a/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/CustomViewTokenExt.kt
+++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/CustomViewTokenExt.kt
@@ -181,24 +181,41 @@ fun View.changeBackground(
*/
fun View.changeBackground(customViewToken: CustomViewToken) {
customViewToken.run {
- setTokenBgColor(
- normalToken = backgroundUIColorToken,
- pressedToken = backgroundUIPressedColorToken,
- hoveredToken = backgroundUIHoveredColorToken,
- disabledToken = backgroundUIDisabledColorToken,
- radiusToken = radiusToken,
- topLeftRadiusToken = topLeftRadiusToken.ifEmpty { radiusToken },
- topRightRadiusToken = topRightRadiusToken.ifEmpty { radiusToken },
- bottomRightRadiusToken = bottomRightRadiusToken.ifEmpty { radiusToken },
- bottomLeftRadiusToken = bottomLeftRadiusToken.ifEmpty { radiusToken },
- strokeColorWidthToken = strokeUIWidthToken,
- normalStrokeColorToken = strokeUIColorToken,
- pressedStrokeColorToken = strokeUIPressedColorToken,
- hoveredStrokeColorToken = strokeUIHoveredColorToken,
- disabledStrokeColorToken = strokeUIDisabledColorToken,
- dashWidth = strokeDashWidth,
- dashGap = strokeDashGap,
- )
+ if (advRadius > 0 || advStrokeWidth > 0 ||
+ advTopRightRadius > 0 || advTopLeftRadius > 0 ||
+ advBottomLeftRadius > 0 || advBottomRightRadius > 0) {
+ setBgColorDirectly(
+ bgColor = advBgColor,
+ radius = advRadius,
+ topLeftRadius = if (advTopLeftRadius > 0F) advTopLeftRadius else advRadius,
+ topRightRadius = if (advTopRightRadius > 0F) advTopRightRadius else advRadius,
+ bottomRightRadius = if (advBottomRightRadius > 0F) advBottomRightRadius else advRadius,
+ bottomLeftRadius = if (advBottomLeftRadius > 0F) advBottomLeftRadius else advRadius,
+ strokeWidth = advStrokeWidth,
+ strokeColor = advStrokeColor,
+ )
+
+ } else {
+ setTokenBgColor(
+ normalToken = backgroundUIColorToken,
+ pressedToken = backgroundUIPressedColorToken,
+ hoveredToken = backgroundUIHoveredColorToken,
+ disabledToken = backgroundUIDisabledColorToken,
+ radiusToken = radiusToken,
+ topLeftRadiusToken = topLeftRadiusToken.ifEmpty { radiusToken },
+ topRightRadiusToken = topRightRadiusToken.ifEmpty { radiusToken },
+ bottomRightRadiusToken = bottomRightRadiusToken.ifEmpty { radiusToken },
+ bottomLeftRadiusToken = bottomLeftRadiusToken.ifEmpty { radiusToken },
+ strokeColorWidthToken = strokeUIWidthToken,
+ normalStrokeColorToken = strokeUIColorToken,
+ pressedStrokeColorToken = strokeUIPressedColorToken,
+ hoveredStrokeColorToken = strokeUIHoveredColorToken,
+ disabledStrokeColorToken = strokeUIDisabledColorToken,
+ dashWidth = strokeDashWidth,
+ dashGap = strokeDashGap,
+ )
+
+ }
}
}
@@ -491,3 +508,67 @@ fun View.getGradientDrawable(
)
return gradientDrawable
}
+
+
+
+
+
+//*------------------------ new added ------------------------*//
+
+/**
+ * 设置背景色
+ */
+fun View.setBgColorDirectly(
+ bgColor: Int = 0,
+ radius: Float = 0F,
+ topLeftRadius: Float = radius,
+ topRightRadius: Float = radius,
+ bottomRightRadius: Float = radius,
+ bottomLeftRadius: Float = radius,
+ strokeWidth: Float = 0F,
+ strokeColor: Int = -1
+) {
+ val resDrawable = StateListDrawable()
+ val normalDrawable = getGradientDrawableDirectly(
+ bgColor,
+ topLeftRadius,
+ topRightRadius,
+ bottomRightRadius,
+ bottomLeftRadius,
+ strokeWidth,
+ strokeColor
+ )
+ resDrawable.addState(intArrayOf(android.R.attr.state_enabled), normalDrawable)
+ background = resDrawable
+}
+
+
+fun View.getGradientDrawableDirectly(
+ bgColor: Int = 0,
+ topLeftRadius: Float = 0F,
+ topRightRadius: Float = 0F,
+ bottomRightRadius: Float = 0F,
+ bottomLeftRadius: Float = 0F,
+ strokeWidth: Float = 0F,
+ strokeColor: Int = -1
+): Drawable {
+ val gradientDrawable = GradientDrawable()
+ gradientDrawable.shape = GradientDrawable.RECTANGLE
+ gradientDrawable.setColor(bgColor)
+
+ if (strokeWidth > 0) {
+ gradientDrawable.setStroke(strokeWidth.toInt(), strokeColor)
+ }
+
+ gradientDrawable.cornerRadii = floatArrayOf(
+ topLeftRadius,
+ topLeftRadius,
+ topRightRadius,
+ topRightRadius,
+ bottomRightRadius,
+ bottomRightRadius,
+ bottomLeftRadius,
+ bottomLeftRadius
+ )
+ return gradientDrawable
+}
diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/bean/CustomViewToken.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/bean/CustomViewToken.kt
index 06b2722..6325aad 100644
--- a/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/bean/CustomViewToken.kt
+++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/bean/CustomViewToken.kt
@@ -1,5 +1,7 @@
package com.remax.visualnovel.widget.uitoken.bean
+import android.graphics.Color
+
/**
* Created by HJW on 2022/9/1
*/
@@ -41,4 +43,15 @@ data class CustomViewToken(
var onlyIconFont: Boolean = false,
var fixTextIsSelectable: Boolean = false,
var underline: Boolean = false,
+
+
+ //---------------------- New added -----------------------
+ var advBgColor:Int = Color.WHITE,
+ var advRadius:Float = 0F,
+ var advTopLeftRadius:Float = 0F,
+ var advTopRightRadius:Float = 0F,
+ var advBottomRightRadius:Float = 0F,
+ var advBottomLeftRadius:Float = 0F,
+ var advStrokeColor: Int = Color.BLACK,
+ var advStrokeWidth:Float = 0F,
)
diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/view/UITokenTextView.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/view/UITokenTextView.kt
index 3e2fae7..8e28cf7 100644
--- a/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/view/UITokenTextView.kt
+++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/widget/uitoken/view/UITokenTextView.kt
@@ -77,6 +77,17 @@ open class UITokenTextView @JvmOverloads constructor(context: Context, private v
onlyIconFont = getBoolean(R.styleable.UITokenTextView_onlyIconFont, onlyIconFont)
underline = getBoolean(R.styleable.UITokenTextView_underline, underline)
fixTextIsSelectable = getBoolean(R.styleable.UITokenTextView_fixTextIsSelectable, fixTextIsSelectable)
+
+
+ //
+ advBgColor = getColor(R.styleable.UITokenTextView_advBgColor, advBgColor)
+ advRadius = getDimension(R.styleable.UITokenTextView_advRadius, advRadius)
+ advTopLeftRadius = getDimension(R.styleable.UITokenTextView_advTopLeftRadius, advTopLeftRadius)
+ advTopRightRadius = getDimension(R.styleable.UITokenTextView_advTopRightRadius, advTopRightRadius)
+ advBottomRightRadius = getDimension(R.styleable.UITokenTextView_advBottomRightRadius, advBottomRightRadius)
+ advBottomLeftRadius = getDimension(R.styleable.UITokenTextView_advBottomLeftRadius, advBottomLeftRadius)
+ advStrokeColor = getColor(R.styleable.UITokenTextView_advStrokeColor, advStrokeColor)
+ advStrokeWidth = getDimension(R.styleable.UITokenTextView_advStrokeWidth, advStrokeWidth)
}
}
diff --git a/VisualNovel/app/src/main/res/layout/layout_chat_menu_view.xml b/VisualNovel/app/src/main/res/layout/layout_chat_menu_view.xml
index d146105..14019f9 100644
--- a/VisualNovel/app/src/main/res/layout/layout_chat_menu_view.xml
+++ b/VisualNovel/app/src/main/res/layout/layout_chat_menu_view.xml
@@ -23,6 +23,19 @@
android:text="@string/setting"
/>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualNovel/app/src/main/res/values/attrs.xml b/VisualNovel/app/src/main/res/values/attrs.xml
index bf36681..cb93cbc 100644
--- a/VisualNovel/app/src/main/res/values/attrs.xml
+++ b/VisualNovel/app/src/main/res/values/attrs.xml
@@ -97,6 +97,17 @@
format="boolean" />
+
+
+
+
+
+
+
+
+
+
+
@@ -125,6 +136,16 @@
+
+
+
@@ -148,6 +169,16 @@
+
+
+
@@ -171,6 +202,16 @@
+
+
+
@@ -194,6 +235,16 @@
+
+
+