gregkorossy/Android-Support-Preference-V7-Fix

Please provide a way to opt-out of the new EditTextPreference getSummary() behavior by default

Closed this issue · 7 comments

I have another custom imolementation of getSummary() which takes other things into acoount and ignores certain conditions that this new behavior doesn't. Could you pleaee at least provide a superGetSummary() method which returns super.getSummary()?

Or more reasonably, since the base library artifact is expected to fix instead of change the behavior, can you move that behavior to another class (extending the original EdtTextPreference) and leave the original class with only fixes unchanged?

Why don't you just simply override getSummary()?

P.S.: The base library does not display the entered value in the summary, so that argument is invalid that the behavior should not be changed.

Oh, I see, you use super.getSummary(). Well, yeah, there could be a protected CharSequence getSuperSummary() even though it's pretty ugly.

The main reason this behavior has been added to EditTextPreference is that all of the other preferences can display their selected values somewhere (mostly in the summary) automatically and it's usually cumbersome to implement a "summary updater" that runs whenever things change.

I just realized it's enough to set the summary field to protected instead of private. Would that be good for you?

Yes I also want the summary to be formatted with text, but in a different way combining different conditions (e.g. android:hint is used, password is not affected and if it is a password input I'll use plain summary directly (the empty case is covered by hint)). In absense of framework defined behavior for this, I think it is an addition instead of a fix. So I still prefer a separate class with the added behavior, maybe called FormatSummaryEditTextPreference or something and leave the EditTextPreference with only UI instead of behavior fixes free for extend.

And I also wonder if that summary field will always have the same value as super.getSummary()? (I'm on mobile sry). And if you make superGetSummary protected, it won't be ugly in terms of API and I've seen framework or support source code using this technique.

The summary field initially gets set by calling super.getSummary() in the constructor and can be modified by calling setSummary(...), so this could work for you, I think.

EditTextPreference is back in its original state. There's a new class, however, called AutoSummaryEditTextPreference that displays the value as the summary automatically.

Thank you so much!