From 26c8497509e6ec1622283c809b128928d4d82e35 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Fri, 4 Dec 2020 11:59:21 +0100 Subject: [PATCH 1/3] Fix crash on some device of some friend of Holger --- .../securesms/contacts/ContactAccessor.java | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/org/thoughtcrime/securesms/contacts/ContactAccessor.java b/src/org/thoughtcrime/securesms/contacts/ContactAccessor.java index 5ec4247da..ebe027a96 100644 --- a/src/org/thoughtcrime/securesms/contacts/ContactAccessor.java +++ b/src/org/thoughtcrime/securesms/contacts/ContactAccessor.java @@ -19,7 +19,9 @@ package org.thoughtcrime.securesms.contacts; import android.content.Context; import android.database.Cursor; import android.provider.ContactsContract; +import android.util.Log; +import org.thoughtcrime.securesms.ContactSelectionListFragment; import org.thoughtcrime.securesms.util.Hash; import org.thoughtcrime.securesms.util.Prefs; @@ -41,6 +43,7 @@ import java.util.Set; */ public class ContactAccessor { + private static final String TAG = ContactSelectionListFragment.class.getSimpleName(); private static final int CONTACT_CURSOR_NAME = 0; @@ -66,13 +69,30 @@ public class ContactAccessor { Set contactPhotoIdentifiers = new HashSet<>(); while (systemContactsCursor != null && systemContactsCursor.moveToNext()) { - String name = systemContactsCursor.getString(CONTACT_CURSOR_NAME); - name = name.replace("\r", ""); // remove characters later used as field separator - name = name.replace("\n", ""); + String name; + try { + name = systemContactsCursor.getString(CONTACT_CURSOR_NAME); + if (name != null) { + name = name.replace("\r", ""); // remove characters later used as field separator + name = name.replace("\n", ""); + } else { + name = ""; + } + } catch(Exception e) { + Log.e(TAG, "Can't get contact name: " + e); + name = ""; + } - String mail = systemContactsCursor.getString(CONTACT_CURSOR_MAIL); - mail = mail.replace("\r", ""); // remove characters later used as field separator - mail = mail.replace("\n", ""); + String mail = null; + try { + mail = systemContactsCursor.getString(CONTACT_CURSOR_MAIL); + if (mail != null) { + mail = mail.replace("\r", ""); // remove characters later used as field separator + mail = mail.replace("\n", ""); + } + } catch(Exception e) { + Log.e(TAG, "Can't get contact addr: " + e); + } String contactId = systemContactsCursor.getString(CONTACT_CURSOR_CONTACT_ID); if (contactId != null) { From 3abaabb38af703848c8f16abb730c4f5e0070918 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Fri, 4 Dec 2020 18:16:13 +0100 Subject: [PATCH 2/3] Put a black circle behind the edit options when editing an image --- res/layout/image_editor_hud.xml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/res/layout/image_editor_hud.xml b/res/layout/image_editor_hud.xml index 98c1c81db..4238ee711 100644 --- a/res/layout/image_editor_hud.xml +++ b/res/layout/image_editor_hud.xml @@ -25,6 +25,7 @@ android:orientation="horizontal" android:layout_marginEnd="20dp" android:layout_marginRight="20dp" + app:chipSpacing="8dp" app:layout_constraintEnd_toStartOf="@id/scribble_save_confirm_barrier" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -33,7 +34,7 @@ android:id="@+id/scribble_undo_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_undo_32" /> @@ -41,7 +42,7 @@ android:id="@+id/scribble_delete_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_trash_filled_32" /> @@ -49,7 +50,7 @@ android:id="@+id/scribble_text_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_text_32" /> @@ -57,7 +58,7 @@ android:id="@+id/scribble_draw_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_brush_marker_32" /> @@ -65,23 +66,23 @@ android:id="@+id/scribble_highlight_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_brush_highlight_32" /> @@ -89,7 +90,7 @@ android:id="@+id/scribble_crop_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_crop_32" /> @@ -97,7 +98,7 @@ android:id="@+id/scribble_crop_flip" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_flip_32" /> @@ -105,7 +106,7 @@ android:id="@+id/scribble_crop_rotate" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" android:src="@drawable/ic_rotate_32" /> @@ -123,7 +124,7 @@ android:id="@+id/scribble_confirm_button" android:layout_width="48dp" android:layout_height="48dp" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@drawable/circle_universal_overlay" android:padding="6dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -137,7 +138,7 @@ android:padding="6dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" - android:background="?attr/selectableItemBackgroundBorderless"/> + android:background="@drawable/circle_universal_overlay"/> Date: Sat, 5 Dec 2020 00:38:20 +0100 Subject: [PATCH 3/3] tweak universal_overlay color for black background the color 'universal_overlay' can be used as backgrounds for semi-transparent overlays. the color guarantees enough contrast to white/light things drawn on it, while still letting the background shine through. the color is the same for both, dark and lite theme as it is also used to draw on customized backgrounds (where we can have any background anyway) before, the shaped formed with this color are not visible on black background, this is fixed by this commit, making the color even more universal. this is an improvement for the image-editor buttons as well as for the info-messages on arbitrary backgrounds. --- res/values/colors.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index e6ee4d5c3..ef35e57ab 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -51,7 +51,7 @@ #808080 #999999 - #44000000 + #55444444 #552090ea #ff2090ea