Skip to content

Commit

Permalink
feat: Disable Custom Wallpaper
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao authored and LiuYi0526 committed Jan 22, 2024
1 parent ff8bcf4 commit f179d8a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit f179d8a

Please sign in to comment.