diff options
author | wangqi <wangqi@google.com> | 2018-03-30 02:05:36 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-03-30 02:05:36 +0000 |
commit | b9e40e19aba398bb774116f3bba889d4a724d2ef (patch) | |
tree | a9362c7a33282bc12dab257884793265519035ac | |
parent | 28a773341687fad5922744a0a8815bebbbc530ae (diff) | |
parent | c3fe30d86f0ff844991de4b712b0bb3de671526a (diff) |
Merge "UI adjustment to RTT screen." am: 26bc51ec4b
am: c3fe30d86f
Change-Id: Iea18b8c40ceef18db9f693bfeca11cbc0f62b134
11 files changed, 58 insertions, 24 deletions
diff --git a/java/com/android/incallui/rtt/impl/AudioSelectMenu.java b/java/com/android/incallui/rtt/impl/AudioSelectMenu.java index 2d4ab3989..01c3950e9 100644 --- a/java/com/android/incallui/rtt/impl/AudioSelectMenu.java +++ b/java/com/android/incallui/rtt/impl/AudioSelectMenu.java @@ -39,7 +39,7 @@ public class AudioSelectMenu extends PopupWindow { Context context, InCallButtonUiDelegate inCallButtonUiDelegate, OnButtonClickListener onButtonClickListener) { - super(context); + super(context, null, 0, R.style.OverflowMenu); this.context = context; this.inCallButtonUiDelegate = inCallButtonUiDelegate; this.onButtonClickListener = onButtonClickListener; @@ -76,7 +76,6 @@ public class AudioSelectMenu extends PopupWindow { } item.setOnClickListener( (v) -> { - dismiss(); inCallButtonUiDelegate.setAudioRoute(itemRoute); }); } diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java index 8d924c9f8..955fc9fec 100644 --- a/java/com/android/incallui/rtt/impl/RttChatAdapter.java +++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java @@ -33,7 +33,9 @@ import java.util.List; public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolder> { interface MessageListener { - void newMessageAdded(); + void onUpdateRemoteMessage(int position); + + void onUpdateLocalMessage(int position); } private static final String KEY_MESSAGE_DATA = "key_message_data"; @@ -114,7 +116,7 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde void addLocalMessage(String message) { updateCurrentLocalMessage(message); if (messageListener != null) { - messageListener.newMessageAdded(); + messageListener.onUpdateLocalMessage(lastIndexOfLocalMessage); } } @@ -143,7 +145,7 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde } updateCurrentRemoteMessage(message); if (messageListener != null) { - messageListener.newMessageAdded(); + messageListener.onUpdateRemoteMessage(RttChatMessage.getLastIndexRemoteMessage(rttMessages)); } } diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index 56ac2429c..a181f88f0 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -85,15 +85,6 @@ public class RttChatFragment extends Fragment private ImageButton submitButton; private boolean isClearingInput; - private final OnScrollListener onScrollListener = - new OnScrollListener() { - @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - if (dy < 0) { - UiUtil.hideKeyboardFrom(getContext(), editText); - } - } - }; private InCallScreenDelegate inCallScreenDelegate; private RttCallScreenDelegate rttCallScreenDelegate; private InCallButtonUiDelegate inCallButtonUiDelegate; @@ -105,6 +96,8 @@ public class RttChatFragment extends Fragment private SecondaryInfo savedSecondaryInfo; private TextView statusBanner; private PrimaryInfo primaryInfo; + private boolean isUserScrolling; + private boolean shouldAutoScrolling; /** * Create a new instance of RttChatFragment. @@ -193,7 +186,27 @@ public class RttChatFragment extends Fragment recyclerView.setHasFixedSize(false); adapter = new RttChatAdapter(getContext(), this, savedInstanceState); recyclerView.setAdapter(adapter); - recyclerView.addOnScrollListener(onScrollListener); + recyclerView.addOnScrollListener( + new OnScrollListener() { + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int i) { + if (i == RecyclerView.SCROLL_STATE_DRAGGING) { + isUserScrolling = true; + } else if (i == RecyclerView.SCROLL_STATE_IDLE) { + isUserScrolling = false; + // Auto scrolling for new messages should be resumed if it's scrolled to bottom. + shouldAutoScrolling = !recyclerView.canScrollVertically(1); + } + } + + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + if (dy < 0 && isUserScrolling) { + UiUtil.hideKeyboardFrom(getContext(), editText); + } + } + }); + submitButton = view.findViewById(R.id.rtt_chat_submit_button); submitButton.setOnClickListener( v -> { @@ -202,6 +215,9 @@ public class RttChatFragment extends Fragment editText.setText(""); isClearingInput = false; rttCallScreenDelegate.onLocalMessage(Constants.BUBBLE_BREAKER); + // Auto scrolling for new messages should be resumed since user has submit current + // message. + shouldAutoScrolling = true; }); submitButton.setEnabled(false); endCallButton = view.findViewById(R.id.rtt_end_call_button); @@ -276,8 +292,21 @@ public class RttChatFragment extends Fragment } @Override - public void newMessageAdded() { - recyclerView.smoothScrollToPosition(adapter.getItemCount()); + public void onUpdateLocalMessage(int position) { + if (position < 0) { + return; + } + recyclerView.smoothScrollToPosition(position); + } + + @Override + public void onUpdateRemoteMessage(int position) { + if (position < 0) { + return; + } + if (shouldAutoScrolling) { + recyclerView.smoothScrollToPosition(position); + } } @Override diff --git a/java/com/android/incallui/rtt/impl/RttChatMessage.java b/java/com/android/incallui/rtt/impl/RttChatMessage.java index cbc53ef15..0060b1bd1 100644 --- a/java/com/android/incallui/rtt/impl/RttChatMessage.java +++ b/java/com/android/incallui/rtt/impl/RttChatMessage.java @@ -162,7 +162,7 @@ final class RttChatMessage implements Parcelable { return i; } - private static int getLastIndexRemoteMessage(List<RttChatMessage> messageList) { + static int getLastIndexRemoteMessage(List<RttChatMessage> messageList) { int i = messageList.size() - 1; while (i >= 0 && !messageList.get(i).isRemote) { i--; diff --git a/java/com/android/incallui/rtt/impl/RttOverflowMenu.java b/java/com/android/incallui/rtt/impl/RttOverflowMenu.java index 6a7aeba96..deee8ee15 100644 --- a/java/com/android/incallui/rtt/impl/RttOverflowMenu.java +++ b/java/com/android/incallui/rtt/impl/RttOverflowMenu.java @@ -42,7 +42,7 @@ public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListe Context context, InCallButtonUiDelegate inCallButtonUiDelegate, InCallScreenDelegate inCallScreenDelegate) { - super(context); + super(context, null, 0, R.style.OverflowMenu); this.inCallButtonUiDelegate = inCallButtonUiDelegate; this.inCallScreenDelegate = inCallScreenDelegate; View view = View.inflate(context, R.layout.overflow_menu, null); @@ -67,7 +67,6 @@ public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListe if (isSwitchToSecondaryButtonEnabled) { this.inCallScreenDelegate.onSecondaryInfoClicked(); } - dismiss(); }); } @@ -80,7 +79,6 @@ public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListe } else if (button == dialpadButton) { inCallButtonUiDelegate.showDialpadClicked(isChecked); } - dismiss(); } void setMuteButtonChecked(boolean isChecked) { diff --git a/java/com/android/incallui/rtt/impl/res/drawable/overflow_menu_background.xml b/java/com/android/incallui/rtt/impl/res/drawable/overflow_menu_background.xml index 614298679..2af14fd8e 100644 --- a/java/com/android/incallui/rtt/impl/res/drawable/overflow_menu_background.xml +++ b/java/com/android/incallui/rtt/impl/res/drawable/overflow_menu_background.xml @@ -18,4 +18,4 @@ android:shape="rectangle"> <solid android:color="@android:color/white"/> <corners android:radius="2dp"/> -</shape>
\ No newline at end of file +</shape> diff --git a/java/com/android/incallui/rtt/impl/res/layout/audio_route.xml b/java/com/android/incallui/rtt/impl/res/layout/audio_route.xml index 89b5c76f0..f098316a1 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/audio_route.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/audio_route.xml @@ -20,7 +20,6 @@ android:layout_height="wrap_content" android:paddingTop="8dp" android:paddingBottom="8dp" - android:background="@drawable/overflow_menu_background" android:orientation="vertical"> <com.android.incallui.rtt.impl.RttCheckableButton android:id="@+id/audioroute_back" diff --git a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml index 34a99544a..ea7ff1095 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml @@ -23,6 +23,7 @@ android:id="@+id/rtt_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:paddingTop="70dp" android:paddingBottom="70dp" android:clipToPadding="false"/> diff --git a/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml b/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml index eb7e38691..0ec36f33e 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml @@ -20,7 +20,6 @@ android:layout_height="wrap_content" android:paddingTop="8dp" android:paddingBottom="8dp" - android:background="@drawable/overflow_menu_background" android:orientation="vertical"> <com.android.incallui.rtt.impl.RttCheckableButton android:id="@+id/menu_mute" diff --git a/java/com/android/incallui/rtt/impl/res/values/dimens.xml b/java/com/android/incallui/rtt/impl/res/values/dimens.xml index 4c3fe02d2..a6418d70e 100644 --- a/java/com/android/incallui/rtt/impl/res/values/dimens.xml +++ b/java/com/android/incallui/rtt/impl/res/values/dimens.xml @@ -18,4 +18,5 @@ <dimen name="rtt_message_margin_top">16dp</dimen> <dimen name="rtt_same_group_message_margin_top">2dp</dimen> <dimen name="rtt_overflow_menu_width">180dp</dimen> + <dimen name="rtt_overflow_menu_elevation">8dp</dimen> </resources>
\ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/values/styles.xml b/java/com/android/incallui/rtt/impl/res/values/styles.xml index bbacde813..667cd1241 100644 --- a/java/com/android/incallui/rtt/impl/res/values/styles.xml +++ b/java/com/android/incallui/rtt/impl/res/values/styles.xml @@ -40,4 +40,10 @@ <item name="android:theme">@style/ButtonTheme</item> <item name="android:background">?attr/selectableItemBackground</item> </style> + + <style name="OverflowMenu"> + <item name="android:popupAnimationStyle">@android:style/Animation.Dialog</item> + <item name="android:popupBackground">@drawable/overflow_menu_background</item> + <item name="android:popupElevation">@dimen/rtt_overflow_menu_elevation</item> + </style> </resources>
\ No newline at end of file |