diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java index 05070cec2a..8efbeb42a5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java @@ -2447,6 +2447,10 @@ public void setRoundRadius(int tl, int tr, int br, int bl) { } public void setRoundRadius(int[] value) { + if (NaConfig.INSTANCE.getShowSquareAvatar().Bool()) { + java.util.Arrays.fill(value, 0); + } + boolean changed = false; int firstValue = value[0]; isRoundRect = true; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCreateUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCreateUserCell.java index 53b5ccfb31..937371d01a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCreateUserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCreateUserCell.java @@ -39,6 +39,8 @@ import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.LayoutHelper; +import xyz.nextalone.nagram.NaConfig; + public class GroupCreateUserCell extends FrameLayout { private BackupImageView avatarImageView; @@ -430,7 +432,12 @@ protected void onDraw(Canvas canvas) { paint.setColor(Theme.getColor(Theme.key_checkboxSquareBackground, resourcesProvider)); float cx = avatarImageView.getLeft() + avatarImageView.getMeasuredWidth() / 2; float cy = avatarImageView.getTop() + avatarImageView.getMeasuredHeight() / 2; - canvas.drawCircle(cx, cy, AndroidUtilities.dp(18) + AndroidUtilities.dp(4) * checkProgress, paint); + if (NaConfig.INSTANCE.getShowSquareAvatar().Bool()) { + float dp = AndroidUtilities.dp(18) + AndroidUtilities.dp(4) * checkProgress; + canvas.drawRect(cx - dp, cy - dp, cx + dp, cy + dp, paint); + } else { + canvas.drawCircle(cx, cy, AndroidUtilities.dp(18) + AndroidUtilities.dp(4) * checkProgress, paint); + } } if (drawDivider) { int start = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 72 + padding); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java index f7dd2b0224..2960c96b10 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java @@ -58,6 +58,8 @@ import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RLottieDrawable; +import xyz.nextalone.nagram.NaConfig; + public class ShareDialogCell extends FrameLayout { private final BackupImageView imageView; @@ -316,7 +318,11 @@ protected void onDraw(Canvas canvas) { Theme.checkboxSquare_checkPaint.setAlpha((int) (checkBox.getProgress() * 255)); int radius = dp(currentType == TYPE_CREATE ? 24 : 28); AndroidUtilities.rectTmp.set(cx - radius, cy - radius, cx + radius, cy + radius); - canvas.drawRoundRect(AndroidUtilities.rectTmp, imageView.getRoundRadius()[0], imageView.getRoundRadius()[0], Theme.checkboxSquare_checkPaint); + if (NaConfig.INSTANCE.getShowSquareAvatar().Bool()) { + canvas.drawRoundRect(AndroidUtilities.rectTmp, 0, 0, Theme.checkboxSquare_checkPaint); + } else { + canvas.drawRoundRect(AndroidUtilities.rectTmp, imageView.getRoundRadius()[0], imageView.getRoundRadius()[0], Theme.checkboxSquare_checkPaint); + } super.onDraw(canvas); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java index 17ad01a59a..01cae9d823 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java @@ -42,6 +42,8 @@ import java.util.ArrayList; +import xyz.nextalone.nagram.NaConfig; + public class AvatarDrawable extends Drawable { private TextPaint namePaint; @@ -465,6 +467,8 @@ public void draw(Canvas canvas) { if (roundRadius > 0) { AndroidUtilities.rectTmp.set(0, 0, size, size); canvas.drawRoundRect(AndroidUtilities.rectTmp, roundRadius, roundRadius, Theme.avatar_backgroundPaint); + } else if (NaConfig.INSTANCE.getShowSquareAvatar().Bool()) { + canvas.drawRect(0f, 0f, size, size, Theme.avatar_backgroundPaint); } else { canvas.drawCircle(size / 2.0f, size / 2.0f, size / 2.0f, Theme.avatar_backgroundPaint); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SenderSelectView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SenderSelectView.java index 300834d3d4..caee6be65f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SenderSelectView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SenderSelectView.java @@ -24,6 +24,8 @@ import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.Theme; +import xyz.nextalone.nagram.NaConfig; + public class SenderSelectView extends View { private final static float SPRING_MULTIPLIER = 100f; private final static FloatPropertyCompat MENU_PROGRESS = new SimpleFloatPropertyCompat("menuProgress", obj -> obj.menuProgress, (obj, value) -> { @@ -56,7 +58,8 @@ public SenderSelectView(Context context) { private void updateColors() { backgroundPaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground)); menuPaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoicePressed)); - selectorDrawable = Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(16), Color.TRANSPARENT, Theme.getColor(Theme.key_windowBackgroundWhite)); + int value = NaConfig.INSTANCE.getShowSquareAvatar().Bool() ? 0 : 16; + selectorDrawable = Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(value), Color.TRANSPARENT, Theme.getColor(Theme.key_windowBackgroundWhite)); selectorDrawable.setCallback(this); } @@ -99,7 +102,12 @@ protected void onDraw(Canvas canvas) { int alpha = (int) (menuProgress * 0xFF); backgroundPaint.setAlpha(alpha); - canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, Math.min(getWidth(), getHeight()) / 2f, backgroundPaint); + if (NaConfig.INSTANCE.getShowSquareAvatar().Bool()) { + AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight()); + canvas.drawRoundRect(AndroidUtilities.rectTmp, 0, 0, backgroundPaint); + } else { + canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, Math.min(getWidth(), getHeight()) / 2f, backgroundPaint); + } canvas.save(); menuPaint.setAlpha(alpha); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleAvatarView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleAvatarView.java index c4dda1bcc0..a9d4bcfff7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleAvatarView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleAvatarView.java @@ -17,6 +17,8 @@ import org.telegram.tgnet.TLObject; import org.telegram.ui.ActionBar.Theme; +import xyz.nextalone.nagram.NaConfig; + public class SimpleAvatarView extends View { public final static int SELECT_ANIMATION_DURATION = 200; @@ -70,7 +72,12 @@ protected void onDraw(Canvas canvas) { selectPaint.setAlpha((int) (Color.alpha(selectPaint.getColor()) * selectProgress)); float stroke = selectPaint.getStrokeWidth(); AndroidUtilities.rectTmp.set(stroke, stroke, getWidth() - stroke, getHeight() - stroke); - canvas.drawArc(AndroidUtilities.rectTmp, -90, selectProgress * 360, false, selectPaint); + if (NaConfig.INSTANCE.getShowSquareAvatar().Bool()) { + final float w = selectPaint.getStrokeWidth(); + canvas.drawRect(w, w, getWidth() - w, getHeight() - w, selectPaint); + } else { + canvas.drawArc(AndroidUtilities.rectTmp, -90, selectProgress * 360, false, selectPaint); + } canvas.restore(); if (!isAvatarHidden) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/ProfileStoriesView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/ProfileStoriesView.java index c5bb953630..54019eac8a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/ProfileStoriesView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/ProfileStoriesView.java @@ -50,6 +50,8 @@ import java.util.Collections; import java.util.List; +import xyz.nextalone.nagram.NaConfig; + public class ProfileStoriesView extends View implements NotificationCenter.NotificationCenterDelegate { private static final int CIRCLES_MAX = 3; @@ -813,6 +815,10 @@ private StoryCircle nearest(StoryCircle a, StoryCircle b, StoryCircle c) { } private void drawArcs(Canvas canvas, StoryCircle A, StoryCircle B, StoryCircle C, Paint paint) { + if (NaConfig.INSTANCE.getShowSquareAvatar().Bool()) { + return; + } + if (A == null && C == null) { canvas.drawArc(B.borderRect, 0, 360, false, paint); } else if (A != null && C != null) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java index 484bbf08b1..7ee87b01c6 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java @@ -93,6 +93,7 @@ public class NekoGeneralSettingsActivity extends BaseNekoXSettingsActivity { private final AbstractConfigCell largeAvatarInDrawerRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.largeAvatarInDrawer, LocaleController.getString("valuesLargeAvatarInDrawer"), null)); private final AbstractConfigCell avatarBackgroundBlurRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.avatarBackgroundBlur)); private final AbstractConfigCell avatarBackgroundDarkenRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.avatarBackgroundDarken)); + private final AbstractConfigCell showSquareAvatarRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowSquareAvatar())); private final AbstractConfigCell hidePhoneRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hidePhone)); private final AbstractConfigCell divider0 = cellGroup.appendCell(new ConfigCellDivider()); diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index c7ab4ae644..21d225cb03 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -460,6 +460,12 @@ object NaConfig { ConfigItem.configTypeBool, false ) + val showSquareAvatar = + addConfig( + "ShowSquareAvatar", + 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 79a9d29fcf..a8d246aa31 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -91,4 +91,5 @@ 偷偷看动态 隐藏文件夹中的\"全部取消静音\" 本地名称颜色 + 显示方形头像 diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index e7633987aa..4c24e5acd5 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -94,4 +94,5 @@ Disable Send Read Stories Hide filter mute all Use local quote color + Show square avatar