diff --git a/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt b/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt index de9ce696e..b3a919bf4 100644 --- a/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt +++ b/stories/src/main/java/com/wordpress/stories/compose/ComposeLoopFrameActivity.kt @@ -1912,6 +1912,10 @@ abstract class ComposeLoopFrameActivity : AppCompatActivity(), OnStoryFrameSelec toggleDeleteSlideMode() } + override fun onStoryFrameMovedLongPressed() { + disableDeleteSlideMode() + } + private fun toggleDeleteSlideMode() { if (delete_slide_view.visibility == View.VISIBLE) { disableDeleteSlideMode() diff --git a/stories/src/main/java/com/wordpress/stories/compose/story/StoryFrameSelectorFragment.kt b/stories/src/main/java/com/wordpress/stories/compose/story/StoryFrameSelectorFragment.kt index 863ef8611..22d8d2210 100644 --- a/stories/src/main/java/com/wordpress/stories/compose/story/StoryFrameSelectorFragment.kt +++ b/stories/src/main/java/com/wordpress/stories/compose/story/StoryFrameSelectorFragment.kt @@ -25,6 +25,7 @@ interface OnStoryFrameSelectorTappedListener { fun onStoryFrameAddTapped() fun onCurrentFrameTapped() fun onStoryFrameLongPressed(oldIndex: Int, newIndex: Int) + fun onStoryFrameMovedLongPressed() } class StoryFrameSelectorFragment : Fragment() { @@ -57,6 +58,10 @@ class StoryFrameSelectorFragment : Fragment() { selectedFrameIndexChange.first, selectedFrameIndexChange.second) }) + storyViewModel.onUserMovedLongPressedFrame.observe(this, Observer { + storyFrameTappedListener?.onStoryFrameMovedLongPressed() + }) + storyViewModel.onFrameIndexMoved.observe(this, Observer> { positionFrameIndexChange -> updateContentUiStateMovedIndex(positionFrameIndexChange.first, positionFrameIndexChange.second) }) diff --git a/stories/src/main/java/com/wordpress/stories/compose/story/StoryViewModel.kt b/stories/src/main/java/com/wordpress/stories/compose/story/StoryViewModel.kt index 194c095dc..90c08774a 100644 --- a/stories/src/main/java/com/wordpress/stories/compose/story/StoryViewModel.kt +++ b/stories/src/main/java/com/wordpress/stories/compose/story/StoryViewModel.kt @@ -50,6 +50,9 @@ class StoryViewModel(private val repository: StoryRepository, val storyIndex: St private val _onUserLongPressedFrame = SingleLiveEvent>() val onUserLongPressedFrame = _onUserLongPressedFrame + private val _onUserMovedLongPressedFrame = SingleLiveEvent() + val onUserMovedLongPressedFrame = _onUserMovedLongPressedFrame + fun createNewStory() { loadStory(StoryRepository.DEFAULT_NONE_SELECTED) } @@ -113,6 +116,10 @@ class StoryViewModel(private val repository: StoryRepository, val storyIndex: St _onUserLongPressedFrame.value = Pair(oldIndex, index) } + private fun setMovedLongPressedFrame() { + _onUserMovedLongPressedFrame.call() + } + fun updateCurrentSelectedFrameOnRetryResult(frameSaveResult: FrameSaveResult) { repository.updateCurrentStorySaveResultOnFrame( currentSelectedFrameIndex, @@ -221,6 +228,7 @@ class StoryViewModel(private val repository: StoryRepository, val storyIndex: St } fun swapItemsInPositions(pos1: Int, pos2: Int) { + setMovedLongPressedFrame() repository.swapItemsInPositions(pos1, pos2) // adjust currentSelectedFrameIndex so it reflects the movement only // if the movement occurred entierly to the left of the selection, don't update it