Skip to content

Commit 4ca0aa8

Browse files
Add disabledTextViewColor attribute & add external library dependency
1 parent 688304e commit 4ca0aa8

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ dependencies {
3838
implementation 'androidx.appcompat:appcompat:1.6.1'
3939
implementation 'com.google.android.material:material:1.8.0'
4040
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
41-
implementation project(path: ':qunatitycardlibrary')
4241
testImplementation 'junit:junit:4.13.2'
4342
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
4443
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
44+
45+
implementation 'com.github.radustavila:Plus-Minus-Quantity-Card-Android-Library:1.0'
4546
}

qunatitycardlibrary/src/main/java/com/radustavila/qunatitycardlibrary/QuantityCardView.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class QuantityCardView @JvmOverloads constructor(context: Context, attrs: Attrib
140140
mTextColor = getColor(R.styleable.QuantityCardView_android_textColor, DEFAULT_TEXT_COLOR_QUANTITY)
141141
mTextSize = getDimension(R.styleable.QuantityCardView_android_textSize, DEFAULT_TEXT_SIZE_QUANTITY)
142142

143+
mTextColorDisabled = getColor(R.styleable.QuantityCardView_disabledButtonsTextColor, DEFAULT_TEXT_COLOR_DISABLED)
143144
mDecreaseTextColor = getColor(R.styleable.QuantityCardView_decreaseTextColor, DEFAULT_TEXT_COLOR_BUTTONS)
144145
mIncreaseTextColor = getColor(R.styleable.QuantityCardView_increaseTextColor, DEFAULT_TEXT_COLOR_BUTTONS)
145146
mIncreaseTextSize = getDimension(R.styleable.QuantityCardView_increaseTextSize, DEFAULT_TEXT_SIZE_INCREASE)
@@ -361,6 +362,13 @@ class QuantityCardView @JvmOverloads constructor(context: Context, attrs: Attrib
361362
setDecreaseTextColor(mDecreaseTextColor)
362363
}
363364

365+
/**
366+
* Set Increasing' and Decreasing' TextViews text color when disabled.
367+
*/
368+
fun setDisabledButtonsTextColor(@ColorInt color: Int) {
369+
mTextColorDisabled = color
370+
}
371+
364372
/**
365373
* Set ImageScaleType for the Decreasing ImageView.
366374
*/
@@ -715,6 +723,7 @@ class QuantityCardView @JvmOverloads constructor(context: Context, attrs: Attrib
715723
mTextColor,
716724
mIncreaseTextColor,
717725
mDecreaseTextColor,
726+
mTextColorDisabled,
718727
mIncreaseTextSize,
719728
mDecreaseTextSize,
720729
mTextSize,
@@ -739,6 +748,7 @@ class QuantityCardView @JvmOverloads constructor(context: Context, attrs: Attrib
739748
mTextColor = myState?.textColor ?: DEFAULT_TEXT_COLOR_QUANTITY
740749
mIncreaseTextColor = myState?.textColorIncrease ?: DEFAULT_TEXT_COLOR_BUTTONS
741750
mDecreaseTextColor = myState?.textColorDecrease ?: DEFAULT_TEXT_COLOR_BUTTONS
751+
mTextColorDisabled = myState?.textColorDisabled ?: DEFAULT_TEXT_COLOR_DISABLED
742752
mIncreaseTextSize = myState?.textSizeIncrease ?: DEFAULT_TEXT_SIZE_INCREASE
743753
mDecreaseTextSize = myState?.textSizeDecrease ?: DEFAULT_TEXT_SIZE_DECREASE
744754
mTextSize = myState?.textSize ?: DEFAULT_TEXT_SIZE_QUANTITY
@@ -764,6 +774,7 @@ class QuantityCardView @JvmOverloads constructor(context: Context, attrs: Attrib
764774
val textColor: Int,
765775
val textColorIncrease: Int,
766776
val textColorDecrease: Int,
777+
val textColorDisabled: Int,
767778
val textSizeIncrease: Float,
768779
val textSizeDecrease: Float,
769780
val textSize: Float,

qunatitycardlibrary/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<attr name="startingQuantity" format="integer" />
1111
<attr name="minQuantity" format="integer" />
1212
<attr name="maxQuantity" format="integer" />
13+
<attr name="disabledButtonsTextColor" format="color" />
1314
<attr name="buttonsTextColor" format="color" />
1415
<attr name="increaseTextColor" format="color" />
1516
<attr name="decreaseTextColor" format="color" />

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencyResolutionManagement {
1010
repositories {
1111
google()
1212
mavenCentral()
13+
maven { url 'https://jitpack.io' }
1314
}
1415
}
1516
rootProject.name = "Quantity CardView Example"

0 commit comments

Comments
 (0)