-
-
Notifications
You must be signed in to change notification settings - Fork 280
Preserve Conversation List position #5049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always place the last opened conversation at the top when coming back. This is not expected but people expect the exact scroll position as when the chat was opened.
It should be solved with
scrollToPositionWithOffset
which gets the scroll position and the offset from when the chat was opened.
6278b2f
to
4792f17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the feeling this can be solved in a simpler way.
Right now the position is passed to ChatActivity and back to ConversationList. This should not be necessary at all but ConversationList should handle this itself.
For example this does not work when the app just goes to background and coming back.
Also, i guess that findFirstVisibleItemPosition is something that should not be necessary. It will "just" scroll to an item instead to the exact position.
Can you have a look if there are simpler ways to achieve this?
Like just using the scroll position on the recyclerview itself and just using lifecycle methods to save/restore the scroll postion, eg. from the viewmodel..?
@rapterjet2004 whats the state for this PR? should it be "to review"? |
… back pressed Signed-off-by: rapterjet2004 <[email protected]>
Signed-off-by: rapterjet2004 <[email protected]>
Signed-off-by: rapterjet2004 <[email protected]>
otherwise, it's would not work when just reopening the app from background Signed-off-by: Marcel Hibbe <[email protected]>
34e1919
to
38b5098
Compare
app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
Show resolved
Hide resolved
private const val SIXTEEN_HOURS_IN_SECONDS: Long = 57600 | ||
const val LONG_1000: Long = 1000 | ||
private const val NOTE_TO_SELF_SHORTCUT_ID = "NOTE_TO_SELF_SHORTCUT_ID" | ||
private const val CONVERSATION_ITEM_HEIGHT = 44 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not the nicest solution but fine for me as the handling will be replaced with Compose anyway
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/5049-talk.apk |
Conversation List jumps to position of clicked conversation item when back pressed
ToDO
Current Implementation is quite simple though, requires keeping a reference to the item's viewHolder in
ConversationItem
. It's then gets the position of the first visible item and calculates the non visible offset to scroll by. The result is the exact position the user left off. Restored/Retrieved fromAppPreferences
.🖼️ Screenshots
Screen_recording_20250609_124059.webm
🏁 Checklist
/backport to stable-xx.x