Fixes the ANR in #840, reported as "parsing emoji reactions" hanging after a
first sync. Three costs compounded, all inside a single Realm transaction:
- The bulk reparse cleared isEmojiReaction by walking every message in the
database and writing the field whether or not it was set. Query the flagged
messages instead, which on a typical history is a handful rather than tens of
thousands.
- findTargetMessage loaded every message in the thread and ran a regex over each
one, and it runs once per reaction. That product is quadratic across an
imported history. Bound it: a reaction can only target a message that already
existed, so filter by date, and cap the scan at the 200 most recent
candidates. A reaction refers to something the sender can still see, so a
target further back is not plausible.
- An untruncated quote, the common case, now matches natively in Realm on the
body column instead of materialising each candidate's text through getText(),
which walks MMS parts. MMS still falls through to the scan, since its text
lives in parts rather than body.
The date filter allows a minute of slack, because clock differences between two
devices can timestamp a reaction fractionally before the message it targets.
Also fixes the progress bar, which counted only messages that turned out to be
reactions while max counted every message examined. Progress could therefore
never reach max, so the bar never completed and the final callback never fired.
reactionDate is optional on the interface so existing callers keep compiling;
all three in-tree callers now pass it.
- Adds a new class of features for message management.
- Adds a manual option to find and delete duplicate messages
- Adds a setting to automatically delete duplicates during sync
- Adds a sha256 hashing function
Co-authored-by: octoshrimpy <octoshrimpy@users.noreply.github.com>
Fixes part of #152
To keep this PR simple, I've left out:
- when long-pressing on the emoji in a group MMS, a popup should come up listing which contact sent each emoji
- notifications (untested)
- sending emoji reactions
move old ReceiveMms interactor code to receive mms worker
move mms processing code from mmsreceivedreceiver to receive mms worker
fix bug of non-unique pending intent for mms ack/notify send
removed some unused android-smsmms files and code that was causing build issues
change compose selectedconversation (chips -> convo monitoring) to take advantage of changes in conversationrepo
conversationrepo change getthreadid to getconversation to avoid duplicate db access
some cleanups and refactoring in conversationrepo
emoji2 compat library to 1.4.0 (required compilesdk upgrade to 34)
make qkedittext use appcompatedittext for emoji compatibility
fix small incompatibilities introduced by new library versions
add instruction status message when bubble char limit exceeded.
add share text feature.
make copy and share text menu options only available when there is text in selected messages.
new FileProvider to share messages text files out of app's cache dir.
add message subject to copy messages text feature.
a lot of refactoring of MessagesAdapter class.
add new FileUtils class.
convert file logging to use new FileUtils class.
change MediaRecorder to use new FileUtils class.
housekeeping worker now cleans messages text cache files.
housekeeping worker now checks cache files older than 2 hours before deleting.
modify sms receive interactor to be used by new worker and add more logging.
create custom workfactory that supports injection into workers.
modify housekeeping worker to use injection.