Distinguish unread threads with background color.
This commit is contained in:
parent
0a8c62e0e3
commit
71f43075a9
10 changed files with 71 additions and 1 deletions
BIN
res/drawable-hdpi/list_selected_holo_light.9.png
Normal file
BIN
res/drawable-hdpi/list_selected_holo_light.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 156 B |
BIN
res/drawable-hdpi/list_selector_background_selected.9.png
Normal file
BIN
res/drawable-hdpi/list_selector_background_selected.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 748 B |
BIN
res/drawable-mdpi/list_selected_holo_light.9.png
Normal file
BIN
res/drawable-mdpi/list_selected_holo_light.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 151 B |
BIN
res/drawable-mdpi/list_selector_background_selected.9.png
Normal file
BIN
res/drawable-mdpi/list_selector_background_selected.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 562 B |
BIN
res/drawable-xhdpi/list_selected_holo_light.9.png
Normal file
BIN
res/drawable-xhdpi/list_selected_holo_light.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 160 B |
BIN
res/drawable-xhdpi/list_selector_background_selected.9.png
Normal file
BIN
res/drawable-xhdpi/list_selector_background_selected.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 985 B |
26
res/drawable/conversation_list_item_background_read.xml
Normal file
26
res/drawable/conversation_list_item_background_read.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2007 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_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/read_bgcolor" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
26
res/drawable/conversation_list_item_background_unread.xml
Normal file
26
res/drawable/conversation_list_item_background_unread.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2007 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_selected="true"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_pressed="true" android:state_selected="false"
|
||||
android:drawable="@android:color/transparent" />
|
||||
<item android:state_selected="false" android:state_activated="false"
|
||||
android:drawable="@color/unread_bgcolor" />
|
||||
<item android:state_activated="true"
|
||||
android:drawable="@drawable/list_selector_background_selected" />
|
||||
</selector>
|
|
@ -2,4 +2,7 @@
|
|||
<resources>
|
||||
<drawable name="white_background">#ffffffff</drawable>
|
||||
<drawable name="text_color_black">#ff000000</drawable>
|
||||
|
||||
<color name="unread_bgcolor">#ffffffff</color>
|
||||
<color name="read_bgcolor">#ffeeeeee</color>
|
||||
</resources>
|
|
@ -113,7 +113,9 @@ public class ConversationListItem extends RelativeLayout
|
|||
this.subjectView.setText(thread.getBody(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
if (thread.getEmphasis())
|
||||
((Spannable)this.subjectView.getText()).setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, this.subjectView.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
((Spannable)this.subjectView.getText()).setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0,
|
||||
this.subjectView.getText().length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
if (thread.getDate() > 0)
|
||||
this.dateView.setText(DateUtils.getRelativeTimeSpanString(getContext(), thread.getDate(), false));
|
||||
|
@ -124,6 +126,7 @@ public class ConversationListItem extends RelativeLayout
|
|||
if (batchMode) checkbox.setVisibility(View.VISIBLE);
|
||||
else checkbox.setVisibility(View.GONE);
|
||||
|
||||
setBackground(read, batchMode);
|
||||
setContactPhoto(this.recipients.getPrimaryRecipient());
|
||||
}
|
||||
|
||||
|
@ -167,6 +170,16 @@ public class ConversationListItem extends RelativeLayout
|
|||
}
|
||||
}
|
||||
|
||||
private void setBackground(boolean read, boolean batch) {
|
||||
if (batch && checkbox.isChecked()) {
|
||||
setBackgroundResource(R.drawable.list_selected_holo_light);
|
||||
} else if (read) {
|
||||
setBackgroundResource(R.drawable.conversation_list_item_background_read);
|
||||
} else {
|
||||
setBackgroundResource(R.drawable.conversation_list_item_background_unread);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBadgeEnabled() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
|
||||
}
|
||||
|
@ -203,6 +216,8 @@ public class ConversationListItem extends RelativeLayout
|
|||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) selectedThreads.add(threadId);
|
||||
else selectedThreads.remove(threadId);
|
||||
|
||||
setBackground(read, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue