mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-08 09:18:39 +01:00
Fix issue where crossfader has wrong story on shared element animation start.
This commit is contained in:
committed by
Cody Henthorne
parent
2b8041d779
commit
a642876bda
@@ -54,6 +54,7 @@ import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
|||||||
import org.thoughtcrime.securesms.database.model.Mention;
|
import org.thoughtcrime.securesms.database.model.Mention;
|
||||||
import org.thoughtcrime.securesms.database.model.MessageId;
|
import org.thoughtcrime.securesms.database.model.MessageId;
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||||
import org.thoughtcrime.securesms.database.model.NotificationMmsMessageRecord;
|
import org.thoughtcrime.securesms.database.model.NotificationMmsMessageRecord;
|
||||||
import org.thoughtcrime.securesms.database.model.ParentStoryId;
|
import org.thoughtcrime.securesms.database.model.ParentStoryId;
|
||||||
import org.thoughtcrime.securesms.database.model.Quote;
|
import org.thoughtcrime.securesms.database.model.Quote;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ data class StoryViewerArgs(
|
|||||||
val recipientIds: List<RecipientId> = emptyList(),
|
val recipientIds: List<RecipientId> = emptyList(),
|
||||||
val isFromNotification: Boolean = false,
|
val isFromNotification: Boolean = false,
|
||||||
val groupReplyStartPosition: Int = -1,
|
val groupReplyStartPosition: Int = -1,
|
||||||
val isUnviewedOnly: Boolean = false,
|
|
||||||
val isFromInfoContextMenuAction: Boolean = false,
|
val isFromInfoContextMenuAction: Boolean = false,
|
||||||
val isFromQuote: Boolean = false,
|
val isFromQuote: Boolean = false,
|
||||||
val isFromMyStories: Boolean = false
|
val isFromMyStories: Boolean = false
|
||||||
@@ -35,7 +34,6 @@ data class StoryViewerArgs(
|
|||||||
private var recipientIds: List<RecipientId> = emptyList()
|
private var recipientIds: List<RecipientId> = emptyList()
|
||||||
private var isFromNotification: Boolean = false
|
private var isFromNotification: Boolean = false
|
||||||
private var groupReplyStartPosition: Int = -1
|
private var groupReplyStartPosition: Int = -1
|
||||||
private var isUnviewedOnly: Boolean = false
|
|
||||||
private var isFromInfoContextMenuAction: Boolean = false
|
private var isFromInfoContextMenuAction: Boolean = false
|
||||||
private var isFromQuote: Boolean = false
|
private var isFromQuote: Boolean = false
|
||||||
|
|
||||||
@@ -74,11 +72,6 @@ data class StoryViewerArgs(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isUnviewedOnly(isUnviewedOnly: Boolean): Builder {
|
|
||||||
this.isUnviewedOnly = isUnviewedOnly
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isFromQuote(isFromQuote: Boolean): Builder {
|
fun isFromQuote(isFromQuote: Boolean): Builder {
|
||||||
this.isFromQuote = isFromQuote
|
this.isFromQuote = isFromQuote
|
||||||
return this
|
return this
|
||||||
@@ -95,7 +88,6 @@ data class StoryViewerArgs(
|
|||||||
recipientIds = recipientIds,
|
recipientIds = recipientIds,
|
||||||
isFromNotification = isFromNotification,
|
isFromNotification = isFromNotification,
|
||||||
groupReplyStartPosition = groupReplyStartPosition,
|
groupReplyStartPosition = groupReplyStartPosition,
|
||||||
isUnviewedOnly = isUnviewedOnly,
|
|
||||||
isFromInfoContextMenuAction = isFromInfoContextMenuAction,
|
isFromInfoContextMenuAction = isFromInfoContextMenuAction,
|
||||||
isFromQuote = isFromQuote
|
isFromQuote = isFromQuote
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -272,7 +272,6 @@ class StoriesLandingFragment : DSLSettingsFragment(layoutId = R.layout.stories_l
|
|||||||
storyThumbUri = image,
|
storyThumbUri = image,
|
||||||
storyThumbBlur = blur,
|
storyThumbBlur = blur,
|
||||||
recipientIds = viewModel.getRecipientIds(model.data.isHidden, false),
|
recipientIds = viewModel.getRecipientIds(model.data.isHidden, false),
|
||||||
isUnviewedOnly = false,
|
|
||||||
isFromInfoContextMenuAction = isFromInfoContextMenuAction
|
isFromInfoContextMenuAction = isFromInfoContextMenuAction
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class StoryViewerFragment :
|
|||||||
storyViewerArgs.storyId,
|
storyViewerArgs.storyId,
|
||||||
storyViewerArgs.isFromNotification,
|
storyViewerArgs.isFromNotification,
|
||||||
storyViewerArgs.groupReplyStartPosition,
|
storyViewerArgs.groupReplyStartPosition,
|
||||||
storyViewerArgs.isUnviewedOnly,
|
|
||||||
storyViewerArgs.isFromMyStories,
|
storyViewerArgs.isFromMyStories,
|
||||||
storyViewerArgs.isFromInfoContextMenuAction
|
storyViewerArgs.isFromInfoContextMenuAction
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-2
@@ -12,7 +12,6 @@ class StoryViewerPagerAdapter(
|
|||||||
private val initialStoryId: Long,
|
private val initialStoryId: Long,
|
||||||
private val isFromNotification: Boolean,
|
private val isFromNotification: Boolean,
|
||||||
private val groupReplyStartPosition: Int,
|
private val groupReplyStartPosition: Int,
|
||||||
private val isUnviewedOnly: Boolean,
|
|
||||||
private val isOutgoingOnly: Boolean,
|
private val isOutgoingOnly: Boolean,
|
||||||
private val isFromInfoContextMenuAction: Boolean
|
private val isFromInfoContextMenuAction: Boolean
|
||||||
) : FragmentStateAdapter(fragment) {
|
) : FragmentStateAdapter(fragment) {
|
||||||
@@ -40,7 +39,7 @@ class StoryViewerPagerAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createFragment(position: Int): Fragment {
|
override fun createFragment(position: Int): Fragment {
|
||||||
return StoryViewerPageFragment.create(pages[position], initialStoryId, isFromNotification, groupReplyStartPosition, isUnviewedOnly, isOutgoingOnly, isFromInfoContextMenuAction)
|
return StoryViewerPageFragment.create(pages[position], initialStoryId, isFromNotification, groupReplyStartPosition, isOutgoingOnly, isFromInfoContextMenuAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Callback(
|
private class Callback(
|
||||||
|
|||||||
+9
-18
@@ -6,7 +6,6 @@ import org.thoughtcrime.securesms.database.MessageDatabase
|
|||||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||||
import org.thoughtcrime.securesms.database.model.DistributionListId
|
import org.thoughtcrime.securesms.database.model.DistributionListId
|
||||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||||
import org.thoughtcrime.securesms.database.model.StoryViewState
|
|
||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
@@ -15,7 +14,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
|||||||
* Open for testing
|
* Open for testing
|
||||||
*/
|
*/
|
||||||
open class StoryViewerRepository {
|
open class StoryViewerRepository {
|
||||||
fun getFirstStory(recipientId: RecipientId, unviewedOnly: Boolean, storyId: Long): Single<MmsMessageRecord> {
|
fun getFirstStory(recipientId: RecipientId, storyId: Long): Single<MmsMessageRecord> {
|
||||||
return if (storyId > 0) {
|
return if (storyId > 0) {
|
||||||
Single.fromCallable {
|
Single.fromCallable {
|
||||||
SignalDatabase.mms.getMessageRecord(storyId) as MmsMessageRecord
|
SignalDatabase.mms.getMessageRecord(storyId) as MmsMessageRecord
|
||||||
@@ -25,18 +24,20 @@ open class StoryViewerRepository {
|
|||||||
val recipient = Recipient.resolved(recipientId)
|
val recipient = Recipient.resolved(recipientId)
|
||||||
val reader: MessageDatabase.Reader = if (recipient.isMyStory || recipient.isSelf) {
|
val reader: MessageDatabase.Reader = if (recipient.isMyStory || recipient.isSelf) {
|
||||||
SignalDatabase.mms.getAllOutgoingStories(false, 1)
|
SignalDatabase.mms.getAllOutgoingStories(false, 1)
|
||||||
} else if (unviewedOnly) {
|
|
||||||
SignalDatabase.mms.getUnreadStories(recipientId, 1)
|
|
||||||
} else {
|
} else {
|
||||||
SignalDatabase.mms.getAllStoriesFor(recipientId, 1)
|
val unread = SignalDatabase.mms.getUnreadStories(recipientId, 1)
|
||||||
|
if (unread.iterator().hasNext()) {
|
||||||
|
unread
|
||||||
|
} else {
|
||||||
|
SignalDatabase.mms.getAllStoriesFor(recipientId, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
reader.use { it.iterator().next() } as MmsMessageRecord
|
||||||
reader.use { it.next } as MmsMessageRecord
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStories(hiddenStories: Boolean, unviewedOnly: Boolean, isOutgoingOnly: Boolean): Single<List<RecipientId>> {
|
fun getStories(hiddenStories: Boolean, isOutgoingOnly: Boolean): Single<List<RecipientId>> {
|
||||||
return Single.create<List<RecipientId>> { emitter ->
|
return Single.create<List<RecipientId>> { emitter ->
|
||||||
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
||||||
val myStories = Recipient.resolved(myStoriesId)
|
val myStories = Recipient.resolved(myStoriesId)
|
||||||
@@ -54,16 +55,6 @@ open class StoryViewerRepository {
|
|||||||
} else {
|
} else {
|
||||||
!it.shouldHideStory()
|
!it.shouldHideStory()
|
||||||
}
|
}
|
||||||
}.filter {
|
|
||||||
if (unviewedOnly) {
|
|
||||||
if (it.isSelf || it.isMyStory) {
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
SignalDatabase.mms.getStoryViewState(it.id) == StoryViewState.UNVIEWED
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}.map { it.id }
|
}.map { it.id }
|
||||||
|
|
||||||
emitter.onSuccess(
|
emitter.onSuccess(
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ class StoryViewerViewModel(
|
|||||||
} else {
|
} else {
|
||||||
repository.getStories(
|
repository.getStories(
|
||||||
hiddenStories = storyViewerArgs.isInHiddenStoryMode,
|
hiddenStories = storyViewerArgs.isInHiddenStoryMode,
|
||||||
unviewedOnly = storyViewerArgs.isUnviewedOnly,
|
|
||||||
isOutgoingOnly = storyViewerArgs.isFromMyStories
|
isOutgoingOnly = storyViewerArgs.isFromMyStories
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,7 @@ class StoryViewerViewModel(
|
|||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
disposables.clear()
|
disposables.clear()
|
||||||
disposables += repository.getFirstStory(storyViewerArgs.recipientId, storyViewerArgs.isUnviewedOnly, storyViewerArgs.storyId).subscribe { record ->
|
disposables += repository.getFirstStory(storyViewerArgs.recipientId, storyViewerArgs.storyId).subscribe { record ->
|
||||||
store.update {
|
store.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
crossfadeTarget = StoryViewerState.CrossfadeTarget.Record(record)
|
crossfadeTarget = StoryViewerState.CrossfadeTarget.Record(record)
|
||||||
|
|||||||
-7
@@ -117,7 +117,6 @@ class StoryViewerPageFragment :
|
|||||||
StoryViewerPageViewModel.Factory(
|
StoryViewerPageViewModel.Factory(
|
||||||
storyRecipientId,
|
storyRecipientId,
|
||||||
initialStoryId,
|
initialStoryId,
|
||||||
isUnviewedOnly,
|
|
||||||
isOutgoingOnly,
|
isOutgoingOnly,
|
||||||
StoryViewerPageRepository(
|
StoryViewerPageRepository(
|
||||||
requireContext()
|
requireContext()
|
||||||
@@ -151,9 +150,6 @@ class StoryViewerPageFragment :
|
|||||||
private val groupReplyStartPosition: Int
|
private val groupReplyStartPosition: Int
|
||||||
get() = requireArguments().getInt(ARG_GROUP_REPLY_START_POSITION, -1)
|
get() = requireArguments().getInt(ARG_GROUP_REPLY_START_POSITION, -1)
|
||||||
|
|
||||||
private val isUnviewedOnly: Boolean
|
|
||||||
get() = requireArguments().getBoolean(ARG_IS_UNVIEWED_ONLY, false)
|
|
||||||
|
|
||||||
private val isOutgoingOnly: Boolean
|
private val isOutgoingOnly: Boolean
|
||||||
get() = requireArguments().getBoolean(ARG_IS_OUTGOING_ONLY, false)
|
get() = requireArguments().getBoolean(ARG_IS_OUTGOING_ONLY, false)
|
||||||
|
|
||||||
@@ -1020,7 +1016,6 @@ class StoryViewerPageFragment :
|
|||||||
private const val ARG_STORY_ID = "arg.story.id"
|
private const val ARG_STORY_ID = "arg.story.id"
|
||||||
private const val ARG_IS_FROM_NOTIFICATION = "is_from_notification"
|
private const val ARG_IS_FROM_NOTIFICATION = "is_from_notification"
|
||||||
private const val ARG_GROUP_REPLY_START_POSITION = "group_reply_start_position"
|
private const val ARG_GROUP_REPLY_START_POSITION = "group_reply_start_position"
|
||||||
private const val ARG_IS_UNVIEWED_ONLY = "is_unviewed_only"
|
|
||||||
private const val ARG_IS_OUTGOING_ONLY = "is_outgoing_only"
|
private const val ARG_IS_OUTGOING_ONLY = "is_outgoing_only"
|
||||||
private const val ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION = "is_from_info_context_menu_action"
|
private const val ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION = "is_from_info_context_menu_action"
|
||||||
|
|
||||||
@@ -1029,7 +1024,6 @@ class StoryViewerPageFragment :
|
|||||||
initialStoryId: Long,
|
initialStoryId: Long,
|
||||||
isFromNotification: Boolean,
|
isFromNotification: Boolean,
|
||||||
groupReplyStartPosition: Int,
|
groupReplyStartPosition: Int,
|
||||||
isUnviewedOnly: Boolean,
|
|
||||||
isOutgoingOnly: Boolean,
|
isOutgoingOnly: Boolean,
|
||||||
isFromInfoContextMenuAction: Boolean
|
isFromInfoContextMenuAction: Boolean
|
||||||
): Fragment {
|
): Fragment {
|
||||||
@@ -1039,7 +1033,6 @@ class StoryViewerPageFragment :
|
|||||||
ARG_STORY_ID to initialStoryId,
|
ARG_STORY_ID to initialStoryId,
|
||||||
ARG_IS_FROM_NOTIFICATION to isFromNotification,
|
ARG_IS_FROM_NOTIFICATION to isFromNotification,
|
||||||
ARG_GROUP_REPLY_START_POSITION to groupReplyStartPosition,
|
ARG_GROUP_REPLY_START_POSITION to groupReplyStartPosition,
|
||||||
ARG_IS_UNVIEWED_ONLY to isUnviewedOnly,
|
|
||||||
ARG_IS_OUTGOING_ONLY to isOutgoingOnly,
|
ARG_IS_OUTGOING_ONLY to isOutgoingOnly,
|
||||||
ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION to isFromInfoContextMenuAction,
|
ARG_IS_FROM_INFO_CONTEXT_MENU_ACTION to isFromInfoContextMenuAction,
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-5
@@ -39,15 +39,13 @@ open class StoryViewerPageRepository(context: Context) {
|
|||||||
|
|
||||||
fun isReadReceiptsEnabled(): Boolean = TextSecurePreferences.isReadReceiptsEnabled(context)
|
fun isReadReceiptsEnabled(): Boolean = TextSecurePreferences.isReadReceiptsEnabled(context)
|
||||||
|
|
||||||
private fun getStoryRecords(recipientId: RecipientId, isUnviewedOnly: Boolean, isOutgoingOnly: Boolean): Observable<List<MessageRecord>> {
|
private fun getStoryRecords(recipientId: RecipientId, isOutgoingOnly: Boolean): Observable<List<MessageRecord>> {
|
||||||
return Observable.create { emitter ->
|
return Observable.create { emitter ->
|
||||||
val recipient = Recipient.resolved(recipientId)
|
val recipient = Recipient.resolved(recipientId)
|
||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
val stories = if (recipient.isMyStory) {
|
val stories = if (recipient.isMyStory) {
|
||||||
SignalDatabase.mms.getAllOutgoingStories(false, 100)
|
SignalDatabase.mms.getAllOutgoingStories(false, 100)
|
||||||
} else if (isUnviewedOnly) {
|
|
||||||
SignalDatabase.mms.getUnreadStories(recipientId, 100)
|
|
||||||
} else if (isOutgoingOnly) {
|
} else if (isOutgoingOnly) {
|
||||||
SignalDatabase.mms.getOutgoingStoriesTo(recipientId)
|
SignalDatabase.mms.getOutgoingStoriesTo(recipientId)
|
||||||
} else {
|
} else {
|
||||||
@@ -148,8 +146,8 @@ open class StoryViewerPageRepository(context: Context) {
|
|||||||
return Stories.enqueueAttachmentsFromStoryForDownload(post.conversationMessage.messageRecord as MmsMessageRecord, true)
|
return Stories.enqueueAttachmentsFromStoryForDownload(post.conversationMessage.messageRecord as MmsMessageRecord, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStoryPostsFor(recipientId: RecipientId, isUnviewedOnly: Boolean, isOutgoingOnly: Boolean): Observable<List<StoryPost>> {
|
fun getStoryPostsFor(recipientId: RecipientId, isOutgoingOnly: Boolean): Observable<List<StoryPost>> {
|
||||||
return getStoryRecords(recipientId, isUnviewedOnly, isOutgoingOnly)
|
return getStoryRecords(recipientId, isOutgoingOnly)
|
||||||
.switchMap { records ->
|
.switchMap { records ->
|
||||||
val posts = records.map { getStoryPostFromRecord(recipientId, it) }
|
val posts = records.map { getStoryPostFromRecord(recipientId, it) }
|
||||||
if (posts.isEmpty()) {
|
if (posts.isEmpty()) {
|
||||||
|
|||||||
+2
-4
@@ -25,7 +25,6 @@ import kotlin.math.min
|
|||||||
class StoryViewerPageViewModel(
|
class StoryViewerPageViewModel(
|
||||||
private val recipientId: RecipientId,
|
private val recipientId: RecipientId,
|
||||||
private val initialStoryId: Long,
|
private val initialStoryId: Long,
|
||||||
private val isUnviewedOnly: Boolean,
|
|
||||||
private val isOutgoingOnly: Boolean,
|
private val isOutgoingOnly: Boolean,
|
||||||
private val repository: StoryViewerPageRepository,
|
private val repository: StoryViewerPageRepository,
|
||||||
val storyCache: StoryCache
|
val storyCache: StoryCache
|
||||||
@@ -62,7 +61,7 @@ class StoryViewerPageViewModel(
|
|||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
disposables.clear()
|
disposables.clear()
|
||||||
disposables += repository.getStoryPostsFor(recipientId, isUnviewedOnly, isOutgoingOnly).subscribe { posts ->
|
disposables += repository.getStoryPostsFor(recipientId, isOutgoingOnly).subscribe { posts ->
|
||||||
store.update { state ->
|
store.update { state ->
|
||||||
val isDisplayingInitialState = state.posts.isEmpty() && posts.isNotEmpty()
|
val isDisplayingInitialState = state.posts.isEmpty() && posts.isNotEmpty()
|
||||||
val startIndex = if (state.posts.isEmpty() && initialStoryId > 0) {
|
val startIndex = if (state.posts.isEmpty() && initialStoryId > 0) {
|
||||||
@@ -294,13 +293,12 @@ class StoryViewerPageViewModel(
|
|||||||
class Factory(
|
class Factory(
|
||||||
private val recipientId: RecipientId,
|
private val recipientId: RecipientId,
|
||||||
private val initialStoryId: Long,
|
private val initialStoryId: Long,
|
||||||
private val isUnviewedOnly: Boolean,
|
|
||||||
private val isOutgoingOnly: Boolean,
|
private val isOutgoingOnly: Boolean,
|
||||||
private val repository: StoryViewerPageRepository,
|
private val repository: StoryViewerPageRepository,
|
||||||
private val storyCache: StoryCache
|
private val storyCache: StoryCache
|
||||||
) : ViewModelProvider.Factory {
|
) : ViewModelProvider.Factory {
|
||||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||||
return modelClass.cast(StoryViewerPageViewModel(recipientId, initialStoryId, isUnviewedOnly, isOutgoingOnly, repository, storyCache)) as T
|
return modelClass.cast(StoryViewerPageViewModel(recipientId, initialStoryId, isOutgoingOnly, repository, storyCache)) as T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user