feat: Disable Custom Wallpaper

This commit is contained in:
xtaodada 2024-01-22 13:28:08 +08:00
parent f3568041ff
commit e9fcaff900
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
7 changed files with 50 additions and 22 deletions

View File

@ -23,6 +23,8 @@ import java.util.HashMap;
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 class ChatThemeController extends BaseController {
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;

View File

@ -1464,17 +1464,18 @@ public class PreviewView extends FrameLayout {
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);
}

View File

@ -100,17 +100,18 @@ public class StoryThemeSheet extends FrameLayout {
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) {

View File

@ -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

View File

@ -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,

View File

@ -92,4 +92,6 @@
<string name="HideFilterMuteAll">隐藏文件夹中的\"全部取消静音\"</string>
<string name="UseLocalQuoteColor">本地名称颜色</string>
<string name="ShowSquareAvatar">显示方形头像</string>
<string name="DisableCustomWallpaperUser">禁用私聊的自定义背景</string>
<string name="DisableCustomWallpaperChannel">禁用频道的自定义背景</string>
</resources>

View File

@ -95,4 +95,6 @@
<string name="HideFilterMuteAll">Hide filter mute all</string>
<string name="UseLocalQuoteColor">Use local quote color</string>
<string name="ShowSquareAvatar">Show square avatar</string>
<string name="DisableCustomWallpaperUser">Disable user custom wallpaper</string>
<string name="DisableCustomWallpaperChannel">Disable channel custom wallpaper</string>
</resources>