Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYi0526 committed Feb 1, 2025
2 parents e999afb + 55b9957 commit fdd201f
Show file tree
Hide file tree
Showing 36 changed files with 589 additions and 639 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
boringssl:
name: Native Build (BoringSSL)
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 3 additions & 1 deletion TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.10"
implementation 'com.neovisionaries:nv-websocket-client:2.14'
implementation 'dnsjava:dnsjava:3.4.1'
implementation "org.dizitart:nitrite:3.4.3"
// db
implementation 'org.dizitart:nitrite:4.3.0'
implementation 'org.dizitart:nitrite-mvstore-adapter:4.3.0'

implementation "cn.hutool:hutool-core:5.7.13"
implementation "cn.hutool:hutool-crypto:5.7.13"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
import tw.nekomimi.nekogram.utils.ProxyUtil;
import tw.nekomimi.nekogram.utils.UIUtil;
import tw.nekomimi.nekogram.utils.TelegramUtil;
import xyz.nextalone.nagram.helper.ColorOsHelper;

import static com.v2ray.ang.V2RayConfig.SSR_PROTOCOL;
import static com.v2ray.ang.V2RayConfig.SS_PROTOCOL;
Expand Down Expand Up @@ -3484,7 +3485,11 @@ public static void shakeViewSpring(View view, float shiftDp, Runnable endCallbac
// }

public static boolean shouldShowClipboardToast() {
return (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || !OneUIUtilities.hasBuiltInClipboardToasts()) && (Build.VERSION.SDK_INT < 32 || XiaomiUtilities.isMIUI());
boolean origin = (Build.VERSION.SDK_INT < Build.VERSION_CODES.S || !OneUIUtilities.hasBuiltInClipboardToasts()) && Build.VERSION.SDK_INT < 32;
if (origin) return true;
boolean isMIUI = XiaomiUtilities.isMIUI();
boolean isColorOS = ColorOsHelper.INSTANCE.isColorOS();
return isMIUI || isColorOS;
}

public static boolean addToClipboard(CharSequence str) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@

import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.ui.PinnedStickerHelper;
import xyz.nextalone.nagram.NaConfig;
import xyz.nextalone.nagram.helper.ExternalStickerCacheHelper;

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -2237,7 +2238,7 @@ public void addNewStickerSet(TLRPC.TL_messages_stickerSet set) {
}

public void loadFeaturedStickers(boolean emoji, boolean cache) {
if (loadingFeaturedStickers[emoji ? 1 : 0] || NekoConfig.disableTrending.Bool()) {
if (loadingFeaturedStickers[emoji ? 1 : 0] || NaConfig.INSTANCE.getDisableFeaturedStickers().Bool()) {
return;
}
loadingFeaturedStickers[emoji ? 1 : 0] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ public static int getLastLocalId() {
public static void saveAccounts() {
FileLog.e("Save accounts: " + activeAccounts, new Exception());
ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit()
.putString("active_accounts", StringUtils.join(activeAccounts, ","))
.putString("active_accounts", StrUtil.join(",", activeAccounts))
.apply();
}

Expand Down Expand Up @@ -1543,7 +1543,7 @@ public static void loadConfig() {
}

if (!SharedConfig.activeAccounts.isEmpty()) {
preferences.edit().putString("active_accounts", StringUtils.join(activeAccounts, ",")).apply();
preferences.edit().putString("active_accounts", StrUtil.join(",", activeAccounts)).apply();
}

preferences.edit().putBoolean("activeAccountsLoaded", true).apply();
Expand Down
6 changes: 3 additions & 3 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8963,7 +8963,7 @@ public void onAllEffectsEnd() {
}
}

if (getDialogId() == getUserConfig().getClientUserId() && (getUserConfig().isPremium() && NekoConfig.disableTrending.Bool())) {
if (getDialogId() == getUserConfig().getClientUserId() && (getUserConfig().isPremium() && !NaConfig.INSTANCE.getDisableFavoriteSearchEmojiTags().Bool())) {
actionBarSearchTags = new SearchTagsList(context, ChatActivity.this, contentView, currentAccount, getSavedDialogId(), themeDelegate, true) {
@Override
protected boolean setFilter(ReactionsLayoutInBubble.VisibleReaction reaction) {
Expand Down Expand Up @@ -24002,7 +24002,7 @@ private void loadSendAsPeers(boolean animatedUpdate) {
}
sendAsPeersObj = getMessagesController().getSendAsPeers(dialog_id);
if (sendAsPeersObj != null) {
if (NekoConfig.disableTrending.Bool()) {
if (NaConfig.INSTANCE.getDisableNonPremiumChannelChatShow().Bool()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
sendAsPeersObj.peers.removeIf(peer -> peer.premium_required);
}
Expand Down Expand Up @@ -31675,7 +31675,7 @@ public boolean onTouch(View v, MotionEvent event) {
sheet.show();
}));
}
if (isReactionsAvailable && (!tags || (!getMessagesController().premiumFeaturesBlocked() && (getUserConfig().isPremium() && NekoConfig.disableTrending.Bool())))) {
if (isReactionsAvailable && (!tags || (!getMessagesController().premiumFeaturesBlocked() && (getUserConfig().isPremium() && !NaConfig.INSTANCE.getDisablePremiumFavoriteEmojiTags().Bool())))) {
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 @@ -47,6 +47,7 @@
import java.util.Map;

import tw.nekomimi.nekogram.NekoConfig;
import xyz.nextalone.nagram.NaConfig;

public class EmojiTabsStrip extends ScrollableHorizontalScrollView {

Expand Down Expand Up @@ -493,7 +494,7 @@ public void updateEmojiPacks(ArrayList<EmojiView.EmojiPack> emojiPacks) {
return;
}
final boolean isPremium = UserConfig.getInstance(UserConfig.selectedAccount).isPremium() || allowEmojisForNonPremium();
if (NekoConfig.disableTrending.Bool() && !isPremium) {
if (NaConfig.INSTANCE.getDisableFeatuerdEmojis().Bool() && !isPremium) {
return;
}
int childCount = contentView.getChildCount() - packsIndexStart - (settingsTab != null ? 1 : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@

import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.ui.PinnedStickerHelper;
import xyz.nextalone.nagram.NaConfig;

public class EmojiView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {

Expand Down Expand Up @@ -5212,7 +5213,7 @@ private void updateStickerTabs(boolean updateStickerSets) {
if (trendingAdapter != null) {
trendingAdapter.notifyDataSetChanged();
}
if (!NekoConfig.disableTrending.Bool() && !featured.isEmpty() && (!BuildVars.DEBUG_PRIVATE_VERSION || featuredStickerSets.isEmpty() || preferences.getLong("featured_hidden", 0) == featured.get(0).set.id)) {
if (!NaConfig.INSTANCE.getDisableFeaturedStickers().Bool() && !featured.isEmpty() && (!BuildVars.DEBUG_PRIVATE_VERSION || 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 @@ -5396,10 +5397,8 @@ private void updateGifTabs() {
gifTabs.addIconTab(0, gifIcons[0]).setContentDescription(LocaleController.getString(R.string.RecentStickers));
}

if (!NekoConfig.disableTrending.Bool()) {
gifTrendingTabNum = gifTabsCount++;
gifTabs.addIconTab(1, gifIcons[1]).setContentDescription(LocaleController.getString(R.string.FeaturedGifs));
}
gifTrendingTabNum = gifTabsCount++;
gifTabs.addIconTab(1, gifIcons[1]).setContentDescription(LocaleController.getString(R.string.FeaturedGifs));

gifFirstEmojiTabNum = gifTabsCount;
final int hPadding = AndroidUtilities.dp(13);
Expand Down Expand Up @@ -8122,6 +8121,7 @@ private void updateRecentItemsCount() {
}

public void loadTrendingGifs() {
if (NaConfig.INSTANCE.getDisableFeaturedGifs().Bool()) return;
search("", "", true, true, true);
}

Expand Down
12 changes: 6 additions & 6 deletions TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5979,7 +5979,7 @@ private void updateDialogsHint() {
}
authHintCell.set(DialogsActivity.this, currentAccount);
updateAuthHintCellVisibility(true);
} else if (folderId == 0 && MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_GRACE") && !NekoConfig.disableTrending.Bool()) {
} else if (folderId == 0 && MessagesController.getInstance(currentAccount).pendingSuggestions.contains("PREMIUM_GRACE") && !NaConfig.INSTANCE.getDisablePremiumExpiring().Bool()) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(true);
Expand All @@ -5995,7 +5995,7 @@ private void updateDialogsHint() {
updateDialogsHint();
});
updateAuthHintCellVisibility(false);
} else if (isStarsSubscriptionHintVisible() && !NekoConfig.disableTrending.Bool()) {
} else if (isStarsSubscriptionHintVisible() && !NaConfig.INSTANCE.getDisableStarsSubscription().Bool()) {
StarsController c = StarsController.getInstance(currentAccount);
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -6036,7 +6036,7 @@ private void updateDialogsHint() {
updateDialogsHint();
});
updateAuthHintCellVisibility(false);
} else if (folderId == 0 && !getMessagesController().premiumPurchaseBlocked() && BirthdayController.getInstance(currentAccount).contains() && !getMessagesController().dismissedSuggestions.contains("BIRTHDAY_CONTACTS_TODAY") && !NekoConfig.disableTrending.Bool()) {
} else if (folderId == 0 && !getMessagesController().premiumPurchaseBlocked() && BirthdayController.getInstance(currentAccount).contains() && !getMessagesController().dismissedSuggestions.contains("BIRTHDAY_CONTACTS_TODAY") && !NaConfig.INSTANCE.getDisableBirthdayContact().Bool()) {
BirthdayController.BirthdayState state = BirthdayController.getInstance(currentAccount).getState();
ArrayList<TLRPC.User> users = state.today;
dialogsHintCellVisible = true;
Expand Down Expand Up @@ -6155,7 +6155,7 @@ private void updateDialogsHint() {
.show();
});
updateAuthHintCellVisibility(false);
} else if (isPremiumChristmasHintVisible()) {
} else if (isPremiumChristmasHintVisible() && !NaConfig.INSTANCE.getDisablePremiumChristmas().Bool()) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(false);
Expand All @@ -6178,7 +6178,7 @@ private void updateDialogsHint() {
.show();
});
updateAuthHintCellVisibility(false);
} else if (isPremiumRestoreHintVisible()) {
} else if (isPremiumRestoreHintVisible() && !NaConfig.INSTANCE.getDisablePremiumRestore().Bool()) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(false);
Expand All @@ -6199,7 +6199,7 @@ private void updateDialogsHint() {
LocaleController.getString(R.string.RestorePremiumHintMessage)
);
updateAuthHintCellVisibility(false);
} else if (isPremiumHintVisible()) {
} else if (isPremiumHintVisible() && !NaConfig.INSTANCE.getDisablePremiumUpgrade().Bool()) {
dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setCompact(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@

import com.jakewharton.processphoenix.ProcessPhoenix;

import org.apache.commons.lang3.StringUtils;

import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public class NekoConfig {
public static ConfigItem disableLinkPreviewByDefault = addConfig("DisableLinkPreviewByDefault", configTypeBool, false);
public static ConfigItem sendCommentAfterForward = addConfig("SendCommentAfterForward", configTypeBool, true);
// public static ConfigItem increaseVoiceMessageQuality = addConfig("IncreaseVoiceMessageQuality", configTypeBool, true);
public static ConfigItem disableTrending = addConfig("DisableTrending", configTypeBool, true);
// public static ConfigItem disableTrending = addConfig("DisableTrending", configTypeBool, true);
public static ConfigItem dontSendGreetingSticker = addConfig("DontSendGreetingSticker", configTypeBool, false);
public static ConfigItem hideTimeForSticker = addConfig("HideTimeForSticker", configTypeBool, false);
public static ConfigItem takeGIFasVideo = addConfig("TakeGIFasVideo", configTypeBool, false);
Expand Down Expand Up @@ -452,8 +452,8 @@ public static void checkMigrate(boolean force) {
sendCommentAfterForward.setConfigBool(preferences.getBoolean("sendCommentAfterForward", true));
// if (preferences.contains("increaseVoiceMessageQuality"))
// increaseVoiceMessageQuality.setConfigBool(preferences.getBoolean("increaseVoiceMessageQuality", true));
if (preferences.contains("disableTrending"))
disableTrending.setConfigBool(preferences.getBoolean("disableTrending", true));
// if (preferences.contains("disableTrending"))
// disableTrending.setConfigBool(preferences.getBoolean("disableTrending", true));
if (preferences.contains("dontSendGreetingSticker"))
dontSendGreetingSticker.setConfigBool(preferences.getBoolean("dontSendGreetingSticker", false));
if (preferences.contains("hideTimeForSticker"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ConfigItem {
public static final int configTypeMapIntInt = 4;
public static final int configTypeLong = 5;
public static final int configTypeFloat = 6;
public static final int configTypeBoolLinkInt = 7;

public final String key;
public final int type;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package tw.nekomimi.nekogram.config;

import android.content.SharedPreferences;

import org.telegram.messenger.FileLog;

import tw.nekomimi.nekogram.NekoConfig;

public class ConfigItemKeyLinked extends ConfigItem {
public final ConfigItem keyLinked;
public final int flag;

public ConfigItemKeyLinked(String key, ConfigItem keyLinked, int flag, Object defaultValue) {
super(key, ConfigItem.configTypeBoolLinkInt, defaultValue);
this.keyLinked = keyLinked;
this.flag = (int) Math.pow(2, flag);
}

public ConfigItem getKeyLinked() {
return keyLinked;
}

public void changedFromKeyLinked(int currentConfig) {
changed((currentConfig & flag) != 0);
}

public boolean toggleConfigBool() {
value = !this.Bool();
saveConfig();
return this.Bool();//返回toggle之后的
}

public void setConfigBool(boolean v) {
value = v;
saveConfig();
}

public void saveConfig() {
synchronized (NekoConfig.sync) {
try {
SharedPreferences.Editor editor = NekoConfig.preferences.edit();

if (this.type == configTypeBoolLinkInt) {
int currentConfig = this.keyLinked.Int();
int newConfig;
if ((boolean) this.value) {
newConfig = currentConfig | flag; // 开启对应位
} else {
newConfig = currentConfig & ~flag; // 关闭对应位
}
this.keyLinked.changed(newConfig);
editor.putInt(this.keyLinked.getKey(), newConfig);
}
editor.apply();
} catch (Exception e) {
FileLog.e(e);
}
}
}

public Object checkConfigFromString(String value) {
try {
if (type == configTypeBoolLinkInt) {
return Boolean.parseBoolean(value);
}
return null;
} catch (Exception ignored) {}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public ConfigItem getBindConfig() {
return bindConfig;
}

public String getTitle() {
return title;
}

public String getKey() {
return bindConfig == null ? null : bindConfig.getKey();
}
Expand Down
Loading

0 comments on commit fdd201f

Please sign in to comment.