mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 19:28:26 +00:00
Add shadow under compose view on scroll
Fixes #5098 Closes #5796 // FREEBIE
This commit is contained in:
parent
b8d938a020
commit
0a72f6b32e
8
res/drawable/compose_divider_background.xml
Normal file
8
res/drawable/compose_divider_background.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:dither="true"
|
||||
android:endColor="@android:color/transparent"
|
||||
android:startColor="@color/conversation_compose_divider" />
|
||||
</shape>
|
@ -1,16 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:cacheColorHint="?conversation_background" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!--suppress AndroidLintUnusedAttribute-->
|
||||
<View android:id="@+id/compose_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/compose_divider_background"
|
||||
android:alpha="0"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</FrameLayout>
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
<color name="gray95_transparent50">#7F111111</color>
|
||||
|
||||
<color name="conversation_compose_divider">#32000000</color>
|
||||
|
||||
<color name="conversation_list_item_background_read_light">@color/gray5</color>
|
||||
<color name="conversation_list_item_background_unread_light">#ffffffff</color>
|
||||
<color name="conversation_list_item_background_read_dark">#ff000000</color>
|
||||
|
@ -33,6 +33,7 @@ import android.support.v7.view.ActionMode;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.ItemAnimator.ItemAnimatorFinishedListener;
|
||||
import android.support.v7.widget.RecyclerView.OnScrollListener;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@ -78,6 +79,7 @@ public class ConversationFragment extends Fragment
|
||||
|
||||
private final ActionModeCallback actionModeCallback = new ActionModeCallback();
|
||||
private final ItemClickListener selectionClickListener = new ConversationFragmentItemClickListener();
|
||||
private final OnScrollListener scrollListener = new ConversationScrollListener();
|
||||
|
||||
private ConversationFragmentListener listener;
|
||||
|
||||
@ -88,6 +90,7 @@ public class ConversationFragment extends Fragment
|
||||
private Locale locale;
|
||||
private RecyclerView list;
|
||||
private View loadMoreView;
|
||||
private View composeDivider;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@ -99,10 +102,13 @@ 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);
|
||||
list = ViewUtil.findById(view, android.R.id.list);
|
||||
composeDivider = ViewUtil.findById(view, R.id.compose_divider);
|
||||
|
||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true);
|
||||
list.setHasFixedSize(false);
|
||||
list.setLayoutManager(layoutManager);
|
||||
list.addOnScrollListener(scrollListener);
|
||||
|
||||
loadMoreView = inflater.inflate(R.layout.load_more_header, container, false);
|
||||
loadMoreView.setOnClickListener(new OnClickListener() {
|
||||
@ -395,6 +401,37 @@ public class ConversationFragment extends Fragment
|
||||
void setThreadId(long threadId);
|
||||
}
|
||||
|
||||
private class ConversationScrollListener extends OnScrollListener {
|
||||
private boolean wasAtBottom = true;
|
||||
|
||||
@Override
|
||||
public void onScrolled(final RecyclerView rv, final int dx, final int dy) {
|
||||
boolean currentlyAtBottom = isAtBottom();
|
||||
|
||||
if (wasAtBottom != currentlyAtBottom) {
|
||||
composeDivider.setVisibility(currentlyAtBottom ? View.INVISIBLE : View.VISIBLE);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
|
||||
composeDivider.animate().alpha(currentlyAtBottom ? 0 : 1);
|
||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
|
||||
composeDivider.setAlpha(currentlyAtBottom ? 0 : 1);
|
||||
}
|
||||
|
||||
wasAtBottom = currentlyAtBottom;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAtBottom() {
|
||||
if (list.getChildCount() == 0) return true;
|
||||
|
||||
View bottomView = list.getChildAt(0);
|
||||
int firstVisibleItem = ((LinearLayoutManager) list.getLayoutManager()).findFirstVisibleItemPosition();
|
||||
boolean isAtBottom = (firstVisibleItem == 0);
|
||||
|
||||
return isAtBottom && bottomView.getBottom() <= list.getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
private class ConversationFragmentItemClickListener implements ItemClickListener {
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user