Skip to content

Commit

Permalink
feat: Trend Recommendations Optional Disable Related Features
Browse files Browse the repository at this point in the history
  • Loading branch information
cinitdev committed Feb 2, 2025
1 parent 7e5db69 commit aeb980a
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ public void addNewStickerSet(TLRPC.TL_messages_stickerSet set) {
}

public void loadFeaturedStickers(boolean emoji, boolean cache) {
if (Config.disableTrendingSticker || (getUserConfig().getCurrentUser() != null && getUserConfig().getCurrentUser().bot) || loadingFeaturedStickers[emoji ? 1 : 0]) {
if (Config.DisableFeaturedStickers || (getUserConfig().getCurrentUser() != null && getUserConfig().getCurrentUser().bot) || loadingFeaturedStickers[emoji ? 1 : 0]) {
return;
}
loadingFeaturedStickers[emoji ? 1 : 0] = true;
Expand Down
9 changes: 7 additions & 2 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8881,7 +8881,7 @@ public void onAllEffectsEnd() {
}
}

if (getDialogId() == getUserConfig().getClientUserId()) {
if (getDialogId() == getUserConfig().getClientUserId() && (getUserConfig().isPremium() && !Config.DisableFavoriteSearchEmojiTags)) {
actionBarSearchTags = new SearchTagsList(context, ChatActivity.this, contentView, currentAccount, getSavedDialogId(), themeDelegate, true) {
@Override
protected boolean setFilter(ReactionsLayoutInBubble.VisibleReaction reaction) {
Expand Down Expand Up @@ -23599,6 +23599,11 @@ private void loadSendAsPeers(boolean animatedUpdate) {
}
sendAsPeersObj = getMessagesController().getSendAsPeers(dialog_id);
if (sendAsPeersObj != null) {
if (Config.DisableNonPremiumChannelChatShow) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
sendAsPeersObj.peers.removeIf(peer -> peer.premium_required);
}
}
chatActivityEnterView.updateSendAsButton(animatedUpdate);
}
}
Expand Down Expand Up @@ -31031,7 +31036,7 @@ public boolean onTouch(View v, MotionEvent event) {
sheet.show();
}));
}
if (isReactionsAvailable && (!tags || !getMessagesController().premiumFeaturesBlocked())) {
if (isReactionsAvailable && (!tags || (!getMessagesController().premiumFeaturesBlocked() && (getUserConfig().isPremium() && !Config.DisablePremiumFavoriteEmojiTags)))) {
int pad = 22;
int sPad = 24;
reactionsLayout.setPadding(AndroidUtilities.dp(4) + (LocaleController.isRTL ? 0 : sPad), AndroidUtilities.dp(4), AndroidUtilities.dp(4) + (LocaleController.isRTL ? sPad : 0), AndroidUtilities.dp(pad));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC;
import xyz.nextalone.gen.Config;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.Premium.PremiumLockIconView;
import org.telegram.ui.Components.Reactions.HwEmojis;
Expand Down Expand Up @@ -464,6 +465,9 @@ public void updateEmojiPacks(ArrayList<EmojiView.EmojiPack> emojiPacks) {
appearCount = emojiPacks.size();
final boolean includeFeatured = doIncludeFeatured();
final boolean isPremium = UserConfig.getInstance(UserConfig.selectedAccount).isPremium() || allowEmojisForNonPremium();
if (Config.DisableFeatuerdEmojis && !isPremium) {
return;
}

ArrayList<EmojiTabButton> attachedEmojiPacks = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5218,7 +5218,7 @@ private void updateStickerTabs(boolean updateStickerSets) {
if (trendingAdapter != null) {
trendingAdapter.notifyDataSetChanged();
}
if (!Config.disableTrendingSticker && !featured.isEmpty() && (featuredStickerSets.isEmpty() || preferences.getLong("featured_hidden", 0) == featured.get(0).set.id)) {
if (!Config.DisableFeaturedStickers && !featured.isEmpty() && (featuredStickerSets.isEmpty() || preferences.getLong("featured_hidden", 0) == featured.get(0).set.id)) {
final int id = mediaDataController.getUnreadStickerSets().isEmpty() ? 2 : 3;
final StickerTabView trendingStickersTabView = stickersTab.addStickerIconTab(id, stickerIcons[id]);
trendingStickersTabView.textView.setText(LocaleController.getString(R.string.FeaturedStickersShort));
Expand Down Expand Up @@ -8130,6 +8130,7 @@ private void updateRecentItemsCount() {
}

public void loadTrendingGifs() {
if (Config.DisableFeaturedGifs) return;
search("", "", true, true, true);
}

Expand Down
87 changes: 76 additions & 11 deletions TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5584,28 +5584,28 @@ public boolean isStarsSubscriptionHintVisible() {
}

public boolean isPremiumRestoreHintVisible() {
/*if (!MessagesController.getInstance(currentAccount).premiumFeaturesBlocked() && folderId == 0) {
if (!MessagesController.getInstance(currentAccount).premiumFeaturesBlocked() && folderId == 0) {
return MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_RESTORE") && !getUserConfig().isPremium() && MediaDataController.getInstance(currentAccount).getPremiumHintAnnualDiscount(false) != null;
}*/
}
return false;
}

public boolean isPremiumChristmasHintVisible() {
/*if (!MessagesController.getInstance(currentAccount).premiumFeaturesBlocked() && folderId == 0) {
if (!MessagesController.getInstance(currentAccount).premiumFeaturesBlocked() && folderId == 0) {
return MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_CHRISTMAS");
}*/
}
return false;
}

public boolean isPremiumHintVisible() {
/*if (!MessagesController.getInstance(currentAccount).premiumFeaturesBlocked() && folderId == 0) {
if (!MessagesController.getInstance(currentAccount).premiumFeaturesBlocked() && folderId == 0) {
if (MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_UPGRADE") && getUserConfig().isPremium() || MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_ANNUAL") && !getUserConfig().isPremium()) {
if (UserConfig.getInstance(currentAccount).isPremium() ? !BuildVars.useInvoiceBilling() && MediaDataController.getInstance(currentAccount).getPremiumHintAnnualDiscount(true) != null : MediaDataController.getInstance(currentAccount).getPremiumHintAnnualDiscount(false) != null) {
isPremiumHintUpgrade = MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_UPGRADE");
return true;
}
}
}*/
}
return false;
}

Expand Down Expand Up @@ -5845,7 +5845,7 @@ private void updateDialogsHint() {
}
authHintCell.set(DialogsActivity.this, currentAccount);
updateAuthHintCellVisibility(true);
} else if (folderId == 0 && MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_GRACE")) {
} else if (folderId == 0 && MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_GRACE") && !Config.DisablePremiumExpiring) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(true);
Expand All @@ -5861,7 +5861,7 @@ private void updateDialogsHint() {
updateDialogsHint();
});
updateAuthHintCellVisibility(false);
} else if (isStarsSubscriptionHintVisible()) {
} else if (isStarsSubscriptionHintVisible() && !Config.DisableStarsSubscription) {
StarsController c = StarsController.getInstance(currentAccount);
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -5902,7 +5902,7 @@ private void updateDialogsHint() {
updateDialogsHint();
});
updateAuthHintCellVisibility(false);
} else if (folderId == 0 && !getMessagesController().premiumPurchaseBlocked() && BirthdayController.getInstance(currentAccount).contains() && !getMessagesController().dismissedSuggestions.contains("BIRTHDAY_CONTACTS_TODAY")) {
} else if (folderId == 0 && !getMessagesController().premiumPurchaseBlocked() && BirthdayController.getInstance(currentAccount).contains() && !getMessagesController().dismissedSuggestions.contains("BIRTHDAY_CONTACTS_TODAY") && !Config.DisableBirthdayContact) {
BirthdayController.BirthdayState state = BirthdayController.getInstance(currentAccount).getState();
ArrayList<TLRPC.User> users = state.today;
dialogsHintCellVisible = true;
Expand Down Expand Up @@ -5970,7 +5970,7 @@ private void updateDialogsHint() {
} else {
if (userFull != null) {
if (oldBirthday == null) {
userFull.flags2 &=~ 32;
userFull.flags2 &= ~32;
} else {
userFull.flags2 |= 32;
}
Expand Down Expand Up @@ -6021,7 +6021,72 @@ private void updateDialogsHint() {
.show();
});
updateAuthHintCellVisibility(false);
} else if (isCacheHintVisible()) {
} else if (isPremiumChristmasHintVisible() && !Config.DisablePremiumChristmas) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(false);
dialogsHintCell.setOnClickListener(v -> UserSelectorBottomSheet.open());
dialogsHintCell.setText(Emoji.replaceEmoji(AndroidUtilities.replaceSingleTag(
LocaleController.getString(R.string.GiftPremiumEventAdsTitle),
Theme.key_windowBackgroundWhiteValueText,
AndroidUtilities.REPLACING_TAG_TYPE_LINKBOLD,
null
), null, false), LocaleController.formatString("BoostingPremiumChristmasSubTitle", R.string.BoostingPremiumChristmasSubTitle));
dialogsHintCell.setOnCloseListener(v -> {
MessagesController.getInstance(currentAccount).removeSuggestion(0, "PREMIUM_CHRISTMAS");
ChangeBounds transition = new ChangeBounds();
transition.setDuration(200);
TransitionManager.beginDelayedTransition((ViewGroup) dialogsHintCell.getParent(), transition);
updateDialogsHint();
BulletinFactory.of(this)
.createSimpleBulletin(R.raw.chats_infotip, LocaleController.getString(R.string.BoostingPremiumChristmasToast), 4)
.setDuration(Bulletin.DURATION_PROLONG)
.show();
});
updateAuthHintCellVisibility(false);
} else if (isPremiumRestoreHintVisible() && !Config.DisablePremiumRestore) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(false);
dialogsHintCell.setOnClickListener(v -> {
presentFragment(new PremiumPreviewFragment("dialogs_hint").setSelectAnnualByDefault());
AndroidUtilities.runOnUIThread(() -> {
MessagesController.getInstance(currentAccount).removeSuggestion(0, "PREMIUM_RESTORE");
updateDialogsHint();
}, 250);
});
dialogsHintCell.setText(
AndroidUtilities.replaceSingleTag(
LocaleController.formatString(R.string.RestorePremiumHintTitle, MediaDataController.getInstance(currentAccount).getPremiumHintAnnualDiscount(false)),
Theme.key_windowBackgroundWhiteValueText,
AndroidUtilities.REPLACING_TAG_TYPE_LINKBOLD,
null
),
LocaleController.getString(R.string.RestorePremiumHintMessage)
);
updateAuthHintCellVisibility(false);
} else if (isPremiumHintVisible() && !Config.DisablePremiumUpgrade) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(false);
dialogsHintCell.setOnClickListener(v -> {
presentFragment(new PremiumPreviewFragment("dialogs_hint").setSelectAnnualByDefault());
AndroidUtilities.runOnUIThread(() -> {
MessagesController.getInstance(currentAccount).removeSuggestion(0, isPremiumHintUpgrade ? "PREMIUM_UPGRADE" : "PREMIUM_ANNUAL");
updateDialogsHint();
}, 250);
});
dialogsHintCell.setText(
AndroidUtilities.replaceSingleTag(
LocaleController.formatString(isPremiumHintUpgrade ? R.string.SaveOnAnnualPremiumTitle : R.string.UpgradePremiumTitle, MediaDataController.getInstance(currentAccount).getPremiumHintAnnualDiscount(false)),
Theme.key_windowBackgroundWhiteValueText,
AndroidUtilities.REPLACING_TAG_TYPE_LINKBOLD,
null
),
LocaleController.getString(isPremiumHintUpgrade ? R.string.UpgradePremiumMessage : R.string.SaveOnAnnualPremiumMessage)
);
updateAuthHintCellVisibility(false);
} else if (isCacheHintVisible()) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(false);
Expand Down
Loading

0 comments on commit aeb980a

Please sign in to comment.