From bd2e984963fc4766ad3680e127b25ab8d9447fd9 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Mon, 1 Jun 2015 16:51:14 -0700 Subject: [PATCH] reduce GPU overdraw Closes #3305 // FREEBIE --- .../conversation_list_item_background.xml | 10 +++++ .../conversation_list_item_background.xml | 4 ++ ...rsation_list_item_background_read_dark.xml | 11 ----- ...sation_list_item_background_read_light.xml | 11 ----- ...ation_list_item_background_unread_dark.xml | 11 ----- ...tion_list_item_background_unread_light.xml | 11 ----- res/drawable/textlines.xml | 16 -------- res/drawable/textlines_dark.xml | 16 -------- res/layout/conversation_activity.xml | 8 ++-- res/layout/conversation_fragment.xml | 2 +- res/layout/conversation_item_received.xml | 3 +- res/layout/conversation_list_item_view.xml | 40 ++++++++----------- .../push_contact_selection_list_activity.xml | 22 +++------- res/values/attrs.xml | 2 +- res/values/colors.xml | 2 + res/values/themes.xml | 12 ++---- .../securesms/ConversationListItem.java | 21 ++-------- 17 files changed, 54 insertions(+), 148 deletions(-) create mode 100644 res/drawable-v21/conversation_list_item_background.xml create mode 100644 res/drawable/conversation_list_item_background.xml delete mode 100644 res/drawable/conversation_list_item_background_read_dark.xml delete mode 100644 res/drawable/conversation_list_item_background_read_light.xml delete mode 100644 res/drawable/conversation_list_item_background_unread_dark.xml delete mode 100644 res/drawable/conversation_list_item_background_unread_light.xml delete mode 100644 res/drawable/textlines.xml delete mode 100644 res/drawable/textlines_dark.xml diff --git a/res/drawable-v21/conversation_list_item_background.xml b/res/drawable-v21/conversation_list_item_background.xml new file mode 100644 index 0000000000..7f73c13f0d --- /dev/null +++ b/res/drawable-v21/conversation_list_item_background.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/res/drawable/conversation_list_item_background.xml b/res/drawable/conversation_list_item_background.xml new file mode 100644 index 0000000000..117a807ce0 --- /dev/null +++ b/res/drawable/conversation_list_item_background.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/res/drawable/conversation_list_item_background_read_dark.xml b/res/drawable/conversation_list_item_background_read_dark.xml deleted file mode 100644 index 1487e00e4d..0000000000 --- a/res/drawable/conversation_list_item_background_read_dark.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/res/drawable/conversation_list_item_background_read_light.xml b/res/drawable/conversation_list_item_background_read_light.xml deleted file mode 100644 index 8b5229099f..0000000000 --- a/res/drawable/conversation_list_item_background_read_light.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/res/drawable/conversation_list_item_background_unread_dark.xml b/res/drawable/conversation_list_item_background_unread_dark.xml deleted file mode 100644 index 8ac65e5d01..0000000000 --- a/res/drawable/conversation_list_item_background_unread_dark.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/res/drawable/conversation_list_item_background_unread_light.xml b/res/drawable/conversation_list_item_background_unread_light.xml deleted file mode 100644 index 3312ee937c..0000000000 --- a/res/drawable/conversation_list_item_background_unread_light.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/res/drawable/textlines.xml b/res/drawable/textlines.xml deleted file mode 100644 index 1e02547f70..0000000000 --- a/res/drawable/textlines.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/drawable/textlines_dark.xml b/res/drawable/textlines_dark.xml deleted file mode 100644 index ec0b664031..0000000000 --- a/res/drawable/textlines_dark.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/conversation_activity.xml b/res/layout/conversation_activity.xml index f3f315e705..2b60633d73 100644 --- a/res/layout/conversation_activity.xml +++ b/res/layout/conversation_activity.xml @@ -3,7 +3,6 @@ + + + android:orientation="horizontal"> + android:cacheColorHint="?android:attr/windowBackground" /> \ No newline at end of file diff --git a/res/layout/conversation_item_received.xml b/res/layout/conversation_item_received.xml index b41f77390b..46b1d4b1e2 100644 --- a/res/layout/conversation_item_received.xml +++ b/res/layout/conversation_item_received.xml @@ -47,8 +47,7 @@ android:layout_height="wrap_content" android:layout_alignParentRight="true" android:orientation="vertical" - android:gravity="center_vertical" - android:background="?conversation_background"> + android:gravity="center_vertical"> - - - - + - - - - - + - + diff --git a/res/values/colors.xml b/res/values/colors.xml index 8fdcdbb138..d0e49d9d8c 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -3,6 +3,8 @@ #ff2090ea #ff1c7ac5 + #552090ea + #ffffffff #ff000000 #ffeeeeee diff --git a/res/values/themes.xml b/res/values/themes.xml index 5abf9202ec..c8575d137a 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -28,9 +28,8 @@ @color/textsecure_primary @color/textsecure_primary_dark @color/textsecure_primary_dark + @color/white - @drawable/conversation_list_item_background_read_light - @drawable/conversation_list_item_background_unread_light @drawable/list_selected_holo_light #66333333 #FF333333 @@ -55,8 +54,7 @@ #66000000 #44000000 - #ffffffff - @drawable/textlines + #22000000 #ff111111 @drawable/ic_delivery_delivered_dark @drawable/ic_send_sms_insecure @@ -138,9 +136,8 @@ @style/ThemeOverlay.AppCompat.Dark @color/text_color_dark_theme @color/text_color_secondary_dark_theme + @color/black true - @drawable/conversation_list_item_background_read_dark - @drawable/conversation_list_item_background_unread_dark @drawable/list_selected_holo_dark #66dddddd #ffdddddd @@ -191,8 +188,7 @@ @color/textsecure_primary_dark @drawable/divet_lower_right_light - @color/black - @drawable/textlines_dark + #22ffffff #ffeeeeee @drawable/ic_delivery_delivered_dark @drawable/ic_send_sms_insecure_dark diff --git a/src/org/thoughtcrime/securesms/ConversationListItem.java b/src/org/thoughtcrime/securesms/ConversationListItem.java index 5840cbc514..99416b704b 100644 --- a/src/org/thoughtcrime/securesms/ConversationListItem.java +++ b/src/org/thoughtcrime/securesms/ConversationListItem.java @@ -17,7 +17,6 @@ package org.thoughtcrime.securesms; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Typeface; import android.os.Handler; import android.util.AttributeSet; @@ -104,7 +103,7 @@ public class ConversationListItem extends RelativeLayout dateView.setTypeface(read ? LIGHT_TYPEFACE : BOLD_TYPEFACE); } - setBackground(read, batchMode); + setBatchState(batchMode); this.contactPhotoImage.setAvatar(recipients.getPrimaryRecipient(), true); } @@ -117,22 +116,8 @@ public class ConversationListItem extends RelativeLayout contactPhotoImage.setVisibility(View.VISIBLE); } - private void setBackground(boolean read, boolean batch) { - int[] attributes = new int[]{R.attr.conversation_list_item_background_selected, - R.attr.conversation_list_item_background_read, - R.attr.conversation_list_item_background_unread}; - - TypedArray drawables = context.obtainStyledAttributes(attributes); - - if (batch && selectedThreads.contains(threadId)) { - setBackgroundDrawable(drawables.getDrawable(0)); - } else if (read) { - setBackgroundDrawable(drawables.getDrawable(1)); - } else { - setBackgroundDrawable(drawables.getDrawable(2)); - } - - drawables.recycle(); + private void setBatchState(boolean batch) { + setSelected(batch && selectedThreads.contains(threadId)); } public Recipients getRecipients() {