razir / ProgressButton

Android Progress Button
856 stars 77 forks source link

ProgressColor not working with textAllCaps true in api 22 #4

Closed rodolfoizidoro closed 5 years ago

rodolfoizidoro commented 5 years ago

With textAllCaps = true the progressCircle not working in api 22

 <style name="DefaultButtonStyle">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textAllCaps">true</item>
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">16sp</item>
        <item name="cornerRadius">30dp</item>
        <item name="layout_constrainedWidth">true</item>
        <item name="layout_constrainedHeight">true</item>
        <item name="layout_constraintWidth_min">@dimen/defaultBtnWidth</item>
        <item name="layout_constraintHeight_min">55dp</item>
    </style> 

@razir

razir commented 5 years ago

@rodolfoizidoro Thanks for reporting the issue. After a quick investigation seems that it's a "feature" of newer Android API versions that ignores any text spans if textAllCaps is set to true. I think the only solution would be to replace AllCapsTransformationMethod to custom one in runtime. I believe I can fix it soon

rodolfoizidoro commented 5 years ago

Okay @razir , I'll be waiting, so far the solution I found was this:

I create a custom view button, to set isAllCaps = false and i do toUpperCase in text Button.

It`s working for me


class GNButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : MaterialButton(context, attrs) {

  val label: String = text.toString().toUpperCase()

  init {
    isAllCaps = false
    text = label
  }

  fun showProgress() {
    showProgress {
      progressColor = currentTextColor
      gravity = DrawableButton.GRAVITY_CENTER
    }
    isEnabled = false
  }

  fun hideProgress() {
    hideProgress(label)
    isEnabled = true
  }
} 
razir commented 5 years ago

@rodolfoizidoro should be fixed in 1.0.2. Please re-open the issue again if not