hide disabled emojis #45

Closed
opened 2019-12-23 22:03:18 +00:00 by Juby210 · 5 comments
Contributor

Patch that hides nitro emojis for users without nitro.

Patch that hides nitro emojis for users without nitro.

yes please I used whole time a outdated discord just because it's hiding nitro emojis.

yes please I used whole time a outdated discord just because it's hiding nitro emojis.
Owner

I like this idea. I'll look into it.

I like this idea. I'll look into it.

Couldn't find 34.0 APK, so I just modded 33.1. Should be very easy to port to latest.

Sorry I don't know how to PR, but this should be helpful, have any questions, let me know.

Below method found in smali/com/discord/widgets/chat/input/emoji/EmojiPickerViewModel$Companion;

patches are near end of method and the modified / added lines begin with a -

.method private final buildEmojiListItems(Ljava/util/List;Ljava/lang/String;Z)Ljava/util/List;
    .locals 7
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List<",
            "+",
            "Lcom/discord/models/domain/emoji/Emoji;",
            ">;",
            "Ljava/lang/String;",
            "Z)",
            "Ljava/util/List<",
            "Lcom/discord/utilities/mg_recycler/MGRecyclerDataPayload;",
            ">;"
        }
    .end annotation

    .line 1
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    if-nez p1, :cond_0

    return-object v0

    .line 2
    :cond_0
    invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object p1

    :cond_1
    :goto_0
    invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_3

    invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/discord/models/domain/emoji/Emoji;

    .line 3
    invoke-interface {v1}, Lcom/discord/models/domain/emoji/Emoji;->getNames()Ljava/util/List;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v2

    :cond_2
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_1

    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    const-string v4, "name"

    .line 4
    invoke-static {v3, v4}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    invoke-static {}, Ljava/util/Locale;->getDefault()Ljava/util/Locale;

    move-result-object v4

    const-string v5, "Locale.getDefault()"

    invoke-static {v4, v5}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    invoke-virtual {v3, v4}, Ljava/lang/String;->toLowerCase(Ljava/util/Locale;)Ljava/lang/String;

    move-result-object v4

    const-string v5, "(this as java.lang.String).toLowerCase(locale)"

    invoke-static {v4, v5}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const/4 v5, 0x0

    const/4 v6, 0x2

    invoke-static {v4, p2, v5, v6}, Lj0/t/p;->contains$default(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZI)Z

    move-result v4

    if-eqz v4, :cond_2

	# check if allowed for use
-	invoke-interface {v1}, Lcom/discord/models/domain/emoji/Emoji;->isActuallyAvailable()Z

-	move-result v4
	
	# if and only if it's allowed, we add to the list
-	if-eqz v4, :cond_2

    .line 5
    new-instance v2, Lcom/discord/widgets/chat/input/emoji/WidgetEmojiAdapter$EmojiItem;

    invoke-direct {v2, v1, v3, p3}, Lcom/discord/widgets/chat/input/emoji/WidgetEmojiAdapter$EmojiItem;-><init>(Lcom/discord/models/domain/emoji/Emoji;Ljava/lang/String;Z)V

    .line 6
    invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0

    :cond_3
    return-object v0
.end method

methods below are required to make this patch and the pseudo nitro patch to be compatible
these are just the unmodded methods for emote checking to see if we are allowed to use it
we need to override in both classes that implement the abstract Emoji class for it to work


Lcom/discord/models/domain/emoji/Emoji;

.method public abstract isActuallyAvailable()Z
.end method

Lcom/discord/models/domain/emoji/ModelEmojiCustom;

.method public isActuallyAvailable()Z
    .locals 1

    .line 1
    iget-boolean v0, p0, Lcom/discord/models/domain/emoji/ModelEmojiCustom;->isUsable:Z

    return v0
.end method

Lcom/discord/models/domain/emoji/ModelEmojiUnicode;

.method public isActuallyAvailable()Z
    .locals 1

    const/4 v0, 0x1

    return v0
