diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostRepository.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostRepository.java index 5e2aecd281..25fac4be58 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostRepository.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostRepository.java @@ -3,10 +3,10 @@ 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.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 static ArrayList getMyChannels(long chatId) { } public static void payGiftCode(List users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 static boolean isGoogleBillingAvailable() { } return BillingController.getInstance().isReady(); } - - public static void payGiftCodeByInvoice(List users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 users, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 chats, List selectedCountries, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, Utilities.Callback onSuccess, Utilities.Callback onError) { MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount); @@ -256,139 +256,139 @@ public static void launchPreparedGiveaway(TL_stories.TL_prepaidGiveaway prepaidG } public static void payGiveAway(List chats, List selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 chats, List selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 chats, List selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 chats, List selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 chats, List selectedCountries, TLRPC.TL_premiumGiftCodeOption option, TLRPC.Chat chat, int date, boolean onlyNewSubscribers, BaseFragment baseFragment, Utilities.Callback onSuccess, Utilities.Callback 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 filterGiftOptions(List list, int selected) { List result = new ArrayList<>(); @@ -457,40 +457,40 @@ public static void loadGiftOptions(TLRPC.Chat chat, Utilities.Callback { - if (response != null) { - TLRPC.Vector vector = (TLRPC.Vector) response; - List result = new ArrayList<>(); - List 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 result = new ArrayList<>(); +// List 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> onDone) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/FlashViews.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/FlashViews.java index 0f10e11c40..02bb674c27 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/FlashViews.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/FlashViews.java @@ -29,7 +29,7 @@ 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; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageHelper.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageHelper.java index d1aa163236..0e5317cc3d 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageHelper.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageHelper.java @@ -503,7 +503,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 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); }