This commit is contained in:
Niels Andriesse 2021-06-17 14:57:47 +10:00
parent 092dad03b7
commit 5a2baae15d
4 changed files with 23 additions and 6 deletions

View File

@ -63,6 +63,9 @@ class InputBarButton : RelativeLayout {
result.layoutParams = LayoutParams(size, size)
result.setBackgroundResource(R.drawable.input_bar_button_background)
result.mainColor = resources.getColorWithID(colorID, context.theme)
if (hasOpaqueBackground) {
result.strokeColor = resources.getColorWithID(R.color.input_bar_button_background_opaque_border, context.theme)
}
result
}

View File

@ -6,16 +6,14 @@ import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View
import android.view.ViewOutlineProvider
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.appcompat.widget.AppCompatImageView
import network.loki.messenger.R
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
import org.thoughtcrime.securesms.loki.utilities.toPx
import kotlin.math.roundToInt
interface GlowView {
var mainColor: Int
@ -162,16 +160,27 @@ class PathDotView : View, GlowView {
class InputBarButtonImageViewContainer : RelativeLayout, GlowView {
@ColorInt override var mainColor: Int = 0
set(newValue) { field = newValue; paint.color = newValue }
set(newValue) { field = newValue; fillPaint.color = newValue }
@ColorInt var strokeColor: Int = 0
set(newValue) { field = newValue; strokePaint.color = newValue }
@ColorInt override var sessionShadowColor: Int = 0 // Unused
private val paint: Paint by lazy {
private val fillPaint: Paint by lazy {
val result = Paint()
result.style = Paint.Style.FILL
result.isAntiAlias = true
result
}
private val strokePaint: Paint by lazy {
val result = Paint()
result.style = Paint.Style.STROKE
result.isAntiAlias = true
result.strokeWidth = 1.0f
result.alpha = (255 * 0.2f).roundToInt()
result
}
// region Lifecycle
constructor(context: Context) : super(context) { }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { }
@ -186,7 +195,10 @@ class InputBarButtonImageViewContainer : RelativeLayout, GlowView {
override fun onDraw(c: Canvas) {
val w = width.toFloat()
val h = height.toFloat()
c.drawCircle(w / 2, h / 2, w / 2, paint)
c.drawCircle(w / 2, h / 2, w / 2, fillPaint)
if (strokeColor != 0) {
c.drawCircle(w / 2, h / 2, w / 2, strokePaint)
}
super.onDraw(c)
}
// endregion

View File

@ -23,6 +23,7 @@
<color name="input_bar_background">#FCFCFC</color>
<color name="input_bar_button_background">#0D000000</color>
<color name="input_bar_button_background_opaque">#EFEFEF</color>
<color name="input_bar_button_background_opaque_border">#33000000</color>
<color name="input_bar_lock_view_background">#FCFCFC</color>
<color name="input_bar_lock_view_border">#66000000</color>

View File

@ -30,6 +30,7 @@
<color name="input_bar_background">#171717</color>
<color name="input_bar_button_background">#0DFFFFFF</color>
<color name="input_bar_button_background_opaque">#232323</color>
<color name="input_bar_button_background_opaque_border">#33FFFFFF</color>
<color name="input_bar_lock_view_background">#171717</color>
<color name="input_bar_lock_view_border">#66FFFFFF</color>