.end method
Couldn't find 34.0 APK, so I just modded 33.1. Should be very easy to port to latest. Sorry I don't know how to PR, but this should be helpful, have any questions, let me know. Below method found in smali/com/discord/widgets/chat/input/emoji/EmojiPickerViewModel$Companion; patches are near end of method and the modified / added lines begin with a - ``` .method private final buildEmojiListItems(Ljava/util/List;Ljava/lang/String;Z)Ljava/util/List; .locals 7 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/util/List<", "+", "Lcom/discord/models/domain/emoji/Emoji;", ">;", "Ljava/lang/String;", "Z)", "Ljava/util/List<", "Lcom/discord/utilities/mg_recycler/MGRecyclerDataPayload;", ">;" } .end annotation .line 1 new-instance v0, Ljava/util/ArrayList; invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V if-nez p1, :cond_0 return-object v0 .line 2 :cond_0 invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator; move-result-object p1 :cond_1 :goto_0 invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z move-result v1 if-eqz v1, :cond_3 invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v1 check-cast v1, Lcom/discord/models/domain/emoji/Emoji; .line 3 invoke-interface {v1}, Lcom/discord/models/domain/emoji/Emoji;->getNames()Ljava/util/List; move-result-object v2 invoke-interface {v2}, Ljava/util/List;->iterator()Ljava/util/Iterator; move-result-object v2 :cond_2 invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z move-result v3 if-eqz v3, :cond_1 invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v3 check-cast v3, Ljava/lang/String; const-string v4, "name" .line 4 invoke-static {v3, v4}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V invoke-static {}, Ljava/util/Locale;->getDefault()Ljava/util/Locale; move-result-object v4 const-string v5, "Locale.getDefault()" invoke-static {v4, v5}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V invoke-virtual {v3, v4}, Ljava/lang/String;->toLowerCase(Ljava/util/Locale;)Ljava/lang/String; move-result-object v4 const-string v5, "(this as java.lang.String).toLowerCase(locale)" invoke-static {v4, v5}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V const/4 v5, 0x0 const/4 v6, 0x2 invoke-static {v4, p2, v5, v6}, Lj0/t/p;->contains$default(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZI)Z move-result v4 if-eqz v4, :cond_2 # check if allowed for use - invoke-interface {v1}, Lcom/discord/models/domain/emoji/Emoji;->isActuallyAvailable()Z - move-result v4 # if and only if it's allowed, we add to the list - if-eqz v4, :cond_2 .line 5 new-instance v2, Lcom/discord/widgets/chat/input/emoji/WidgetEmojiAdapter$EmojiItem; invoke-direct {v2, v1, v3, p3}, Lcom/discord/widgets/chat/input/emoji/WidgetEmojiAdapter$EmojiItem;-><init>(Lcom/discord/models/domain/emoji/Emoji;Ljava/lang/String;Z)V .line 6 invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z goto :goto_0 :cond_3 return-object v0 .end method ``` methods below are required to make this patch and the pseudo nitro patch to be compatible these are just the unmodded methods for emote checking to see if we are allowed to use it we need to override in both classes that implement the abstract Emoji class for it to work ---------------- ``` Lcom/discord/models/domain/emoji/Emoji; .method public abstract isActuallyAvailable()Z .end method ``` ---------------- ``` Lcom/discord/models/domain/emoji/ModelEmojiCustom; .method public isActuallyAvailable()Z .locals 1 .line 1 iget-boolean v0, p0, Lcom/discord/models/domain/emoji/ModelEmojiCustom;->isUsable:Z return v0 .end method ``` ---------------- ``` Lcom/discord/models/domain/emoji/ModelEmojiUnicode; .method public isActuallyAvailable()Z .locals 1 const/4 v0, 0x1 return v0 .end method ```
Owner

Hey @BlueMods,

Thanks a lot for this patch, I will port it to 34.0 and push it (and I'll make sure to give you credit).

Can you email me at distok at ave dot zone? I think I may help with sourcing APKs and such.

Hey @BlueMods, Thanks a lot for this patch, I will port it to 34.0 and push it (and I'll make sure to give you credit). Can you email me at distok at ave dot zone? I think I may help with sourcing APKs and such.
a closed this issue 2020-07-31 12:38:39 +00:00
Owner

People interested in this patch:

I've added it to every branch of CutTheCord, and updated builds should be available on the repos in an hour or so.

BlueMods (and future me):

I've implemented this directly with isAvailable instead of isActuallyAvailable for now, as I like to keep patches as simple as possible. When we get around to implementing pseudoNitro I'll change it if need be.

People interested in this patch: I've added it to every branch of CutTheCord, and updated builds should be available on the repos in an hour or so. BlueMods (and future me): I've implemented this directly with isAvailable instead of isActuallyAvailable for now, as I like to keep patches as simple as possible. When we get around to implementing pseudoNitro I'll change it if need be.
This repo is archived. You cannot comment on issues.
No milestone
No project
No assignees
4 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: distok/cutthecord#45
No description provided.