Donations fixes + success post text from campaign
This commit is contained in:
parent
d3344e3e03
commit
f96237b6f1
7 changed files with 15 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
@ -82,7 +83,7 @@ public class DonationWebViewFragment extends WebViewFragment{
|
||||||
String campaignID=getArguments().getString("campaignID");
|
String campaignID=getArguments().getString("campaignID");
|
||||||
AccountSessionManager.getInstance().markDonationCampaignAsDismissed(campaignID);
|
AccountSessionManager.getInstance().markDonationCampaignAsDismissed(campaignID);
|
||||||
E.post(new DismissDonationCampaignBannerEvent(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();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -719,7 +719,7 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD
|
||||||
if(donationSheet!=null)
|
if(donationSheet!=null)
|
||||||
donationSheet.dismissWithoutAnimation();
|
donationSheet.dismissWithoutAnimation();
|
||||||
if(resultCode==Activity.RESULT_OK){
|
if(resultCode==Activity.RESULT_OK){
|
||||||
new DonationSuccessfulSheet(getActivity(), accountID).showWithoutAnimation();
|
new DonationSuccessfulSheet(getActivity(), accountID, data.getStringExtra("postText")).showWithoutAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class DonationCampaign extends BaseModel{
|
||||||
public Amounts amounts;
|
public Amounts amounts;
|
||||||
public String defaultCurrency;
|
public String defaultCurrency;
|
||||||
public String donationUrl;
|
public String donationUrl;
|
||||||
|
public String donationSuccessPost;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postprocess() throws ObjectValidationException{
|
public void postprocess() throws ObjectValidationException{
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class DonationSheet extends BottomSheet{
|
||||||
}
|
}
|
||||||
updateSuggestedAmounts(campaign.defaultCurrency);
|
updateSuggestedAmounts(campaign.defaultCurrency);
|
||||||
button.setEnabled(false);
|
button.setEnabled(false);
|
||||||
buttonText.setText(campaign.bannerButtonText);
|
buttonText.setText(campaign.donationButtonText);
|
||||||
button.setOnClickListener(v->openWebView());
|
button.setOnClickListener(v->openWebView());
|
||||||
|
|
||||||
Arrays.stream(getCurrentSuggestedAmounts(campaign.defaultCurrency)).min().ifPresent(amountField::setAmount);
|
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("url", builder.build().toString());
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
args.putString("campaignID", campaign.id);
|
args.putString("campaignID", campaign.id);
|
||||||
|
args.putString("successPostText", campaign.donationSuccessPost);
|
||||||
args.putBoolean("_can_go_back", true);
|
args.putBoolean("_can_go_back", true);
|
||||||
startCallback.accept(new Intent(activity, DonationFragmentActivity.class).putExtra("fragmentArgs", args));
|
startCallback.accept(new Intent(activity, DonationFragmentActivity.class).putExtra("fragmentArgs", args));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import me.grishka.appkit.views.BottomSheet;
|
||||||
|
|
||||||
public class DonationSuccessfulSheet extends 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);
|
super(context);
|
||||||
View content=context.getSystemService(LayoutInflater.class).inflate(R.layout.sheet_donation_success, null);
|
View content=context.getSystemService(LayoutInflater.class).inflate(R.layout.sheet_donation_success, null);
|
||||||
setContentView(content);
|
setContentView(content);
|
||||||
|
@ -25,10 +25,14 @@ public class DonationSuccessfulSheet extends BottomSheet{
|
||||||
UiUtils.getThemeColor(context, R.attr.colorM3Primary), 0.05f)), !UiUtils.isDarkTheme());
|
UiUtils.getThemeColor(context, R.attr.colorM3Primary), 0.05f)), !UiUtils.isDarkTheme());
|
||||||
|
|
||||||
content.findViewById(R.id.btn_done).setOnClickListener(v->dismiss());
|
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();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
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);
|
Nav.go((Activity) context, ComposeFragment.class, args);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
|
@ -105,6 +105,7 @@
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:duplicateParentState="true"
|
android:duplicateParentState="true"
|
||||||
|
android:minWidth="0dp"
|
||||||
tools:text="Donate"/>
|
tools:text="Donate"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:duplicateParentState="true"
|
android:duplicateParentState="true"
|
||||||
|
android:minWidth="0dp"
|
||||||
android:text="@string/donation_success_share"/>
|
android:text="@string/donation_success_share"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue