From c05d0b600eef4e30560a70393acc32f865e443d2 Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 16 Feb 2023 16:42:47 +0100 Subject: [PATCH] default role color if not provided fixes sk22#430 --- .../org/joinmastodon/android/fragments/ProfileFragment.java | 6 ++++-- mastodon/src/main/res/drawable/bg_pill.xml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index 5357306db..ab7f987a6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -489,8 +489,10 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList for (Account.Role role : account.roles) { TextView roleText = new TextView(getActivity(), null, 0, R.style.role_label); roleText.setText(role.name); - GradientDrawable bg = (GradientDrawable) roleText.getBackground().mutate(); - bg.setStroke(V.dp(2), Color.parseColor(role.color)); + if (!TextUtils.isEmpty(role.color) && role.color.startsWith("#")) try { + GradientDrawable bg = (GradientDrawable) roleText.getBackground().mutate(); + bg.setStroke(V.dp(2), Color.parseColor(role.color)); + } catch (Exception ignored) {} rolesView.addView(roleText); } } diff --git a/mastodon/src/main/res/drawable/bg_pill.xml b/mastodon/src/main/res/drawable/bg_pill.xml index af6a69a4f..d2318453f 100644 --- a/mastodon/src/main/res/drawable/bg_pill.xml +++ b/mastodon/src/main/res/drawable/bg_pill.xml @@ -4,5 +4,5 @@ android:shape="rectangle"> - + \ No newline at end of file