From 1c6da783ad4e9f921909fd0cc16febec11004abb Mon Sep 17 00:00:00 2001 From: Grishka Date: Mon, 17 Jun 2024 16:38:00 +0300 Subject: [PATCH] Add cancellation callback URL --- mastodon/build.gradle | 2 +- .../android/fragments/DonationWebViewFragment.java | 13 ++++++++++--- .../android/ui/sheets/DonationSheet.java | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mastodon/build.gradle b/mastodon/build.gradle index 7d4f50c66..3be8bb113 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -13,7 +13,7 @@ android { applicationId "org.joinmastodon.android" minSdk 23 targetSdk 33 - versionCode 101 + versionCode 102 versionName "2.5.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } 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 51d95b0cc..ba873f296 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/DonationWebViewFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/DonationWebViewFragment.java @@ -15,15 +15,15 @@ import org.joinmastodon.android.R; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.DismissDonationCampaignBannerEvent; import org.joinmastodon.android.ui.M3AlertDialogBuilder; -import org.joinmastodon.android.ui.sheets.DonationSuccessfulSheet; import java.util.Objects; import me.grishka.appkit.Nav; public class DonationWebViewFragment extends WebViewFragment{ - public static final String SUCCESS_URL="https://sponsor.joinmastodon.org/donation/success"; - public static final String FAILURE_URL="https://sponsor.joinmastodon.org/donation/failure"; + public static final String SUCCESS_URL="https://sponsor.joinmastodon.org/donate/success"; + public static final String FAILURE_URL="https://sponsor.joinmastodon.org/donate/failure"; + public static final String CANCEL_URL="https://sponsor.joinmastodon.org/donate/cancel"; @Override public void onCreate(Bundle savedInstanceState){ @@ -48,6 +48,9 @@ public class DonationWebViewFragment extends WebViewFragment{ }else if(url.equalsIgnoreCase(FAILURE_URL)){ onFailure(); return true; + }else if(url.equalsIgnoreCase(CANCEL_URL)){ + onCancel(); + return true; } return false; } @@ -86,4 +89,8 @@ public class DonationWebViewFragment extends WebViewFragment{ getActivity().setResult(Activity.RESULT_OK, new Intent().putExtra("postText", getArguments().getString("successPostText"))); getActivity().finish(); } + + private void onCancel(){ + getActivity().finish(); + } } 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 5ea290b83..a6e0ef89f 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 @@ -244,6 +244,7 @@ public class DonationSheet extends BottomSheet{ case YEARLY -> "yearly"; }) .appendQueryParameter("success_callback_url", DonationWebViewFragment.SUCCESS_URL) + .appendQueryParameter("cancel_callback_url", DonationWebViewFragment.CANCEL_URL) .appendQueryParameter("failure_callback_url", DonationWebViewFragment.FAILURE_URL); Bundle args=new Bundle(); args.putString("url", builder.build().toString());