Closed Bug 997447 Opened 10 years ago Closed 10 years ago

Modify EditText to shrink hint when text is not empty

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 32

People

(Reporter: bnicholson, Assigned: bnicholson)

Details

Attachments

(2 files, 1 obsolete file)

The hint on EditTexts isn't very user-friendly since it disappears if the EditText isn't empty. This is especially true when showing a form that has pre-filled text fields (e.g., Edit Bookmark), and the user has to figure out what they're editing based on the context of the field.

We don't have too many EditTexts in our existing UI, so this isn't a big problem. With autofill support (bug 946022), however, we'll want a clean way to show many form inputs. Permanent labels next to/on top of each field take up a lot of space and can be visually overwhelming; disappearing hints suffer the problems mentioned above. We can compromise by using hints that shrink when text is entered.
Ian, here's a build with the fancy new text inputs. Thoughts?

http://people.mozilla.org/~bnicholson/fennec_builds/shrinking-hint.apk

Three ways to test:
1) Settings > Customize > Autofill > Add
2) Bookmarks panel > context menu > Edit
3) Go to intranet.mozilla.org and enter username/password
Flags: needinfo?(ibarlow)
This is pretty freakin hot. 

My one comment so far would be that we could add a little more visual emphasis to the text in the active field. Maybe make it the same blue as the field highlight? Like so: http://cl.ly/image/3M0N1p1p261r
Flags: needinfo?(ibarlow)
Here's a build where the hint fades to holo blue:

http://people.mozilla.org/~bnicholson/fennec_builds/shrinking-hint2.apk

This build works only with the Edit Bookmark dialog.

A couple of notes:
1) The underline that appears under the focused TextView is a drawable png in Android, so there's no way to get the blue color programmatically, meaning the color (#33b5e5) is hard-coded. If the phone's uses a theme other than holo blue, our floating hint color won't match the underline color.
2) It feels strange switching between a non-empty text field and an empty one since the focused color changes for floating hints, but it doesn't change for normal hints. Switching focus from Location to Keyword, for example, I kind of expect the Keyword hint to switch to blue as well.
Flags: needinfo?(ibarlow)
Going from comment 3, here's another build where the focused hint is always blue, regardless of whether the text field is empty. It feels more consistent when switching fields, but it's kind of weird seeing a non-gray hint on Android.
I think you had it right the first time in comment 3, this looks great :)

I don't think we want to add colour to normal hints, it feels a little too severe to me.
Flags: needinfo?(ibarlow)
Attached patch Add FloatingHintEditText widget (obsolete) — Splinter Review
Implements the widget.
Attachment #8418513 - Flags: review?(lucasr.at.mozilla)
Replaces our existing EditTexts with FloatingHintEditTexts (excluding search fields).
Attachment #8418514 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 8418513 [details] [diff] [review]
Add FloatingHintEditText widget

Review of attachment 8418513 [details] [diff] [review]:
-----------------------------------------------------------------

Looking good overall. It's probably a good idea to be focus aware here so that we float the hint out of the way when the entry gets focus? With this patch as is, I guess the hint animates 'over' the text you initially typed i.e. when you first go from empty to non-empty. Just giving f+ to get some discussion about this.

::: mobile/android/base/widget/FloatingHintEditText.java
@@ +38,5 @@
> +        super(context, attrs, defStyle);
> +
> +        floatingHintColors = getResources().getColorStateList(R.color.floating_hint_text);
> +        normalHintColors = getHintTextColors();
> +        wasEmpty = TextUtils.isEmpty(getText());

Is even possible to have non-empty text at this point?

@@ +92,5 @@
> +        // The large hint is drawn by Android, so do nothing.
> +        if (!isAnimating && TextUtils.isEmpty(getText())) {
> +            return;
> +        }
> +

Do paint = getPaint() here and reuse the value throughout this method? Same for getDrawableState().
Attachment #8418513 - Flags: review?(lucasr.at.mozilla) → feedback+
Comment on attachment 8418514 [details] [diff] [review]
Replace uses of EditText with FloatingHintEditText

Review of attachment 8418514 [details] [diff] [review]:
-----------------------------------------------------------------

Nice.
Attachment #8418514 - Flags: review?(lucasr.at.mozilla) → review+
(In reply to Lucas Rocha (:lucasr) from comment #9)
> Looking good overall. It's probably a good idea to be focus aware here so
> that we float the hint out of the way when the entry gets focus? With this
> patch as is, I guess the hint animates 'over' the text you initially typed
> i.e. when you first go from empty to non-empty. 

Interesting idea. Build here: http://people.mozilla.org/~bnicholson/fennec_builds/shrinking-hint4.apk

This solves the focus color inconsistency I mentioned in comment 3. On the downside, it's a bit more difficult to read the hint of an empty focused field, which might slow people down if they don't look at the hint before touching the field.

Ian, thoughts?
Flags: needinfo?(ibarlow)
(In reply to Brian Nicholson (:bnicholson) from comment #11)
> (In reply to Lucas Rocha (:lucasr) from comment #9)
> > Looking good overall. It's probably a good idea to be focus aware here so
> > that we float the hint out of the way when the entry gets focus? With this
> > patch as is, I guess the hint animates 'over' the text you initially typed
> > i.e. when you first go from empty to non-empty. 
> 
> Interesting idea. Build here:
> http://people.mozilla.org/~bnicholson/fennec_builds/shrinking-hint4.apk
> 
> This solves the focus color inconsistency I mentioned in comment 3. On the
> downside, it's a bit more difficult to read the hint of an empty focused
> field, which might slow people down if they don't look at the hint before
> touching the field.
> 
> Ian, thoughts?

Heh, I still prefer the one in comment 3.

The fact that the hint animates away just in time is part of what makes it feel so nice. If we are really worried about the hint animating over top of the text a user is typing, we could try other kinds of transitions, like a crossfade or something, but I'm not sure it's necessary...
Flags: needinfo?(ibarlow)
(In reply to Lucas Rocha (:lucasr) from comment #9)
> ::: mobile/android/base/widget/FloatingHintEditText.java
> @@ +38,5 @@
> > +        super(context, attrs, defStyle);
> > +
> > +        floatingHintColors = getResources().getColorStateList(R.color.floating_hint_text);
> > +        normalHintColors = getHintTextColors();
> > +        wasEmpty = TextUtils.isEmpty(getText());
> 
> Is even possible to have non-empty text at this point?

Sure, just set android:text="foo" in the XML.

> @@ +92,5 @@
> > +        // The large hint is drawn by Android, so do nothing.
> > +        if (!isAnimating && TextUtils.isEmpty(getText())) {
> > +            return;
> > +        }
> > +
> 
> Do paint = getPaint() here and reuse the value throughout this method? Same
> for getDrawableState().

Done (along with some other fixup).
Attachment #8418513 - Attachment is obsolete: true
Attachment #8427196 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 8427196 [details] [diff] [review]
Add FloatingHintEditText widget

Review of attachment 8427196 [details] [diff] [review]:
-----------------------------------------------------------------

Good.
Attachment #8427196 - Flags: review?(lucasr.at.mozilla) → review+
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: