Skip to content

Commit ee824cb

Browse files
committed
Merge branch 'develop'
2 parents 3cbe12a + 24c0062 commit ee824cb

7 files changed

Lines changed: 64 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project does not use semantic versioning.
44

5-
## [UNRELEASED]
5+
## 0.0.12 [UNRELEASED]
66

77
### Added
88

@@ -28,6 +28,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2828

2929
- ..
3030

31+
32+
## 0.0.11 - 2024.02.02
33+
34+
### Changed
35+
36+
- LabTextField.`setCursorColorOverride` replaced with `setCursorColor` and `setCursorErrorColor` from MaterialTextInputLayout.
37+
- Updated Material dependency to version 1.11.0
38+
3139
## 0.0.10 - 2023.10.18
3240

3341
### Changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010

1111
ext {
1212
// Current version of the library
13-
libraryVersion = "0.0.10"
13+
libraryVersion = "0.0.11"
1414
}
1515

1616
subprojects {

gradle/libs.versions.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ android-sdk-min = "23"
33
android-sdk-target = "34"
44
android-sdk-compile = "android-34"
55

6-
android-gradle-plugin = "8.1.2"
7-
kotlin = "1.9.10"
8-
navigation = "2.7.3"
6+
android-gradle-plugin = "8.2.2"
7+
kotlin = "1.9.22"
8+
navigation = "2.7.6"
99

1010
[plugins]
1111
# Gradle plugin
@@ -16,16 +16,16 @@ kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref =
1616
# NB! Make sure to update the kltint version set in the root build.gradle file. subprojects / ktlint / version
1717
# NB! ktlint-gradle doesn"t always depend on the latest ktlint version, but since it is a thin wrapper around ktlint
1818
# NB! it can be usefult to use a newer version of ktlint to get ruleset updates, etc.
19-
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "11.6.0" }
19+
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.1.0" }
2020
gradleVersions = { id = "com.github.ben-manes.versions", version = "0.48.0" }
21-
detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.23.1" }
21+
detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.23.5" }
2222

2323
[libraries]
2424
# Language
2525
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
2626

2727
# Android + UI
28-
material = "com.google.android.material:material:1.10.0-rc01"
28+
material = "com.google.android.material:material:1.11.0"
2929
constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
3030
androidx-navigation-fragment = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigation" }
3131
androidx-navigation-ui = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigation" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

lib/java/mobi/lab/components/color/res/values/colors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304
<color name="lab_internal_ref_palette_neutral_variant90">#DEE2ED</color>
305305

306306
<!-- Debug colors for development -->
307-
<color name="lab_internal_todo">#50FF00FF</color>
307+
<color name="lab_internal_todo">#FF00FF</color>
308308
<color name="lab_internal_todo2">#00FFFF</color>
309309
<color name="lab_internal_todo3">#FFFF00</color>
310310
</resources>

lib/java/mobi/lab/components/shared/DrawableUtil.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ package mobi.lab.components.shared
22

33
import android.content.res.ColorStateList
44
import android.graphics.drawable.Drawable
5-
import androidx.annotation.ColorInt
65
import androidx.core.graphics.drawable.DrawableCompat
76

