diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/DonationWebViewFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/DonationWebViewFragment.java index 1770ccf3..51d95b0c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/DonationWebViewFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/DonationWebViewFragment.java @@ -1,6 +1,7 @@ package org.joinmastodon.android.fragments; import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; @@ -82,7 +83,7 @@ public class DonationWebViewFragment extends WebViewFragment{ String campaignID=getArguments().getString("campaignID"); AccountSessionManager.getInstance().markDonationCampaignAsDismissed(campaignID); E.post(new DismissDonationCampaignBannerEvent(campaignID)); - getActivity().setResult(Activity.RESULT_OK); + getActivity().setResult(Activity.RESULT_OK, new Intent().putExtra("postText", getArguments().getString("successPostText"))); getActivity().finish(); } } 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 d4322135..da639b12 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java @@ -719,7 +719,7 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD if(donationSheet!=null) donationSheet.dismissWithoutAnimation(); if(resultCode==Activity.RESULT_OK){ - new DonationSuccessfulSheet(getActivity(), accountID).showWithoutAnimation(); + new DonationSuccessfulSheet(getActivity(), accountID, data.getStringExtra("postText")).showWithoutAnimation(); } } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/donations/DonationCampaign.java b/mastodon/src/main/java/org/joinmastodon/android/model/donations/DonationCampaign.java index 819011d0..fe672bc0 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/donations/DonationCampaign.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/donations/DonationCampaign.java @@ -17,6 +17,7 @@ public class DonationCampaign extends BaseModel{ public Amounts amounts; public String defaultCurrency; public String donationUrl; + public String donationSuccessPost; @Override public void postprocess() throws ObjectValidationException{ 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 ee5f8498..5ea290b8 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 @@ -154,7 +154,7 @@ public class DonationSheet extends BottomSheet{ } updateSuggestedAmounts(campaign.defaultCurrency); button.setEnabled(false); - buttonText.setText(campaign.bannerButtonText); + buttonText.setText(campaign.donationButtonText); button.setOnClickListener(v->openWebView()); Arrays.stream(getCurrentSuggestedAmounts(campaign.defaultCurrency)).min().ifPresent(amountField::setAmount); @@ -249,6 +249,7 @@ public class DonationSheet extends BottomSheet{ args.putString("url", builder.build().toString()); args.putString("account", accountID); args.putString("campaignID", campaign.id); + args.putString("successPostText", campaign.donationSuccessPost); args.putBoolean("_can_go_back", true); startCallback.accept(new Intent(activity, DonationFragmentActivity.class).putExtra("fragmentArgs", args)); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSuccessfulSheet.java b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSuccessfulSheet.java index cce55203..d6c59ac8 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSuccessfulSheet.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/DonationSuccessfulSheet.java @@ -17,7 +17,7 @@ import me.grishka.appkit.views.BottomSheet; public class DonationSuccessfulSheet extends BottomSheet{ - public DonationSuccessfulSheet(@NonNull Context context, @NonNull String accountID){ + public DonationSuccessfulSheet(@NonNull Context context, @NonNull String accountID, String postText){ super(context); View content=context.getSystemService(LayoutInflater.class).inflate(R.layout.sheet_donation_success, null); setContentView(content); @@ -25,10 +25,14 @@ public class DonationSuccessfulSheet extends BottomSheet{ UiUtils.getThemeColor(context, R.attr.colorM3Primary), 0.05f)), !UiUtils.isDarkTheme()); content.findViewById(R.id.btn_done).setOnClickListener(v->dismiss()); - content.findViewById(R.id.btn_share).setOnClickListener(v->{ + View shareButton=content.findViewById(R.id.btn_share); + if(postText==null){ + shareButton.setEnabled(false); + } + shareButton.setOnClickListener(v->{ Bundle args=new Bundle(); args.putString("account", accountID); - args.putString("prefilledText", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi a sapien metus. Nunc feugiat a felis sed hendrerit."); + args.putString("prefilledText", postText); Nav.go((Activity) context, ComposeFragment.class, args); dismiss(); }); diff --git a/mastodon/src/main/res/layout/sheet_donation.xml b/mastodon/src/main/res/layout/sheet_donation.xml index 7ac019f8..7b4fe156 100644 --- a/mastodon/src/main/res/layout/sheet_donation.xml +++ b/mastodon/src/main/res/layout/sheet_donation.xml @@ -105,6 +105,7 @@ android:clickable="false" android:focusable="false" android:duplicateParentState="true" + android:minWidth="0dp" tools:text="Donate"/> diff --git a/mastodon/src/main/res/layout/sheet_donation_success.xml b/mastodon/src/main/res/layout/sheet_donation_success.xml index a9600665..323fb679 100644 --- a/mastodon/src/main/res/layout/sheet_donation_success.xml +++ b/mastodon/src/main/res/layout/sheet_donation_success.xml @@ -67,6 +67,7 @@ android:clickable="false" android:focusable="false" android:duplicateParentState="true" + android:minWidth="0dp" android:text="@string/donation_success_share"/>