Skip to content

Commit 6ace02d

Browse files
committed
[TF][FEATURE] Hide sponsored channels
1 parent a3b9ee0 commit 6ace02d

3 files changed

Lines changed: 27 additions & 15 deletions

File tree

TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@
181181
import org.telegram.ui.Components.TypefaceSpan;
182182
import org.telegram.ui.Components.URLSpanReplacement;
183183
import org.telegram.ui.Components.UndoView;
184-
import org.telegram.ui.Components.spoilers.SpoilersTextView;
185184
import org.telegram.ui.DebugRecordingCanvasReplayFragment;
186185
import org.telegram.ui.LaunchActivity;
187186
import org.telegram.ui.Stories.PeerStoriesView;
@@ -4723,14 +4722,6 @@ public static void showProxyAlert(Activity activity, final String address, final
47234722
.show();
47244723
}
47254724
}));
4726-
if (!TextUtils.isEmpty(secret)) {
4727-
final TableView.TableRowFullContent tableRow = tableView.addFullRow(getString(R.string.UseProxyTelegramInfo2));
4728-
tableRow.setFilled(true);
4729-
final SpoilersTextView textView = (SpoilersTextView) tableRow.getChildAt(0);
4730-
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
4731-
textView.setGravity(Gravity.CENTER);
4732-
}
4733-
47344725
final ButtonWithCounterView buttonView = new ButtonWithCounterView(activity, null).setRound();
47354726
buttonView.setText(getString(R.string.ConnectingConnectProxy));
47364727
buttonView.setOnClickListener(v -> {

TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,18 @@ public MessagesController(int num) {
16091609
promoPsaMessage = mainPreferences.getString("promo_psa_message", null);
16101610
promoPsaType = mainPreferences.getString("promo_psa_type", null);
16111611
proxyDialogAddress = mainPreferences.getString("proxyDialogAddress", null);
1612+
if (promoDialogType == PROMO_TYPE_PROXY) {
1613+
// never show proxy sponsored channels in the chat list
1614+
promoDialogId = 0;
1615+
proxyDialogAddress = null;
1616+
promoDialogType = PROMO_TYPE_OTHER;
1617+
promoDialog = null;
1618+
mainPreferences.edit()
1619+
.putLong("proxy_dialog", 0)
1620+
.remove("proxyDialogAddress")
1621+
.putInt("promo_dialog_type", PROMO_TYPE_OTHER)
1622+
.commit();
1623+
}
16121624
venueSearchBot = mainPreferences.getString("venueSearchBot", "foursquare");
16131625
storyVenueSearchBot = mainPreferences.getString("storyVenueSearchBot", "foursquare");
16141626
gifSearchBot = mainPreferences.getString("gifSearchBot", "gif");
@@ -9972,8 +9984,9 @@ public void hidePromoDialog() {
99729984
Utilities.stageQueue.postRunnable(() -> {
99739985
promoDialogId = 0;
99749986
proxyDialogAddress = null;
9987+
promoDialogType = PROMO_TYPE_OTHER;
99759988
nextPromoInfoCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60;
9976-
getGlobalMainSettings().edit().putLong("proxy_dialog", promoDialogId).remove("proxyDialogAddress").putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime).commit();
9989+
getGlobalMainSettings().edit().putLong("proxy_dialog", promoDialogId).remove("proxyDialogAddress").putInt("promo_dialog_type", PROMO_TYPE_OTHER).putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime).commit();
99779990
});
99789991
removePromoDialog();
99799992
}
@@ -10886,6 +10899,11 @@ private void checkPromoInfoInternal(boolean reset) {
1088610899
TLRPC.TL_help_promoDataEmpty res = (TLRPC.TL_help_promoDataEmpty) response;
1088710900
nextPromoInfoCheckTime = res.expires;
1088810901
noDialog = true;
10902+
} else if (response instanceof TLRPC.TL_help_promoData && ((TLRPC.TL_help_promoData) response).proxy) {
10903+
// never show proxy sponsored channels in the chat list
10904+
TLRPC.TL_help_promoData res = (TLRPC.TL_help_promoData) response;
10905+
nextPromoInfoCheckTime = res.expires;
10906+
noDialog = true;
1088910907
} else if (response instanceof TLRPC.TL_help_promoData) {
1089010908
TLRPC.TL_help_promoData res = (TLRPC.TL_help_promoData) response;
1089110909

@@ -10920,6 +10938,7 @@ private void checkPromoInfoInternal(boolean reset) {
1092010938
promoDialogId = did;
1092110939
if (res.proxy) {
1092210940
promoDialogType = PROMO_TYPE_PROXY;
10941+
noDialog = true;
1092310942
} else if (!TextUtils.isEmpty(res.psa_type)) {
1092410943
promoDialogType = PROMO_TYPE_PSA;
1092510944
promoPsaType = res.psa_type;
@@ -11126,7 +11145,8 @@ private void checkPromoInfoInternal(boolean reset) {
1112611145
}
1112711146
if (noDialog) {
1112811147
promoDialogId = 0;
11129-
getGlobalMainSettings().edit().putLong("proxy_dialog", promoDialogId).remove("proxyDialogAddress").putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime).commit();
11148+
promoDialogType = PROMO_TYPE_OTHER;
11149+
getGlobalMainSettings().edit().putLong("proxy_dialog", promoDialogId).remove("proxyDialogAddress").putInt("promo_dialog_type", PROMO_TYPE_OTHER).putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime).commit();
1113011150
checkingPromoInfoRequestId = 0;
1113111151
checkingPromoInfo = false;
1113211152
AndroidUtilities.runOnUIThread(this::removePromoDialog);
@@ -11135,8 +11155,9 @@ private void checkPromoInfoInternal(boolean reset) {
1113511155
if (removeCurrent != 0) {
1113611156
promoDialogId = 0;
1113711157
proxyDialogAddress = null;
11158+
promoDialogType = PROMO_TYPE_OTHER;
1113811159
nextPromoInfoCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60;
11139-
getGlobalMainSettings().edit().putLong("proxy_dialog", promoDialogId).remove("proxyDialogAddress").putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime).commit();
11160+
getGlobalMainSettings().edit().putLong("proxy_dialog", promoDialogId).remove("proxyDialogAddress").putInt("promo_dialog_type", PROMO_TYPE_OTHER).putInt("nextPromoInfoCheckTime", nextPromoInfoCheckTime).commit();
1114011161
AndroidUtilities.runOnUIThread(this::removePromoDialog);
1114111162
}
1114211163
}
@@ -11159,7 +11180,7 @@ private void removePromoDialog() {
1115911180
}
1116011181

1116111182
public boolean isPromoDialog(long did, boolean checkLeft) {
11162-
return promoDialog != null && promoDialog.id == did && (!checkLeft || isLeftPromoChannel);
11183+
return promoDialog != null && promoDialogType != PROMO_TYPE_PROXY && promoDialog.id == did && (!checkLeft || isLeftPromoChannel);
1116311184
}
1116411185

1116511186
private String getUserNameForTyping(TLRPC.User user) {
@@ -22410,7 +22431,7 @@ public void sortDialogs(LongSparseArray<TLRPC.Chat> chatsDict) {
2241022431
}
2241122432

2241222433
}
22413-
if (promoDialog != null && isLeftPromoChannel) {
22434+
if (promoDialog != null && isLeftPromoChannel && promoDialogType != PROMO_TYPE_PROXY) {
2241422435
allDialogs.add(0, promoDialog);
2241522436
addDialogToItsFolder(-2, promoDialog);
2241622437
}

TMessagesProj/src/main/java/org/telegram/ui/ProxySettingsActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public void afterTextChanged(Editable s) {
442442
if (i == 0) {
443443
bottomCells[i].setText(LocaleController.getString(R.string.UseProxyInfo));
444444
} else {
445-
bottomCells[i].setText(LocaleController.getString(R.string.UseProxyTelegramInfo) + "\n\n" + LocaleController.getString(R.string.UseProxyTelegramInfo2));
445+
bottomCells[i].setText(LocaleController.getString(R.string.UseProxyTelegramInfo));
446446
bottomCells[i].setVisibility(View.GONE);
447447
}
448448
linearLayout2.addView(bottomCells[i], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

0 commit comments

Comments
 (0)