Implement gif autoplay option

Closes #63
This commit is contained in:
ave 2020-07-31 19:12:01 +03:00
parent bcbb19690b
commit cb48362e57
Signed by: a
GPG key ID: 398DD7BD03276F6D
3 changed files with 191 additions and 36 deletions

View file

@ -1,8 +1,8 @@
Only in to: build
Only in to: dist
diff -crB from/smali/com/discord/stores/StoreMessages.smali to/smali/com/discord/stores/StoreMessages.smali
*** from/smali/com/discord/stores/StoreMessages.smali 2020-07-10 17:08:48.010000000 +0300
--- to/smali/com/discord/stores/StoreMessages.smali 2020-07-10 17:11:59.000000000 +0300
Binary files com.discord-base/build/apk/classes.dex and com.discord/build/apk/classes.dex differ
Binary files com.discord-base/dist/com.discord-1213.apk and com.discord/dist/com.discord-1213.apk differ
diff --color -crB com.discord-base/smali/com/discord/stores/StoreMessages.smali com.discord/smali/com/discord/stores/StoreMessages.smali
*** com.discord-base/smali/com/discord/stores/StoreMessages.smali 2020-07-30 01:52:31.926342249 +0300
--- com.discord/smali/com/discord/stores/StoreMessages.smali 2020-07-31 19:06:14.644725600 +0300
***************
*** 640,645 ****
--- 640,649 ----
@ -35,7 +35,7 @@ diff -crB from/smali/com/discord/stores/StoreMessages.smali to/smali/com/discord
move-object/from16 v8, p4
***************
*** 1411,1413 ****
--- 1423,4687 ----
--- 1423,4722 ----
throw v0
.end method
@ -2941,7 +2941,7 @@ diff -crB from/smali/com/discord/stores/StoreMessages.smali to/smali/com/discord
+
+ move-result v0
+
+ if-eqz v0, :cond_1
+ if-eqz v0, :cond_a
+
+ # Move to config value interpretation
+
@ -2969,8 +2969,43 @@ diff -crB from/smali/com/discord/stores/StoreMessages.smali to/smali/com/discord
+
+ return-object p0
+
+ :cond_a
+ const-string v0, "gifautoplay "
+
+ invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
+
+ move-result v0
+
+ if-eqz v0, :cond_1
+
+ # Move to config value interpretation
+
+ const/16 v0, 0xc
+
+ invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;
+
+ move-result-object p0
+
+ const-string v0, "true"
+
+ invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
+
+ move-result v1
+
+ # Set value
+
+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
+
+ move-result-object v0
+
+ invoke-virtual {v0, v1}, Lcom/discord/stores/StoreUserSettings;->setAutoplayGifs(Z)V
+
+ const-string p0, "CTC: Successfully set gifautoplay state."
+
+ return-object p0
+
+ :cond_1
+ const-string p0, "CTC: No known command supplied. (available: token, showtyping, channelleak, addaccount, account, nodelete. Everything except specified token needs to be lowercase)"
+ const-string p0, "CTC: No known command supplied. (available: token, showtyping, channelleak, addaccount, account, nodelete, gifautoplay. Everything except specified token needs to be lowercase)"
+
+ return-object p0
+ .end method
@ -3301,14 +3336,14 @@ diff -crB from/smali/com/discord/stores/StoreMessages.smali to/smali/com/discord
+ :cond_0
+ return-object p0
+ .end method
diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali to/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali
*** from/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2020-07-10 17:08:48.450000000 +0300
--- to/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2020-07-10 17:16:37.740000000 +0300
diff --color -crB com.discord-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali com.discord/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali
*** com.discord-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2020-07-30 01:52:32.293011301 +0300
--- com.discord/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2020-07-31 19:05:30.521097636 +0300
***************
*** 576,581 ****
--- 576,611 ----
invoke-static {v8, v10}, Li0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
invoke-static {v8, v10}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
+ # intercept edit here
+
@ -3347,7 +3382,7 @@ diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configur
*** 624,629 ****
--- 654,689 ----
invoke-static {v15, v10}, Li0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
invoke-static {v15, v10}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
+ # intercept send here
+
@ -3382,5 +3417,5 @@ diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configur
.line 55
invoke-virtual {v2}, Lcom/discord/models/domain/ModelMessage$Content;->getMentions()Ljava/util/List;
Only in to/smali/com/discord/widgets/chat/input: WidgetChatInputSend$configureSendListeners$1.smali.orig
Only in to/smali/com/discord/widgets/chat/input: WidgetChatInputSend$configureSendListeners$1.smali.rej
Only in com.discord/smali/com/discord/widgets/chat/input: WidgetChatInputSend$configureSendListeners$1.smali.orig

View file

