Skip to content

Commit

Permalink
feat: add 2024 iaps
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsCalebJones committed Mar 6, 2024
1 parent 090ac1e commit 291c9d3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ protected void onCreate(Bundle savedInstanceState) {
ownedProducts = new ArrayList<>();


if (SupporterHelper.is2023Supporter()) {
if (SupporterHelper.is2024Supporter()) {
purchaseButton.setText(R.string.support_us_2022);
title.setText("Thank You!");
subtitle.setText("Here's to another year...");
} else if (SupporterHelper.isSupporter() && !SupporterHelper.is2023Supporter()) {
purchaseButton.setText(R.string.support_again_2023);
title.setText("Become a 2023 Supporter");
} else if (SupporterHelper.isSupporter() && !SupporterHelper.is2024Supporter()) {
purchaseButton.setText(R.string.support_again_2024);
title.setText("Become a 2024 Supporter");
subtitle.setText("Continue Your Support!");
} else {
title.setText("Become a Supporter");
Expand Down Expand Up @@ -274,19 +274,19 @@ public void checkClick() {
.setProductList(
ImmutableList.of(
QueryProductDetailsParams.Product.newBuilder()
.setProductId(SupporterHelper.SKU_2023_BRONZE)
.setProductId(SupporterHelper.SKU_2024_BRONZE)
.setProductType(BillingClient.ProductType.INAPP)
.build(),
QueryProductDetailsParams.Product.newBuilder()
.setProductId(SupporterHelper.SKU_2023_METAL)
.setProductId(SupporterHelper.SKU_2024_METAL)
.setProductType(BillingClient.ProductType.INAPP)
.build(),
QueryProductDetailsParams.Product.newBuilder()
.setProductId(SupporterHelper.SKU_2023_SILVER)
.setProductId(SupporterHelper.SKU_2024_SILVER)
.setProductType(BillingClient.ProductType.INAPP)
.build(),
QueryProductDetailsParams.Product.newBuilder()
.setProductId(SupporterHelper.SKU_2023_PLATINUM)
.setProductId(SupporterHelper.SKU_2024_PLATINUM)
.setProductType(BillingClient.ProductType.INAPP)
.build()
))
Expand Down Expand Up @@ -341,9 +341,9 @@ private void showPurchaseDialog(List<ProductDetails> productDetailsList) {
TextView bottomMessage = view.findViewById(R.id.bottom_message);
TextView description = view.findViewById(R.id.descriptionView);

if (SupporterHelper.is2023Supporter()) {
if (SupporterHelper.is2024Supporter()) {
description.setText(R.string.thanks_support_development);
} else if (SupporterHelper.isSupporter() && !SupporterHelper.is2023Supporter()) {
} else if (SupporterHelper.isSupporter() && !SupporterHelper.is2024Supporter()) {
description.setText(R.string.supporter_unlock_text_previous);
} else {
description.setText(R.string.supporter_unlock_text);
Expand All @@ -369,36 +369,36 @@ private void showPurchaseDialog(List<ProductDetails> productDetailsList) {
for (ProductDetails productDetail : productDetailsList) {
Timber.v("Checking %s...", productDetail.getName());
switch (productDetail.getProductId()) {
case SupporterHelper.SKU_2023_BRONZE:
case SupporterHelper.SKU_2024_BRONZE:
configureProductItem(bronzeButton, bronzeTitle, bronzeDescription, productDetail,
SupporterHelper.SKU_2023_BRONZE,
SupporterHelper.SKU_2024_BRONZE,
new IconicsDrawable(this)
.icon(FontAwesome.Icon.faw_thumbs_up)
.color(Color.WHITE)
.sizeDp(24));
break;

case SupporterHelper.SKU_2023_METAL:
case SupporterHelper.SKU_2024_METAL:
configureProductItem(metalButton, metalTitle, metalDescription, productDetail,
SupporterHelper.SKU_2023_METAL,
SupporterHelper.SKU_2024_METAL,
new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_local_cafe)
.color(Color.WHITE)
.sizeDp(24));
break;

case SupporterHelper.SKU_2023_SILVER:
case SupporterHelper.SKU_2024_SILVER:
configureProductItem(silverButton, silverTitle, silverDescription, productDetail,
SupporterHelper.SKU_2023_SILVER,
SupporterHelper.SKU_2024_SILVER,
new IconicsDrawable(this)
.icon(FontAwesome.Icon.faw_store)
.color(Color.WHITE)
.sizeDp(24));
break;

case SupporterHelper.SKU_2023_PLATINUM:
case SupporterHelper.SKU_2024_PLATINUM:
configureProductItem(platinumButton, platinumTitle, platinumDescription, productDetail,
SupporterHelper.SKU_2023_PLATINUM,
SupporterHelper.SKU_2024_PLATINUM,
new IconicsDrawable(this)
.icon(FontAwesome.Icon.faw_money_bill_wave)
.color(Color.WHITE)
Expand Down Expand Up @@ -477,13 +477,13 @@ private void animatePurchase() {
runOnUiThread(() -> {
if (supportThankYou.getVisibility() != View.VISIBLE) {
enterReveal(supportThankYou);
if (SupporterHelper.is2023Supporter()) {
if (SupporterHelper.is2024Supporter()) {
purchaseButton.setText(R.string.support_us_2022);
title.setText("Thank You!");
subtitle.setText("Here's to another year...");
} else if (SupporterHelper.isSupporter() && !SupporterHelper.is2023Supporter()) {
purchaseButton.setText(R.string.support_again_2023);
title.setText("Become a 2023 Supporter");
} else if (SupporterHelper.isSupporter() && !SupporterHelper.is2024Supporter()) {
purchaseButton.setText(R.string.support_again_2024);
title.setText("Become a 2024 Supporter");
subtitle.setText("Continue Your Support!");
} else {
title.setText("Become a Supporter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public class SupporterHelper {
public static final String SKU_2023_METAL = "2023_metal_supporter";
public static final String SKU_2023_SILVER = "2023_silver_support";
public static final String SKU_2023_PLATINUM = "2023_platinum_support";

public static final String SKU_2024_BRONZE = "2024_bronze_supporter";

public static final String SKU_2024_METAL = "2024_metal_supporter";

public static final String SKU_2024_SILVER = "2024_silver_support";

public static final String SKU_2024_PLATINUM = "2024_platinum_support";
public static final String SKU_OTHER = "beta_supporter";

public static Products getProduct(String productID){
Expand Down Expand Up @@ -201,6 +209,30 @@ public static Products getProduct(String productID){
product.setDescription("This ensures you will always have access to every supporter features.");
product.setType("Supporter");
product.setPrice(6);
}else if (productID.equals(SKU_2024_PLATINUM)) {
product.setName("Supporter 2024 - Platinum");
product.setSku(productID);
product.setDescription("This ensures you will always have access to every supporter features.");
product.setType("Supporter");
product.setPrice(30);
} else if (productID.equals(SKU_2024_SILVER)){
product.setName("Supporter 2024 - Silver");
product.setSku(productID);
product.setDescription("This ensures you will always have access to every supporter features.");
product.setType("Supporter");
product.setPrice(10);
} else if (productID.equals(SKU_2024_BRONZE)){
product.setName("Supporter 2024 - Bronze");
product.setSku(productID);
product.setDescription("This ensures you will always have access to every supporter features.");
product.setType("Supporter");
product.setPrice(3);
} else if (productID.equals(SKU_2024_METAL)){
product.setName("Supporter 2024 - Metal");
product.setSku(productID);
product.setDescription("This ensures you will always have access to every supporter features.");
product.setType("Supporter");
product.setPrice(6);
} else if (productID.equals(SKU_OTHER)){
product.setName("Promotion Supporter");
product.setSku(productID);
Expand Down Expand Up @@ -331,5 +363,22 @@ public static boolean is2023Supporter(){
}
}


public static boolean is2024Supporter(){
try {
Realm realm = Realm.getDefaultInstance();
RealmResults<Products> products = realm.where(Products.class).findAll();
if (products != null) {
for (Products product: products){
if (product.getName().contains("2024")){
return true;
}
}
}
realm.close();
return false;
} catch (Exception e){
Timber.e(e);
return false;
}
}
}
6 changes: 3 additions & 3 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,9 @@
<string name="support_again_2022" translatable="false">Become a 2022 Supporter!</string>
<string name="support_us_2022" translatable="false">Support us again!</string>

<string name="supporter_title_2023" translatable="false">Become a Supporter!</string>
<string name="support_again_2023" translatable="false">Become a 2023 Supporter!</string>
<string name="support_us_2023" translatable="false">Support me again!</string>
<string name="supporter_title_2024" translatable="false">Become a Supporter!</string>
<string name="support_again_2024" translatable="false">Become a 2024 Supporter!</string>
<string name="support_us_2024" translatable="false">Support me again!</string>
<string name="supporter_unlock_text_previous">I appreciate you considering supporting Space Launch Now again in 2023! \n\nPay what you want to support continued development and updates!</string>
<string name="open_links_in_app_summary">Choose whether to open apps locally or in a browser.</string>
<string name="open_links_in_app_title">Open Links in App</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import jonathanfinerty.once.Once;
import me.calebjones.spacelaunchnow.BuildConfig;
import me.calebjones.spacelaunchnow.R;
import me.calebjones.spacelaunchnow.common.R2;
import me.calebjones.spacelaunchnow.common.base.BaseActivity;
import me.calebjones.spacelaunchnow.common.ui.settings.SettingsActivity;
import me.calebjones.spacelaunchnow.events.list.EventListFragment;
Expand Down Expand Up @@ -160,9 +159,9 @@ protected void onCreate(Bundle savedInstanceState) {
if (!Once.beenDone(Once.THIS_APP_INSTALL, "showTutorial")) {
showFilter = true;
startActivityForResult(new Intent(this, OnboardingActivity.class), SHOW_INTRO);
} else if (!Once.beenDone("show2023dialog") && Once.beenDone("appOpen", Amount.moreThan(5))) {
Once.markDone("show2023dialog");
if (!SupporterHelper.is2023Supporter()) {
} else if (!Once.beenDone("show2024dialog") && Once.beenDone("appOpen", Amount.moreThan(5))) {
Once.markDone("show2024dialog");
if (!SupporterHelper.is2024Supporter()) {
becomeSupporter();
}
} else if (!Once.beenDone("showNotificationPermission")){
Expand Down Expand Up @@ -443,7 +442,7 @@ public void onResume() {
&& Once.beenDone("appOpen", Amount.moreThan(2))) {
Once.markDone("showChangelog");
final Handler handler = new Handler();
handler.postDelayed(() -> showChangelogSnackbar(), 1000);
handler.postDelayed(() -> showChangelogSnackBar(), 1000);

} else if (!SupporterHelper.isSupporter()) {
if (!Once.beenDone("userCheckedSupporter")) {
Expand Down Expand Up @@ -537,7 +536,7 @@ private void showDiscord() {
.show();
}

private void showChangelogSnackbar() {
private void showChangelogSnackBar() {
snackbar = Snackbar
.make(coordinatorLayout, getString(R.string.updated_version) + " " + Utils.getVersionName(context), Snackbar.LENGTH_LONG)
.setActionTextColor(ContextCompat.getColor(context, R.color.colorPrimary))
Expand Down

0 comments on commit 291c9d3

Please sign in to comment.