Skip to content

Commit

Permalink
feat: Hide reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
jplie committed Dec 5, 2023
1 parent 0a650aa commit ba8d9de
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
8 changes: 8 additions & 0 deletions app/src/main/java/moe/kirao/mgx/MoexConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}
};
Expand All @@ -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));
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/org/thunderdog/challegram/data/TGChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -969,7 +971,7 @@ public long mediaTextComplexColor () {
}

public boolean needDrawReactionsPreview () {
return isPrivate() && !isSelfChat();
return isPrivate() && !isSelfChat() && !MoexConfig.disableReactions;
}

public @Nullable EmojiStatusHelper.EmojiStatusDrawable getEmojiStatus () {
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/org/thunderdog/challegram/data/TGMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -8140,7 +8141,7 @@ public final boolean useBubbles () {
}*/

public final boolean useReactionBubbles () {
return manager().useReactionBubbles();
return manager().useReactionBubbles() && !MoexConfig.disableReactions;
}

//
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/moex_ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
<item name="btn_headerTextUsername" type="id" />
<item name="btn_headerTextName" type="id" />
<item name="btn_typingInstead" type="id"/>
</resources>
<item name="btn_disableReactions" type="id"/>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/moex_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@
<string name="TypingInstead">Send choosing sticker status</string>
<string name="TypingInsteadInfo" formatted="true">This will send **typing** status instead of **choosing** sticker</string>
<string name="cuteToast" translatable="false">Moe moe, kyun!</string>
<string name="DisableReactions">Hide reactions</string>
</resources>

0 comments on commit ba8d9de

Please sign in to comment.