Show correct activated/selected effect for lists
- copy system assets for activated/selected states to the project
-- rename existing list_pressed_holo_light to
action_bar_item_pressed_holo_light since the name is not
appropriate and used by system assets.
- use white color for activated/selected texts
- make ContactListItemView show "pressed" effect correctly
-- "activated" background should not be shown when the item
is not activated. If it shows it, "pressed" effect is hidden
by the wrong background.
-- The background itself is needed to not highlight section
headers.
-- manually call setActivated() toward children. Without it,
they look "black" on the first app boot.
- remove an animation parameter for ContactListItemView's
"activated" background. The animation makes the whole item
flicker.
Bug: 5191524
Bug: 5199800
Bug: 5136917
Change-Id: I7c08d8f533f0dd5318c614e3df14bb39207485e9
diff --git a/res/color/list_primary_text_color.xml b/res/color/list_primary_text_color.xml
new file mode 100644
index 0000000..7c185fc
--- /dev/null
+++ b/res/color/list_primary_text_color.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:state_activated="true" android:color="@color/primary_text_color_activated"/>
+ <item android:color="@color/primary_text_color" /> <!-- not selected -->
+
+</selector>
diff --git a/res/color/list_secondary_text_color.xml b/res/color/list_secondary_text_color.xml
new file mode 100644
index 0000000..edf8678
--- /dev/null
+++ b/res/color/list_secondary_text_color.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:state_activated="true" android:color="@color/secondary_text_color_activated" />
+ <item android:color="@color/secondary_text_color" /> <!-- not selected -->
+
+</selector>
diff --git a/res/drawable-hdpi/action_bar_item_pressed_holo_light.9.png b/res/drawable-hdpi/action_bar_item_pressed_holo_light.9.png
new file mode 100644
index 0000000..cf5ff8e
--- /dev/null
+++ b/res/drawable-hdpi/action_bar_item_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-hdpi/list_activated_holo.9.png b/res/drawable-hdpi/list_activated_holo.9.png
index 046b24a..4ea7afa 100644
--- a/res/drawable-hdpi/list_activated_holo.9.png
+++ b/res/drawable-hdpi/list_activated_holo.9.png
Binary files differ
diff --git a/res/drawable-hdpi/list_focused_holo.9.png b/res/drawable-hdpi/list_focused_holo.9.png
index e962ce8..516f5c7 100644
--- a/res/drawable-hdpi/list_focused_holo.9.png
+++ b/res/drawable-hdpi/list_focused_holo.9.png
Binary files differ
diff --git a/res/drawable-hdpi/list_pressed_holo_light.9.png b/res/drawable-hdpi/list_pressed_holo_light.9.png
index cf5ff8e..5654cd6 100644
--- a/res/drawable-hdpi/list_pressed_holo_light.9.png
+++ b/res/drawable-hdpi/list_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-mdpi/action_bar_item_pressed_holo_light.9.png b/res/drawable-mdpi/action_bar_item_pressed_holo_light.9.png
new file mode 100644
index 0000000..3a9686d
--- /dev/null
+++ b/res/drawable-mdpi/action_bar_item_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-mdpi/list_activated_holo.9.png b/res/drawable-mdpi/list_activated_holo.9.png
index 1ff3373..3bf8e03 100644
--- a/res/drawable-mdpi/list_activated_holo.9.png
+++ b/res/drawable-mdpi/list_activated_holo.9.png
Binary files differ
diff --git a/res/drawable-mdpi/list_focused_holo.9.png b/res/drawable-mdpi/list_focused_holo.9.png
index 6e041f3..7c0599e 100644
--- a/res/drawable-mdpi/list_focused_holo.9.png
+++ b/res/drawable-mdpi/list_focused_holo.9.png
Binary files differ
diff --git a/res/drawable-mdpi/list_pressed_holo_light.9.png b/res/drawable-mdpi/list_pressed_holo_light.9.png
index 3a9686d..6e77525 100644
--- a/res/drawable-mdpi/list_pressed_holo_light.9.png
+++ b/res/drawable-mdpi/list_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/action_bar_item_pressed_holo_light.9.png b/res/drawable-xhdpi/action_bar_item_pressed_holo_light.9.png
new file mode 100644
index 0000000..8ff9dca
--- /dev/null
+++ b/res/drawable-xhdpi/action_bar_item_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/list_activated_holo.9.png b/res/drawable-xhdpi/list_activated_holo.9.png
index 2eb7c7e..eda10e6 100644
--- a/res/drawable-xhdpi/list_activated_holo.9.png
+++ b/res/drawable-xhdpi/list_activated_holo.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/list_focused_holo.9.png b/res/drawable-xhdpi/list_focused_holo.9.png
index 9c90c2b..690cb1e 100644
--- a/res/drawable-xhdpi/list_focused_holo.9.png
+++ b/res/drawable-xhdpi/list_focused_holo.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/list_pressed_holo_light.9.png b/res/drawable-xhdpi/list_pressed_holo_light.9.png
index 8ff9dca..e4b3393 100644
--- a/res/drawable-xhdpi/list_pressed_holo_light.9.png
+++ b/res/drawable-xhdpi/list_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable/action_bar_item_background.xml b/res/drawable/action_bar_item_background.xml
index 1fd4614..8dd8d9b 100644
--- a/res/drawable/action_bar_item_background.xml
+++ b/res/drawable/action_bar_item_background.xml
@@ -16,6 +16,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
- <item android:state_pressed="true" android:drawable="@drawable/list_pressed_holo_light"/>
+ <item android:state_pressed="true" android:drawable="@drawable/action_bar_item_pressed_holo_light"/>
<item android:drawable="@android:color/transparent" />
-</selector>
\ No newline at end of file
+</selector>
diff --git a/res/drawable/group_list_item_background.xml b/res/drawable/group_list_item_background.xml
index 0e2e604..345117f 100644
--- a/res/drawable/group_list_item_background.xml
+++ b/res/drawable/group_list_item_background.xml
@@ -17,6 +17,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_activated="true" android:drawable="@drawable/list_activated_holo" />
- <item android:state_pressed="true" android:drawable="@drawable/list_pressed_holo" />
+ <item android:state_pressed="true" android:drawable="@drawable/list_pressed_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/list_focused_holo" />
-</selector>
\ No newline at end of file
+</selector>
diff --git a/res/drawable/list_item_activated_background.xml b/res/drawable/list_item_activated_background.xml
index 6ea21d3..a58577e 100644
--- a/res/drawable/list_item_activated_background.xml
+++ b/res/drawable/list_item_activated_background.xml
@@ -14,8 +14,7 @@
limitations under the License.
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android"
- android:exitFadeDuration="@android:integer/config_mediumAnimTime">
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@drawable/list_activated_holo" />
<item android:drawable="@drawable/list_background_holo" />
-</selector>
\ No newline at end of file
+</selector>
diff --git a/res/layout/group_browse_list_item.xml b/res/layout/group_browse_list_item.xml
index cc388f7..b213754 100644
--- a/res/layout/group_browse_list_item.xml
+++ b/res/layout/group_browse_list_item.xml
@@ -71,6 +71,7 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/list_primary_text_color"
android:ellipsize="end"
android:singleLine="true" />
@@ -79,7 +80,7 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorTertiary"
+ android:textColor="@color/list_secondary_text_color"
android:ellipsize="end"
android:singleLine="true" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0b8f1b7..5e8bd70 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -83,10 +83,16 @@
<!-- Primary text color in the People app -->
<color name="primary_text_color">#333333</color>
+ <!-- Activated primary text color in the People app -->
+ <color name="primary_text_color_activated">#FFFFFF</color>
+
<!-- Secondary text color in the People app -->
<color name="secondary_text_color">#777777</color>
<color name="dialtacts_secondary_text_color">#888888</color>
+ <!-- Activated secondary text color in the People app -->
+ <color name="secondary_text_color_activated">#FFFFFF</color>
+
<!-- Colors in the contact browser list -->
<color name="contact_count_text_color">#AAAAAA</color>
diff --git a/src/com/android/contacts/list/ContactEntryListFragment.java b/src/com/android/contacts/list/ContactEntryListFragment.java
index a4163fd..e43e94e 100644
--- a/src/com/android/contacts/list/ContactEntryListFragment.java
+++ b/src/com/android/contacts/list/ContactEntryListFragment.java
@@ -751,8 +751,6 @@
"'android.R.id.list'");
}
- mListView.setSelector(getContext().getResources().getDrawable(R.drawable.list_selector));
-
View emptyView = mView.findViewById(com.android.internal.R.id.empty);
if (emptyView != null) {
mListView.setEmptyView(emptyView);
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index f16102d..4b86295 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -24,6 +24,7 @@
import com.android.contacts.widget.TextWithHighlightingFactory;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.database.CharArrayBuffer;
import android.database.Cursor;
@@ -120,6 +121,9 @@
private TextView mCountView;
private ImageView mPresenceIcon;
+ private ColorStateList mPrimaryTextColor;
+ private ColorStateList mSecondaryTextColor;
+
private char[] mHighlightedPrefix;
private int mDefaultPhotoViewSize;
@@ -248,6 +252,9 @@
Color.GREEN));
a.recycle();
+ mPrimaryTextColor = getResources().getColorStateList(R.color.list_primary_text_color);
+ mSecondaryTextColor = getResources().getColorStateList(R.color.list_secondary_text_color);
+
mHorizontalDividerHeight = mHorizontalDividerDrawable.getIntrinsicHeight();
if (mActivatedBackgroundDrawable != null) {
@@ -409,7 +416,7 @@
mBoundsWithoutHeader.set(0, topBound, width, bottomBound);
- if (mActivatedStateSupported) {
+ if (mActivatedStateSupported && isActivated()) {
mActivatedBackgroundDrawable.setBounds(mBoundsWithoutHeader);
}
@@ -624,7 +631,7 @@
@Override
public void dispatchDraw(Canvas canvas) {
- if (mActivatedStateSupported) {
+ if (mActivatedStateSupported && isActivated()) {
mActivatedBackgroundDrawable.draw(canvas);
}
if (mHorizontalDividerVisible) {
@@ -759,6 +766,10 @@
mNameTextView.setSingleLine(true);
mNameTextView.setEllipsize(getTextEllipsis());
mNameTextView.setTextAppearance(mContext, android.R.style.TextAppearance_Medium);
+ mNameTextView.setTextColor(mPrimaryTextColor);
+ // Manually call setActivated() since this view may be added after the first
+ // setActivated() call toward this whole item view.
+ mNameTextView.setActivated(isActivated());
mNameTextView.setGravity(Gravity.CENTER_VERTICAL);
addView(mNameTextView);
}
@@ -815,6 +826,8 @@
mPhoneticNameTextView.setEllipsize(getTextEllipsis());
mPhoneticNameTextView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
mPhoneticNameTextView.setTypeface(mPhoneticNameTextView.getTypeface(), Typeface.BOLD);
+ mPhoneticNameTextView.setTextColor(mPrimaryTextColor);
+ mPhoneticNameTextView.setActivated(isActivated());
addView(mPhoneticNameTextView);
}
return mPhoneticNameTextView;
@@ -860,6 +873,8 @@
mLabelView.setEllipsize(getTextEllipsis());
mLabelView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
mLabelView.setTypeface(mLabelView.getTypeface(), Typeface.BOLD);
+ mLabelView.setTextColor(mPrimaryTextColor);
+ mLabelView.setActivated(isActivated());
addView(mLabelView);
}
return mLabelView;
@@ -890,6 +905,8 @@
mDataView.setSingleLine(true);
mDataView.setEllipsize(getTextEllipsis());
mDataView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
+ mDataView.setTextColor(mPrimaryTextColor);
+ mDataView.setActivated(isActivated());
addView(mDataView);
}
return mDataView;
@@ -919,6 +936,8 @@
mSnippetView.setEllipsize(getTextEllipsis());
mSnippetView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
mSnippetView.setTypeface(mSnippetView.getTypeface(), Typeface.BOLD);
+ mSnippetView.setTextColor(mPrimaryTextColor);
+ mSnippetView.setActivated(isActivated());
addView(mSnippetView);
}
return mSnippetView;
@@ -927,14 +946,14 @@
/**
* Returns the text view for the status, creating it if necessary.
*/
-
public TextView getStatusView() {
if (mStatusView == null) {
mStatusView = new TextView(mContext);
mStatusView.setSingleLine(true);
mStatusView.setEllipsize(getTextEllipsis());
mStatusView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
- mStatusView.setTextColor(R.color.secondary_text_color);
+ mStatusView.setTextColor(mSecondaryTextColor);
+ mStatusView.setActivated(isActivated());
addView(mStatusView);
}
return mStatusView;