diff options
-rw-r--r-- | src/com/android/contacts/editor/EditorAnimator.java | 22 | ||||
-rw-r--r-- | src/com/android/contacts/editor/LabeledEditorView.java | 11 | ||||
-rw-r--r-- | src/com/android/contacts/editor/TextFieldsEditorView.java | 4 |
3 files changed, 31 insertions, 6 deletions
diff --git a/src/com/android/contacts/editor/EditorAnimator.java b/src/com/android/contacts/editor/EditorAnimator.java index 2e17e2323..251357a52 100644 --- a/src/com/android/contacts/editor/EditorAnimator.java +++ b/src/com/android/contacts/editor/EditorAnimator.java @@ -47,7 +47,15 @@ public class EditorAnimator { private AnimatorRunner mRunner = new AnimatorRunner(); + public void hideEditorView(final View victim) { + removeEditorView(victim, /* removeVictimFromParent =*/ false); + } + public void removeEditorView(final View victim) { + removeEditorView(victim, /* removeVictimFromParent =*/ true); + } + + private void removeEditorView(final View victim, final boolean removeVictimFromParent) { mRunner.endOldAnimation(); final int offset = victim.getHeight(); @@ -71,11 +79,15 @@ public class EditorAnimator { final View view = viewsToMove.get(i); view.setTranslationY(0.0f); } - // Remove our target view (if parent is null, we were run several times by quick - // fingers. Just ignore) - final ViewGroup victimParent = (ViewGroup) victim.getParent(); - if (victimParent != null) { - victimParent.removeView(victim); + if (removeVictimFromParent) { + // Remove our target view (if parent is null, we were run several times by quick + // fingers. Just ignore) + final ViewGroup victimParent = (ViewGroup) victim.getParent(); + if (victimParent != null) { + victimParent.removeView(victim); + } + } else { + victim.setVisibility(View.GONE); } } }); diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java index b60ae5c11..cf94d8f6a 100644 --- a/src/com/android/contacts/editor/LabeledEditorView.java +++ b/src/com/android/contacts/editor/LabeledEditorView.java @@ -254,7 +254,16 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor, */ public void showType() { if (mHasTypes && mLabel != null && mLabel.getVisibility() != View.VISIBLE) { - mLabel.setVisibility(View.VISIBLE); + EditorAnimator.getInstance().slideAndFadeIn(mLabel, mLabel.getHeight()); + } + } + + /** + * Hides the type drop down if there are types to display and it is not already hidden. + */ + public void hideType() { + if (mHasTypes && mLabel != null && mLabel.getVisibility() != View.GONE) { + EditorAnimator.getInstance().hideEditorView(mLabel); } } diff --git a/src/com/android/contacts/editor/TextFieldsEditorView.java b/src/com/android/contacts/editor/TextFieldsEditorView.java index 6f24bb911..93454344d 100644 --- a/src/com/android/contacts/editor/TextFieldsEditorView.java +++ b/src/com/android/contacts/editor/TextFieldsEditorView.java @@ -159,7 +159,11 @@ public class TextFieldsEditorView extends LabeledEditorView { getEditorListener().onRequest(EditorListener.EDITOR_FOCUS_CHANGED); } if (foundFocus && !isTypeVisible()) { + // We just got focus and the types are not visible showType(); + } else if (isEmpty()) { + // We just lost focus and the field is empty + hideType(); } // Rebuild the label spinner using the new colors. rebuildLabel(); |