diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java index a48bcfbed..e1b4c0a9b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java @@ -53,6 +53,7 @@ import tw.nekomimi.nekogram.NekoConfig; public class DrawerProfileCell extends FrameLayout { private BackupImageView avatarImageView; + private BackupImageView avatarBackgroundView; private TextView nameTextView; private TextView phoneTextView; private ImageView shadowView; @@ -70,6 +71,10 @@ public class DrawerProfileCell extends FrameLayout { public DrawerProfileCell(Context context) { super(context); + avatarBackgroundView = new BackupImageView(context); + avatarBackgroundView.setVisibility(INVISIBLE); + addView(avatarBackgroundView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); + shadowView = new ImageView(context); shadowView.setVisibility(INVISIBLE); shadowView.setScaleType(ImageView.ScaleType.FIT_XY); @@ -183,7 +188,7 @@ public class DrawerProfileCell extends FrameLayout { boolean useImageBackground = !backgroundKey.equals(Theme.key_chats_menuTopBackground) && Theme.isCustomTheme() && !Theme.isPatternWallpaper() && backgroundDrawable != null && !(backgroundDrawable instanceof ColorDrawable) && !(backgroundDrawable instanceof GradientDrawable); boolean drawCatsShadow = false; int color; - if (!useImageBackground && Theme.hasThemeKey(Theme.key_chats_menuTopShadowCats)) { + if (!NekoConfig.avatarAsDrawerBackground && !useImageBackground && Theme.hasThemeKey(Theme.key_chats_menuTopShadowCats)) { color = Theme.getColor(Theme.key_chats_menuTopShadowCats); drawCatsShadow = true; } else { @@ -203,7 +208,7 @@ public class DrawerProfileCell extends FrameLayout { darkThemeView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); } nameTextView.setTextColor(Theme.getColor(Theme.key_chats_menuName)); - if (useImageBackground) { + if (NekoConfig.avatarAsDrawerBackground || useImageBackground) { phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhone)); if (shadowView.getVisibility() != VISIBLE) { shadowView.setVisibility(VISIBLE); @@ -271,6 +276,14 @@ public class DrawerProfileCell extends FrameLayout { AvatarDrawable avatarDrawable = new AvatarDrawable(user); avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue)); avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); + if (NekoConfig.avatarAsDrawerBackground) { + avatarBackgroundView.setImage(ImageLocation.getForUser(user, true), "512_512", avatarDrawable, user); + avatarBackgroundView.setVisibility(VISIBLE); + avatarImageView.setVisibility(INVISIBLE); + } else { + avatarBackgroundView.setVisibility(INVISIBLE); + avatarImageView.setVisibility(VISIBLE); + } applyBackground(true); } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java index af9a40625..2b43afdda 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java @@ -44,6 +44,7 @@ public class NekoConfig { public static boolean transparentStatusBar = false; public static boolean forceTablet = false; public static boolean openArchiveOnPull = false; + public static boolean avatarAsDrawerBackground = false; public static int nameOrder = 1; public static int eventType = 0; public static boolean newYear = false; @@ -91,6 +92,7 @@ public class NekoConfig { editor.putBoolean("openFilterByActionBar", openFilterByActionBar); editor.putBoolean("openFilterByFab", openFilterByFab); editor.putBoolean("showHiddenFeature", showHiddenFeature); + editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground); editor.putFloat("stickerSize", stickerSize); editor.putInt("typeface", typeface); editor.putInt("nameOrder", nameOrder); @@ -146,6 +148,7 @@ public class NekoConfig { openFilterByFab = preferences.getBoolean("openFilterByFab", false); showHiddenFeature = preferences.getBoolean("showHiddenFeature", false); hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false); + avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", false); configLoaded = true; } } @@ -424,4 +427,12 @@ public class NekoConfig { editor.putBoolean("hideKeyboardOnChatScroll", hideKeyboardOnChatScroll); editor.commit(); } + + public static void toggleAvatarAsDrawerBackground() { + avatarAsDrawerBackground = !avatarAsDrawerBackground; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground); + editor.commit(); + } } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java index 7b11fec49..c23166003 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java @@ -97,6 +97,7 @@ public class NekoSettingsActivity extends BaseFragment { private int transparentStatusBarRow; private int forceTabletRow; private int openArchiveOnPullRow; + private int avatarAsDrawerBackgroundRow; private int eventTypeRow; private int newYearRow; private int actionBarDecorationRow; @@ -529,6 +530,12 @@ public class NekoSettingsActivity extends BaseFragment { if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(NekoConfig.hideKeyboardOnChatScroll); } + } else if (position == avatarAsDrawerBackgroundRow) { + NekoConfig.toggleAvatarAsDrawerBackground(); + NotificationCenter.getInstance(UserConfig.selectedAccount).postNotificationName(NotificationCenter.mainUserInfoChanged); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(NekoConfig.avatarAsDrawerBackground); + } } }); @@ -574,6 +581,7 @@ public class NekoSettingsActivity extends BaseFragment { transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1; forceTabletRow = rowCount++; openArchiveOnPullRow = rowCount++; + avatarAsDrawerBackgroundRow = rowCount++; nameOrderRow = rowCount++; eventTypeRow = NekoConfig.showHiddenFeature ? rowCount++ : -1; newYearRow = NekoConfig.showHiddenFeature ? rowCount++ : -1; @@ -1064,6 +1072,8 @@ public class NekoSettingsActivity extends BaseFragment { textCell.setTextAndCheck(LocaleController.getString("TapOnFab", R.string.TapOnFab), NekoConfig.openFilterByFab, false); } else if (position == hideKeyboardOnChatScrollRow) { textCell.setTextAndCheck(LocaleController.getString("HideKeyboardOnChatScroll", R.string.HideKeyboardOnChatScroll), NekoConfig.hideKeyboardOnChatScroll, true); + } else if (position == avatarAsDrawerBackgroundRow) { + textCell.setTextAndCheck(LocaleController.getString("UseAvatarAsDrawerBackground", R.string.UseAvatarAsDrawerBackground), NekoConfig.avatarAsDrawerBackground, true); } break; } @@ -1105,7 +1115,7 @@ public class NekoSettingsActivity extends BaseFragment { position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow || position == openFilterByActionBarRow || position == openFilterByFabRow || position == connection2Row || - position == hideKeyboardOnChatScrollRow; + position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow; } @Override @@ -1158,7 +1168,8 @@ public class NekoSettingsActivity extends BaseFragment { position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow || position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow || - position == openFilterByActionBarRow || position == openFilterByFabRow || position == hideKeyboardOnChatScrollRow) { + position == openFilterByActionBarRow || position == openFilterByFabRow || position == hideKeyboardOnChatScrollRow || + position == avatarAsDrawerBackgroundRow) { return 3; } else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow || position == dialogsFilterRow) { diff --git a/TMessagesProj/src/main/res/values/strings_neko.xml b/TMessagesProj/src/main/res/values/strings_neko.xml index ab651d239..6e8d3a84f 100644 --- a/TMessagesProj/src/main/res/values/strings_neko.xml +++ b/TMessagesProj/src/main/res/values/strings_neko.xml @@ -93,4 +93,5 @@ Hide keyboard on chat scroll Send Stickers Send GIFs + Use avatar as drawer background \ No newline at end of file