Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
030 committed Nov 24, 2023
1 parent d8e481b commit aeefeac
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ private BillingController(Context ctx) {
}

public void setOnCanceled(Runnable onCanceled) {
this.onCanceled = onCanceled;
}

public String getLastPremiumTransaction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7060,13 +7060,8 @@ public static void prepareSendingLocation(AccountInstance accountInstance, final
sendingMedia.geo = new TLRPC.TL_geoPoint();
sendingMedia.geo.lat = location.getLatitude();
sendingMedia.geo._long = location.getLongitude();

// 030: fix build - dunno if this would work
// accountInstance.getSendMessagesHelper().sendMessage(sendingMedia, dialog_id, null, null, null, null, true, 0);
SendingMediaInfo info = new SendingMediaInfo();
ArrayList<SendingMediaInfo> infos = new ArrayList<>();
infos.add(info);
prepareSendingMedia(accountInstance, infos, dialog_id, null, null, null, false, false, null, true, 0, false, null);
// 030: fix build, ref: https://github.com/Telegram-FOSS-Team/Telegram-FOSS/commit/0676f797e59a4f72381c0ed1769051494ff06f50
accountInstance.getSendMessagesHelper().sendMessage(SendMessageParams.of(sendingMedia, dialog_id, null, null, null, null, true, 0));
})));
}

Expand Down
10 changes: 5 additions & 5 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not

private MessageObject selectedObjectToEditCaption;
private MessageObject selectedObject;
private MessageObject.GroupedMessages selectedObjectGroup;
public MessageObject.GroupedMessages selectedObjectGroup;
private boolean forbidForwardingWithDismiss;
public MessagePreviewParams messagePreviewParams;
private CharSequence formwardingNameText;
Expand Down Expand Up @@ -12008,11 +12008,11 @@ public void showFieldPanelForEdit(boolean show, MessageObject messageObjectToEdi

public void beforeMessageSend(boolean notify, int scheduleDate, boolean beforeSend) {
if (beforeSend != NekoConfig.sendCommentAfterForward.Bool()) return;
if (forwardingMessages != null) {
if (messagePreviewParams.forwardMessages != null) {
ArrayList<MessageObject> messagesToForward = new ArrayList<>();
forwardingMessages.getSelectedMessages(messagesToForward);
forwardMessages(messagesToForward, forwardingMessages.hideForwardSendersName, forwardingMessages.hideCaption, notify, scheduleDate != 0 && scheduleDate != 0x7ffffffe ? scheduleDate + 1 : scheduleDate);
forwardingMessages = null;
messagePreviewParams.forwardMessages.getSelectedMessages(messagesToForward);
forwardMessages(messagesToForward, messagePreviewParams.hideForwardSendersName, messagePreviewParams.hideCaption, notify, scheduleDate != 0 && scheduleDate != 0x7ffffffe ? scheduleDate + 1 : scheduleDate);
messagePreviewParams.forwardMessages = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4640,15 +4640,19 @@ protected void onAttachedToWindow() {
messageEditText.setFallbackLineSpacing(false);
}
messageEditText.wrapCanvasToFixClipping = true;
messageEditText.setDelegate(() -> {
messageEditText.invalidateEffects();
if (delegate != null) {
delegate.onTextSpansChanged(messageEditText.getText());

// 030: is this Delegate thingy correct?
messageEditText.setDelegate(new EditTextCaption.EditTextCaptionDelegate() {
@Override
public void onSpansChanged() {
messageEditText.invalidateEffects();
if (delegate != null) {
delegate.onTextSpansChanged(messageEditText.getText());
}
}

@Override
public long getCurrentChat() {

long chatId;
if (parentFragment.getCurrentChat() != null) {
chatId = parentFragment.getCurrentChat().id;
Expand All @@ -4660,7 +4664,6 @@ public long getCurrentChat() {

return chatId;
}

});
if (parentFragment != null && parentFragment.getParentLayout() != null && parentFragment.getParentLayout().isSheet()) {
messageEditText.setWindowView(parentFragment.getParentLayout().getWindow().getDecorView());
Expand Down Expand Up @@ -11861,7 +11864,7 @@ protected void dispatchDraw(Canvas canvas) {
}
}

private int getThemedColor(int key) {
protected int getThemedColor(int key) {
if (resourcesProvider != null) {
return resourcesProvider.getColor(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,53 +105,7 @@ public static void payGiftCodeByInvoice(List<TLObject> users, TLRPC.TL_premiumGi
}

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())
);
}
}));
});
// 030: remove premium shit
}

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) {
Expand Down Expand Up @@ -207,61 +161,7 @@ public static void payGiveAwayByInvoice(List<TLObject> chats, List<TLObject> sel
}

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())
);
}
}));
});
// 030: remove premium shit
}

public static List<TLRPC.TL_premiumGiftCodeOption> filterGiftOptions(List<TLRPC.TL_premiumGiftCodeOption> list, int selected) {
Expand Down Expand Up @@ -325,46 +225,7 @@ public static void loadCountries(Utilities.Callback<Pair<Map<String, List<TLRPC.
}

public static void loadGiftOptions(TLRPC.Chat chat, Utilities.Callback<List<TLRPC.TL_premiumGiftCodeOption>> onDone) {
MessagesController controller = MessagesController.getInstance(UserConfig.selectedAccount);
ConnectionsManager connection = ConnectionsManager.getInstance(UserConfig.selectedAccount);
TLRPC.TL_payments_getPremiumGiftCodeOptions req = new TLRPC.TL_payments_getPremiumGiftCodeOptions();
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));
});
}
});
// 030: remove premium shit
}

public static void searchChats(long currentChatId, int guid, String query, int count, Utilities.Callback<List<TLRPC.InputPeer>> onDone) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

import androidx.core.graphics.ColorUtils;

import com.google.android.gms.vision.Frame;

import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,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, resourcesProvider));
} else {
ForumUtilities.setTopicIcon(imageView, forumTopic, false, true, resourcesProvider);
}
Expand Down

0 comments on commit aeefeac

Please sign in to comment.