summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/rtt
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-03-29 16:13:00 -0700
committerCopybara-Service <copybara-piper@google.com>2018-03-29 17:21:15 -0700
commit2789d6a0014209f7bafa8a8cc15f88b1edfa3f61 (patch)
tree91e691c7d40231dff2223be410624da8755a4f06 /java/com/android/incallui/rtt
parentd6a2f81c52918e1d988979c83dcb779087c2ed13 (diff)
UI adjustment to RTT screen.
1. Don't close overflow menu after menu item is clicked. 2. Add correct shadow and animation to overflow menu. 3. Only scroll when remote message is updated if input box is empty. 4. Only hide keyboard if scrolling up is triggered by user. 5. Add paddingTop to recyclerView so that first message won't be covered by toolbar. Bug: 70177426 Test: manual PiperOrigin-RevId: 191002774 Change-Id: Ic69f80323e3d31d7853d4e8d0c6e4c100fe4a776
Diffstat (limited to 'java/com/android/incallui/rtt')
-rw-r--r--java/com/android/incallui/rtt/impl/AudioSelectMenu.java3
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatAdapter.java8
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatFragment.java53
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatMessage.java2
-rw-r--r--java/com/android/incallui/rtt/impl/RttOverflowMenu.java4
-rw-r--r--java/com/android/incallui/rtt/impl/res/drawable/overflow_menu_background.xml2
-rw-r--r--java/com/android/incallui/rtt/impl/res/layout/audio_route.xml1
-rw-r--r--java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml1
-rw-r--r--java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml1
-rw-r--r--java/com/android/incallui/rtt/impl/res/values/dimens.xml1
-rw-r--r--java/com/android/incallui/rtt/impl/res/values/styles.xml6
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