mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-13 13:32:45 +00:00
Add scroll to bottom button in conversation view
Added a FloatingActionButton to the conversation_fragment that appears and disappears using the same logic as the existing compose divider: appear when the conversation list is scrolled away from the bottom, disappear when the list is scrolled to the bottom. Fixes #5651
This commit is contained in:
committed by
Moxie Marlinspike
parent
4c815db076
commit
aa9d8e4d14
@@ -91,6 +91,7 @@ public class ConversationFragment extends Fragment
|
||||
private RecyclerView list;
|
||||
private View loadMoreView;
|
||||
private View composeDivider;
|
||||
private View scrollToBottomButton;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -102,8 +103,16 @@ public class ConversationFragment extends Fragment
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
final View view = inflater.inflate(R.layout.conversation_fragment, container, false);
|
||||
list = ViewUtil.findById(view, android.R.id.list);
|
||||
composeDivider = ViewUtil.findById(view, R.id.compose_divider);
|
||||
list = ViewUtil.findById(view, android.R.id.list);
|
||||
composeDivider = ViewUtil.findById(view, R.id.compose_divider);
|
||||
scrollToBottomButton = ViewUtil.findById(view, R.id.scroll_to_bottom_button);
|
||||
|
||||
scrollToBottomButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
scrollToBottom();
|
||||
}
|
||||
});
|
||||
|
||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true);
|
||||
list.setHasFixedSize(false);
|
||||
@@ -407,11 +416,14 @@ public class ConversationFragment extends Fragment
|
||||
|
||||
if (wasAtBottom != currentlyAtBottom) {
|
||||
composeDivider.setVisibility(currentlyAtBottom ? View.INVISIBLE : View.VISIBLE);
|
||||
scrollToBottomButton.setVisibility(currentlyAtBottom ? View.INVISIBLE : View.VISIBLE);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
|
||||
composeDivider.animate().alpha(currentlyAtBottom ? 0 : 1);
|
||||
scrollToBottomButton.animate().alpha(currentlyAtBottom ? 0 : 1);
|
||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
|
||||
composeDivider.setAlpha(currentlyAtBottom ? 0 : 1);
|
||||
scrollToBottomButton.setAlpha(currentlyAtBottom ? 0 : 1);
|
||||
}
|
||||
|
||||
wasAtBottom = currentlyAtBottom;
|
||||
|
||||
Reference in New Issue
Block a user