Expand/Collapse for RawContact sections in the Editor
Change-Id: I5330bcce244f813189886ae1e431d862d62cf5c9
diff --git a/res/layout/item_contact_editor.xml b/res/layout/item_contact_editor.xml
index 6882f85..7566b37 100644
--- a/res/layout/item_contact_editor.xml
+++ b/res/layout/item_contact_editor.xml
@@ -26,6 +26,7 @@
<RelativeLayout android:id="@+id/header"
android:layout_height="64dip"
android:layout_width="match_parent"
+ android:background="@android:drawable/list_selector_background"
>
<ImageView android:id="@+id/header_color_bar"
@@ -75,52 +76,57 @@
android:background="?android:attr/listDivider"
/>
-
</RelativeLayout>
- <FrameLayout
- android:id="@+id/stub_photo"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingLeft="12dip"
- android:paddingTop="10dip">
-
- <include
- android:id="@+id/edit_photo"
- layout="@layout/item_photo_editor" />
-
- </FrameLayout>
-
- <com.android.contacts.ui.widget.GenericEditorView
- android:id="@+id/edit_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="?android:attr/scrollbarSize"
- android:layout_below="@id/stub_photo"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="4dip" />
-
<LinearLayout
- android:id="@+id/sect_fields"
+ android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- />
+ android:orientation="vertical">
- <View
- android:layout_width="match_parent"
- android:layout_height="1px"
- android:layout_alignParentBottom="true"
- android:background="?android:attr/listDivider"
- />
+ <FrameLayout
+ android:id="@+id/stub_photo"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="12dip"
+ android:paddingTop="10dip">
- <Button
- android:id="@+id/button_add_field"
- android:text="@string/add_field"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:layout_marginTop="10dip"
- />
+ <include
+ android:id="@+id/edit_photo"
+ layout="@layout/item_photo_editor" />
+ </FrameLayout>
+
+ <com.android.contacts.ui.widget.GenericEditorView
+ android:id="@+id/edit_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="?android:attr/scrollbarSize"
+ android:layout_below="@id/stub_photo"
+ android:layout_marginTop="6dip"
+ android:layout_marginBottom="4dip" />
+
+ <LinearLayout
+ android:id="@+id/sect_fields"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:layout_alignParentBottom="true"
+ android:background="?android:attr/listDivider"
+ />
+
+ <Button
+ android:id="@+id/button_add_field"
+ android:text="@string/add_field"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:layout_marginTop="10dip"
+ />
+ </LinearLayout>
</com.android.contacts.ui.widget.ContactEditorView>
diff --git a/src/com/android/contacts/ui/widget/ContactEditorView.java b/src/com/android/contacts/ui/widget/ContactEditorView.java
index ff90f65..4cae9a6 100644
--- a/src/com/android/contacts/ui/widget/ContactEditorView.java
+++ b/src/com/android/contacts/ui/widget/ContactEditorView.java
@@ -27,6 +27,7 @@
import com.android.contacts.ui.ViewIdGenerator;
import com.android.contacts.util.DialogManager;
import com.android.contacts.util.DialogManager.DialogShowingView;
+import com.android.contacts.util.ViewGroupAnimator;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -47,6 +48,7 @@
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toast;
import java.util.ArrayList;
@@ -67,11 +69,14 @@
private ViewGroup mFields;
+ private View mHeader;
+ private View mBody;
private ImageView mHeaderIcon;
private TextView mHeaderAccountType;
private TextView mHeaderAccountName;
private Button mAddFieldButton;
+ private boolean mExpanded = true;
private long mRawContactId = -1;
@@ -106,6 +111,14 @@
mFields = (ViewGroup)findViewById(R.id.sect_fields);
+ mHeader = findViewById(R.id.header);
+ mBody = findViewById(R.id.body);
+ mHeader.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setExpanded(!mExpanded, true);
+ }
+ });
mHeaderIcon = (ImageView) findViewById(R.id.header_icon);
mHeaderAccountType = (TextView) findViewById(R.id.header_account_type);
mHeaderAccountName = (TextView) findViewById(R.id.header_account_name);
@@ -202,8 +215,16 @@
return mRawContactId;
}
- /* package */
- void showDialog(int bundleDialogId) {
+ /* package */ void setExpanded(boolean value, boolean animate) {
+ if (value == mExpanded) return;
+
+ ViewGroupAnimator animator = animate ? ViewGroupAnimator.captureView(getRootView()) : null;
+ mExpanded = value;
+ mBody.setVisibility(value ? View.VISIBLE : View.GONE);
+ if (animate) animator.animate();
+ }
+
+ /* package */ void showDialog(int bundleDialogId) {
final Bundle bundle = new Bundle();
bundle.putInt(DIALOG_ID_KEY, bundleDialogId);
getDialogManager().showDialogInView(this, bundle);