87
internal object DrawableUtil {
98

10-
fun setDrawableColor(drawable: Drawable?, @ColorInt color: Int) {
9+
fun setTintList(drawable: Drawable?, tint: ColorStateList) {
1110
if (drawable != null) {
12-
DrawableCompat.setTintList(drawable, ColorStateList.valueOf(color))
11+
DrawableCompat.setTintList(drawable, tint)
1312
}
1413
}
1514
}

lib/java/mobi/lab/components/textfield/LabTextField.kt

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import android.view.MotionEvent
1212
import android.view.View
1313
import android.view.ViewGroup
1414
import android.view.inputmethod.EditorInfo
15-
import androidx.annotation.ColorInt
1615
import androidx.annotation.Dimension
1716
import androidx.annotation.Px
1817
import androidx.annotation.RequiresApi
@@ -71,7 +70,8 @@ public open class LabTextField @JvmOverloads constructor(
7170
private var textPaddingHorizontal: Int = NO_VALUE_INT
7271

7372
// A temporary solution to update the cursor color until the Material lib's support for this becomes available
74-
private var cursorColorOverride: Int = NO_VALUE_INT
73+
private var cursorColorOverride: ColorStateList? = null
74+
private var cursorErrorColorOverride: ColorStateList? = null
7575

7676
init {
7777
attrs?.let {
@@ -90,6 +90,11 @@ public open class LabTextField @JvmOverloads constructor(
9090
}
9191

9292
boxHelper = LabTextFieldBoxBackgroundHelper(this, attrs, defStyleAttr)
93+
94+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
95+
cursorColorOverride = cursorColor
96+
cursorErrorColorOverride = cursorErrorColor
97+
}
9398
}
9499

95100
override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams) {
@@ -256,11 +261,31 @@ public open class LabTextField @JvmOverloads constructor(
256261
* Set a color for the cursor and text select handles. This overrides the default color from colorControlActivated value.
257262
* NB! Only supported on API 29+
258263
*
259-
* @param color The new color override
264+
* We want to modify the default behaviour here because the material lib's cursorColor does not override the select handle colors.
265+
*
266+
* @param cursorColor The new color override
267+
* TODO: material 1.12.0: Check if select handles are added
260268
*/
261269
@RequiresApi(Build.VERSION_CODES.Q)
262-
public fun setCursorColorOverride(@ColorInt color: Int) {
263-
cursorColorOverride = color
270+
override fun setCursorColor(cursorColor: ColorStateList?) {
271+
super.setCursorColor(cursorColor)
272+
cursorColorOverride = cursorColor
273+
updateCursorColor()
274+
}
275+
276+
/**
277+
* Set a color for the cursor and text select handles in error mode. This overrides the default color from colorControlActivated value.
278+
* NB! Only supported on API 29+
279+
*
280+
* We want to modify the default behaviour here because the material lib's cursorErrorColor does not override the select handle colors.
281+
*
282+
* @param cursorErrorColor The new color override
283+
* TODO: material 1.12.0: Check if select handles are added
284+
*/
285+
@RequiresApi(Build.VERSION_CODES.Q)
286+
override fun setCursorErrorColor(cursorErrorColor: ColorStateList?) {
287+
super.setCursorErrorColor(cursorErrorColor)
288+
cursorErrorColorOverride = cursorErrorColor
264289
updateCursorColor()
265290
}
266291

@@ -390,7 +415,7 @@ public open class LabTextField @JvmOverloads constructor(
390415
}
391416

392417
private fun updateCursorColor() {
393-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || cursorColorOverride == NO_VALUE_INT) {
418+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
394419
// Not supported.
395420
return
396421
}
@@ -401,10 +426,19 @@ public open class LabTextField @JvmOverloads constructor(
401426
return
402427
}
403428

404-
DrawableUtil.setDrawableColor(editText.textSelectHandleLeft, cursorColorOverride)
405-
DrawableUtil.setDrawableColor(editText.textSelectHandleRight, cursorColorOverride)
406-
DrawableUtil.setDrawableColor(editText.textSelectHandle, cursorColorOverride)
407-
DrawableUtil.setDrawableColor(editText.textCursorDrawable, cursorColorOverride)
429+
val color = if (isOnError()) cursorErrorColorOverride else cursorColorOverride
430+
if (color == null) {
431+
return
432+
}
433+
434+
DrawableUtil.setTintList(editText.textSelectHandleLeft, color)
435+
DrawableUtil.setTintList(editText.textSelectHandleRight, color)
436+
DrawableUtil.setTintList(editText.textSelectHandle, color)
437+
DrawableUtil.setTintList(editText.textCursorDrawable, color)
438+
}
439+
440+
private fun isOnError(): Boolean {
441+
return errorState
408442
}
409443

410444
internal companion object {

0 commit comments

Comments
 (0)