@ -27,6 +27,7 @@ CutTheCord has a couple features that can utilized with slash commands as well:
- /ctc channelleak true/false -> Shows all channels, even those you don't have permissions to view (might mess with channel editing or editing while it's enabled)
- /ctc notyping true/false -> Disables typing event so that it's not visible when you type (true = typing is shown, false = not shown)
- /ctc nodelete true/false -> Disables handling of message delete events. Currently deletes messages don't have anything changed about them, but I plan to append "(deleted)" to them eventually. (true = Deleted messages stay, false = they get deleted)
- /ctc gifautoplay true/false -> Disables auto play of GIFs (true (default) = GIFs autoplay, false = GIFs don't autoplay)
- /ctc token -> Gives your token
- /ctc token $token -> Sets your token to the one specified, allowing switching between accounts
- /ctc addaccount $name $token -> Adds an account to the account switcher (name can be anything, token will be set to the current one if it's `current`)

View file

@ -1,6 +1,8 @@
diff -crB from/smali/com/discord/gateway/io/IncomingParser.smali to/smali/com/discord/gateway/io/IncomingParser.smali
*** from/smali/com/discord/gateway/io/IncomingParser.smali 2020-07-07 21:22:23.990000000 +0300
--- to/smali/com/discord/gateway/io/IncomingParser.smali 2020-07-08 01:48:57.070000000 +0300
Binary files com.discord-base/build/apk/classes.dex and com.discord/build/apk/classes.dex differ
Binary files com.discord-base/dist/com.discord-1213.apk and com.discord/dist/com.discord-1213.apk differ
diff --color -crB com.discord-base/smali/com/discord/gateway/io/IncomingParser.smali com.discord/smali/com/discord/gateway/io/IncomingParser.smali
*** com.discord-base/smali/com/discord/gateway/io/IncomingParser.smali 2020-07-30 01:52:31.613006878 +0300
--- com.discord/smali/com/discord/gateway/io/IncomingParser.smali 2020-07-31 18:10:39.565855661 +0300
***************
*** 762,767 ****
--- 762,778 ----
@ -21,10 +23,9 @@ diff -crB from/smali/com/discord/gateway/io/IncomingParser.smali to/smali/com/di
new-instance v0, Lcom/discord/models/domain/ModelMessageDelete;
invoke-direct {v0}, Lcom/discord/models/domain/ModelMessageDelete;-><init>()V
Only in to/smali/com/discord/gateway/io: IncomingParser.smali.orig
diff -crB from/smali/com/discord/models/domain/ModelChannel.smali to/smali/com/discord/models/domain/ModelChannel.smali
*** from/smali/com/discord/models/domain/ModelChannel.smali 2020-07-07 21:22:24.010000000 +0300
--- to/smali/com/discord/models/domain/ModelChannel.smali 2020-07-08 01:48:57.070000000 +0300
diff --color -crB com.discord-base/smali/com/discord/models/domain/ModelChannel.smali com.discord/smali/com/discord/models/domain/ModelChannel.smali
*** com.discord-base/smali/com/discord/models/domain/ModelChannel.smali 2020-07-30 01:52:31.633007008 +0300
--- com.discord/smali/com/discord/models/domain/ModelChannel.smali 2020-07-31 18:10:39.565855661 +0300
***************
*** 2230,2235 ****
--- 2230,2245 ----
@ -44,15 +45,111 @@ diff -crB from/smali/com/discord/models/domain/ModelChannel.smali to/smali/com/d
.line 1
iget-object v0, p0, Lcom/discord/models/domain/ModelChannel;->permissionOverwrites:Ljava/util/Map;
diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/discord/stores/StoreUserSettings.smali
*** from/smali/com/discord/stores/StoreUserSettings.smali 2020-07-07 21:22:24.420000000 +0300
--- to/smali/com/discord/stores/StoreUserSettings.smali 2020-07-08 01:48:57.070000000 +0300
diff --color -crB com.discord-base/smali/com/discord/models/domain/ModelMessageEmbed.smali com.discord/smali/com/discord/models/domain/ModelMessageEmbed.smali
*** com.discord-base/smali/com/discord/models/domain/ModelMessageEmbed.smali 2020-07-30 01:52:31.669673914 +0300
--- com.discord/smali/com/discord/models/domain/ModelMessageEmbed.smali 2020-07-31 18:45:31.763120456 +0300
***************
*** 2021,2027 ****
.end method
.method public isVideo()Z
! .locals 2
.line 1
iget-object v0, p0, Lcom/discord/models/domain/ModelMessageEmbed;->type:Ljava/lang/String;
--- 2021,2027 ----
.end method
.method public isVideo()Z
! .locals 3
.line 1
iget-object v0, p0, Lcom/discord/models/domain/ModelMessageEmbed;->type:Ljava/lang/String;
***************
*** 2030,2038 ****
invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
! move-result v0
! return v0
.end method
.method public toString()Ljava/lang/String;
--- 2030,2057 ----
invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
! move-result v1
! invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
!
! move-result-object v2
!
! invoke-virtual {v2}, Lcom/discord/stores/StoreUserSettings;->getAutoplayGifs()Z
!
! move-result v2
!
! if-nez v2, :cond_0
!
! const-string/jumbo v2, "gifv"
!
! invoke-virtual {v0, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
!
! move-result v2
!
! or-int v1, v1, v2
!
! :cond_0
! return v1
.end method
.method public toString()Ljava/lang/String;
diff --color -crB com.discord-base/smali/com/discord/stores/StoreUserSettings.smali com.discord/smali/com/discord/stores/StoreUserSettings.smali
*** com.discord-base/smali/com/discord/stores/StoreUserSettings.smali 2020-07-30 01:52:31.979675930 +0300
--- com.discord/smali/com/discord/stores/StoreUserSettings.smali 2020-07-31 18:47:50.584047719 +0300
***************
*** 396,401 ****
--- 396,649 ----
--- 396,685 ----
return-void
.end method
+ .method public getAutoplayGifs()Z
+ .locals 3
+
+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences;
+
+ const-string v1, "CACHE_KEY_CTC_AUTOPLAY_GIFS"
+
+ const/4 v2, 0x1
+
+ invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z
+
+ move-result v0
+
+ return v0
+ .end method
+
+ .method public setAutoplayGifs(Z)V
+ .locals 2
+
+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences;
+
+ invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;
+
+ move-result-object v0
+
+ const-string v1, "CACHE_KEY_CTC_AUTOPLAY_GIFS"
+
+ invoke-interface {v0, v1, p1}, Landroid/content/SharedPreferences$Editor;->putBoolean(Ljava/lang/String;Z)Landroid/content/SharedPreferences$Editor;
+
+ move-result-object p1
+
+ invoke-interface {p1}, Landroid/content/SharedPreferences$Editor;->apply()V
+
+ return-void
+ .end method
+
+ .method public getLeakChannels()Z
+ .locals 3
+
@ -304,9 +401,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis
.method private getAdjustedTheme(Ljava/lang/String;)Ljava/lang/String;
.locals 1
diff -crB from/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali to/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali
*** from/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali 2020-07-07 21:22:24.590000000 +0300
--- to/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali 2020-07-08 01:49:10.340000000 +0300
diff --color -crB com.discord-base/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali com.discord/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali
*** com.discord-base/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali 2020-07-30 01:52:32.099676710 +0300
--- com.discord/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali 2020-07-31 18:10:39.565855661 +0300
***************
*** 46,51 ****
--- 46,85 ----
@ -363,10 +460,9 @@ diff -crB from/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali to/s
.line 4
iget-object p1, p0, Lcom/discord/utilities/rest/SendUtils$getPart$1$1;->this$0:Lcom/discord/utilities/rest/SendUtils$getPart$1;
Only in to/smali/com/discord/utilities/rest: SendUtils$getPart$1$1.smali.orig
diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali to/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali
*** from/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2020-07-07 21:22:24.900000000 +0300
--- to/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2020-07-08 01:48:57.070000000 +0300
diff --color -crB com.discord-base/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali com.discord/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali
*** com.discord-base/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2020-07-30 01:52:32.289677946 +0300
--- com.discord/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2020-07-31 18:10:39.569189017 +0300
***************
*** 59,64 ****
--- 59,74 ----
@ -386,9 +482,9 @@ diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.sm
.line 4
invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali to/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali
*** from/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2020-07-07 21:22:24.900000000 +0300
--- to/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2020-07-08 01:48:57.070000000 +0300
diff --color -crB com.discord-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali com.discord/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali
*** com.discord-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2020-07-30 01:52:32.296344655 +0300
--- com.discord/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2020-07-31 18:10:39.569189017 +0300
***************
*** 60,65 ****
--- 60,89 ----
@ -422,3 +518,26 @@ diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali to
.method private final clearInput(Lcom/discord/widgets/chat/input/WidgetChatInputEditText;Lcom/lytefast/flexinput/viewmodel/FlexInputViewModel;Ljava/lang/Boolean;)Z
.locals 1
diff --color -crB com.discord-base/smali/com/discord/widgets/chat/list/InlineMediaView.smali com.discord/smali/com/discord/widgets/chat/list/InlineMediaView.smali
*** com.discord-base/smali/com/discord/widgets/chat/list/InlineMediaView.smali 2020-07-30 01:52:32.349678336 +0300
--- com.discord/smali/com/discord/widgets/chat/list/InlineMediaView.smali 2020-07-31 18:45:58.116629820 +0300
***************
*** 1289,1294 ****
--- 1289,1304 ----
move-result v1
+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
+
+ move-result-object v7
+
+ invoke-virtual {v7}, Lcom/discord/stores/StoreUserSettings;->getAutoplayGifs()Z
+
+ move-result v7
+
+ and-int v1, v1, v7
+
if-eqz v1, :cond_6
const/4 v7, 0x1