From 81ac72e4eb435e263fc9c4e9f1a21e1ae6709810 Mon Sep 17 00:00:00 2001 From: Grishka Date: Tue, 10 Sep 2024 13:43:48 +0300 Subject: [PATCH] Trim strings in donation campaigns --- .../joinmastodon/android/fragments/HomeTimelineFragment.java | 5 +++-- .../android/fragments/settings/SettingsDebugFragment.java | 2 +- .../org/joinmastodon/android/ui/sheets/DonationSheet.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java index c30a8f13..66dbd5c7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java @@ -744,9 +744,10 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD } TextView text=donationBanner.findViewById(R.id.banner_text); SpannableStringBuilder ssb=new SpannableStringBuilder(campaign.bannerMessage); - ssb.append(' '); + if(!campaign.bannerMessage.endsWith("\n")) + ssb.append(' '); int start=ssb.length(); - ssb.append(campaign.bannerButtonText); + ssb.append(campaign.bannerButtonText.trim()); ssb.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.masterialDark_colorGoldenrodContainer, getActivity().getTheme())), start, ssb.length(), 0); ssb.setSpan(new UnderlineSpan(), start, ssb.length(), 0); ssb.setSpan(new TypefaceSpan("sans-serif-medium"), start, ssb.length(), 0); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java index ce6e0add..43697d58 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java @@ -35,7 +35,7 @@ public class SettingsDebugFragment extends BaseSettingsFragment{ new ListItem<>("Reset search info banners", null, this::onResetDiscoverBannersClick), new ListItem<>("Reset pre-reply sheets", null, this::onResetPreReplySheetsClick), new ListItem<>("Clear dismissed donation campaigns", null, this::onClearDismissedCampaignsClick), - donationsStagingItem=new CheckableListItem<>("Use staging environment for donations", null, CheckableListItem.Style.SWITCH, getPrefs().getBoolean("donationsStaging", false), this::toggleCheckableItem) + donationsStagingItem=new CheckableListItem<>("Use staging environment for donations", "Restart app to apply", CheckableListItem.Style.SWITCH, getPrefs().getBoolean("donationsStaging", false), this::toggleCheckableItem) )); if(!GithubSelfUpdater.needSelfUpdating()){ resetUpdateItem.isEnabled=selfUpdateItem.isEnabled=false; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSheet.java b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSheet.java index f3624f8c..25f7b476 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSheet.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSheet.java @@ -66,7 +66,7 @@ public class DonationSheet extends BottomSheet{ UiUtils.getThemeColor(context, R.attr.colorM3Primary), 0.05f)), !UiUtils.isDarkTheme()); TextView text=findViewById(R.id.text); - text.setText(campaign.donationMessage); + text.setText(campaign.donationMessage.trim()); onceTab=findViewById(R.id.once); monthlyTab=findViewById(R.id.monthly);