Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get rid of : AllCapsTransformationMethod 'caller did not enable length changes'

Tags:

android

I noticed many time this Warning in my logs and I want to know how to get rid of it.

I understand it comes from this where the AllCapsTransformationMethod has a disable state.

  • How to solve it ? Where should I call the method setLengthChangesAllowed(boolean allowLengthChanges) ?
  • Why does it appear ?
  • How much impact does it have on the processing (I am running on very very low memory devices) ?

Thanks.

PS : if you know better tags, I will add them.

like image 249
Poutrathor Avatar asked Jun 22 '15 10:06

Poutrathor


1 Answers

The method setLengthChangesAllowed(boolean) will be called by TextView in setTransformationMethod(TransformationMethod). The value of the boolean flag is evaluated like this (I only checked API 18): mAllowTransformationLengthChange = !isTextSelectable() && !(mText instanceof Editable);.

So if the text is selectable or editable (for example your component is an EditText), the AllCapsTransformationMethod will be ignored and you will get the warning message W/AllCapsTransformationMethod: Caller did not enable length changes; not transforming text.

To hopefully answer your questions:

  • Use non-selectable, non-editable text components if you wish the transform to be applied, or don't set android:textAllCaps to true for editable/selectable text - that should get rid of the warning. You cannot really call setLengthChangesAllowed(boolean) unless you use reflection voodoo which might work or not, break things and make your code harder to maintain.
  • See explanation above. I hope it helps
  • Getting the warning basically means you have a useless AllCapsTransformationMethod in memory which ocasionally produces that warning but otherwise does nothing. The performance impact should be minimal, tending towards zero. It's probably best to manually set your editable/selectable text to caps instead of applying the textAllCaps attribute with no effect.
like image 70
sfera Avatar answered Oct 07 '22 09:10

sfera