fix: merge 10.2.0
This commit is contained in:
parent
a50062e837
commit
6230554618
@ -3,10 +3,10 @@ package org.telegram.ui.Components.Premium.boosts;
|
||||
import android.os.Build;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.BillingFlowParams;
|
||||
import com.android.billingclient.api.ProductDetails;
|
||||
import com.android.billingclient.api.QueryProductDetailsParams;
|
||||
//import com.android.billingclient.api.BillingClient;
|
||||
//import com.android.billingclient.api.BillingFlowParams;
|
||||
//import com.android.billingclient.api.ProductDetails;
|
||||
//import com.android.billingclient.api.QueryProductDetailsParams;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
@ -27,7 +27,7 @@ import org.telegram.tgnet.tl.TL_stories;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Components.BotWebViewSheet;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
import org.telegram.ui.PaymentFormActivity;
|
||||
//import org.telegram.ui.PaymentFormActivity;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
@ -92,11 +92,11 @@ public class BoostRepository {
|
||||
}
|
||||
|
||||
public static void payGiftCode(List<TLObject> users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
if (!isGoogleBillingAvailable()) {
|
||||
payGiftCodeByInvoice(users, option, chat, baseFragment, onSuccess, onError);
|
||||
} else {
|
||||
payGiftCodeByGoogle(users, option, chat, baseFragment, onSuccess, onError);
|
||||
}
|
||||
// if (!isGoogleBillingAvailable()) {
|
||||
// payGiftCodeByInvoice(users, option, chat, baseFragment, onSuccess, onError);
|
||||
// } else {
|
||||
// payGiftCodeByGoogle(users, option, chat, baseFragment, onSuccess, onError);
|
||||
// }
|
||||
}
|
||||
|
||||
public static boolean isGoogleBillingAvailable() {
|
||||
@ -105,115 +105,115 @@ public class BoostRepository {
|
||||
}
|
||||
return BillingController.getInstance().isReady();
|
||||
}
|
||||
|
||||
public static void payGiftCodeByInvoice(List<TLObject> users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
|
||||
TLRPC.TL_payments_getPaymentForm req = new TLRPC.TL_payments_getPaymentForm();
|
||||
TLRPC.TL_inputInvoicePremiumGiftCode invoice = new TLRPC.TL_inputInvoicePremiumGiftCode();
|
||||
TLRPC.TL_inputStorePaymentPremiumGiftCode payload = new TLRPC.TL_inputStorePaymentPremiumGiftCode();
|
||||
|
||||
payload.flags = 1;
|
||||
payload.users = new ArrayList<>();
|
||||
for (TLObject user : users) {
|
||||
if (user instanceof TLRPC.User) {
|
||||
payload.users.add(controller.getInputUser((TLRPC.User) user));
|
||||
}
|
||||
}
|
||||
payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
payload.currency = option.currency;
|
||||
payload.amount = option.amount;
|
||||
|
||||
invoice.purpose = payload;
|
||||
invoice.option = option;
|
||||
|
||||
final JSONObject themeParams = BotWebViewSheet.makeThemeParams(baseFragment.getResourceProvider());
|
||||
if (themeParams != null) {
|
||||
req.theme_params = new TLRPC.TL_dataJSON();
|
||||
req.theme_params.data = themeParams.toString();
|
||||
req.flags |= 1;
|
||||
}
|
||||
req.invoice = invoice;
|
||||
|
||||
int requestId = connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error != null) {
|
||||
onError.run(error);
|
||||
return;
|
||||
}
|
||||
PaymentFormActivity paymentFormActivity = null;
|
||||
if (response instanceof TLRPC.TL_payments_paymentForm) {
|
||||
TLRPC.TL_payments_paymentForm form = (TLRPC.TL_payments_paymentForm) response;
|
||||
form.invoice.recurring = true;
|
||||
controller.putUsers(form.users, false);
|
||||
paymentFormActivity = new PaymentFormActivity(form, invoice, baseFragment);
|
||||
} else if (response instanceof TLRPC.TL_payments_paymentReceipt) {
|
||||
paymentFormActivity = new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response);
|
||||
}
|
||||
if (paymentFormActivity != null) {
|
||||
paymentFormActivity.setPaymentFormCallback(status -> {
|
||||
if (status == PaymentFormActivity.InvoiceStatus.PAID) {
|
||||
onSuccess.run(null);
|
||||
} else if (status != PaymentFormActivity.InvoiceStatus.PENDING) {
|
||||
onError.run(null);
|
||||
}
|
||||
});
|
||||
LaunchActivity.getLastFragment().showAsSheet(paymentFormActivity, new BaseFragment.BottomSheetParams());
|
||||
} else {
|
||||
onError.run(null);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void payGiftCodeByGoogle(List<TLObject> users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
TLRPC.TL_inputStorePaymentPremiumGiftCode payload = new TLRPC.TL_inputStorePaymentPremiumGiftCode();
|
||||
|
||||
payload.flags = 1;
|
||||
payload.users = new ArrayList<>();
|
||||
for (TLObject user : users) {
|
||||
if (user instanceof TLRPC.User) {
|
||||
payload.users.add(controller.getInputUser((TLRPC.User) user));
|
||||
}
|
||||
}
|
||||
payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
|
||||
QueryProductDetailsParams.Product product = QueryProductDetailsParams.Product.newBuilder()
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.setProductId(option.store_product)
|
||||
.build();
|
||||
BillingController.getInstance().queryProductDetails(Arrays.asList(product), (billingResult, list) -> {
|
||||
ProductDetails.OneTimePurchaseOfferDetails offerDetails = list.get(0).getOneTimePurchaseOfferDetails();
|
||||
payload.currency = offerDetails.getPriceCurrencyCode();
|
||||
payload.amount = (long) ((offerDetails.getPriceAmountMicros() / Math.pow(10, 6)) * Math.pow(10, BillingController.getInstance().getCurrencyExp(option.currency)));
|
||||
|
||||
TLRPC.TL_payments_canPurchasePremium req = new TLRPC.TL_payments_canPurchasePremium();
|
||||
req.purpose = payload;
|
||||
connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error != null) {
|
||||
onError.run(error);
|
||||
return;
|
||||
}
|
||||
if (response != null) {
|
||||
BillingController.getInstance().addResultListener(list.get(0).getProductId(), billingResult1 -> {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
AndroidUtilities.runOnUIThread(() -> onSuccess.run(null));
|
||||
}
|
||||
});
|
||||
BillingController.getInstance().setOnCanceled(() -> {
|
||||
AndroidUtilities.runOnUIThread(() -> onError.run(null));
|
||||
});
|
||||
BillingController.getInstance().launchBillingFlow(
|
||||
baseFragment.getParentActivity(), AccountInstance.getInstance(UserConfig.selectedAccount), payload,
|
||||
Collections.singletonList(BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(list.get(0))
|
||||
.build())
|
||||
);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
//
|
||||
// public static void payGiftCodeByInvoice(List<TLObject> users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
// MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
// ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
//
|
||||
// TLRPC.TL_payments_getPaymentForm req = new TLRPC.TL_payments_getPaymentForm();
|
||||
// TLRPC.TL_inputInvoicePremiumGiftCode invoice = new TLRPC.TL_inputInvoicePremiumGiftCode();
|
||||
// TLRPC.TL_inputStorePaymentPremiumGiftCode payload = new TLRPC.TL_inputStorePaymentPremiumGiftCode();
|
||||
//
|
||||
// payload.flags = 1;
|
||||
// payload.users = new ArrayList<>();
|
||||
// for (TLObject user : users) {
|
||||
// if (user instanceof TLRPC.User) {
|
||||
// payload.users.add(controller.getInputUser((TLRPC.User) user));
|
||||
// }
|
||||
// }
|
||||
// payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
// payload.currency = option.currency;
|
||||
// payload.amount = option.amount;
|
||||
//
|
||||
// invoice.purpose = payload;
|
||||
// invoice.option = option;
|
||||
//
|
||||
// final JSONObject themeParams = BotWebViewSheet.makeThemeParams(baseFragment.getResourceProvider());
|
||||
// if (themeParams != null) {
|
||||
// req.theme_params = new TLRPC.TL_dataJSON();
|
||||
// req.theme_params.data = themeParams.toString();
|
||||
// req.flags |= 1;
|
||||
// }
|
||||
// req.invoice = invoice;
|
||||
//
|
||||
// int requestId = connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
// if (error != null) {
|
||||
// onError.run(error);
|
||||
// return;
|
||||
// }
|
||||
// PaymentFormActivity paymentFormActivity = null;
|
||||
// if (response instanceof TLRPC.TL_payments_paymentForm) {
|
||||
// TLRPC.TL_payments_paymentForm form = (TLRPC.TL_payments_paymentForm) response;
|
||||
// form.invoice.recurring = true;
|
||||
// controller.putUsers(form.users, false);
|
||||
// paymentFormActivity = new PaymentFormActivity(form, invoice, baseFragment);
|
||||
// } else if (response instanceof TLRPC.TL_payments_paymentReceipt) {
|
||||
// paymentFormActivity = new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response);
|
||||
// }
|
||||
// if (paymentFormActivity != null) {
|
||||
// paymentFormActivity.setPaymentFormCallback(status -> {
|
||||
// if (status == PaymentFormActivity.InvoiceStatus.PAID) {
|
||||
// onSuccess.run(null);
|
||||
// } else if (status != PaymentFormActivity.InvoiceStatus.PENDING) {
|
||||
// onError.run(null);
|
||||
// }
|
||||
// });
|
||||
// LaunchActivity.getLastFragment().showAsSheet(paymentFormActivity, new BaseFragment.BottomSheetParams());
|
||||
// } else {
|
||||
// onError.run(null);
|
||||
// }
|
||||
// }));
|
||||
// }
|
||||
//
|
||||
// public static void payGiftCodeByGoogle(List<TLObject> users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
// MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
// ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
// TLRPC.TL_inputStorePaymentPremiumGiftCode payload = new TLRPC.TL_inputStorePaymentPremiumGiftCode();
|
||||
//
|
||||
// payload.flags = 1;
|
||||
// payload.users = new ArrayList<>();
|
||||
// for (TLObject user : users) {
|
||||
// if (user instanceof TLRPC.User) {
|
||||
// payload.users.add(controller.getInputUser((TLRPC.User) user));
|
||||
// }
|
||||
// }
|
||||
// payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
//
|
||||
// QueryProductDetailsParams.Product product = QueryProductDetailsParams.Product.newBuilder()
|
||||
// .setProductType(BillingClient.ProductType.INAPP)
|
||||
// .setProductId(option.store_product)
|
||||
// .build();
|
||||
// BillingController.getInstance().queryProductDetails(Arrays.asList(product), (billingResult, list) -> {
|
||||
// ProductDetails.OneTimePurchaseOfferDetails offerDetails = list.get(0).getOneTimePurchaseOfferDetails();
|
||||
// payload.currency = offerDetails.getPriceCurrencyCode();
|
||||
// payload.amount = (long) ((offerDetails.getPriceAmountMicros() / Math.pow(10, 6)) * Math.pow(10, BillingController.getInstance().getCurrencyExp(option.currency)));
|
||||
//
|
||||
// TLRPC.TL_payments_canPurchasePremium req = new TLRPC.TL_payments_canPurchasePremium();
|
||||
// req.purpose = payload;
|
||||
// connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
// if (error != null) {
|
||||
// onError.run(error);
|
||||
// return;
|
||||
// }
|
||||
// if (response != null) {
|
||||
// BillingController.getInstance().addResultListener(list.get(0).getProductId(), billingResult1 -> {
|
||||
// if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
// AndroidUtilities.runOnUIThread(() -> onSuccess.run(null));
|
||||
// }
|
||||
// });
|
||||
// BillingController.getInstance().setOnCanceled(() -> {
|
||||
// AndroidUtilities.runOnUIThread(() -> onError.run(null));
|
||||
// });
|
||||
// BillingController.getInstance().launchBillingFlow(
|
||||
// baseFragment.getParentActivity(), AccountInstance.getInstance(UserConfig.selectedAccount), payload,
|
||||
// Collections.singletonList(BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
// .setProductDetails(list.get(0))
|
||||
// .build())
|
||||
// );
|
||||
// }
|
||||
// }));
|
||||
// });
|
||||
// }
|
||||
|
||||
public static void launchPreparedGiveaway(TL_stories.TL_prepaidGiveaway prepaidGiveaway, List<TLObject> chats, List<TLObject> selectedCountries, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
@ -256,139 +256,139 @@ public class BoostRepository {
|
||||
}
|
||||
|
||||
public static void payGiveAway(List<TLObject> chats, List<TLObject> selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
if (!isGoogleBillingAvailable()) {
|
||||
payGiveAwayByInvoice(chats, selectedCountries, option, chat, date, onlyNewSubscribers, baseFragment, onSuccess, onError);
|
||||
} else {
|
||||
payGiveAwayByGoogle(chats, selectedCountries, option, chat, date, onlyNewSubscribers, baseFragment, onSuccess, onError);
|
||||
}
|
||||
}
|
||||
|
||||
public static void payGiveAwayByInvoice(List<TLObject> chats, List<TLObject> selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
|
||||
TLRPC.TL_payments_getPaymentForm req = new TLRPC.TL_payments_getPaymentForm();
|
||||
TLRPC.TL_inputInvoicePremiumGiftCode invoice = new TLRPC.TL_inputInvoicePremiumGiftCode();
|
||||
TLRPC.TL_inputStorePaymentPremiumGiveaway payload = new TLRPC.TL_inputStorePaymentPremiumGiveaway();
|
||||
|
||||
payload.only_new_subscribers = onlyNewSubscribers;
|
||||
payload.until_date = date;
|
||||
payload.flags |= 2;
|
||||
payload.flags |= 4;
|
||||
payload.random_id = System.currentTimeMillis();
|
||||
payload.additional_peers = new ArrayList<>();
|
||||
for (TLObject o : chats) {
|
||||
if (o instanceof TLRPC.Chat) {
|
||||
payload.additional_peers.add(controller.getInputPeer(-((TLRPC.Chat) o).id));
|
||||
}
|
||||
}
|
||||
payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
payload.currency = option.currency;
|
||||
payload.amount = option.amount;
|
||||
|
||||
for (TLObject object : selectedCountries) {
|
||||
TLRPC.TL_help_country country = (TLRPC.TL_help_country) object;
|
||||
payload.countries_iso2.add(country.iso2);
|
||||
}
|
||||
|
||||
invoice.purpose = payload;
|
||||
invoice.option = option;
|
||||
|
||||
final JSONObject themeParams = BotWebViewSheet.makeThemeParams(baseFragment.getResourceProvider());
|
||||
if (themeParams != null) {
|
||||
req.theme_params = new TLRPC.TL_dataJSON();
|
||||
req.theme_params.data = themeParams.toString();
|
||||
req.flags |= 1;
|
||||
}
|
||||
req.invoice = invoice;
|
||||
|
||||
int requestId = connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error != null) {
|
||||
onError.run(error);
|
||||
return;
|
||||
}
|
||||
PaymentFormActivity paymentFormActivity = null;
|
||||
if (response instanceof TLRPC.TL_payments_paymentForm) {
|
||||
TLRPC.TL_payments_paymentForm form = (TLRPC.TL_payments_paymentForm) response;
|
||||
form.invoice.recurring = true;
|
||||
controller.putUsers(form.users, false);
|
||||
paymentFormActivity = new PaymentFormActivity(form, invoice, baseFragment);
|
||||
} else if (response instanceof TLRPC.TL_payments_paymentReceipt) {
|
||||
paymentFormActivity = new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response);
|
||||
}
|
||||
if (paymentFormActivity != null) {
|
||||
paymentFormActivity.setPaymentFormCallback(status -> {
|
||||
if (status == PaymentFormActivity.InvoiceStatus.PAID) {
|
||||
onSuccess.run(null);
|
||||
} else if (status != PaymentFormActivity.InvoiceStatus.PENDING) {
|
||||
onError.run(null);
|
||||
}
|
||||
});
|
||||
LaunchActivity.getLastFragment().showAsSheet(paymentFormActivity, new BaseFragment.BottomSheetParams());
|
||||
} else {
|
||||
onError.run(null);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void payGiveAwayByGoogle(List<TLObject> chats, List<TLObject> selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
TLRPC.TL_inputStorePaymentPremiumGiveaway payload = new TLRPC.TL_inputStorePaymentPremiumGiveaway();
|
||||
|
||||
payload.only_new_subscribers = onlyNewSubscribers;
|
||||
payload.until_date = date;
|
||||
payload.flags |= 2;
|
||||
payload.flags |= 4;
|
||||
payload.random_id = System.currentTimeMillis();
|
||||
payload.additional_peers = new ArrayList<>();
|
||||
for (TLObject o : chats) {
|
||||
if (o instanceof TLRPC.Chat) {
|
||||
payload.additional_peers.add(controller.getInputPeer(-((TLRPC.Chat) o).id));
|
||||
}
|
||||
}
|
||||
payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
for (TLObject object : selectedCountries) {
|
||||
TLRPC.TL_help_country country = (TLRPC.TL_help_country) object;
|
||||
payload.countries_iso2.add(country.iso2);
|
||||
}
|
||||
|
||||
QueryProductDetailsParams.Product product = QueryProductDetailsParams.Product.newBuilder()
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.setProductId(option.store_product)
|
||||
.build();
|
||||
BillingController.getInstance().queryProductDetails(Arrays.asList(product), (billingResult, list) -> {
|
||||
ProductDetails.OneTimePurchaseOfferDetails offerDetails = list.get(0).getOneTimePurchaseOfferDetails();
|
||||
payload.currency = offerDetails.getPriceCurrencyCode();
|
||||
payload.amount = (long) ((offerDetails.getPriceAmountMicros() / Math.pow(10, 6)) * Math.pow(10, BillingController.getInstance().getCurrencyExp(option.currency)));
|
||||
|
||||
TLRPC.TL_payments_canPurchasePremium req = new TLRPC.TL_payments_canPurchasePremium();
|
||||
req.purpose = payload;
|
||||
connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error != null) {
|
||||
onError.run(error);
|
||||
return;
|
||||
}
|
||||
if (response != null) {
|
||||
BillingController.getInstance().addResultListener(list.get(0).getProductId(), billingResult1 -> {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
AndroidUtilities.runOnUIThread(() -> onSuccess.run(null));
|
||||
}
|
||||
});
|
||||
BillingController.getInstance().setOnCanceled(() -> {
|
||||
AndroidUtilities.runOnUIThread(() -> onError.run(null));
|
||||
});
|
||||
BillingController.getInstance().launchBillingFlow(
|
||||
baseFragment.getParentActivity(), AccountInstance.getInstance(UserConfig.selectedAccount), payload,
|
||||
Collections.singletonList(BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(list.get(0))
|
||||
.build())
|
||||
);
|
||||
}
|
||||
}));
|
||||
});
|
||||
// if (!isGoogleBillingAvailable()) {
|
||||
// payGiveAwayByInvoice(chats, selectedCountries, option, chat, date, onlyNewSubscribers, baseFragment, onSuccess, onError);
|
||||
// } else {
|
||||
// payGiveAwayByGoogle(chats, selectedCountries, option, chat, date, onlyNewSubscribers, baseFragment, onSuccess, onError);
|
||||
// }
|
||||
}
|
||||
//
|
||||
// public static void payGiveAwayByInvoice(List<TLObject> chats, List<TLObject> selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
// MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
// ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
//
|
||||
// TLRPC.TL_payments_getPaymentForm req = new TLRPC.TL_payments_getPaymentForm();
|
||||
// TLRPC.TL_inputInvoicePremiumGiftCode invoice = new TLRPC.TL_inputInvoicePremiumGiftCode();
|
||||
// TLRPC.TL_inputStorePaymentPremiumGiveaway payload = new TLRPC.TL_inputStorePaymentPremiumGiveaway();
|
||||
//
|
||||
// payload.only_new_subscribers = onlyNewSubscribers;
|
||||
// payload.until_date = date;
|
||||
// payload.flags |= 2;
|
||||
// payload.flags |= 4;
|
||||
// payload.random_id = System.currentTimeMillis();
|
||||
// payload.additional_peers = new ArrayList<>();
|
||||
// for (TLObject o : chats) {
|
||||
// if (o instanceof TLRPC.Chat) {
|
||||
// payload.additional_peers.add(controller.getInputPeer(-((TLRPC.Chat) o).id));
|
||||
// }
|
||||
// }
|
||||
// payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
// payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
// payload.currency = option.currency;
|
||||
// payload.amount = option.amount;
|
||||
//
|
||||
// for (TLObject object : selectedCountries) {
|
||||
// TLRPC.TL_help_country country = (TLRPC.TL_help_country) object;
|
||||
// payload.countries_iso2.add(country.iso2);
|
||||
// }
|
||||
//
|
||||
// invoice.purpose = payload;
|
||||
// invoice.option = option;
|
||||
//
|
||||
// final JSONObject themeParams = BotWebViewSheet.makeThemeParams(baseFragment.getResourceProvider());
|
||||
// if (themeParams != null) {
|
||||
// req.theme_params = new TLRPC.TL_dataJSON();
|
||||
// req.theme_params.data = themeParams.toString();
|
||||
// req.flags |= 1;
|
||||
// }
|
||||
// req.invoice = invoice;
|
||||
//
|
||||
// int requestId = connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
// if (error != null) {
|
||||
// onError.run(error);
|
||||
// return;
|
||||
// }
|
||||
// PaymentFormActivity paymentFormActivity = null;
|
||||
// if (response instanceof TLRPC.TL_payments_paymentForm) {
|
||||
// TLRPC.TL_payments_paymentForm form = (TLRPC.TL_payments_paymentForm) response;
|
||||
// form.invoice.recurring = true;
|
||||
// controller.putUsers(form.users, false);
|
||||
// paymentFormActivity = new PaymentFormActivity(form, invoice, baseFragment);
|
||||
// } else if (response instanceof TLRPC.TL_payments_paymentReceipt) {
|
||||
// paymentFormActivity = new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response);
|
||||
// }
|
||||
// if (paymentFormActivity != null) {
|
||||
// paymentFormActivity.setPaymentFormCallback(status -> {
|
||||
// if (status == PaymentFormActivity.InvoiceStatus.PAID) {
|
||||
// onSuccess.run(null);
|
||||
// } else if (status != PaymentFormActivity.InvoiceStatus.PENDING) {
|
||||
// onError.run(null);
|
||||
// }
|
||||
// });
|
||||
// LaunchActivity.getLastFragment().showAsSheet(paymentFormActivity, new BaseFragment.BottomSheetParams());
|
||||
// } else {
|
||||
// onError.run(null);
|
||||
// }
|
||||
// }));
|
||||
// }
|
||||
//
|
||||
// public static void payGiveAwayByGoogle(List<TLObject> chats, List<TLObject> selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback<Void> onSuccess, Utilities.Callback<TLRPC.TL_error> onError) {
|
||||
// MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
|
||||
// ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
|
||||
// TLRPC.TL_inputStorePaymentPremiumGiveaway payload = new TLRPC.TL_inputStorePaymentPremiumGiveaway();
|
||||
//
|
||||
// payload.only_new_subscribers = onlyNewSubscribers;
|
||||
// payload.until_date = date;
|
||||
// payload.flags |= 2;
|
||||
// payload.flags |= 4;
|
||||
// payload.random_id = System.currentTimeMillis();
|
||||
// payload.additional_peers = new ArrayList<>();
|
||||
// for (TLObject o : chats) {
|
||||
// if (o instanceof TLRPC.Chat) {
|
||||
// payload.additional_peers.add(controller.getInputPeer(-((TLRPC.Chat) o).id));
|
||||
// }
|
||||
// }
|
||||
// payload.boost_peer = controller.getInputPeer(-chat.id);
|
||||
// for (TLObject object : selectedCountries) {
|
||||
// TLRPC.TL_help_country country = (TLRPC.TL_help_country) object;
|
||||
// payload.countries_iso2.add(country.iso2);
|
||||
// }
|
||||
//
|
||||
// QueryProductDetailsParams.Product product = QueryProductDetailsParams.Product.newBuilder()
|
||||
// .setProductType(BillingClient.ProductType.INAPP)
|
||||
// .setProductId(option.store_product)
|
||||
// .build();
|
||||
// BillingController.getInstance().queryProductDetails(Arrays.asList(product), (billingResult, list) -> {
|
||||
// ProductDetails.OneTimePurchaseOfferDetails offerDetails = list.get(0).getOneTimePurchaseOfferDetails();
|
||||
// payload.currency = offerDetails.getPriceCurrencyCode();
|
||||
// payload.amount = (long) ((offerDetails.getPriceAmountMicros() / Math.pow(10, 6)) * Math.pow(10, BillingController.getInstance().getCurrencyExp(option.currency)));
|
||||
//
|
||||
// TLRPC.TL_payments_canPurchasePremium req = new TLRPC.TL_payments_canPurchasePremium();
|
||||
// req.purpose = payload;
|
||||
// connection.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
// if (error != null) {
|
||||
// onError.run(error);
|
||||
// return;
|
||||
// }
|
||||
// if (response != null) {
|
||||
// BillingController.getInstance().addResultListener(list.get(0).getProductId(), billingResult1 -> {
|
||||
// if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
// AndroidUtilities.runOnUIThread(() -> onSuccess.run(null));
|
||||
// }
|
||||
// });
|
||||
// BillingController.getInstance().setOnCanceled(() -> {
|
||||
// AndroidUtilities.runOnUIThread(() -> onError.run(null));
|
||||
// });
|
||||
// BillingController.getInstance().launchBillingFlow(
|
||||
// baseFragment.getParentActivity(), AccountInstance.getInstance(UserConfig.selectedAccount), payload,
|
||||
// Collections.singletonList(BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
// .setProductDetails(list.get(0))
|
||||
// .build())
|
||||
// );
|
||||
// }
|
||||
// }));
|
||||
// });
|
||||
// }
|
||||
|
||||
public static List<TLRPC.TL_premiumGiftCodeOption> filterGiftOptions(List<TLRPC.TL_premiumGiftCodeOption> list, int selected) {
|
||||
List<TLRPC.TL_premiumGiftCodeOption> result = new ArrayList<>();
|
||||
@ -457,40 +457,40 @@ public class BoostRepository {
|
||||
req.flags = 1;
|
||||
req.boost_peer = controller.getInputPeer(-chat.id);
|
||||
|
||||
int reqId = connection.sendRequest(req, (response, error) -> {
|
||||
if (response != null) {
|
||||
TLRPC.Vector vector = (TLRPC.Vector) response;
|
||||
List<TLRPC.TL_premiumGiftCodeOption> result = new ArrayList<>();
|
||||
List<QueryProductDetailsParams.Product> products = new ArrayList<>();
|
||||
for (int i = 0; i < vector.objects.size(); i++) {
|
||||
final TLRPC.TL_premiumGiftCodeOption object = (TLRPC.TL_premiumGiftCodeOption) vector.objects.get(i);
|
||||
result.add(object);
|
||||
if (object.store_product != null) {
|
||||
products.add(QueryProductDetailsParams.Product.newBuilder()
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.setProductId(object.store_product)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
if (products.isEmpty() || !isGoogleBillingAvailable()) {
|
||||
AndroidUtilities.runOnUIThread(() -> onDone.run(result));
|
||||
return;
|
||||
}
|
||||
BillingController.getInstance().queryProductDetails(products, (billingResult, list) -> {
|
||||
for (ProductDetails productDetails : list) {
|
||||
ProductDetails.OneTimePurchaseOfferDetails offerDetails = productDetails.getOneTimePurchaseOfferDetails();
|
||||
for (TLRPC.TL_premiumGiftCodeOption option : result) {
|
||||
if (option.store_product != null && option.store_product.equals(productDetails.getProductId())) {
|
||||
option.amount = (long) ((offerDetails.getPriceAmountMicros() / Math.pow(10, 6)) * Math.pow(10, BillingController.getInstance().getCurrencyExp(option.currency)));
|
||||
option.currency = offerDetails.getPriceCurrencyCode();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(() -> onDone.run(result));
|
||||
});
|
||||
}
|
||||
});
|
||||
// int reqId = connection.sendRequest(req, (response, error) -> {
|
||||
// if (response != null) {
|
||||
// TLRPC.Vector vector = (TLRPC.Vector) response;
|
||||
// List<TLRPC.TL_premiumGiftCodeOption> result = new ArrayList<>();
|
||||
// List<QueryProductDetailsParams.Product> products = new ArrayList<>();
|
||||
// for (int i = 0; i < vector.objects.size(); i++) {
|
||||
// final TLRPC.TL_premiumGiftCodeOption object = (TLRPC.TL_premiumGiftCodeOption) vector.objects.get(i);
|
||||
// result.add(object);
|
||||
// if (object.store_product != null) {
|
||||
// products.add(QueryProductDetailsParams.Product.newBuilder()
|
||||
// .setProductType(BillingClient.ProductType.INAPP)
|
||||
// .setProductId(object.store_product)
|
||||
// .build());
|
||||
// }
|
||||
// }
|
||||
// if (products.isEmpty() || !isGoogleBillingAvailable()) {
|
||||
// AndroidUtilities.runOnUIThread(() -> onDone.run(result));
|
||||
// return;
|
||||
// }
|
||||
// BillingController.getInstance().queryProductDetails(products, (billingResult, list) -> {
|
||||
// for (ProductDetails productDetails : list) {
|
||||
// ProductDetails.OneTimePurchaseOfferDetails offerDetails = productDetails.getOneTimePurchaseOfferDetails();
|
||||
// for (TLRPC.TL_premiumGiftCodeOption option : result) {
|
||||
// if (option.store_product != null && option.store_product.equals(productDetails.getProductId())) {
|
||||
// option.amount = (long) ((offerDetails.getPriceAmountMicros() / Math.pow(10, 6)) * Math.pow(10, BillingController.getInstance().getCurrencyExp(option.currency)));
|
||||
// option.currency = offerDetails.getPriceCurrencyCode();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// AndroidUtilities.runOnUIThread(() -> onDone.run(result));
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public static void searchChats(long currentChatId, int guid, String query, int count, Utilities.Callback<List<TLRPC.InputPeer>> onDone) {
|
||||
|
@ -29,7 +29,7 @@ import android.widget.ViewAnimator;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.google.android.gms.vision.Frame;
|
||||
//import com.google.android.gms.vision.Frame;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
@ -503,7 +503,7 @@ public class MessageHelper extends BaseController {
|
||||
imageView.setRoundRadius(AndroidUtilities.dp(20));
|
||||
if (forumTopic != null) {
|
||||
if (forumTopic.id == 1) {
|
||||
imageView.setImageDrawable(ForumUtilities.createGeneralTopicDrawable(context, 0.75f, Theme.getColor(Theme.key_dialogTextBlack, resourcesProvider)));
|
||||
imageView.setImageDrawable(ForumUtilities.createGeneralTopicDrawable(context, 0.75f, Theme.getColor(Theme.key_dialogTextBlack, resourcesProvider), false));
|
||||
} else {
|
||||
ForumUtilities.setTopicIcon(imageView, forumTopic, false, true, resourcesProvider);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user