diff --git a/app/src/main/java/moe/kirao/mgx/MoexConfig.java b/app/src/main/java/moe/kirao/mgx/MoexConfig.java index fbdbba1d24..72f07c533b 100644 --- a/app/src/main/java/moe/kirao/mgx/MoexConfig.java +++ b/app/src/main/java/moe/kirao/mgx/MoexConfig.java @@ -46,6 +46,8 @@ public class MoexConfig { public static final String KEY_BLUR_DRAWER = "blur_drawer"; public static final String KEY_CHANGE_HEADER_TEXT = "change_header_text"; public static final String KEY_TYPING_INSTEAD_CHOOSING = "typing_instead_choosing"; + public static final String KEY_DISABLE_REACTIONS = "disable_reactions"; + public static final int SIZE_LIMIT_800 = 0; public static final int SIZE_LIMIT_1280 = 1; @@ -74,6 +76,7 @@ public class MoexConfig { public static boolean squareAvatar = instance().getBoolean(KEY_SQUARE_AVATAR, false); public static boolean blurDrawer = instance().getBoolean(KEY_BLUR_DRAWER, false); public static boolean typingInsteadChoosing = instance().getBoolean(KEY_TYPING_INSTEAD_CHOOSING, true); + public static boolean disableReactions = instance().getBoolean(KEY_DISABLE_REACTIONS, false); private MoexConfig () { File configDir = new File(UI.getAppContext().getFilesDir(), "moexconf"); @@ -303,4 +306,9 @@ public void setHeaderText (int mode) { public void toggleTypingInsteadChoosing () { putBoolean(KEY_TYPING_INSTEAD_CHOOSING, typingInsteadChoosing ^= true); } + + public void toggleDisableReactions () { + notifyNewSettingsListeners(KEY_DISABLE_REACTIONS, !disableReactions, disableReactions); + putBoolean(KEY_DISABLE_REACTIONS, disableReactions ^= true); + } } diff --git a/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java b/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java index 5d9de6247d..c6a361dfa0 100644 --- a/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java +++ b/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java @@ -50,6 +50,9 @@ public InterfaceSettingsMoexController (Context context, Tdlib tdlib) { adapter.updateValuedSettingById(R.id.btn_blurDrawer); } else if (viewId == R.id.btn_headerText) { showChangeHeader(); + } else if (viewId == R.id.btn_disableReactions) { + MoexConfig.instance().toggleDisableReactions(); + adapter.updateValuedSettingById(R.id.btn_disableReactions); } } @@ -114,6 +117,8 @@ private void showChangeHeader () { view.setData(R.string.login_FirstName); break; } + } else if (itemId == R.id.btn_disableReactions) { + view.getToggler().setRadioEnabled(MoexConfig.disableReactions, isUpdate); } } }; @@ -130,6 +135,8 @@ private void showChangeHeader () { items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_headerText, 0, R.string.changeHeaderText)); items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_squareAvatar, 0, R.string.SquareAvatar)); + items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); + items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_disableReactions, 0, R.string.DisableReactions)); items.add(new ListItem(ListItem.TYPE_SHADOW_BOTTOM)); items.add(new ListItem(ListItem.TYPE_HEADER, 0, 0, R.string.MoexHideButtons)); diff --git a/app/src/main/java/org/thunderdog/challegram/data/TGChat.java b/app/src/main/java/org/thunderdog/challegram/data/TGChat.java index cbf8c21213..e42f4346ba 100644 --- a/app/src/main/java/org/thunderdog/challegram/data/TGChat.java +++ b/app/src/main/java/org/thunderdog/challegram/data/TGChat.java @@ -63,6 +63,8 @@ import java.util.Set; import java.util.concurrent.TimeUnit; +import moe.kirao.mgx.MoexConfig; + import me.vkryl.android.AnimatorUtils; import me.vkryl.android.animator.BounceAnimator; import me.vkryl.android.util.MultipleViewProvider; @@ -803,7 +805,7 @@ public int getCurrentWidth () { } private void setCounter (boolean allowAnimation) { - boolean hasReactions = hasUnreadReactions(); + boolean hasReactions = hasUnreadReactions() && !MoexConfig.disableReactions; boolean hasMentions = hasUnreadMentions(); int unreadCount = getUnreadCount(); @@ -969,7 +971,7 @@ public long mediaTextComplexColor () { } public boolean needDrawReactionsPreview () { - return isPrivate() && !isSelfChat(); + return isPrivate() && !isSelfChat() && !MoexConfig.disableReactions; } public @Nullable EmojiStatusHelper.EmojiStatusDrawable getEmojiStatus () { diff --git a/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java b/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java index 531a620d28..cfd1eae3e1 100644 --- a/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java +++ b/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java @@ -303,6 +303,7 @@ public void onFactorChanged (int id, float factor, float fraction, FactorAnimato public static final int REACTIONS_DRAW_MODE_BUBBLE = 0; public static final int REACTIONS_DRAW_MODE_FLAT = 1; public static final int REACTIONS_DRAW_MODE_ONLY_ICON = 2; + public static final int REACTIONS_DRAW_MODE_NONE = 3; private final TranslationsManager mTranslationsManager; @@ -4921,7 +4922,7 @@ public boolean canBeForwarded () { } public boolean canBeReacted () { - return !isSponsoredMessage() && !isEventLog() && !(msg.content instanceof TdApi.MessageCall) && !Td.isEmpty(messageAvailableReactions); + return !isSponsoredMessage() && !isEventLog() && !(msg.content instanceof TdApi.MessageCall) && !Td.isEmpty(messageAvailableReactions) && !MoexConfig.disableReactions; } public boolean canBeSaved () { @@ -4991,7 +4992,7 @@ public boolean markAsViewed () { } result = true; } - if (containsUnreadReactions() && !BitwiseUtils.hasFlag(flags, FLAG_IGNORE_REACTIONS_VIEW)) { + if (containsUnreadReactions() && !BitwiseUtils.hasFlag(flags, FLAG_IGNORE_REACTIONS_VIEW) && !MoexConfig.disableReactions) { flags |= FLAG_IGNORE_REACTIONS_VIEW; highlightUnreadReactions(); @@ -8140,7 +8141,7 @@ public final boolean useBubbles () { }*/ public final boolean useReactionBubbles () { - return manager().useReactionBubbles(); + return manager().useReactionBubbles() && !MoexConfig.disableReactions; } // @@ -8470,6 +8471,10 @@ private Point getReactionPosition (TGReaction reaction) { } private int getReactionsDrawMode () { + if (MoexConfig.disableReactions) { + return REACTIONS_DRAW_MODE_NONE; + } + if (useReactionBubbles()) { return REACTIONS_DRAW_MODE_BUBBLE; } diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index f927368679..092d922b6e 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -6063,7 +6063,7 @@ private void setReactionButtonVisible (boolean visible, boolean animated) { } private void setReactionCountBadge (int reactionCount) { - if (reactionCount > 0 && (inPreviewMode || isInForceTouchMode() || areScheduledOnly())) { + if (reactionCount > 0 && (inPreviewMode || isInForceTouchMode() || areScheduledOnly() || MoexConfig.disableReactions)) { return; } if (reactionCountBadge != reactionCount) { diff --git a/app/src/main/res/values/moex_ids.xml b/app/src/main/res/values/moex_ids.xml index d6b597cfec..066ae17c63 100644 --- a/app/src/main/res/values/moex_ids.xml +++ b/app/src/main/res/values/moex_ids.xml @@ -39,4 +39,5 @@ - \ No newline at end of file + + diff --git a/app/src/main/res/values/moex_strings.xml b/app/src/main/res/values/moex_strings.xml index db285fa750..b3c3573d73 100755 --- a/app/src/main/res/values/moex_strings.xml +++ b/app/src/main/res/values/moex_strings.xml @@ -68,4 +68,5 @@ Send choosing sticker status This will send **typing** status instead of **choosing** sticker Moe moe, kyun! + Hide reactions