Merge "Contact editor fixes"
diff --git a/res/layout-sw580dp/event_field_editor_view.xml b/res/layout-sw580dp/event_field_editor_view.xml
index c9eef08..f31b283 100644
--- a/res/layout-sw580dp/event_field_editor_view.xml
+++ b/res/layout-sw580dp/event_field_editor_view.xml
@@ -23,10 +23,6 @@
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical">
- <include
- android:id="@+id/title"
- layout="@layout/edit_field_title" />
-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout-sw580dp/item_kind_section.xml b/res/layout-sw580dp/item_kind_section.xml
index dd38e26..31538bb 100644
--- a/res/layout-sw580dp/item_kind_section.xml
+++ b/res/layout-sw580dp/item_kind_section.xml
@@ -22,11 +22,9 @@
android:layout_height="wrap_content"
android:paddingBottom="@dimen/editor_field_bottom_padding"
android:orientation="vertical">
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:scaleType="fitXY"
- android:src="@drawable/divider_horizontal_light" />
+
+ <include
+ layout="@layout/edit_kind_title" />
<LinearLayout
android:id="@+id/kind_editors"
diff --git a/res/layout-sw580dp/text_fields_editor_view.xml b/res/layout-sw580dp/text_fields_editor_view.xml
index 8be354b..be0ea67 100644
--- a/res/layout-sw580dp/text_fields_editor_view.xml
+++ b/res/layout-sw580dp/text_fields_editor_view.xml
@@ -21,10 +21,6 @@
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical">
- <include
- android:id="@+id/title"
- layout="@layout/edit_field_title" />
-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/edit_field_title.xml b/res/layout/edit_field_title.xml
deleted file mode 100644
index 4918c4d..0000000
--- a/res/layout/edit_field_title.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Title of a field in the contact editor. -->
-
-<TextView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="@dimen/editor_field_top_padding"
- android:paddingLeft="@dimen/editor_field_left_padding"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
\ No newline at end of file
diff --git a/res/layout/edit_kind_title.xml b/res/layout/edit_kind_title.xml
new file mode 100644
index 0000000..619ba49
--- /dev/null
+++ b/res/layout/edit_kind_title.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="@dimen/editor_field_left_padding"
+ android:paddingRight="@dimen/editor_field_right_padding"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/kind_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="@dimen/editor_field_left_padding"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/people_app_theme_color"
+ android:textStyle="bold"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:paddingTop="5dip"
+ android:paddingBottom="2dip" />
+
+ <ImageView
+ android:id="@+id/divider"
+ android:layout_width="match_parent"
+ android:layout_height="2dip"
+ android:scaleType="fitXY"
+ android:src="@color/people_app_theme_color"/>
+
+</LinearLayout>
diff --git a/res/layout/edit_spinner.xml b/res/layout/edit_spinner.xml
index 9e22ee7..3896702 100644
--- a/res/layout/edit_spinner.xml
+++ b/res/layout/edit_spinner.xml
@@ -16,11 +16,12 @@
<!-- Spinner for a field in the contact editor. -->
+<!-- Note: explicitly override the default left and right padding on spinner -->
<Spinner
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinner"
- android:layout_width="wrap_content"
+ android:layout_width="@dimen/editor_type_label_width"
android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/editor_field_left_padding"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:paddingLeft="5dip"/>
\ No newline at end of file
+ android:paddingLeft="5dip"
+ android:paddingRight="0dip"
+ android:textAppearance="?android:attr/textAppearanceSmall"/>
\ No newline at end of file
diff --git a/res/layout/event_field_editor_view.xml b/res/layout/event_field_editor_view.xml
index 6625279..0dceafc 100644
--- a/res/layout/event_field_editor_view.xml
+++ b/res/layout/event_field_editor_view.xml
@@ -22,15 +22,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">
- <include
- android:id="@+id/title"
- layout="@layout/edit_field_title" />
-
- <include
- android:id="@+id/spinner"
- layout="@layout/edit_spinner"
- android:visibility="gone" />
-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -45,6 +36,11 @@
layout="@layout/edit_date_picker" />
<include
+ android:id="@+id/spinner"
+ layout="@layout/edit_spinner"
+ android:visibility="gone" />
+
+ <include
android:id="@+id/delete_button_container"
layout="@layout/edit_delete_button"
android:visibility="gone" />
diff --git a/res/layout/item_group_membership.xml b/res/layout/item_group_membership.xml
index 13ddb20..62d06ea 100644
--- a/res/layout/item_group_membership.xml
+++ b/res/layout/item_group_membership.xml
@@ -20,15 +20,8 @@
android:layout_height="wrap_content"
android:orientation="vertical">
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:scaleType="fitXY"
- android:src="@drawable/divider_horizontal_light" />
-
<include
- android:id="@+id/kind_title"
- layout="@layout/edit_field_title" />
+ layout="@layout/edit_kind_title" />
<Button
style="?android:attr/spinnerStyle"
@@ -41,7 +34,6 @@
android:gravity="left|center_vertical"
android:ellipsize="end"
android:focusable="true"
- android:paddingLeft="@dimen/editor_field_left_padding"
- />
+ android:paddingLeft="@dimen/editor_field_left_padding" />
</com.android.contacts.editor.GroupMembershipView>
diff --git a/res/layout/item_kind_section.xml b/res/layout/item_kind_section.xml
index 2c6dc6f..edc9d37 100644
--- a/res/layout/item_kind_section.xml
+++ b/res/layout/item_kind_section.xml
@@ -23,11 +23,8 @@
android:paddingBottom="@dimen/editor_field_bottom_padding"
android:orientation="vertical">
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:scaleType="fitXY"
- android:src="@drawable/divider_horizontal_light" />
+ <include
+ layout="@layout/edit_kind_title" />
<LinearLayout
android:id="@+id/kind_editors"
diff --git a/res/layout/text_fields_editor_view.xml b/res/layout/text_fields_editor_view.xml
index d33e804..c8d35a4 100644
--- a/res/layout/text_fields_editor_view.xml
+++ b/res/layout/text_fields_editor_view.xml
@@ -20,15 +20,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">
- <include
- android:id="@+id/title"
- layout="@layout/edit_field_title" />
-
- <include
- android:id="@+id/spinner"
- layout="@layout/edit_spinner"
- android:visibility="gone" />
-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -43,6 +34,11 @@
layout="@layout/edit_field_list" />
<include
+ android:id="@+id/spinner"
+ layout="@layout/edit_spinner"
+ android:visibility="gone" />
+
+ <include
android:id="@+id/expansion_view_container"
layout="@layout/edit_expansion_view"
android:visibility="gone" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5f288da..9ee88a8 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -45,7 +45,7 @@
<dimen name="editor_round_button_padding_bottom">8dip</dimen>
<!-- Width of the Type-Label in the Editor -->
- <dimen name="editor_type_label_width">120dip</dimen>
+ <dimen name="editor_type_label_width">100dip</dimen>
<!-- Left padding of a field in the Editor -->
<dimen name="editor_field_left_padding">5dip</dimen>
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 6afe8b9..85d21f3 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -571,8 +571,8 @@
final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
- int size = mState.size();
- for (int i = 0; i < size; i++) {
+ int numRawContacts = mState.size();
+ for (int i = 0; i < numRawContacts; i++) {
// TODO ensure proper ordering of entities in the list
final EntityDelta entity = mState.get(i);
final ValuesDelta values = entity.getValues();
@@ -588,10 +588,16 @@
R.layout.external_raw_contact_editor_view, mContent, false);
((ExternalRawContactEditorView) editor).setListener(this);
} else {
- editor = (BaseRawContactEditorView)
+ final RawContactEditorView rawContactEditor = (RawContactEditorView)
inflater.inflate(R.layout.raw_contact_editor_view, mContent, false);
+ // For existing contacts, only show the account header if there is more than 1 raw
+ // contact in the aggregate contact.
+ if (Intent.ACTION_EDIT.equals(mAction)) {
+ rawContactEditor.setAccountHeaderVisible(numRawContacts > 1);
+ }
+ editor = rawContactEditor;
}
- if (Intent.ACTION_INSERT.equals(mAction) && size == 1) {
+ if (Intent.ACTION_INSERT.equals(mAction) && numRawContacts == 1) {
final ArrayList<Account> accounts =
AccountTypeManager.getInstance(mContext).getAccounts(true);
if (accounts.size() > 1) {
@@ -600,6 +606,7 @@
disableAccountSwitcher(editor);
}
}
+
editor.setEnabled(mEnabled);
mContent.addView(editor);
@@ -708,6 +715,7 @@
// on an existing contact
final View accountView = editor.findViewById(R.id.account);
accountView.setBackgroundDrawable(null);
+ accountView.setEnabled(false);
}
@Override
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index 8ca7a05..bd2a9a6 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -43,6 +43,7 @@
public class KindSectionView extends LinearLayout implements EditorListener {
private static final String TAG = "KindSectionView";
+ private TextView mTitle;
private ViewGroup mEditors;
private View mAddFieldFooter;
private TextView mAddFieldText;
@@ -93,7 +94,8 @@
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mEditors = (ViewGroup)findViewById(R.id.kind_editors);
+ mTitle = (TextView) findViewById(R.id.kind_title);
+ mEditors = (ViewGroup) findViewById(R.id.kind_editors);
mAddFieldText = (TextView) findViewById(R.id.add_text);
mAddFieldFooter = findViewById(R.id.add_field_footer);
mAddFieldFooter.setOnClickListener(new OnClickListener() {
@@ -135,6 +137,7 @@
mTitleString = (kind.titleRes == -1 || kind.titleRes == 0)
? ""
: getResources().getString(kind.titleRes);
+ mTitle.setText(mTitleString.toUpperCase());
// Set "add field" footer message according to MIME type. Some MIME types
// can only have max 1 field, so the resource ID will be -1 if these sections
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index ddecf5a..361d769 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -62,7 +62,6 @@
private static final int INPUT_TYPE_CUSTOM = EditorInfo.TYPE_CLASS_TEXT
| EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS;
- private TextView mTitle;
private Spinner mLabel;
private EditTypeAdapter mEditTypeAdapter;
private View mDeleteContainer;
@@ -124,8 +123,6 @@
@Override
protected void onFinishInflate() {
- mTitle = (TextView) findViewById(R.id.title);
-
mLabel = (Spinner) findViewById(R.id.spinner);
mLabel.setOnItemSelectedListener(mSpinnerListener);
@@ -165,26 +162,19 @@
}
/**
- * Creates or removes the type/label button. Doesn't do anything if already correctly configured
+ * Configures the visibility of the type label button and enables or disables it properly.
*/
private void setupLabelButton(boolean shouldExist) {
- if (mTitle == null) {
- return;
- }
if (shouldExist) {
mLabel.setEnabled(!mReadOnly && isEnabled());
mLabel.setVisibility(View.VISIBLE);
-
- // Since there's a spinner for this editor, use this as the title
- // instead of the title TextView.
- mTitle.setVisibility(View.GONE);
} else {
mLabel.setVisibility(View.GONE);
}
}
/**
- * Creates or removes the remove button. Doesn't do anything if already correctly configured
+ * Configures the visibility of the "delete" button and enables or disables it properly.
*/
private void setupDeleteButton() {
if (mIsDeletable) {
@@ -197,7 +187,7 @@
public void setDeleteButtonVisible(boolean visible) {
if (mIsDeletable) {
- mDeleteContainer.setVisibility(visible ? View.VISIBLE : View.GONE);
+ mDeleteContainer.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
}
@@ -275,7 +265,7 @@
if (mWasEmpty != isEmpty) {
if (isEmpty) {
mListener.onRequest(EditorListener.FIELD_TURNED_EMPTY);
- if (mIsDeletable) mDeleteContainer.setVisibility(View.GONE);
+ if (mIsDeletable) mDeleteContainer.setVisibility(View.INVISIBLE);
} else {
mListener.onRequest(EditorListener.FIELD_TURNED_NON_EMPTY);
if (mIsDeletable) mDeleteContainer.setVisibility(View.VISIBLE);
@@ -318,18 +308,6 @@
}
setVisibility(View.VISIBLE);
- // TODO: handle resources from remote packages
- String titleString = (kind.titleRes == -1 || kind.titleRes == 0)
- ? ""
- : getResources().getString(kind.titleRes);
-
- // If there is a title field, then setup the title (although it may not be shown if there is
- // a Spinner setup later). There are cases where a title may not be present (i.e. structured
- // name).
- if (mTitle != null) {
- mTitle.setText(titleString.toUpperCase());
- }
-
// Display label selector if multiple types available
final boolean hasTypes = EntityModifier.hasEditTypes(kind);
setupLabelButton(hasTypes);
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index b0230fc..881f590 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -139,7 +139,7 @@
mFields = (ViewGroup)findViewById(R.id.sect_fields);
- mAccountContainer = findViewById(R.id.account);
+ mAccountContainer = findViewById(R.id.anchor_for_account_switcher);
mAccountIcon = (ImageView) findViewById(R.id.account_icon);
mAccountTypeTextView = (TextView) findViewById(R.id.account_type);
mAccountNameTextView = (TextView) findViewById(R.id.account_name);
@@ -153,6 +153,10 @@
});
}
+ public void setAccountHeaderVisible(boolean visible) {
+ mAccountContainer.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+
/**
* Set the internal state for this view, given a current
* {@link EntityDelta} state and the {@link AccountType} that
@@ -176,9 +180,6 @@
ValuesDelta values = state.getValues();
mRawContactId = values.getAsLong(RawContacts._ID);
- final ArrayList<Account> accounts =
- AccountTypeManager.getInstance(mContext).getAccounts(true);
-
// Fill in the account info
String accountName = values.getAsString(RawContacts.ACCOUNT_NAME);
CharSequence accountType = type.getDisplayLabel(mContext);