add (deleted) to deleted messages (#77)

add (deleted) to deleted messages

Co-authored-by: BlueMods
Reviewed-on: distok/cutthecord#77
This commit is contained in:
Juby210 2020-08-20 10:05:57 +00:00 committed by eatsfoobars
parent e17082f086
commit ec246529e2
2 changed files with 320 additions and 38 deletions

View file

@ -26,7 +26,7 @@ Following commands are supported, but create less accessible text (so you should
CutTheCord has a couple features that can utilized with slash commands as well: 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 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 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 nodelete true/false -> Disables handling of message delete events. (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 gifautoplay true/false -> Disables auto play of GIFs (true (default) = GIFs autoplay, false = GIFs don't autoplay)
- /ctc token -> Gives your token - /ctc token -> Gives your token
- /ctc token $token -> Sets your token to the one specified, allowing switching between accounts - /ctc token $token -> Sets your token to the one specified, allowing switching between accounts

View file

@ -1,29 +1,117 @@
diff -crB from/smali/com/discord/gateway/io/IncomingParser.smali to/smali/com/discord/gateway/io/IncomingParser.smali diff -crBN from/smali/com/cutthecord/Utils.smali to/smali/com/cutthecord/Utils.smali
*** from/smali/com/discord/gateway/io/IncomingParser.smali 2020-08-01 14:44:26.287759774 +0300 *** from/smali/com/cutthecord/Utils.smali Thu Jan 1 01:00:00 1970
--- to/smali/com/discord/gateway/io/IncomingParser.smali 2020-08-01 14:44:50.484584664 +0300 --- to/smali/com/cutthecord/Utils.smali Thu Aug 13 14:15:11 2020
*************** ***************
*** 762,767 **** *** 0 ****
--- 762,778 ---- --- 1,36 ----
+ .class public Lcom/cutthecord/Utils;
.line 57 + .super Ljava/lang/Object;
:goto_2
+ +
+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
+ +
+ move-result-object v0 + # static fields
+ .field public static messageFragment:Landroidx/fragment/app/Fragment;
+ +
+ invoke-virtual {v0}, Lcom/discord/stores/StoreUserSettings;->getNoDelete()Z
+ +
+ move-result v4 + # direct methods
+ .method public constructor <init>()V
+ .locals 0
+ +
+ if-nez v4, :cond_b + invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+ +
new-instance v0, Lcom/discord/models/domain/ModelMessageDelete; + return-void
+ .end method
invoke-direct {v0}, Lcom/discord/models/domain/ModelMessageDelete;-><init>()V +
diff -crB from/smali/com/discord/models/domain/ModelChannel.smali to/smali/com/discord/models/domain/ModelChannel.smali + .method public static refreshView()V
*** from/smali/com/discord/models/domain/ModelChannel.smali 2020-08-01 14:44:26.307759905 +0300 + .locals 2
--- to/smali/com/discord/models/domain/ModelChannel.smali 2020-08-01 14:44:50.484584664 +0300 +
+ new-instance v0, Landroid/os/Handler;
+
+ invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;
+
+ move-result-object v1
+
+ invoke-direct {v0, v1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V
+
+ new-instance v1, Lcom/cutthecord/refreshView;
+
+ invoke-direct {v1}, Lcom/cutthecord/refreshView;-><init>()V
+
+ invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
+
+ return-void
+ .end method
diff -crBN from/smali/com/cutthecord/refreshView.smali to/smali/com/cutthecord/refreshView.smali
*** from/smali/com/cutthecord/refreshView.smali Thu Jan 1 01:00:00 1970
--- to/smali/com/cutthecord/refreshView.smali Thu Aug 13 13:56:59 2020
***************
*** 0 ****
--- 1,63 ----
+ .class final Lcom/cutthecord/refreshView;
+ .super Ljava/lang/Object;
+
+ # interfaces
+ .implements Ljava/lang/Runnable;
+
+
+ # direct methods
+ .method public constructor <init>()V
+ .locals 0
+
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+
+ return-void
+ .end method
+
+
+ # virtual methods
+ .method public run()V
+ .locals 4
+
+ sget-object v0, Lcom/cutthecord/Utils;->messageFragment:Landroidx/fragment/app/Fragment;
+
+ if-eqz v0, :cond_0
+
+ invoke-virtual {v0}, Landroidx/fragment/app/Fragment;->isStateSaved()Z
+
+ move-result v1
+
+ if-nez v1, :cond_0
+
+ invoke-virtual {v0}, Landroidx/fragment/app/Fragment;->getFragmentManager()Landroidx/fragment/app/FragmentManager;
+
+ move-result-object v1
+
+ invoke-virtual {v1}, Landroidx/fragment/app/FragmentManager;->beginTransaction()Landroidx/fragment/app/FragmentTransaction;
+
+ move-result-object v1
+
+ sget v2, Landroid/os/Build$VERSION;->SDK_INT:I
+
+ const/16 v3, 0x1a # 26
+
+ if-lt v2, v3, :cond_1
+
+ const/4 v2, 0x0
+
+ invoke-virtual {v1, v2}, Landroidx/fragment/app/FragmentTransaction;->setReorderingAllowed(Z)Landroidx/fragment/app/FragmentTransaction;
+
+ :cond_1
+ invoke-virtual {v1, v0}, Landroidx/fragment/app/FragmentTransaction;->detach(Landroidx/fragment/app/Fragment;)Landroidx/fragment/app/FragmentTransaction;
+
+ move-result-object v1
+
+ invoke-virtual {v1, v0}, Landroidx/fragment/app/FragmentTransaction;->attach(Landroidx/fragment/app/Fragment;)Landroidx/fragment/app/FragmentTransaction;
+
+ move-result-object v1
+
+ invoke-virtual {v1}, Landroidx/fragment/app/FragmentTransaction;->commit()I
+
+ :cond_0
+ return-void
+ .end method
diff -crBN from/smali/com/discord/models/domain/ModelChannel.smali to/smali/com/discord/models/domain/ModelChannel.smali
*** from/smali/com/discord/models/domain/ModelChannel.smali Wed Aug 12 18:07:37 2020
--- to/smali/com/discord/models/domain/ModelChannel.smali Thu Aug 13 00:12:31 2020
*************** ***************
*** 2285,2290 **** *** 2285,2290 ****
--- 2285,2300 ---- --- 2285,2300 ----
@ -43,9 +131,36 @@ diff -crB from/smali/com/discord/models/domain/ModelChannel.smali to/smali/com/d
.line 1 .line 1
iget-object v0, p0, Lcom/discord/models/domain/ModelChannel;->permissionOverwrites:Ljava/util/Map; iget-object v0, p0, Lcom/discord/models/domain/ModelChannel;->permissionOverwrites:Ljava/util/Map;
diff -crB from/smali/com/discord/models/domain/ModelMessageEmbed.smali to/smali/com/discord/models/domain/ModelMessageEmbed.smali diff -crBN from/smali/com/discord/models/domain/ModelMessage.smali to/smali/com/discord/models/domain/ModelMessage.smali
*** from/smali/com/discord/models/domain/ModelMessageEmbed.smali 2020-08-01 14:44:26.327760036 +0300 *** from/smali/com/discord/models/domain/ModelMessage.smali Wed Aug 12 18:07:38 2020
--- to/smali/com/discord/models/domain/ModelMessageEmbed.smali 2020-08-01 14:44:50.484584664 +0300 --- to/smali/com/discord/models/domain/ModelMessage.smali Thu Aug 13 12:03:45 2020
***************
*** 151,156 ****
--- 151,158 ----
.field public content:Ljava/lang/String;
+ .field public deleted:Z
+
.field public editedTimestamp:Ljava/lang/String;
.field public final editedTimestampMilliseconds:Ljava/util/concurrent/atomic/AtomicReference;
***************
*** 330,335 ****
--- 332,341 ----
iput-object v0, p0, Lcom/discord/models/domain/ModelMessage;->editedTimestampMilliseconds:Ljava/util/concurrent/atomic/AtomicReference;
+ const/4 v0, 0x0
+
+ iput-boolean v0, p0, Lcom/discord/models/domain/ModelMessage;->deleted:Z
+
return-void
.end method
diff -crBN from/smali/com/discord/models/domain/ModelMessageEmbed.smali to/smali/com/discord/models/domain/ModelMessageEmbed.smali
*** from/smali/com/discord/models/domain/ModelMessageEmbed.smali Wed Aug 12 18:07:38 2020
--- to/smali/com/discord/models/domain/ModelMessageEmbed.smali Thu Aug 13 00:12:31 2020
*************** ***************
*** 2021,2027 **** *** 2021,2027 ****
.end method .end method
@ -103,9 +218,91 @@ diff -crB from/smali/com/discord/models/domain/ModelMessageEmbed.smali to/smali/
.end method .end method
.method public toString()Ljava/lang/String; .method public toString()Ljava/lang/String;
diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/discord/stores/StoreUserSettings.smali diff -crBN from/smali/com/discord/stores/StoreMessagesHolder.smali to/smali/com/discord/stores/StoreMessagesHolder.smali
*** from/smali/com/discord/stores/StoreUserSettings.smali 2020-08-01 14:44:26.557761540 +0300 *** from/smali/com/discord/stores/StoreMessagesHolder.smali Wed Aug 12 18:07:38 2020
--- to/smali/com/discord/stores/StoreUserSettings.smali 2020-08-01 14:44:50.484584664 +0300 --- to/smali/com/discord/stores/StoreMessagesHolder.smali Thu Aug 13 15:01:22 2020
***************
*** 1395,1401 ****
.end method
.method public deleteMessages(JLjava/util/List;)V
! .locals 5
.param p3 # Ljava/util/List;
.annotation build Landroidx/annotation/Nullable;
.end annotation
--- 1395,1401 ----
.end method
.method public deleteMessages(JLjava/util/List;)V
! .locals 6
.param p3 # Ljava/util/List;
.annotation build Landroidx/annotation/Nullable;
.end annotation
***************
*** 1451,1456 ****
--- 1451,1464 ----
move-result-object p3
+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
+
+ move-result-object v5
+
+ invoke-virtual {v5}, Lcom/discord/stores/StoreUserSettings;->getNoDelete()Z
+
+ move-result v5
+
:cond_1
:goto_0
invoke-interface {p3}, Ljava/util/Iterator;->hasNext()Z
***************
*** 1485,1493 ****
--- 1493,1520 ----
move-result-object v2
+ if-nez v5, :cond_4
+
invoke-interface {v1, v2}, Ljava/util/Map;->remove(Ljava/lang/Object;)Ljava/lang/Object;
+ goto :goto_2
+
+ :cond_4
+ invoke-interface {v1, v2}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;
+
+ move-result-object v2
+
+ check-cast v2, Lcom/discord/models/domain/ModelMessage;
+
+ if-eqz v2, :cond_5
+
+ const/4 v3, 0x1
+
+ iput-boolean v3, v2, Lcom/discord/models/domain/ModelMessage;->deleted:Z
+
.line 7
+ :goto_2
+ :cond_5
iget-object v2, p0, Lcom/discord/stores/StoreMessagesHolder;->updatedChannels:Ljava/util/Set;
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
***************
*** 1500,1505 ****
--- 1527,1537 ----
.line 8
:cond_2
+ if-eqz v5, :cond_6
+
+ invoke-static {}, Lcom/cutthecord/Utils;->refreshView()V
+
+ :cond_6
invoke-direct {p0}, Lcom/discord/stores/StoreMessagesHolder;->publishIfUpdated()V
.line 9
diff -crBN from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/discord/stores/StoreUserSettings.smali
*** from/smali/com/discord/stores/StoreUserSettings.smali Wed Aug 12 18:07:39 2020
--- to/smali/com/discord/stores/StoreUserSettings.smali Thu Aug 13 00:12:31 2020
*************** ***************
*** 396,401 **** *** 396,401 ****
--- 396,685 ---- --- 396,685 ----
@ -399,9 +596,9 @@ diff -crB from/smali/com/discord/stores/StoreUserSettings.smali to/smali/com/dis
.method private getAdjustedTheme(Ljava/lang/String;)Ljava/lang/String; .method private getAdjustedTheme(Ljava/lang/String;)Ljava/lang/String;
.locals 1 .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 diff -crBN 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-08-01 14:44:26.644428773 +0300 *** from/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali Wed Aug 12 18:07:39 2020
--- to/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali 2020-08-01 14:44:50.484584664 +0300 --- to/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali Thu Aug 13 00:12:31 2020
*************** ***************
*** 46,51 **** *** 46,51 ****
--- 46,85 ---- --- 46,85 ----
@ -458,9 +655,9 @@ diff -crB from/smali/com/discord/utilities/rest/SendUtils$getPart$1$1.smali to/s
.line 4 .line 4
iget-object p1, p0, Lcom/discord/utilities/rest/SendUtils$getPart$1$1;->this$0:Lcom/discord/utilities/rest/SendUtils$getPart$1; iget-object p1, p0, Lcom/discord/utilities/rest/SendUtils$getPart$1$1;->this$0:Lcom/discord/utilities/rest/SendUtils$getPart$1;
diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali to/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali diff -crBN 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-08-01 14:44:26.797763109 +0300 *** from/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali Wed Aug 12 18:07:40 2020
--- to/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2020-08-01 14:44:50.484584664 +0300 --- to/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali Thu Aug 13 00:12:31 2020
*************** ***************
*** 59,64 **** *** 59,64 ****
--- 59,74 ---- --- 59,74 ----
@ -480,9 +677,9 @@ diff -crB from/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.sm
.line 4 .line 4
invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z 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 diff -crBN 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-08-01 14:44:26.801096464 +0300 *** from/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali Wed Aug 12 18:07:40 2020
--- to/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2020-08-01 14:44:50.484584664 +0300 --- to/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali Thu Aug 13 00:12:31 2020
*************** ***************
*** 60,65 **** *** 60,65 ****
--- 60,89 ---- --- 60,89 ----
@ -516,9 +713,9 @@ 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 .method private final clearInput(Lcom/discord/widgets/chat/input/WidgetChatInputEditText;Lcom/lytefast/flexinput/viewmodel/FlexInputViewModel;Ljava/lang/Boolean;)Z
.locals 1 .locals 1
diff -crB from/smali/com/discord/widgets/chat/list/InlineMediaView.smali to/smali/com/discord/widgets/chat/list/InlineMediaView.smali diff -crBN from/smali/com/discord/widgets/chat/list/InlineMediaView.smali to/smali/com/discord/widgets/chat/list/InlineMediaView.smali
*** from/smali/com/discord/widgets/chat/list/InlineMediaView.smali 2020-08-01 14:44:26.824429950 +0300 *** from/smali/com/discord/widgets/chat/list/InlineMediaView.smali Wed Aug 12 18:07:40 2020
--- to/smali/com/discord/widgets/chat/list/InlineMediaView.smali 2020-08-01 14:44:50.484584664 +0300 --- to/smali/com/discord/widgets/chat/list/InlineMediaView.smali Thu Aug 13 00:12:31 2020
*************** ***************
*** 1289,1294 **** *** 1289,1294 ****
--- 1289,1304 ---- --- 1289,1304 ----
@ -538,3 +735,88 @@ diff -crB from/smali/com/discord/widgets/chat/list/InlineMediaView.smali to/smal
if-eqz v1, :cond_6 if-eqz v1, :cond_6
const/4 v7, 0x1 const/4 v7, 0x1
diff -crBN from/smali/com/discord/widgets/chat/list/WidgetChatList.smali to/smali/com/discord/widgets/chat/list/WidgetChatList.smali
*** from/smali/com/discord/widgets/chat/list/WidgetChatList.smali Wed Aug 12 18:07:40 2020
--- to/smali/com/discord/widgets/chat/list/WidgetChatList.smali Thu Aug 13 13:58:01 2020
***************
*** 40,45 ****
--- 40,47 ----
.line 3
iput-object v0, p0, Lcom/discord/widgets/chat/list/WidgetChatList;->_flexInputViewModel:Lcom/discord/widgets/chat/input/AppFlexInputViewModel;
+ sput-object p0, Lcom/cutthecord/Utils;->messageFragment:Landroidx/fragment/app/Fragment;
+
return-void
.end method
diff -crBN from/smali/com/discord/widgets/chat/list/WidgetChatListAdapterItemMessage.smali to/smali/com/discord/widgets/chat/list/WidgetChatListAdapterItemMessage.smali
*** from/smali/com/discord/widgets/chat/list/WidgetChatListAdapterItemMessage.smali Wed Aug 12 18:07:40 2020
--- to/smali/com/discord/widgets/chat/list/WidgetChatListAdapterItemMessage.smali Thu Aug 13 12:19:34 2020
***************
*** 1193,1198 ****
--- 1193,1257 ----
.line 20
:cond_3
+ iget-boolean v2, v14, Lcom/discord/models/domain/ModelMessage;->deleted:Z
+
+ if-eqz v2, :cond_d
+
+ new-instance v2, Ljava/util/ArrayList;
+
+ const/4 v3, 0x2
+
+ invoke-direct {v2, v3}, Ljava/util/ArrayList;-><init>(I)V
+
+ .line 14
+ new-instance v3, Landroid/text/style/RelativeSizeSpan;
+
+ const/high16 v4, 0x3f400000 # 0.75f
+
+ invoke-direct {v3, v4}, Landroid/text/style/RelativeSizeSpan;-><init>(F)V
+
+ invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
+
+ .line 15
+ new-instance v3, Landroid/text/style/ForegroundColorSpan;
+
+ const v4, 0x7f040166
+
+ invoke-static {v15, v4}, Lcom/discord/utilities/color/ColorCompat;->getThemedColor(Landroid/content/Context;I)I
+
+ move-result v4
+
+ invoke-direct {v3, v4}, Landroid/text/style/ForegroundColorSpan;-><init>(I)V
+
+ invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
+
+ .line 16
+ new-instance v3, Lf/a/j/a/a/a;
+
+ const-string v4, " "
+
+ invoke-direct {v3, v4}, Lf/a/j/a/a/a;-><init>(Ljava/lang/String;)V
+
+ invoke-interface {v13, v3}, Ljava/util/Collection;->add(Ljava/lang/Object;)Z
+
+ .line 17
+ new-instance v3, Lcom/discord/simpleast/core/node/StyleNode;
+
+ invoke-direct {v3, v2}, Lcom/discord/simpleast/core/node/StyleNode;-><init>(Ljava/util/List;)V
+
+ .line 18
+ new-instance v2, Lf/a/j/a/a/a;
+
+ const-string v4, "(deleted)"
+
+ invoke-direct {v2, v4}, Lf/a/j/a/a/a;-><init>(Ljava/lang/String;)V
+
+ invoke-virtual {v3, v2}, Lcom/discord/simpleast/core/node/Node;->addChild(Lcom/discord/simpleast/core/node/Node;)V
+
+ .line 19
+ invoke-interface {v13, v3}, Ljava/util/Collection;->add(Ljava/lang/Object;)Z
+
+ :cond_d
invoke-virtual {v12}, Lcom/discord/utilities/textprocessing/MessagePreprocessor;->isLinkifyConflicting()Z
move-result v2