Skip to content

Commit

Permalink
Fix missing emote url replacements (#270)
Browse files Browse the repository at this point in the history
* now covering all code paths related to emote url replacement

* update CHANGELOG
  • Loading branch information
FoseFx authored Sep 24, 2021
1 parent ac9e1c2 commit 6dfdeb9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 57 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# master
- add "show deleted messages" feature
- fix some bugs related to missing emotes

# v0.13.0-beta
- rebase to v11.6.0
Expand Down
24 changes: 1 addition & 23 deletions mod/app/src/main/java/bttv/emote/EmoteUrlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@
import tv.twitch.android.shared.emotes.utils.AnimatedEmotesUrlUtil;

public class EmoteUrlUtil {
private static final String TAG = "LBTTVEMoteurlUtil";

public static AnimatedEmotesUrlUtil.EmoteUrlDetails generateEmoteUrl(AnimatedEmotesUrlUtil util, Context context, String id, float f, AnimatedEmotesUrlUtil.EmoteUrlAnimationSetting emoteUrlAnimationSetting) {
String realId = extractBTTVId(id);
if (realId != null) {
return wrapInDetails(realIdToUrl(realId));
} else if (util != null) {
return util.generateEmoteUrl(context, id, f, emoteUrlAnimationSetting);
} else {
return wrapInDetails(tv.twitch.android.util.EmoteUrlUtil.generateEmoteUrl(id, f));
}
}

public static String getEmoteUrl(AnimatedEmotesUrlUtil util, Context c, String id) {
if (id.startsWith("BTTV-")) {
return EmoteUrlUtil.generateEmoteUrl(util, c, id, 1.0f, AnimatedEmotesUrlUtil.EmoteUrlAnimationSetting.DEFAULT).getEmoteUrl();
} else {
return util.getEmoteUrl(c, id);
}
}
private static final String TAG = "LBTTVEmoteurlUtil";

public static String getEmoteUrl(String id) {
String realId = extractBTTVId(id);
Expand All @@ -51,7 +32,4 @@ public static String realIdToUrl(String realId) {
return emote.url;
}

private static AnimatedEmotesUrlUtil.EmoteUrlDetails wrapInDetails(String s) {
return new AnimatedEmotesUrlUtil.EmoteUrlDetails(s, AnimatedEmotesUrlUtil.EmoteUrlAnimationSetting.DEFAULT);
}
}
62 changes: 28 additions & 34 deletions monke.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ index 2f4cf70db..74cb66121 100644
instance-of v1, p1, Ltv/twitch/android/shared/chat/model/EmoteCardModel$ChannelPointsEmoteCardModel;

diff --git a/smali_classes6/tv/twitch/android/shared/chat/messagefactory/ChatMessageFactory.smali b/smali_classes6/tv/twitch/android/shared/chat/messagefactory/ChatMessageFactory.smali
index ba3b7cbe1..fa79bdac9 100644
index ba3b7cbe1..269d89935 100644
--- a/smali_classes6/tv/twitch/android/shared/chat/messagefactory/ChatMessageFactory.smali
+++ b/smali_classes6/tv/twitch/android/shared/chat/messagefactory/ChatMessageFactory.smali
@@ -623,6 +623,12 @@
Expand All @@ -1119,24 +1119,7 @@ index ba3b7cbe1..fa79bdac9 100644
if-eqz p12, :cond_4

.line 678
@@ -1318,7 +1324,15 @@

sget-object v6, Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlAnimationSetting;->STATIC:Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlAnimationSetting;

- invoke-virtual {v0, v3, v4, v5, v6}, Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil;->generateEmoteUrl(Landroid/content/Context;Ljava/lang/String;FLtv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlAnimationSetting;)Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlDetails;
+ # BTTV
+ # expects:
+ # - v0: tv.twitch.android.shared.emotes.utils.AnimatedEmotesUrlUtil
+ # - v3: android.content.Context
+ # - v4: java.lang.String
+ # - v5: F
+ # - v6: AnimatedEmotesUrlUtil.EmoteUrlAnimationSetting
+ invoke-static {v0, v3, v4, v5, v6}, Lbttv/emote/EmoteUrlUtil;->generateEmoteUrl(Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil;Landroid/content/Context;Ljava/lang/String;FLtv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlAnimationSetting;)Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlDetails;
+ # /BTTV

move-result-object v0

@@ -2736,6 +2750,13 @@
@@ -2736,6 +2742,13 @@

move-object/from16 v0, p1

Expand All @@ -1150,7 +1133,7 @@ index ba3b7cbe1..fa79bdac9 100644
const-string v1, "chatMessageInfo"

invoke-static {v0, v1}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
@@ -4072,6 +4093,13 @@
@@ -4072,6 +4085,13 @@
.line 305
iget-object v6, v0, Ltv/twitch/chat/ChatSubscriptionNotice;->userMessage:Ltv/twitch/chat/ChatMessageInfo;

Expand Down Expand Up @@ -1275,24 +1258,35 @@ index dfcd86f6c..a0a8e4ff6 100644
.line 237
invoke-virtual {p2}, Ltv/twitch/android/util/Optional;->isPresent()Z

diff --git a/smali_classes6/tv/twitch/android/shared/emotes/emotepicker/adapter/EmoteAdapterItem.smali b/smali_classes6/tv/twitch/android/shared/emotes/emotepicker/adapter/EmoteAdapterItem.smali
index ee78921c6..83cd44107 100644
--- a/smali_classes6/tv/twitch/android/shared/emotes/emotepicker/adapter/EmoteAdapterItem.smali
+++ b/smali_classes6/tv/twitch/android/shared/emotes/emotepicker/adapter/EmoteAdapterItem.smali
@@ -369,7 +369,13 @@
diff --git a/smali_classes6/tv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil.smali b/smali_classes6/tv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil.smali
index c20456261..9776d5d9d 100644
--- a/smali_classes6/tv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil.smali
+++ b/smali_classes6/tv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil.smali
@@ -126,6 +126,16 @@
:goto_2
new-instance p4, Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlDetails;

move-result-object v3

- invoke-virtual {v1, v2, v3}, Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil;->getEmoteUrl(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;
+ # BTTV
+ # expects:
+ # - v1: tv.twitch.android.shared.emotes.utils.AnimatedEmotesUrlUtil
+ # - v2: android.content.Context
+ # - v3: java.jang.String
+ invoke-static {v1, v2, v3}, Lbttv/emote/EmoteUrlUtil;->getEmoteUrl(Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil;Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;
+ # use our url if bttv emote
+ invoke-static {p2}, Lbttv/emote/EmoteUrlUtil;->getEmoteUrl(Ljava/lang/String;)Ljava/lang/String;
+ move-result-object v1
+ if-eqz v1, :after_bttv
+ move-object p1, v1
+ goto :after_url_built
+ :after_bttv
+ # /BTTV
+
.line 115
new-instance v1, Ljava/lang/StringBuilder;

move-result-object v1
@@ -159,6 +169,8 @@

move-result-object p1

+ :after_url_built
+
.line 114
invoke-direct {p4, p1, p3}, Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlDetails;-><init>(Ljava/lang/String;Ltv/twitch/android/shared/emotes/utils/AnimatedEmotesUrlUtil$EmoteUrlAnimationSetting;)V

diff --git a/smali_classes6/tv/twitch/android/shared/player/overlay/BottomPlayerControlOverlayViewDelegate.smali b/smali_classes6/tv/twitch/android/shared/player/overlay/BottomPlayerControlOverlayViewDelegate.smali
index 3d2ad62a6..fa1538124 100644
Expand Down

0 comments on commit 6dfdeb9

Please sign in to comment.