Merge "Add final backgrounds to message list items"

This commit is contained in:
Marc Blank 2011-01-05 11:46:53 -08:00 committed by Android (Google) Code Review
commit 12247faa91
5 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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_focused="true"
android:drawable="@drawable/list_message_focused_holo" />
<item android:state_pressed="true"
android:drawable="@drawable/list_message_pressed_holo" />
<item android:drawable="@drawable/list_message_read_holo" />
</selector>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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_focused="true"
android:drawable="@drawable/list_message_focused_holo" />
<item android:state_pressed="true"
android:drawable="@drawable/list_message_pressed_holo" />
<item android:drawable="@drawable/list_message_unread_holo" />
</selector>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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:drawable="@drawable/list_message_wide_read_pressed_holo" />
<item android:drawable="@drawable/list_message_wide_read_normal_holo" />
</selector>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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:drawable="@drawable/list_message_wide_unread_pressed_holo" />
<item android:drawable="@drawable/list_message_wide_unread_normal_holo" />
</selector>

View File

@ -27,6 +27,7 @@ import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.FontMetricsInt;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.Layout.Alignment;
import android.text.Spannable;
import android.text.SpannableString;
@ -136,6 +137,10 @@ public class MessageListItem extends View {
private static int sColorTipHeight;
private static int sColorTipRightMarginOnNarrow;
private static int sColorTipRightMarginOnWide;
private static Drawable sReadSelector;
private static Drawable sUnreadSelector;
private static Drawable sWideReadSelector;
private static Drawable sWideUnreadSelector;
public int mSnippetLineCount = NEEDS_LAYOUT;
private final CharSequence[] mSnippetLines = new CharSequence[MAX_SUBJECT_SNIPPET_LINES];
@ -205,6 +210,10 @@ public class MessageListItem extends View {
BitmapFactory.decodeResource(r, R.drawable.btn_check_off_normal_holo_light);
sSelectedIconOn =
BitmapFactory.decodeResource(r, R.drawable.btn_check_on_normal_holo_light);
sReadSelector = r.getDrawable(R.drawable.message_list_read_selector);
sUnreadSelector = r.getDrawable(R.drawable.message_list_unread_selector);
sWideReadSelector = r.getDrawable(R.drawable.message_list_wide_read_selector);
sWideUnreadSelector = r.getDrawable(R.drawable.message_list_wide_unread_selector);
sFavoriteIconWidth = sFavoriteIconOff.getWidth();
sInit = true;
@ -226,6 +235,20 @@ public class MessageListItem extends View {
}
private void calculateDrawingData() {
if (mRead) {
if (mMode == MODE_WIDE) {
setBackgroundDrawable(sWideReadSelector);
} else {
setBackgroundDrawable(sReadSelector);
}
} else {
if (mMode == MODE_WIDE) {
setBackgroundDrawable(sWideUnreadSelector);
} else {
setBackgroundDrawable(sUnreadSelector);
}
}
SpannableStringBuilder ssb = new SpannableStringBuilder();
boolean hasSubject = false;
if (!TextUtils.isEmpty(mSubject)) {