Donations fixes + success post text from campaign

This commit is contained in:
Grishka 2024-06-15 00:46:42 +03:00
parent d3344e3e03
commit f96237b6f1
7 changed files with 15 additions and 6 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}
}

View File

@ -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{

View File

@ -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));
}

View File

@ -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();
});

View File

@ -105,6 +105,7 @@
android:clickable="false"
android:focusable="false"
android:duplicateParentState="true"
android:minWidth="0dp"
tools:text="Donate"/>
</FrameLayout>

View File

@ -67,6 +67,7 @@
android:clickable="false"
android:focusable="false"
android:duplicateParentState="true"
android:minWidth="0dp"
android:text="@string/donation_success_share"/>
</FrameLayout>