From 2ed8e2517a8dfed8bf8f8ab5b1f97a180b20a135 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 20 Jan 2024 20:27:14 +0800 Subject: [PATCH 1/5] style: scroll to row after import settings --- .../nekomimi/nekogram/settings/BaseNekoXSettingsActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/BaseNekoXSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/BaseNekoXSettingsActivity.java index 39ea08de63..f5929236bd 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/BaseNekoXSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/BaseNekoXSettingsActivity.java @@ -138,11 +138,12 @@ public void importToRow(String key, String value, Runnable unknown) { var builder = new AlertDialog.Builder(context); builder.setTitle(LocaleController.getString("ImportSettings", R.string.ImportSettings)); builder.setMessage(LocaleController.getString("ImportSettingsAlert", R.string.ImportSettingsAlert)); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialogInter, i) -> scrollToRow(key, unknown)); builder.setPositiveButton(LocaleController.getString("Import", R.string.Import), (dialogInter, i) -> { config.changed(new_value); config.saveConfig(); updateRows(); + scrollToRow(key, unknown); }); builder.show(); } else { From f3568041ffc2a83ef1a6848a6755ac31e622cefe Mon Sep 17 00:00:00 2001 From: Nikita Artikhovich <33029221+notaLonelyDay@users.noreply.github.com> Date: Sun, 21 Jan 2024 07:44:19 +0300 Subject: [PATCH 2/5] fix: memory leak in LaunchActivity (#28) --- TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 828b7d9baa..99e4cedbc9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -6046,6 +6046,7 @@ protected void onDestroy() { } catch (Exception e) { FileLog.e(e); } + clearFragments(); super.onDestroy(); onFinish(); FloatingDebugController.onDestroy(); From e9fcaff9000ca055adfb4c3b2a2580d74173a28b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 22 Jan 2024 13:28:08 +0800 Subject: [PATCH 3/5] feat: Disable Custom Wallpaper --- .../messenger/ChatThemeController.java | 8 +++++++ .../ui/Stories/recorder/PreviewView.java | 23 ++++++++++--------- .../ui/Stories/recorder/StoryThemeSheet.java | 23 ++++++++++--------- .../settings/NekoChatSettingsActivity.java | 2 ++ .../kotlin/xyz/nextalone/nagram/NaConfig.kt | 12 ++++++++++ .../src/main/res/values-zh-rCN/strings_na.xml | 2 ++ .../src/main/res/values/strings_na.xml | 2 ++ 7 files changed, 50 insertions(+), 22 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java index 6c8239e620..a1b7f4a9f4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Locale; +import xyz.nextalone.nagram.NaConfig; + public class ChatThemeController extends BaseController { private final long reloadTimeoutMs = 2 * 60 * 60 * 1000; @@ -300,11 +302,17 @@ public void saveChatWallpaper(long dialogId, TLRPC.WallPaper wallPaper) { public TLRPC.WallPaper getDialogWallpaper(long dialogId) { if (dialogId >= 0) { + if (NaConfig.INSTANCE.getDisableCustomWallpaperUser().Bool()) { + return null; + } TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId); if (userFull != null) { return userFull.wallpaper; } } else { + if (NaConfig.INSTANCE.getDisableCustomWallpaperChannel().Bool()) { + return null; + } TLRPC.ChatFull chatFull = getMessagesController().getChatFull(-dialogId); if (chatFull != null) { return chatFull.wallpaper; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PreviewView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PreviewView.java index e90825ba8e..265948373f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PreviewView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/PreviewView.java @@ -1464,17 +1464,18 @@ public static Drawable getBackgroundDrawable(Drawable prevDrawable, int currentA return null; } TLRPC.WallPaper wallpaper = null; - if (dialogId >= 0) { - TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId); - if (userFull != null) { - wallpaper = userFull.wallpaper; - } - } else { - TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(-dialogId); - if (chatFull != null) { - wallpaper = chatFull.wallpaper; - } - } +// if (dialogId >= 0) { +// TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId); +// if (userFull != null) { +// wallpaper = userFull.wallpaper; +// } +// } else { +// TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(-dialogId); +// if (chatFull != null) { +// wallpaper = chatFull.wallpaper; +// } +// } + wallpaper = ChatThemeController.getInstance(currentAccount).getDialogWallpaper(dialogId); return getBackgroundDrawable(prevDrawable, currentAccount, wallpaper, isDark); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryThemeSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryThemeSheet.java index 4c2a95c054..a97506d49d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryThemeSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryThemeSheet.java @@ -100,17 +100,18 @@ public void open(StoryEntry entry) { if (entry != null) { TLRPC.WallPaper wallpaper = null; if (entry.backgroundWallpaperPeerId != Long.MIN_VALUE) { - if (entry.backgroundWallpaperPeerId < 0) { - TLRPC.ChatFull chatFull = MessagesController.getInstance(entry.currentAccount).getChatFull(-entry.backgroundWallpaperPeerId); - if (chatFull != null) { - wallpaper = chatFull.wallpaper; - } - } else { - TLRPC.UserFull userFull = MessagesController.getInstance(entry.currentAccount).getUserFull(entry.backgroundWallpaperPeerId); - if (userFull != null) { - wallpaper = userFull.wallpaper; - } - } +// if (entry.backgroundWallpaperPeerId < 0) { +// TLRPC.ChatFull chatFull = MessagesController.getInstance(entry.currentAccount).getChatFull(-entry.backgroundWallpaperPeerId); +// if (chatFull != null) { +// wallpaper = chatFull.wallpaper; +// } +// } else { +// TLRPC.UserFull userFull = MessagesController.getInstance(entry.currentAccount).getUserFull(entry.backgroundWallpaperPeerId); +// if (userFull != null) { +// wallpaper = userFull.wallpaper; +// } +// } + wallpaper = ChatThemeController.getInstance(entry.currentAccount).getDialogWallpaper(entry.backgroundWallpaperPeerId); } themeView.setGalleryWallpaper(wallpaper); if (entry.backgroundWallpaperEmoticon != null) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java index 6f863b3a92..3f54197c1f 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java @@ -122,6 +122,8 @@ public class NekoChatSettingsActivity extends BaseNekoXSettingsActivity implemen private final AbstractConfigCell quickToggleAnonymousRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getQuickToggleAnonymous(), LocaleController.getString("QuickToggleAnonymousNotice", R.string.QuickToggleAnonymousNotice))); private final AbstractConfigCell showOnlineStatusRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowOnlineStatus(), LocaleController.getString("ShowOnlineStatusNotice", R.string.ShowOnlineStatusNotice))); private final AbstractConfigCell showRecentOnlineStatusRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowRecentOnlineStatus())); + private final AbstractConfigCell disableCustomWallpaperUserRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableCustomWallpaperUser())); + private final AbstractConfigCell disableCustomWallpaperChannelRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableCustomWallpaperChannel())); private final AbstractConfigCell dividerChat = cellGroup.appendCell(new ConfigCellDivider()); // Interactions diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index 21d225cb03..eb1ed83f15 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -466,6 +466,18 @@ object NaConfig { ConfigItem.configTypeBool, false ) + val disableCustomWallpaperUser = + addConfig( + "DisableCustomWallpaperUser", + ConfigItem.configTypeBool, + false + ) + val disableCustomWallpaperChannel = + addConfig( + "DisableCustomWallpaperChannel", + ConfigItem.configTypeBool, + false + ) private fun addConfig( k: String, diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml index a8d246aa31..46181258e5 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -92,4 +92,6 @@ 隐藏文件夹中的\"全部取消静音\" 本地名称颜色 显示方形头像 + 禁用私聊的自定义背景 + 禁用频道的自定义背景 diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index 4c24e5acd5..efcb79f01a 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -95,4 +95,6 @@ Hide filter mute all Use local quote color Show square avatar + Disable user custom wallpaper + Disable channel custom wallpaper From d6a2090406bf8e71f6b83def45d29737e00266f4 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 24 Jan 2024 16:33:05 +0800 Subject: [PATCH 4/5] feat: remote custom wallpaper --- .../messenger/ChatThemeController.java | 8 + .../java/org/telegram/ui/LaunchActivity.java | 2 + .../helpers/remote/WallpaperHelper.java | 270 ++++++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java index a1b7f4a9f4..13741e16b0 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Locale; +import tw.nekomimi.nekogram.helpers.remote.WallpaperHelper; import xyz.nextalone.nagram.NaConfig; public class ChatThemeController extends BaseController { @@ -301,10 +302,14 @@ public void saveChatWallpaper(long dialogId, TLRPC.WallPaper wallPaper) { } public TLRPC.WallPaper getDialogWallpaper(long dialogId) { + TLRPC.WallPaper info = WallpaperHelper.getInstance().getDialogWallpaper(dialogId); if (dialogId >= 0) { if (NaConfig.INSTANCE.getDisableCustomWallpaperUser().Bool()) { return null; } + if (info != null) { + return info; + } TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId); if (userFull != null) { return userFull.wallpaper; @@ -313,6 +318,9 @@ public TLRPC.WallPaper getDialogWallpaper(long dialogId) { if (NaConfig.INSTANCE.getDisableCustomWallpaperChannel().Bool()) { return null; } + if (info != null) { + return info; + } TLRPC.ChatFull chatFull = getMessagesController().getChatFull(-dialogId); if (chatFull != null) { return chatFull.wallpaper; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 99e4cedbc9..793ea1c487 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -219,6 +219,7 @@ import tw.nekomimi.nekogram.InternalUpdater; import tw.nekomimi.nekogram.helpers.SettingsHelper; import tw.nekomimi.nekogram.helpers.remote.EmojiHelper; +import tw.nekomimi.nekogram.helpers.remote.WallpaperHelper; import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; @@ -1012,6 +1013,7 @@ public void onViewDetachedFromWindow(View v) { }); } EmojiHelper.getInstance().checkEmojiPacks(); + WallpaperHelper.getInstance().checkWallPaper(); BackupAgent.requestBackup(this); RestrictedLanguagesSelectActivity.checkRestrictedLanguages(false); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java new file mode 100644 index 0000000000..bad674c25b --- /dev/null +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java @@ -0,0 +1,270 @@ +package tw.nekomimi.nekogram.helpers.remote; + +import android.text.TextUtils; +import android.util.Base64; + +import org.json.JSONException; +import org.json.JSONObject; +import org.telegram.messenger.FileLog; +import org.telegram.tgnet.AbstractSerializedData; +import org.telegram.tgnet.SerializedData; +import org.telegram.tgnet.TLRPC; + +import java.util.ArrayList; +import java.util.HashMap; + +public class WallpaperHelper extends BaseRemoteHelper { + private static final String WALLPAPER_TAG = "wallpaper"; + private static volatile WallpaperHelper Instance; + private final ArrayList wallPaperInfo = new ArrayList<>(); + private final HashMap wallpaperInfoMap = new HashMap<>(); + private boolean loading = false; + + public static WallpaperHelper getInstance() { + WallpaperHelper localInstance = Instance; + if (localInstance == null) { + synchronized (WallpaperHelper.class) { + localInstance = Instance; + if (localInstance == null) { + Instance = localInstance = new WallpaperHelper(); + } + return localInstance; + } + } + return localInstance; + } + + @Override + protected void onError(String text, Delegate delegate) { + + } + + @Override + protected String getTag() { + return WALLPAPER_TAG; + } + + @Override + protected void onLoadSuccess(ArrayList responses, Delegate delegate) { + var tag = getTag(); + var json = responses.size() > 0 ? responses.get(0) : null; + if (json == null) { + preferences.edit() + .remove(tag + "_update_time") + .remove(tag) + .apply(); + return; + } + + try { + ArrayList wallpapers = new ArrayList<>(); + var array = json.getJSONArray("wallpapers"); + + for (int i = 0; i < array.length(); i++) { + var obj = array.getJSONObject(i); + var info = new WallPaperInfo( + obj.getLong("chat_id"), + obj.getInt("version"), + obj.getString("slug"), + obj.getString("emoticon"), + obj.getString("mode")); + if (wallpaperInfoMap.containsKey(info.chatId)) { + var oldInfo = wallpaperInfoMap.get(info.chatId); + if (oldInfo != null && oldInfo.version == info.version) { + wallpapers.add(oldInfo); + } else { + wallpapers.add(info); + } + } else { + wallpapers.add(info); + } + } + + wallPaperInfo.clear(); + wallPaperInfo.addAll(wallpapers); + wallpaperInfoMap.clear(); + for (WallPaperInfo info: wallPaperInfo) { + wallpaperInfoMap.put(info.chatId, info); + } + loadWallPaperFromServer(); + } catch (JSONException e) { + FileLog.e(e); + delegate.onTLResponse(null, e.getLocalizedMessage()); + } + } + + public void loadWallPaperInfo() { + var tag = getTag(); + String list = preferences.getString(tag, ""); + wallPaperInfo.clear(); + wallpaperInfoMap.clear(); + if (!TextUtils.isEmpty(list)) { + byte[] bytes = Base64.decode(list, Base64.DEFAULT); + SerializedData data = new SerializedData(bytes); + int count = data.readInt32(false); + for (int a = 0; a < count; a++) { + WallPaperInfo info = WallPaperInfo.deserialize(data); + wallPaperInfo.add(info); + wallpaperInfoMap.put(info.chatId, info); + } + data.cleanup(); + } + } + + public void saveWallPaperInfo() { + var tag = getTag(); + SerializedData serializedData = new SerializedData(); + serializedData.writeInt32(wallPaperInfo.size()); + for (WallPaperInfo info: wallPaperInfo) { + info.serializeToStream(serializedData); + } + preferences.edit() + .putLong(tag + "_update_time", System.currentTimeMillis()) + .putString(tag, Base64.encodeToString(serializedData.toByteArray(), Base64.NO_WRAP | Base64.NO_PADDING)) + .apply(); + serializedData.cleanup(); + } + + private void loadWallPaperFromServer() { + for (WallPaperInfo info : wallPaperInfo) { + if (info.wallPaper != null) { + continue; + } + if (!info.emoticon.isEmpty()) { + TLRPC.TL_wallPaperNoFile wallpaper = new TLRPC.TL_wallPaperNoFile(); + wallpaper.id = 0; + wallpaper.isDefault = false; + wallpaper.dark = false; + wallpaper.settings = info.parseSettings(); + info.flags |= 1; + info.wallPaper = wallpaper; + } + } + for (WallPaperInfo info: wallPaperInfo) { + if (info.wallPaper != null) { + continue; + } + if (info.slug != null && !info.slug.isEmpty()) { + TLRPC.TL_account_getWallPaper req = new TLRPC.TL_account_getWallPaper(); + TLRPC.TL_inputWallPaperSlug inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug(); + inputWallPaperSlug.slug = info.slug; + req.wallpaper = inputWallPaperSlug; + getConnectionsManager().sendRequest(req, (response, error1) -> { + if (error1 == null) { + if (response instanceof TLRPC.TL_wallPaper) { + info.flags |= 1; + info.wallPaper = (TLRPC.WallPaper) response; + info.wallPaper.settings = info.parseSettings(); + saveWallPaperInfo(); + } + } + }); + } + } + saveWallPaperInfo(); + } + + public TLRPC.WallPaper getDialogWallpaper(long dialogId) { + if (!wallpaperInfoMap.containsKey(dialogId)) { + return null; + } + var info = wallpaperInfoMap.get(dialogId); + if (info != null) { + return info.wallPaper; + } + return null; + } + + public boolean needUpdate() { + var tag = getTag(); + long oldTime = preferences.getLong(tag + "_update_time", 0L); + long nowTime = System.currentTimeMillis(); + int TTL = 15 * 60; + return oldTime + TTL <= nowTime; + } + + public void checkWallPaper() { + if (loading) { + return; + } + loading = true; + loadWallPaperInfo(); + if (needUpdate()) { + load(); + } + loading = false; + } + + public static class WallPaperInfo { + private int flags; + public long chatId; + public int version; + public String slug; + public String emoticon; + public String mode; + public TLRPC.WallPaper wallPaper; + + public WallPaperInfo(long chatId, int version, String slug, String emoticon, String mode) { + this.chatId = chatId; + this.version = version; + this.slug = slug; + this.emoticon = emoticon; + this.mode = mode; + } + + public WallPaperInfo() {} + + public TLRPC.WallPaperSettings parseSettings() { + TLRPC.WallPaperSettings settings = new TLRPC.TL_wallPaperSettings(); + if (emoticon != null && !emoticon.isBlank()) { + settings.emoticon = emoticon; + } + if (mode != null && !mode.isEmpty()) { + mode = mode.toLowerCase(); + String[] modes = mode.split(" "); + for (String s : modes) { + if ("blur".equals(s)) { + settings.blur = true; + } else if ("motion".equals(s)) { + settings.motion = true; + } else if (s.startsWith("intensity_")) { + try { + settings.intensity = Integer.parseInt(s.replace("intensity_", "")); + } catch (Exception ignore) { + } + } + } + } + return settings; + } + + public static WallpaperHelper.WallPaperInfo deserialize(AbstractSerializedData stream) { + WallpaperHelper.WallPaperInfo wallPaperInfo = new WallpaperHelper.WallPaperInfo(); + wallPaperInfo.flags = stream.readInt32(false); + wallPaperInfo.chatId = stream.readInt64(false); + wallPaperInfo.version = stream.readInt32(false); + wallPaperInfo.slug = stream.readString(false); + wallPaperInfo.emoticon = stream.readString(false); + wallPaperInfo.mode = stream.readString(false); + + if ((wallPaperInfo.flags & 1) != 0) { + wallPaperInfo.wallPaper = TLRPC.WallPaper.TLdeserialize(stream, stream.readInt32(false), false); + } + + return wallPaperInfo; + } + + public void serializeToStream(AbstractSerializedData serializedData) { + serializedData.writeInt32(flags); + serializedData.writeInt64(chatId); + serializedData.writeInt32(version); + serializedData.writeString(slug); + serializedData.writeString(emoticon); + serializedData.writeString(mode); + + if ((flags & 1) != 0) { + wallPaper.serializeToStream(serializedData); + } + } + } +} From ba8da2bcb18a8a2fb85afe9b07313c7e9930219a Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 24 Jan 2024 18:31:42 +0800 Subject: [PATCH 5/5] fix: remote custom wallpaper flags --- .../nekomimi/nekogram/helpers/remote/WallpaperHelper.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java index bad674c25b..f195762f4c 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/WallpaperHelper.java @@ -104,6 +104,11 @@ public void loadWallPaperInfo() { int count = data.readInt32(false); for (int a = 0; a < count; a++) { WallPaperInfo info = WallPaperInfo.deserialize(data); + if (info.wallPaper == null) { + continue; + } + info.wallPaper.flags |= 4; + info.wallPaper.settings = info.parseSettings(); wallPaperInfo.add(info); wallpaperInfoMap.put(info.chatId, info); } @@ -135,6 +140,7 @@ private void loadWallPaperFromServer() { wallpaper.id = 0; wallpaper.isDefault = false; wallpaper.dark = false; + wallpaper.flags |= 4; wallpaper.settings = info.parseSettings(); info.flags |= 1; info.wallPaper = wallpaper; @@ -154,6 +160,7 @@ private void loadWallPaperFromServer() { if (response instanceof TLRPC.TL_wallPaper) { info.flags |= 1; info.wallPaper = (TLRPC.WallPaper) response; + info.wallPaper.flags |= 4; info.wallPaper.settings = info.parseSettings(); saveWallPaperInfo(); }