More adjustments to quick contacts to fixup layout.
1) make website 1 line and ellipsize
2) give 12dip margin on top and bottom of all text
More fixes for bug:5233213 Quick contacts still needs some UI fixes
Change-Id: Ibba14d51bee44ca4e551ca411693035a5a45d57c
diff --git a/res/layout/quickcontact_list_item.xml b/res/layout/quickcontact_list_item.xml
index 5a1643c..ac258de 100755
--- a/res/layout/quickcontact_list_item.xml
+++ b/res/layout/quickcontact_list_item.xml
@@ -17,22 +17,9 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actions_view_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:background="?android:attr/selectableItemBackground"
- android:nextFocusRight="@+id/secondary_action_button">
- <LinearLayout
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingLeft="16dip"
- android:paddingRight="16dip"
- android:gravity="center_vertical"
- android:orientation="vertical"
- >
+ android:nextFocusRight="@+id/secondary_action_button"
+ style="@style/QuickContactListItemStyle">
+ <LinearLayout style="@style/QuickContactListItemTextWrapperStyle">
<TextView
android:id="@android:id/text1"
android:layout_width="wrap_content"
@@ -47,27 +34,5 @@
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
- <View
- android:id="@+id/vertical_divider"
- android:layout_width="1dip"
- android:layout_height="match_parent"
- android:layout_gravity="center_vertical"
- android:layout_marginTop="@dimen/detail_vertical_divider_vertical_margin"
- android:layout_marginBottom="@dimen/detail_vertical_divider_vertical_margin"
- android:background="?android:attr/dividerVertical" />
- <ImageView
- android:id="@+id/secondary_action_button"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="@dimen/detail_item_icon_margin"
- android:paddingRight="@dimen/detail_item_icon_margin"
- android:background="?android:attr/selectableItemBackground"
- android:duplicateParentState="false"
- android:nextFocusLeft="@id/actions_view_container" />
- <View
- android:id="@+id/vertical_divider"
- android:layout_width="1dip"
- android:layout_height="match_parent"
- android:layout_gravity="center_vertical"
- android:background="?android:attr/dividerVertical" />
+ <include layout="@layout/quickcontact_list_item_base"/>
</LinearLayout>
diff --git a/res/layout/quickcontact_list_item_base.xml b/res/layout/quickcontact_list_item_base.xml
new file mode 100644
index 0000000..84fc104
--- /dev/null
+++ b/res/layout/quickcontact_list_item_base.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <View
+ android:id="@+id/vertical_divider"
+ android:layout_width="1dip"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_vertical"
+ android:layout_marginTop="@dimen/detail_vertical_divider_vertical_margin"
+ android:layout_marginBottom="@dimen/detail_vertical_divider_vertical_margin"
+ android:background="?android:attr/dividerVertical" />
+ <ImageView
+ android:id="@+id/secondary_action_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/detail_item_icon_margin"
+ android:paddingRight="@dimen/detail_item_icon_margin"
+ android:background="?android:attr/selectableItemBackground"
+ android:duplicateParentState="false"
+ android:nextFocusLeft="@id/actions_view_container" />
+ <View
+ android:id="@+id/vertical_divider"
+ android:layout_width="1dip"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_vertical"
+ android:background="?android:attr/dividerVertical" />
+</merge>
diff --git a/res/layout/quickcontact_list_item_email.xml b/res/layout/quickcontact_list_item_email.xml
new file mode 100755
index 0000000..1524eab
--- /dev/null
+++ b/res/layout/quickcontact_list_item_email.xml
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/actions_view_container"
+ android:nextFocusRight="@+id/secondary_action_button"
+ style="@style/QuickContactListItemStyle">
+ <LinearLayout style="@style/QuickContactListItemTextWrapperStyle">
+ <TextView
+ android:id="@android:id/text1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/primary_text_color"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:singleLine="true"
+ android:ellipsize="middle" />
+ <TextView
+ android:id="@android:id/text2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/secondary_text_color"
+ android:textAllCaps="true"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+ </LinearLayout>
+ <include layout="@layout/quickcontact_list_item_base"/>
+</LinearLayout>
diff --git a/res/layout/quickcontact_list_item_website.xml b/res/layout/quickcontact_list_item_website.xml
new file mode 100755
index 0000000..3b1ccb1
--- /dev/null
+++ b/res/layout/quickcontact_list_item_website.xml
@@ -0,0 +1,33 @@
+<?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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/actions_view_container"
+ android:nextFocusRight="@+id/secondary_action_button"
+ style="@style/QuickContactListItemStyle">
+ <LinearLayout style="@style/QuickContactListItemTextWrapperStyle">
+ <TextView
+ android:id="@android:id/text1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="@color/primary_text_color"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:ellipsize="middle"
+ android:singleLine="true" />
+ </LinearLayout>
+ <include layout="@layout/quickcontact_list_item_base"/>
+</LinearLayout>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5e7d9e2..343d42c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -263,4 +263,24 @@
<item name="android:displayOptions"></item>
</style>
+ <style name="QuickContactListItemStyle">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:minHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="android:orientation">horizontal</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:background">?android:attr/selectableItemBackground</item>
+ </style>
+
+ <style name="QuickContactListItemTextWrapperStyle">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_weight">1</item>
+ <item name="android:paddingLeft">16dip</item>
+ <item name="android:paddingRight">16dip</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:orientation">vertical</item>
+ <item name="android:layout_marginTop">12dip</item>
+ <item name="android:layout_marginBottom">12dip</item>
+ </style>
</resources>
diff --git a/src/com/android/contacts/quickcontact/QuickContactListFragment.java b/src/com/android/contacts/quickcontact/QuickContactListFragment.java
index 5dd9db7..eed122f 100644
--- a/src/com/android/contacts/quickcontact/QuickContactListFragment.java
+++ b/src/com/android/contacts/quickcontact/QuickContactListFragment.java
@@ -20,7 +20,9 @@
import android.app.Fragment;
import android.os.Bundle;
+import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.CommonDataKinds.Website;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -87,12 +89,20 @@
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- final View resultView = convertView != null ? convertView
- : getActivity().getLayoutInflater()
- .inflate(R.layout.quickcontact_list_item, parent, false);
-
// Set action title based on summary value
final Action action = mActions.get(position);
+ String mimeType = action.getMimeType();
+ int layout = 0;
+ if (mimeType.equals(Website.CONTENT_ITEM_TYPE)) {
+ layout = R.layout.quickcontact_list_item_website;
+ } else if (mimeType.equals(Email.CONTENT_ITEM_TYPE)) {
+ layout = R.layout.quickcontact_list_item_email;
+ } else {
+ layout = R.layout.quickcontact_list_item;
+ }
+ final View resultView = convertView != null ? convertView
+ : getActivity().getLayoutInflater().inflate(layout, parent, false);
+
// TODO: Put those findViewByIds in a container
final TextView text1 = (TextView) resultView.findViewById(
@@ -116,7 +126,7 @@
alternateActionButton.setVisibility(hasAlternateAction ? View.VISIBLE : View.GONE);
// Special case for phone numbers in accessibility mode
- if (action.getMimeType().equals(Phone.CONTENT_ITEM_TYPE)) {
+ if (mimeType.equals(Phone.CONTENT_ITEM_TYPE)) {
text1.setContentDescription(getActivity().getString(
R.string.description_dial_phone_number, action.getBody()));
if (hasAlternateAction) {
@@ -126,14 +136,15 @@
}
text1.setText(action.getBody());
- CharSequence subtitle = action.getSubtitle();
- text2.setText(subtitle);
- if (TextUtils.isEmpty(subtitle)) {
- text2.setVisibility(View.GONE);
- } else {
- text2.setVisibility(View.VISIBLE);
+ if (text2 != null) {
+ CharSequence subtitle = action.getSubtitle();
+ text2.setText(subtitle);
+ if (TextUtils.isEmpty(subtitle)) {
+ text2.setVisibility(View.GONE);
+ } else {
+ text2.setVisibility(View.VISIBLE);
+ }
}
-
return resultView;
}
});