kopia lustrzana https://github.com/ryukoposting/Signal-Android
rodzic
aa9d8e4d14
commit
e2b81c9637
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 629 B |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 416 B |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 692 B |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 1.3 KiB |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 498 B |
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
|
@ -11,26 +12,29 @@
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:cacheColorHint="?conversation_background" />
|
android:cacheColorHint="?conversation_background" />
|
||||||
|
|
||||||
|
|
||||||
<!--suppress AndroidLintUnusedAttribute-->
|
|
||||||
<View android:id="@+id/compose_divider"
|
<View android:id="@+id/compose_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="2dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:background="@drawable/compose_divider_background"
|
android:background="@drawable/compose_divider_background"
|
||||||
android:alpha="0"
|
android:alpha="1"
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<ImageButton
|
||||||
android:id="@+id/scroll_to_bottom_button"
|
android:id="@+id/scroll_to_bottom_button"
|
||||||
android:visibility="invisible"
|
android:visibility="gone"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/scroll_to_bottom_button_margin_end"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_marginRight="@dimen/scroll_to_bottom_button_margin_end"
|
android:layout_marginRight="10dp"
|
||||||
android:layout_marginBottom="@dimen/scroll_to_bottom_button_margin_bottom"
|
android:layout_marginBottom="10dp"
|
||||||
android:layout_gravity="bottom|end"
|
android:padding="5dp"
|
||||||
android:contentDescription="@string/conversation_fragment__scroll_to_the_bottom_content_description"
|
android:layout_gravity="bottom|end"
|
||||||
android:src="@drawable/ic_keyboard_arrow_down_white_36dp" />
|
android:background="@drawable/circle_tintable"
|
||||||
|
android:tint="@color/grey_600"
|
||||||
|
android:elevation="1dp"
|
||||||
|
android:alpha="0.9"
|
||||||
|
android:contentDescription="@string/conversation_fragment__scroll_to_the_bottom_content_description"
|
||||||
|
android:src="@drawable/ic_scroll_down"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -66,7 +66,4 @@
|
||||||
<dimen name="onboarding_subtitle_size">20sp</dimen>
|
<dimen name="onboarding_subtitle_size">20sp</dimen>
|
||||||
|
|
||||||
<dimen name="scribble_stroke_size">3dp</dimen>
|
<dimen name="scribble_stroke_size">3dp</dimen>
|
||||||
|
|
||||||
<dimen name="scroll_to_bottom_button_margin_end">10dp</dimen>
|
|
||||||
<dimen name="scroll_to_bottom_button_margin_bottom">10dp</dimen>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.database.Cursor;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
@ -44,6 +45,8 @@ import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ConversationAdapter.ItemClickListener;
|
import org.thoughtcrime.securesms.ConversationAdapter.ItemClickListener;
|
||||||
|
@ -79,7 +82,6 @@ public class ConversationFragment extends Fragment
|
||||||
|
|
||||||
private final ActionModeCallback actionModeCallback = new ActionModeCallback();
|
private final ActionModeCallback actionModeCallback = new ActionModeCallback();
|
||||||
private final ItemClickListener selectionClickListener = new ConversationFragmentItemClickListener();
|
private final ItemClickListener selectionClickListener = new ConversationFragmentItemClickListener();
|
||||||
private final OnScrollListener scrollListener = new ConversationScrollListener();
|
|
||||||
|
|
||||||
private ConversationFragmentListener listener;
|
private ConversationFragmentListener listener;
|
||||||
|
|
||||||
|
@ -117,7 +119,6 @@ public class ConversationFragment extends Fragment
|
||||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true);
|
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true);
|
||||||
list.setHasFixedSize(false);
|
list.setHasFixedSize(false);
|
||||||
list.setLayoutManager(layoutManager);
|
list.setLayoutManager(layoutManager);
|
||||||
list.addOnScrollListener(scrollListener);
|
|
||||||
list.setItemAnimator(null);
|
list.setItemAnimator(null);
|
||||||
|
|
||||||
loadMoreView = inflater.inflate(R.layout.load_more_header, container, false);
|
loadMoreView = inflater.inflate(R.layout.load_more_header, container, false);
|
||||||
|
@ -173,8 +174,11 @@ public class ConversationFragment extends Fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeResources() {
|
private void initializeResources() {
|
||||||
this.recipients = RecipientFactory.getRecipientsForIds(getActivity(), getActivity().getIntent().getLongArrayExtra("recipients"), true);
|
this.recipients = RecipientFactory.getRecipientsForIds(getActivity(), getActivity().getIntent().getLongArrayExtra("recipients"), true);
|
||||||
this.threadId = this.getActivity().getIntent().getLongExtra("thread_id", -1);
|
this.threadId = this.getActivity().getIntent().getLongExtra("thread_id", -1);
|
||||||
|
|
||||||
|
OnScrollListener scrollListener = new ConversationScrollListener(getActivity());
|
||||||
|
list.addOnScrollListener(scrollListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeListAdapter() {
|
private void initializeListAdapter() {
|
||||||
|
@ -408,26 +412,39 @@ public class ConversationFragment extends Fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ConversationScrollListener extends OnScrollListener {
|
private class ConversationScrollListener extends OnScrollListener {
|
||||||
private boolean wasAtBottom = true;
|
|
||||||
|
private final Animation scrollButtonInAnimation;
|
||||||
|
private final Animation scrollButtonOutAnimation;
|
||||||
|
|
||||||
|
private boolean wasAtBottom = true;
|
||||||
|
private boolean wasAtZoomScrollHeight = false;
|
||||||
|
|
||||||
|
ConversationScrollListener(@NonNull Context context) {
|
||||||
|
this.scrollButtonInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_scale_in);
|
||||||
|
this.scrollButtonOutAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_scale_out);
|
||||||
|
|
||||||
|
this.scrollButtonInAnimation.setDuration(100);
|
||||||
|
this.scrollButtonOutAnimation.setDuration(50);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(final RecyclerView rv, final int dx, final int dy) {
|
public void onScrolled(final RecyclerView rv, final int dx, final int dy) {
|
||||||
boolean currentlyAtBottom = isAtBottom();
|
boolean currentlyAtBottom = isAtBottom();
|
||||||
|
boolean currentlyAtZoomScrollHeight = isAtZoomScrollHeight();
|
||||||
|
|
||||||
if (wasAtBottom != currentlyAtBottom) {
|
if (currentlyAtBottom && !wasAtBottom) {
|
||||||
composeDivider.setVisibility(currentlyAtBottom ? View.INVISIBLE : View.VISIBLE);
|
ViewUtil.fadeOut(composeDivider, 50, View.INVISIBLE);
|
||||||
scrollToBottomButton.setVisibility(currentlyAtBottom ? View.INVISIBLE : View.VISIBLE);
|
ViewUtil.animateOut(scrollToBottomButton, scrollButtonOutAnimation, View.INVISIBLE);
|
||||||
|
} else if (!currentlyAtBottom && wasAtBottom) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
|
ViewUtil.fadeIn(composeDivider, 500);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentlyAtZoomScrollHeight && !wasAtZoomScrollHeight) {
|
||||||
|
ViewUtil.animateIn(scrollToBottomButton, scrollButtonInAnimation);
|
||||||
|
}
|
||||||
|
|
||||||
|
wasAtBottom = currentlyAtBottom;
|
||||||
|
wasAtZoomScrollHeight = currentlyAtZoomScrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAtBottom() {
|
private boolean isAtBottom() {
|
||||||
|
@ -439,6 +456,10 @@ public class ConversationFragment extends Fragment
|
||||||
|
|
||||||
return isAtBottom && bottomView.getBottom() <= list.getHeight();
|
return isAtBottom && bottomView.getBottom() <= list.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAtZoomScrollHeight() {
|
||||||
|
return ((LinearLayoutManager) list.getLayoutManager()).findFirstCompletelyVisibleItemPosition() > 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ConversationFragmentItemClickListener implements ItemClickListener {
|
private class ConversationFragmentItemClickListener implements ItemClickListener {
|
||||||
|
|
Ładowanie…
Reference in New Issue