2021-05-31 06:06:02 +02:00
|
|
|
package org.thoughtcrime.securesms.conversation.v2.messages
|
|
|
|
|
|
|
|
import android.content.Context
|
2022-08-10 10:17:48 +02:00
|
|
|
import android.content.Intent
|
2021-06-23 03:32:05 +02:00
|
|
|
import android.content.res.Resources
|
2021-06-09 07:12:48 +02:00
|
|
|
import android.graphics.Canvas
|
|
|
|
import android.graphics.Rect
|
2021-06-09 04:04:50 +02:00
|
|
|
import android.graphics.drawable.ColorDrawable
|
2021-06-09 03:18:15 +02:00
|
|
|
import android.os.Handler
|
|
|
|
import android.os.Looper
|
2021-05-31 06:06:02 +02:00
|
|
|
import android.util.AttributeSet
|
2022-01-14 06:56:15 +01:00
|
|
|
import android.view.HapticFeedbackConstants
|
|
|
|
import android.view.MotionEvent
|
|
|
|
import android.view.View
|
2021-05-31 06:06:02 +02:00
|
|
|
import android.widget.LinearLayout
|
2021-07-14 06:39:20 +02:00
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
2021-06-09 07:12:48 +02:00
|
|
|
import androidx.core.content.ContextCompat
|
2021-12-16 05:47:26 +01:00
|
|
|
import androidx.core.os.bundleOf
|
2022-08-08 07:16:33 +02:00
|
|
|
import androidx.core.view.isInvisible
|
2021-06-07 08:06:37 +02:00
|
|
|
import androidx.core.view.isVisible
|
2022-08-08 07:16:33 +02:00
|
|
|
import androidx.core.view.marginBottom
|
2021-10-04 09:51:19 +02:00
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
2021-05-31 06:29:11 +02:00
|
|
|
import network.loki.messenger.R
|
2022-01-14 06:56:15 +01:00
|
|
|
import network.loki.messenger.databinding.ViewVisibleMessageBinding
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
import org.session.libsession.messaging.contacts.Contact
|
2021-06-01 05:01:03 +02:00
|
|
|
import org.session.libsession.messaging.contacts.Contact.ContactContext
|
2022-09-04 13:03:32 +02:00
|
|
|
import org.session.libsession.messaging.open_groups.OpenGroupApi
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.session.libsession.utilities.Address
|
2021-06-07 07:37:21 +02:00
|
|
|
import org.session.libsession.utilities.ViewUtil
|
New app theming (#913)
* feat: start new app theming feature
* feat: add some theming colours
* refactor: start refactoring themes and colours to use dynamic attributes
* feat: adding more colours and switching over default colours to be theme based instead of hard-coded or day/night specific
* refactor: take a look at ocean light and logo colour
* feat: global search colours for light and dark ocean
* feat: more styling
* feat: adding themes to conversation activity and refactoring the base theme to apply over the top of the activity's theme so it retains noActionBar etc
* feat: add dynamic accent color
* docs: add todo for changing how accent colour is applied
* feat: update new theming to use override primary style so that the regular colorAccent attribute can be used in existing layouts
* feat: coordinating styles across layouts, fixing up pinned icons and naming for conversation list items
* refactor: re-styling layouts to match new themes and attributes. Need to figure out action mode close button
* refactor: remove @color/text and replace with ?android:textColorPrimary to override in themes
* refactor: add context theme wrapper to bottom sheet dialog that references accent color
* fix: input bar bug fix and preference activity themes
* refactor: new settings menu options
* fix: crash for PNModeActivity.kt
refactor: move ordering in seed dialog to match designs, copy changes to match new settings menu
* feat: add new appearance settings activity
* refactor: title and VM changes
* fix: correct override
* feat: add theme appearance screen UI features and start VM implementation. re-add legacy theme utils to get default for migration
* fix: compile errors and missing themes from emoji features
* refactor: remove background shape alteration and old bottom sheet styles, re-add the theme mode attr
* feat: appearance screen wired up, just need to refresh theme
* feat: add theme state recreation and fix match system settings option
* refactor: add bottom margin
* feat: explore custom preference category
* feat: add the customized session theme for CorrectedPreferenceFragment
* feat: replace AppProtectionPreferenceFragment to extend ListSummaryPreferenceFragment
* refactor: change drawable style and remove explicit dividers
* refactor: remove divider in CorrectedPreferenceFragment
* feat: add theme state check on resume, might be jarring currently
* feat: add preference divider elements for settings menu
* refactor: settings menu redesigns
* refactor: change led preference to integer and refactor TextSecurePreferences.kt
* feat: add scroll parcel to save/restore hierarchy on restart with appearance changes
* feat: add the conversations blocked contacts and refactor preference order and copy
* feat: add blocked contacts activity, basic layout and vm
* feat: add unblock DB functions and storage protocol, start working on the DB query state flow, might have to just implement recipient on modified listener
* feat: add blocked contacts and notif recipient listeners
* feat: add recipient db reader
* feat: add blocked contact interactions and fix a theming crash for notifications
* feat: introduce better equals and hashcode implementations to recipient, replace home diff util content check with hashcode-based comparison
* feat: add settings menu vectors
* fix: preview compile error
* refactor: migrating settings menu to new designs
* feat: help menu
* refactor: simplify link opening
* refactor: remove space
* feat: refactor preferences and start theming for light mode options
* refactor: fixing dark and light modes with dialogs
* refactor: popup dialogs use proper themes now
* refactor: alert dialogs and media edit fragments use attribute references
* refactor: use input bar button attribute instead color control normal in vector tint
* refactor: transparency, dialog fixes, notification fix
* refactor: attrs and styles for buttons
* fix: use prominent button color on the outline button's border
* fix: fix the trash
* refactor: remove the appearance
* refactor: avatar placeholder generation, chips and element border styles
* refactor: use colors instead of style references
* refactor: theming changes to match designs and feedback
* refactor: the titles are bold and the categories are tertiary coloured now
* fix: appearance settings match preferences, search bottom bar uses themed attributes
* refactor: increase setting button height
* Update clear all data dialog
* Update seed dialog
* refactor: more qa feedback changes
* feat: add new TLs and fa-rIR TLs
* Update notification content dialog
* Fix message requests clear all button text color
* feat: re-add screenshot observer
* refactor: make send tint accent color
* feat: add unread background differences
* fix: change unread count indicator
* build: upgrade build numbers
* Fix message requests popupmenu background color
* fix: crash from attr reference in color attribute
* build: upgrade build number
* fix: message bubbles, thumbnail backgrounds, search bar visibility with input bar, attachment buttons
* fix: tertiary text for keyboard page search view
* fix: emoji overflow colour differences
* fix: reaction pill dialog background is now correct colour
* Add style to reactions tab layout
* fix: appearance activity reverting primary color at correct time
* fix: show call privacy warning every time instead of just once
* fix: gradient background(?) and audio autoplay disable
* fix: crash in all media containing documents
* fix: reaction dialog heading fixes
* Add style to reactions tab layout
* fix: remove gradient backgrounds
* fix: adding new reaction normal text attribute to try correct the tab layout
* fix: ocean dark unread/read colours
* build; update build number
* build: update build number
Co-authored-by: charles <charles@oxen.io>
2022-10-12 08:05:55 +02:00
|
|
|
import org.session.libsession.utilities.getColorFromAttr
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.session.libsignal.utilities.IdPrefix
|
2021-06-30 07:40:15 +02:00
|
|
|
import org.session.libsignal.utilities.ThreadUtils
|
|
|
|
import org.thoughtcrime.securesms.ApplicationContext
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
2022-09-04 13:03:32 +02:00
|
|
|
import org.thoughtcrime.securesms.database.LokiAPIDatabase
|
2022-01-14 06:56:15 +01:00
|
|
|
import org.thoughtcrime.securesms.database.LokiThreadDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.MmsDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.MmsSmsDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.SmsDatabase
|
|
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase
|
2021-05-31 06:06:02 +02:00
|
|
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.thoughtcrime.securesms.groups.OpenGroupManager
|
2021-07-14 06:39:20 +02:00
|
|
|
import org.thoughtcrime.securesms.home.UserDetailsBottomSheet
|
2021-06-21 07:26:09 +02:00
|
|
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
2022-01-14 06:56:15 +01:00
|
|
|
import org.thoughtcrime.securesms.util.DateUtils
|
|
|
|
import org.thoughtcrime.securesms.util.disableClipping
|
|
|
|
import org.thoughtcrime.securesms.util.toDp
|
|
|
|
import org.thoughtcrime.securesms.util.toPx
|
|
|
|
import java.util.Date
|
2022-08-08 07:16:33 +02:00
|
|
|
import java.util.Locale
|
2021-10-04 09:51:19 +02:00
|
|
|
import javax.inject.Inject
|
2021-06-09 02:57:40 +02:00
|
|
|
import kotlin.math.abs
|
2021-06-09 07:12:48 +02:00
|
|
|
import kotlin.math.min
|
2021-06-07 07:37:21 +02:00
|
|
|
import kotlin.math.roundToInt
|
2021-06-09 02:57:40 +02:00
|
|
|
import kotlin.math.sqrt
|
2022-01-14 06:56:15 +01:00
|
|
|
|
2021-10-04 09:51:19 +02:00
|
|
|
@AndroidEntryPoint
|
2021-06-01 01:48:02 +02:00
|
|
|
class VisibleMessageView : LinearLayout {
|
2021-10-04 09:51:19 +02:00
|
|
|
|
|
|
|
@Inject lateinit var threadDb: ThreadDatabase
|
|
|
|
@Inject lateinit var lokiThreadDb: LokiThreadDatabase
|
2022-09-04 13:03:32 +02:00
|
|
|
@Inject lateinit var lokiApiDb: LokiAPIDatabase
|
2021-10-04 09:51:19 +02:00
|
|
|
@Inject lateinit var mmsSmsDb: MmsSmsDatabase
|
|
|
|
@Inject lateinit var smsDb: SmsDatabase
|
|
|
|
@Inject lateinit var mmsDb: MmsDatabase
|
|
|
|
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
private val binding by lazy { ViewVisibleMessageBinding.bind(this) }
|
2021-06-23 03:32:05 +02:00
|
|
|
private val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
2021-06-10 02:39:15 +02:00
|
|
|
private val swipeToReplyIcon = ContextCompat.getDrawable(context, R.drawable.ic_baseline_reply_24)!!.mutate()
|
2021-06-09 07:12:48 +02:00
|
|
|
private val swipeToReplyIconRect = Rect()
|
2021-06-09 02:57:40 +02:00
|
|
|
private var dx = 0.0f
|
|
|
|
private var previousTranslationX = 0.0f
|
2021-06-09 03:18:15 +02:00
|
|
|
private val gestureHandler = Handler(Looper.getMainLooper())
|
2021-06-28 07:41:23 +02:00
|
|
|
private var pressCallback: Runnable? = null
|
2021-06-09 03:18:15 +02:00
|
|
|
private var longPressCallback: Runnable? = null
|
2021-06-09 03:37:50 +02:00
|
|
|
private var onDownTimestamp = 0L
|
2021-06-28 07:41:23 +02:00
|
|
|
private var onDoubleTap: (() -> Unit)? = null
|
2021-07-14 01:37:18 +02:00
|
|
|
var indexInAdapter: Int = -1
|
2021-06-09 04:04:50 +02:00
|
|
|
var snIsSelected = false
|
2022-01-14 06:56:15 +01:00
|
|
|
set(value) {
|
|
|
|
field = value
|
|
|
|
handleIsSelectedChanged()
|
|
|
|
}
|
2021-06-30 06:29:32 +02:00
|
|
|
var onPress: ((event: MotionEvent) -> Unit)? = null
|
2021-06-09 03:37:50 +02:00
|
|
|
var onSwipeToReply: (() -> Unit)? = null
|
|
|
|
var onLongPress: (() -> Unit)? = null
|
2022-09-04 13:03:32 +02:00
|
|
|
val messageContentView: VisibleMessageContentView by lazy { binding.messageContentView }
|
2021-06-09 02:57:40 +02:00
|
|
|
|
|
|
|
companion object {
|
2021-07-14 03:07:46 +02:00
|
|
|
const val swipeToReplyThreshold = 64.0f // dp
|
2022-01-14 06:56:15 +01:00
|
|
|
const val longPressMovementThreshold = 10.0f // dp
|
2021-06-09 03:37:50 +02:00
|
|
|
const val longPressDurationThreshold = 250L // ms
|
2021-06-28 07:41:23 +02:00
|
|
|
const val maxDoubleTapInterval = 200L
|
2021-06-09 02:57:40 +02:00
|
|
|
}
|
2021-05-31 06:06:02 +02:00
|
|
|
|
|
|
|
// region Lifecycle
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
constructor(context: Context) : super(context)
|
|
|
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
|
|
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
|
|
|
|
|
|
|
override fun onFinishInflate() {
|
|
|
|
super.onFinishInflate()
|
|
|
|
initialize()
|
|
|
|
}
|
2021-05-31 06:06:02 +02:00
|
|
|
|
2021-06-09 02:57:40 +02:00
|
|
|
private fun initialize() {
|
|
|
|
isHapticFeedbackEnabled = true
|
2021-06-09 07:12:48 +02:00
|
|
|
setWillNotDraw(false)
|
2022-09-04 13:03:32 +02:00
|
|
|
binding.messageInnerContainer.disableClipping()
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
binding.messageContentView.disableClipping()
|
2021-05-31 06:06:02 +02:00
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
// region Updating
|
2022-09-04 13:03:32 +02:00
|
|
|
fun bind(
|
|
|
|
message: MessageRecord,
|
|
|
|
previous: MessageRecord?,
|
|
|
|
next: MessageRecord?,
|
|
|
|
glide: GlideRequests,
|
|
|
|
searchQuery: String?,
|
|
|
|
contact: Contact?,
|
|
|
|
senderSessionID: String,
|
|
|
|
delegate: VisibleMessageViewDelegate?,
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
) {
|
2021-06-01 05:01:03 +02:00
|
|
|
val threadID = message.threadId
|
2021-10-04 09:51:19 +02:00
|
|
|
val thread = threadDb.getRecipientForThreadId(threadID) ?: return
|
2021-06-23 05:57:13 +02:00
|
|
|
val isGroupThread = thread.isGroupRecipient
|
2021-06-22 08:42:53 +02:00
|
|
|
val isStartOfMessageCluster = isStartOfMessageCluster(message, previous, isGroupThread)
|
|
|
|
val isEndOfMessageCluster = isEndOfMessageCluster(message, next, isGroupThread)
|
2021-06-01 06:28:14 +02:00
|
|
|
// Show profile picture and sender name if this is a group thread AND
|
|
|
|
// the message is incoming
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
binding.moderatorIconImageView.isVisible = false
|
|
|
|
binding.profilePictureView.root.visibility = when {
|
|
|
|
thread.isGroupRecipient && !message.isOutgoing && isEndOfMessageCluster -> View.VISIBLE
|
|
|
|
thread.isGroupRecipient -> View.INVISIBLE
|
|
|
|
else -> View.GONE
|
|
|
|
}
|
|
|
|
|
|
|
|
val bottomMargin = if (isEndOfMessageCluster) resources.getDimensionPixelSize(R.dimen.small_spacing)
|
|
|
|
else ViewUtil.dpToPx(context,2)
|
|
|
|
|
|
|
|
if (binding.profilePictureView.root.visibility == View.GONE) {
|
2022-09-04 13:03:32 +02:00
|
|
|
val expirationParams = binding.messageInnerContainer.layoutParams as MarginLayoutParams
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
expirationParams.bottomMargin = bottomMargin
|
2022-09-04 13:03:32 +02:00
|
|
|
binding.messageInnerContainer.layoutParams = expirationParams
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
} else {
|
|
|
|
val avatarLayoutParams = binding.profilePictureView.root.layoutParams as MarginLayoutParams
|
|
|
|
avatarLayoutParams.bottomMargin = bottomMargin
|
|
|
|
binding.profilePictureView.root.layoutParams = avatarLayoutParams
|
|
|
|
}
|
|
|
|
|
2021-06-01 06:28:14 +02:00
|
|
|
if (isGroupThread && !message.isOutgoing) {
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
if (isEndOfMessageCluster) {
|
|
|
|
binding.profilePictureView.root.publicKey = senderSessionID
|
|
|
|
binding.profilePictureView.root.glide = glide
|
|
|
|
binding.profilePictureView.root.update(message.individualRecipient)
|
|
|
|
binding.profilePictureView.root.setOnClickListener {
|
2022-08-10 10:17:48 +02:00
|
|
|
if (thread.isOpenGroupRecipient) {
|
|
|
|
if (IdPrefix.fromValue(senderSessionID) == IdPrefix.BLINDED) {
|
|
|
|
val intent = Intent(context, ConversationActivityV2::class.java)
|
|
|
|
intent.putExtra(ConversationActivityV2.FROM_GROUP_THREAD_ID, threadID)
|
|
|
|
intent.putExtra(ConversationActivityV2.ADDRESS, Address.fromSerialized(senderSessionID))
|
|
|
|
context.startActivity(intent)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
maybeShowUserDetails(senderSessionID, threadID)
|
|
|
|
}
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
}
|
|
|
|
if (thread.isOpenGroupRecipient) {
|
|
|
|
val openGroup = lokiThreadDb.getOpenGroupChat(threadID) ?: return
|
2022-08-10 10:17:48 +02:00
|
|
|
var standardPublicKey = ""
|
|
|
|
var blindedPublicKey: String? = null
|
|
|
|
if (IdPrefix.fromValue(senderSessionID) == IdPrefix.BLINDED) {
|
|
|
|
blindedPublicKey = senderSessionID
|
|
|
|
} else {
|
|
|
|
standardPublicKey = senderSessionID
|
|
|
|
}
|
|
|
|
val isModerator = OpenGroupManager.isUserModerator(context, openGroup.groupId, standardPublicKey, blindedPublicKey)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
binding.moderatorIconImageView.isVisible = !message.isOutgoing && isModerator
|
|
|
|
}
|
2021-06-22 08:42:53 +02:00
|
|
|
}
|
2021-06-01 05:01:03 +02:00
|
|
|
}
|
2022-08-08 07:16:33 +02:00
|
|
|
binding.senderNameTextView.isVisible = !message.isOutgoing && (isStartOfMessageCluster && (isGroupThread || snIsSelected))
|
|
|
|
val contactContext =
|
|
|
|
if (thread.isOpenGroupRecipient) ContactContext.OPEN_GROUP else ContactContext.REGULAR
|
|
|
|
binding.senderNameTextView.text = contact?.displayName(contactContext) ?: senderSessionID
|
2021-06-01 06:38:52 +02:00
|
|
|
// Date break
|
2022-08-08 07:16:33 +02:00
|
|
|
val showDateBreak = isStartOfMessageCluster || snIsSelected
|
|
|
|
binding.dateBreakTextView.text = if (showDateBreak) DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), message.timestamp) else null
|
|
|
|
binding.dateBreakTextView.isVisible = showDateBreak
|
2021-06-22 07:41:14 +02:00
|
|
|
// Message status indicator
|
2021-07-01 03:06:11 +02:00
|
|
|
val (iconID, iconColor) = getMessageStatusImage(message)
|
2021-06-22 07:41:14 +02:00
|
|
|
if (iconID != null) {
|
2021-07-01 03:06:11 +02:00
|
|
|
val drawable = ContextCompat.getDrawable(context, iconID)?.mutate()
|
|
|
|
if (iconColor != null) {
|
|
|
|
drawable?.setTint(iconColor)
|
|
|
|
}
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.messageStatusImageView.setImageDrawable(drawable)
|
2021-06-22 07:41:14 +02:00
|
|
|
}
|
|
|
|
if (message.isOutgoing) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val lastMessageID = mmsSmsDb.getLastMessageID(message.threadId)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
binding.messageStatusImageView.isVisible =
|
|
|
|
!message.isSent || message.id == lastMessageID
|
2021-06-22 07:41:14 +02:00
|
|
|
} else {
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.messageStatusImageView.isVisible = false
|
2021-06-22 07:41:14 +02:00
|
|
|
}
|
2021-06-30 07:40:15 +02:00
|
|
|
// Expiration timer
|
|
|
|
updateExpirationTimer(message)
|
2022-09-04 13:03:32 +02:00
|
|
|
// Emoji Reactions
|
|
|
|
val emojiLayoutParams = binding.emojiReactionsView.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
emojiLayoutParams.horizontalBias = if (message.isOutgoing) 1f else 0f
|
|
|
|
binding.emojiReactionsView.layoutParams = emojiLayoutParams
|
|
|
|
val capabilities = lokiThreadDb.getOpenGroupChat(threadID)?.server?.let { lokiApiDb.getServerCapabilities(it) }
|
|
|
|
if (message.reactions.isNotEmpty() &&
|
|
|
|
(capabilities.isNullOrEmpty() || capabilities.contains(OpenGroupApi.Capability.REACTIONS.name.lowercase()))
|
|
|
|
) {
|
|
|
|
binding.emojiReactionsView.setReactions(message.id, message.reactions, message.isOutgoing, delegate)
|
|
|
|
binding.emojiReactionsView.isVisible = true
|
|
|
|
} else {
|
|
|
|
binding.emojiReactionsView.isVisible = false
|
|
|
|
}
|
|
|
|
|
2021-06-23 05:57:13 +02:00
|
|
|
// Populate content view
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.messageContentView.indexInAdapter = indexInAdapter
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
binding.messageContentView.bind(
|
|
|
|
message,
|
|
|
|
isStartOfMessageCluster,
|
|
|
|
isEndOfMessageCluster,
|
|
|
|
glide,
|
|
|
|
thread,
|
|
|
|
searchQuery,
|
|
|
|
message.isOutgoing || isGroupThread || (contact?.isTrusted ?: false)
|
|
|
|
)
|
2022-09-04 13:03:32 +02:00
|
|
|
binding.messageContentView.delegate = delegate
|
2022-01-14 06:56:15 +01:00
|
|
|
onDoubleTap = { binding.messageContentView.onContentDoubleTap?.invoke() }
|
2021-05-31 06:06:02 +02:00
|
|
|
}
|
|
|
|
|
2021-06-07 07:37:21 +02:00
|
|
|
private fun isStartOfMessageCluster(current: MessageRecord, previous: MessageRecord?, isGroupThread: Boolean): Boolean {
|
|
|
|
return if (isGroupThread) {
|
2021-07-14 06:27:21 +02:00
|
|
|
previous == null || previous.isUpdate || !DateUtils.isSameHour(current.timestamp, previous.timestamp)
|
2021-06-07 07:37:21 +02:00
|
|
|
|| current.recipient.address != previous.recipient.address
|
|
|
|
} else {
|
2021-07-14 06:27:21 +02:00
|
|
|
previous == null || previous.isUpdate || !DateUtils.isSameHour(current.timestamp, previous.timestamp)
|
2021-06-07 07:37:21 +02:00
|
|
|
|| current.isOutgoing != previous.isOutgoing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun isEndOfMessageCluster(current: MessageRecord, next: MessageRecord?, isGroupThread: Boolean): Boolean {
|
|
|
|
return if (isGroupThread) {
|
2021-07-08 05:37:08 +02:00
|
|
|
next == null || next.isUpdate || !DateUtils.isSameHour(current.timestamp, next.timestamp)
|
2021-06-07 07:37:21 +02:00
|
|
|
|| current.recipient.address != next.recipient.address
|
|
|
|
} else {
|
2021-07-08 05:37:08 +02:00
|
|
|
next == null || next.isUpdate || !DateUtils.isSameHour(current.timestamp, next.timestamp)
|
2021-06-07 07:37:21 +02:00
|
|
|
|| current.isOutgoing != next.isOutgoing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-01 03:06:11 +02:00
|
|
|
private fun getMessageStatusImage(message: MessageRecord): Pair<Int?,Int?> {
|
|
|
|
return when {
|
|
|
|
!message.isOutgoing -> null to null
|
|
|
|
message.isFailed -> R.drawable.ic_error to resources.getColor(R.color.destructive, context.theme)
|
|
|
|
message.isPending -> R.drawable.ic_circle_dot_dot_dot to null
|
|
|
|
message.isRead -> R.drawable.ic_filled_circle_check to null
|
|
|
|
else -> R.drawable.ic_circle_check to null
|
2021-06-22 07:41:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 07:40:15 +02:00
|
|
|
private fun updateExpirationTimer(message: MessageRecord) {
|
2022-09-04 13:03:32 +02:00
|
|
|
val container = binding.messageInnerContainer
|
2022-01-18 04:33:04 +01:00
|
|
|
val content = binding.messageContentView
|
|
|
|
val expiration = binding.expirationTimerView
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
val spacing = binding.messageContentSpacing
|
2022-01-18 04:33:04 +01:00
|
|
|
container.removeAllViewsInLayout()
|
|
|
|
container.addView(if (message.isOutgoing) expiration else content)
|
|
|
|
container.addView(if (message.isOutgoing) content else expiration)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
container.addView(spacing, if (message.isOutgoing) 0 else 2)
|
|
|
|
val containerParams = container.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
containerParams.horizontalBias = if (message.isOutgoing) 1f else 0f
|
|
|
|
container.layoutParams = containerParams
|
2021-06-30 07:40:15 +02:00
|
|
|
if (message.expiresIn > 0 && !message.isPending) {
|
New app theming (#913)
* feat: start new app theming feature
* feat: add some theming colours
* refactor: start refactoring themes and colours to use dynamic attributes
* feat: adding more colours and switching over default colours to be theme based instead of hard-coded or day/night specific
* refactor: take a look at ocean light and logo colour
* feat: global search colours for light and dark ocean
* feat: more styling
* feat: adding themes to conversation activity and refactoring the base theme to apply over the top of the activity's theme so it retains noActionBar etc
* feat: add dynamic accent color
* docs: add todo for changing how accent colour is applied
* feat: update new theming to use override primary style so that the regular colorAccent attribute can be used in existing layouts
* feat: coordinating styles across layouts, fixing up pinned icons and naming for conversation list items
* refactor: re-styling layouts to match new themes and attributes. Need to figure out action mode close button
* refactor: remove @color/text and replace with ?android:textColorPrimary to override in themes
* refactor: add context theme wrapper to bottom sheet dialog that references accent color
* fix: input bar bug fix and preference activity themes
* refactor: new settings menu options
* fix: crash for PNModeActivity.kt
refactor: move ordering in seed dialog to match designs, copy changes to match new settings menu
* feat: add new appearance settings activity
* refactor: title and VM changes
* fix: correct override
* feat: add theme appearance screen UI features and start VM implementation. re-add legacy theme utils to get default for migration
* fix: compile errors and missing themes from emoji features
* refactor: remove background shape alteration and old bottom sheet styles, re-add the theme mode attr
* feat: appearance screen wired up, just need to refresh theme
* feat: add theme state recreation and fix match system settings option
* refactor: add bottom margin
* feat: explore custom preference category
* feat: add the customized session theme for CorrectedPreferenceFragment
* feat: replace AppProtectionPreferenceFragment to extend ListSummaryPreferenceFragment
* refactor: change drawable style and remove explicit dividers
* refactor: remove divider in CorrectedPreferenceFragment
* feat: add theme state check on resume, might be jarring currently
* feat: add preference divider elements for settings menu
* refactor: settings menu redesigns
* refactor: change led preference to integer and refactor TextSecurePreferences.kt
* feat: add scroll parcel to save/restore hierarchy on restart with appearance changes
* feat: add the conversations blocked contacts and refactor preference order and copy
* feat: add blocked contacts activity, basic layout and vm
* feat: add unblock DB functions and storage protocol, start working on the DB query state flow, might have to just implement recipient on modified listener
* feat: add blocked contacts and notif recipient listeners
* feat: add recipient db reader
* feat: add blocked contact interactions and fix a theming crash for notifications
* feat: introduce better equals and hashcode implementations to recipient, replace home diff util content check with hashcode-based comparison
* feat: add settings menu vectors
* fix: preview compile error
* refactor: migrating settings menu to new designs
* feat: help menu
* refactor: simplify link opening
* refactor: remove space
* feat: refactor preferences and start theming for light mode options
* refactor: fixing dark and light modes with dialogs
* refactor: popup dialogs use proper themes now
* refactor: alert dialogs and media edit fragments use attribute references
* refactor: use input bar button attribute instead color control normal in vector tint
* refactor: transparency, dialog fixes, notification fix
* refactor: attrs and styles for buttons
* fix: use prominent button color on the outline button's border
* fix: fix the trash
* refactor: remove the appearance
* refactor: avatar placeholder generation, chips and element border styles
* refactor: use colors instead of style references
* refactor: theming changes to match designs and feedback
* refactor: the titles are bold and the categories are tertiary coloured now
* fix: appearance settings match preferences, search bottom bar uses themed attributes
* refactor: increase setting button height
* Update clear all data dialog
* Update seed dialog
* refactor: more qa feedback changes
* feat: add new TLs and fa-rIR TLs
* Update notification content dialog
* Fix message requests clear all button text color
* feat: re-add screenshot observer
* refactor: make send tint accent color
* feat: add unread background differences
* fix: change unread count indicator
* build: upgrade build numbers
* Fix message requests popupmenu background color
* fix: crash from attr reference in color attribute
* build: upgrade build number
* fix: message bubbles, thumbnail backgrounds, search bar visibility with input bar, attachment buttons
* fix: tertiary text for keyboard page search view
* fix: emoji overflow colour differences
* fix: reaction pill dialog background is now correct colour
* Add style to reactions tab layout
* fix: appearance activity reverting primary color at correct time
* fix: show call privacy warning every time instead of just once
* fix: gradient background(?) and audio autoplay disable
* fix: crash in all media containing documents
* fix: reaction dialog heading fixes
* Add style to reactions tab layout
* fix: remove gradient backgrounds
* fix: adding new reaction normal text attribute to try correct the tab layout
* fix: ocean dark unread/read colours
* build; update build number
* build: update build number
Co-authored-by: charles <charles@oxen.io>
2022-10-12 08:05:55 +02:00
|
|
|
binding.expirationTimerView.setColorFilter(context.getColorFromAttr(android.R.attr.textColorPrimary))
|
2022-08-08 07:16:33 +02:00
|
|
|
binding.expirationTimerView.isInvisible = false
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.expirationTimerView.setPercentComplete(0.0f)
|
2021-06-30 07:40:15 +02:00
|
|
|
if (message.expireStarted > 0) {
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.expirationTimerView.setExpirationTime(message.expireStarted, message.expiresIn)
|
|
|
|
binding.expirationTimerView.startAnimation()
|
2021-06-30 07:40:15 +02:00
|
|
|
if (message.expireStarted + message.expiresIn <= System.currentTimeMillis()) {
|
|
|
|
ApplicationContext.getInstance(context).expiringMessageManager.checkSchedule()
|
|
|
|
}
|
2021-09-13 05:45:55 +02:00
|
|
|
} else if (!message.isMediaPending) {
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.expirationTimerView.setPercentComplete(0.0f)
|
|
|
|
binding.expirationTimerView.stopAnimation()
|
2021-06-30 07:40:15 +02:00
|
|
|
ThreadUtils.queue {
|
|
|
|
val expirationManager = ApplicationContext.getInstance(context).expiringMessageManager
|
|
|
|
val id = message.getId()
|
|
|
|
val mms = message.isMms
|
2021-10-04 09:51:19 +02:00
|
|
|
if (mms) mmsDb.markExpireStarted(id) else smsDb.markExpireStarted(id)
|
2021-06-30 07:40:15 +02:00
|
|
|
expirationManager.scheduleDeletion(id, mms, message.expiresIn)
|
|
|
|
}
|
2021-09-13 05:45:55 +02:00
|
|
|
} else {
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.expirationTimerView.stopAnimation()
|
|
|
|
binding.expirationTimerView.setPercentComplete(0.0f)
|
2021-06-30 07:40:15 +02:00
|
|
|
}
|
|
|
|
} else {
|
2022-08-08 07:16:33 +02:00
|
|
|
binding.expirationTimerView.isInvisible = true
|
2021-06-30 07:40:15 +02:00
|
|
|
}
|
2022-01-18 04:33:04 +01:00
|
|
|
container.requestLayout()
|
2021-06-30 07:40:15 +02:00
|
|
|
}
|
|
|
|
|
2021-06-09 04:04:50 +02:00
|
|
|
private fun handleIsSelectedChanged() {
|
|
|
|
background = if (snIsSelected) {
|
New app theming (#913)
* feat: start new app theming feature
* feat: add some theming colours
* refactor: start refactoring themes and colours to use dynamic attributes
* feat: adding more colours and switching over default colours to be theme based instead of hard-coded or day/night specific
* refactor: take a look at ocean light and logo colour
* feat: global search colours for light and dark ocean
* feat: more styling
* feat: adding themes to conversation activity and refactoring the base theme to apply over the top of the activity's theme so it retains noActionBar etc
* feat: add dynamic accent color
* docs: add todo for changing how accent colour is applied
* feat: update new theming to use override primary style so that the regular colorAccent attribute can be used in existing layouts
* feat: coordinating styles across layouts, fixing up pinned icons and naming for conversation list items
* refactor: re-styling layouts to match new themes and attributes. Need to figure out action mode close button
* refactor: remove @color/text and replace with ?android:textColorPrimary to override in themes
* refactor: add context theme wrapper to bottom sheet dialog that references accent color
* fix: input bar bug fix and preference activity themes
* refactor: new settings menu options
* fix: crash for PNModeActivity.kt
refactor: move ordering in seed dialog to match designs, copy changes to match new settings menu
* feat: add new appearance settings activity
* refactor: title and VM changes
* fix: correct override
* feat: add theme appearance screen UI features and start VM implementation. re-add legacy theme utils to get default for migration
* fix: compile errors and missing themes from emoji features
* refactor: remove background shape alteration and old bottom sheet styles, re-add the theme mode attr
* feat: appearance screen wired up, just need to refresh theme
* feat: add theme state recreation and fix match system settings option
* refactor: add bottom margin
* feat: explore custom preference category
* feat: add the customized session theme for CorrectedPreferenceFragment
* feat: replace AppProtectionPreferenceFragment to extend ListSummaryPreferenceFragment
* refactor: change drawable style and remove explicit dividers
* refactor: remove divider in CorrectedPreferenceFragment
* feat: add theme state check on resume, might be jarring currently
* feat: add preference divider elements for settings menu
* refactor: settings menu redesigns
* refactor: change led preference to integer and refactor TextSecurePreferences.kt
* feat: add scroll parcel to save/restore hierarchy on restart with appearance changes
* feat: add the conversations blocked contacts and refactor preference order and copy
* feat: add blocked contacts activity, basic layout and vm
* feat: add unblock DB functions and storage protocol, start working on the DB query state flow, might have to just implement recipient on modified listener
* feat: add blocked contacts and notif recipient listeners
* feat: add recipient db reader
* feat: add blocked contact interactions and fix a theming crash for notifications
* feat: introduce better equals and hashcode implementations to recipient, replace home diff util content check with hashcode-based comparison
* feat: add settings menu vectors
* fix: preview compile error
* refactor: migrating settings menu to new designs
* feat: help menu
* refactor: simplify link opening
* refactor: remove space
* feat: refactor preferences and start theming for light mode options
* refactor: fixing dark and light modes with dialogs
* refactor: popup dialogs use proper themes now
* refactor: alert dialogs and media edit fragments use attribute references
* refactor: use input bar button attribute instead color control normal in vector tint
* refactor: transparency, dialog fixes, notification fix
* refactor: attrs and styles for buttons
* fix: use prominent button color on the outline button's border
* fix: fix the trash
* refactor: remove the appearance
* refactor: avatar placeholder generation, chips and element border styles
* refactor: use colors instead of style references
* refactor: theming changes to match designs and feedback
* refactor: the titles are bold and the categories are tertiary coloured now
* fix: appearance settings match preferences, search bottom bar uses themed attributes
* refactor: increase setting button height
* Update clear all data dialog
* Update seed dialog
* refactor: more qa feedback changes
* feat: add new TLs and fa-rIR TLs
* Update notification content dialog
* Fix message requests clear all button text color
* feat: re-add screenshot observer
* refactor: make send tint accent color
* feat: add unread background differences
* fix: change unread count indicator
* build: upgrade build numbers
* Fix message requests popupmenu background color
* fix: crash from attr reference in color attribute
* build: upgrade build number
* fix: message bubbles, thumbnail backgrounds, search bar visibility with input bar, attachment buttons
* fix: tertiary text for keyboard page search view
* fix: emoji overflow colour differences
* fix: reaction pill dialog background is now correct colour
* Add style to reactions tab layout
* fix: appearance activity reverting primary color at correct time
* fix: show call privacy warning every time instead of just once
* fix: gradient background(?) and audio autoplay disable
* fix: crash in all media containing documents
* fix: reaction dialog heading fixes
* Add style to reactions tab layout
* fix: remove gradient backgrounds
* fix: adding new reaction normal text attribute to try correct the tab layout
* fix: ocean dark unread/read colours
* build; update build number
* build: update build number
Co-authored-by: charles <charles@oxen.io>
2022-10-12 08:05:55 +02:00
|
|
|
ColorDrawable(context.getColorFromAttr(R.attr.message_selected))
|
2021-06-09 04:04:50 +02:00
|
|
|
} else {
|
|
|
|
null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-09 07:12:48 +02:00
|
|
|
override fun onDraw(canvas: Canvas) {
|
2022-08-08 07:16:33 +02:00
|
|
|
val spacing = context.resources.getDimensionPixelSize(R.dimen.small_spacing)
|
|
|
|
val iconSize = toPx(24, context.resources)
|
2022-09-04 13:03:32 +02:00
|
|
|
val left = binding.messageInnerContainer.left + binding.messageContentView.right + spacing
|
|
|
|
val top = height - (binding.messageInnerContainer.height / 2) - binding.profilePictureView.root.marginBottom - (iconSize / 2)
|
2022-08-08 07:16:33 +02:00
|
|
|
val right = left + iconSize
|
|
|
|
val bottom = top + iconSize
|
|
|
|
swipeToReplyIconRect.left = left
|
|
|
|
swipeToReplyIconRect.top = top
|
|
|
|
swipeToReplyIconRect.right = right
|
|
|
|
swipeToReplyIconRect.bottom = bottom
|
|
|
|
|
2022-01-14 06:56:15 +01:00
|
|
|
if (translationX < 0 && !binding.expirationTimerView.isVisible) {
|
|
|
|
val threshold = swipeToReplyThreshold
|
2021-06-09 07:12:48 +02:00
|
|
|
swipeToReplyIcon.bounds = swipeToReplyIconRect
|
|
|
|
swipeToReplyIcon.alpha = (255.0f * (min(abs(translationX), threshold) / threshold)).roundToInt()
|
|
|
|
} else {
|
|
|
|
swipeToReplyIcon.alpha = 0
|
|
|
|
}
|
2021-06-10 02:04:50 +02:00
|
|
|
swipeToReplyIcon.draw(canvas)
|
2021-06-09 07:12:48 +02:00
|
|
|
super.onDraw(canvas)
|
|
|
|
}
|
|
|
|
|
2021-05-31 06:06:02 +02:00
|
|
|
fun recycle() {
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
binding.profilePictureView.root.recycle()
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.messageContentView.recycle()
|
2021-05-31 06:06:02 +02:00
|
|
|
}
|
|
|
|
// endregion
|
2021-06-09 02:57:40 +02:00
|
|
|
|
|
|
|
// region Interaction
|
|
|
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
2021-08-12 07:01:48 +02:00
|
|
|
if (onPress == null || onSwipeToReply == null || onLongPress == null) { return false }
|
2021-06-09 02:57:40 +02:00
|
|
|
when (event.action) {
|
|
|
|
MotionEvent.ACTION_DOWN -> onDown(event)
|
|
|
|
MotionEvent.ACTION_MOVE -> onMove(event)
|
2021-06-16 02:54:33 +02:00
|
|
|
MotionEvent.ACTION_CANCEL -> onCancel(event)
|
|
|
|
MotionEvent.ACTION_UP -> onUp(event)
|
2021-06-09 02:57:40 +02:00
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun onDown(event: MotionEvent) {
|
|
|
|
dx = x - event.rawX
|
2021-06-09 03:37:50 +02:00
|
|
|
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
|
|
|
val newLongPressCallback = Runnable { onLongPress() }
|
|
|
|
this.longPressCallback = newLongPressCallback
|
2022-01-14 06:56:15 +01:00
|
|
|
gestureHandler.postDelayed(newLongPressCallback, longPressDurationThreshold)
|
2021-06-09 03:37:50 +02:00
|
|
|
onDownTimestamp = Date().time
|
2021-06-09 02:57:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun onMove(event: MotionEvent) {
|
|
|
|
val translationX = toDp(event.rawX + dx, context.resources)
|
2022-01-14 06:56:15 +01:00
|
|
|
if (abs(translationX) < longPressMovementThreshold || snIsSelected) {
|
2021-06-09 03:18:15 +02:00
|
|
|
return
|
|
|
|
} else {
|
2021-06-09 03:37:50 +02:00
|
|
|
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
2021-06-09 03:18:15 +02:00
|
|
|
}
|
2021-06-30 02:30:10 +02:00
|
|
|
if (translationX > 0) { return } // Only allow swipes to the left
|
2021-06-09 02:57:40 +02:00
|
|
|
// The idea here is to asymptotically approach a maximum drag distance
|
|
|
|
val damping = 50.0f
|
|
|
|
val sign = -1.0f
|
|
|
|
val x = (damping * (sqrt(abs(translationX)) / sqrt(damping))) * sign
|
|
|
|
this.translationX = x
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.dateBreakTextView.translationX = -x // Bit of a hack to keep the date break text view from moving
|
2021-06-09 07:12:48 +02:00
|
|
|
postInvalidate() // Ensure onDraw(canvas:) is called
|
2022-01-14 06:56:15 +01:00
|
|
|
if (abs(x) > swipeToReplyThreshold && abs(previousTranslationX) < swipeToReplyThreshold) {
|
|
|
|
performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
|
2021-06-09 02:57:40 +02:00
|
|
|
}
|
|
|
|
previousTranslationX = x
|
|
|
|
}
|
|
|
|
|
2021-06-16 02:54:33 +02:00
|
|
|
private fun onCancel(event: MotionEvent) {
|
2022-01-14 06:56:15 +01:00
|
|
|
if (abs(translationX) > swipeToReplyThreshold) {
|
2021-06-21 01:40:23 +02:00
|
|
|
onSwipeToReply?.invoke()
|
|
|
|
}
|
2021-06-16 02:54:33 +02:00
|
|
|
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
2021-06-16 06:50:41 +02:00
|
|
|
resetPosition()
|
2021-06-16 02:54:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun onUp(event: MotionEvent) {
|
2022-01-14 06:56:15 +01:00
|
|
|
if (abs(translationX) > swipeToReplyThreshold) {
|
2021-06-09 03:37:50 +02:00
|
|
|
onSwipeToReply?.invoke()
|
2022-01-14 06:56:15 +01:00
|
|
|
} else if ((Date().time - onDownTimestamp) < longPressDurationThreshold) {
|
2021-06-09 03:37:50 +02:00
|
|
|
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
2021-06-28 07:41:23 +02:00
|
|
|
val pressCallback = this.pressCallback
|
|
|
|
if (pressCallback != null) {
|
|
|
|
// If we're here and pressCallback isn't null, it means that we tapped again within
|
|
|
|
// maxDoubleTapInterval ms and we should count this as a double tap
|
|
|
|
gestureHandler.removeCallbacks(pressCallback)
|
|
|
|
this.pressCallback = null
|
|
|
|
onDoubleTap?.invoke()
|
|
|
|
} else {
|
2021-06-30 06:29:32 +02:00
|
|
|
val newPressCallback = Runnable { onPress(event) }
|
2021-06-28 07:41:23 +02:00
|
|
|
this.pressCallback = newPressCallback
|
2022-09-04 13:03:32 +02:00
|
|
|
gestureHandler.postDelayed(newPressCallback, maxDoubleTapInterval)
|
2021-06-28 07:41:23 +02:00
|
|
|
}
|
2021-06-09 02:57:40 +02:00
|
|
|
}
|
2021-06-16 06:50:41 +02:00
|
|
|
resetPosition()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun resetPosition() {
|
2021-06-09 02:57:40 +02:00
|
|
|
animate()
|
|
|
|
.translationX(0.0f)
|
|
|
|
.setDuration(150)
|
2021-06-10 02:54:26 +02:00
|
|
|
.setUpdateListener {
|
|
|
|
postInvalidate() // Ensure onDraw(canvas:) is called
|
|
|
|
}
|
2021-06-09 02:57:40 +02:00
|
|
|
.start()
|
2021-06-10 02:54:26 +02:00
|
|
|
// Bit of a hack to keep the date break text view from moving
|
2022-01-14 06:56:15 +01:00
|
|
|
binding.dateBreakTextView.animate()
|
2021-06-16 06:50:41 +02:00
|
|
|
.translationX(0.0f)
|
|
|
|
.setDuration(150)
|
|
|
|
.start()
|
2021-06-09 02:57:40 +02:00
|
|
|
}
|
2021-06-09 03:18:15 +02:00
|
|
|
|
|
|
|
private fun onLongPress() {
|
|
|
|
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
2021-06-09 03:37:50 +02:00
|
|
|
onLongPress?.invoke()
|
2021-06-09 03:18:15 +02:00
|
|
|
}
|
2021-06-21 06:48:27 +02:00
|
|
|
|
2021-06-30 06:29:32 +02:00
|
|
|
fun onContentClick(event: MotionEvent) {
|
2022-02-07 07:06:27 +01:00
|
|
|
binding.messageContentView.onContentClick.iterator().forEach { clickHandler -> clickHandler.invoke(event) }
|
2021-06-21 06:48:27 +02:00
|
|
|
}
|
2021-06-29 02:05:34 +02:00
|
|
|
|
2021-06-30 06:29:32 +02:00
|
|
|
private fun onPress(event: MotionEvent) {
|
|
|
|
onPress?.invoke(event)
|
2021-06-28 07:41:23 +02:00
|
|
|
pressCallback = null
|
|
|
|
}
|
2021-07-14 06:39:20 +02:00
|
|
|
|
2022-08-10 10:17:48 +02:00
|
|
|
private fun maybeShowUserDetails(publicKey: String, threadID: Long) {
|
2021-07-14 06:39:20 +02:00
|
|
|
val userDetailsBottomSheet = UserDetailsBottomSheet()
|
2021-12-16 05:47:26 +01:00
|
|
|
val bundle = bundleOf(
|
|
|
|
UserDetailsBottomSheet.ARGUMENT_PUBLIC_KEY to publicKey,
|
|
|
|
UserDetailsBottomSheet.ARGUMENT_THREAD_ID to threadID
|
|
|
|
)
|
2021-07-14 06:39:20 +02:00
|
|
|
userDetailsBottomSheet.arguments = bundle
|
|
|
|
val activity = context as AppCompatActivity
|
|
|
|
userDetailsBottomSheet.show(activity.supportFragmentManager, userDetailsBottomSheet.tag)
|
|
|
|
}
|
2022-01-14 06:56:15 +01:00
|
|
|
|
|
|
|
fun playVoiceMessage() {
|
|
|
|
binding.messageContentView.playVoiceMessage()
|
|
|
|
}
|
2021-06-09 02:57:40 +02:00
|
|
|
// endregion
|
2021-06-09 03:37:50 +02:00
|
|
|
}
|