summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/rtt/impl/RttChatFragment.java
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-02-13 09:34:41 -0800
committerCopybara-Service <copybara-piper@google.com>2018-02-22 01:20:26 -0800
commit219b870aa9e9c4046ca1dd915d586010eec1b69f (patch)
treeca226e9143d0a0edd69f03ad49eacc254a910e23 /java/com/android/incallui/rtt/impl/RttChatFragment.java
parentc54ce2658988ca36ca3dfab00daefca4dcfed3b2 (diff)
Add simulator RTT call.
This change will also: 1. Disable proximity sensor for RTT call 2. Update RTT call screen, including colors and banner buttons Bug: 67596257 Test: presubmit PiperOrigin-RevId: 185541897 Change-Id: I571373efbb8ced4ee2ad94879e9d37bed33b6a28
Diffstat (limited to 'java/com/android/incallui/rtt/impl/RttChatFragment.java')
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatFragment.java223
1 files changed, 203 insertions, 20 deletions
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java
index 0b0ad2a8e..82dce3ed4 100644
--- a/java/com/android/incallui/rtt/impl/RttChatFragment.java
+++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java
@@ -16,21 +16,25 @@
package com.android.incallui.rtt.impl;
+import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnScrollListener;
+import android.telecom.CallAudioState;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.view.Window;
+import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Chronometer;
@@ -38,11 +42,31 @@ import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
+import com.android.dialer.common.Assert;
+import com.android.dialer.common.FragmentUtils;
+import com.android.dialer.common.LogUtil;
+import com.android.incallui.incall.protocol.InCallButtonUi;
+import com.android.incallui.incall.protocol.InCallButtonUiDelegate;
+import com.android.incallui.incall.protocol.InCallButtonUiDelegateFactory;
+import com.android.incallui.incall.protocol.InCallScreen;
+import com.android.incallui.incall.protocol.InCallScreenDelegate;
+import com.android.incallui.incall.protocol.InCallScreenDelegateFactory;
+import com.android.incallui.incall.protocol.PrimaryCallState;
+import com.android.incallui.incall.protocol.PrimaryInfo;
+import com.android.incallui.incall.protocol.SecondaryInfo;
import com.android.incallui.rtt.impl.RttChatAdapter.MessageListener;
+import com.android.incallui.rtt.protocol.RttCallScreen;
+import com.android.incallui.rtt.protocol.RttCallScreenDelegate;
+import com.android.incallui.rtt.protocol.RttCallScreenDelegateFactory;
/** RTT chat fragment to show chat bubbles. */
public class RttChatFragment extends Fragment
- implements OnClickListener, OnEditorActionListener, TextWatcher, MessageListener {
+ implements OnEditorActionListener,
+ TextWatcher,
+ MessageListener,
+ RttCallScreen,
+ InCallScreen,
+ InCallButtonUi {
private static final String ARG_CALL_ID = "call_id";
private static final String ARG_NAME_OR_NUMBER = "name_or_number";
@@ -63,27 +87,58 @@ public class RttChatFragment extends Fragment
}
}
};
+ private InCallScreenDelegate inCallScreenDelegate;
+ private RttCallScreenDelegate rttCallScreenDelegate;
+ private InCallButtonUiDelegate inCallButtonUiDelegate;
+ private View endCallButton;
/**
* Create a new instance of RttChatFragment.
*
* @param callId call id of the RTT call.
- * @param nameOrNumber name or number of the caller to be displayed
- * @param sessionStartTimeMillis start time of RTT session in terms of {@link
- * SystemClock#elapsedRealtime}.
* @return new RttChatFragment
*/
- public static RttChatFragment newInstance(
- String callId, String nameOrNumber, long sessionStartTimeMillis) {
+ public static RttChatFragment newInstance(String callId) {
Bundle bundle = new Bundle();
bundle.putString(ARG_CALL_ID, callId);
- bundle.putString(ARG_NAME_OR_NUMBER, nameOrNumber);
- bundle.putLong(ARG_SESSION_START_TIME, sessionStartTimeMillis);
+ bundle.putString(ARG_NAME_OR_NUMBER, "Jane Williamson");
+ bundle.putLong(ARG_SESSION_START_TIME, SystemClock.elapsedRealtime());
RttChatFragment instance = new RttChatFragment();
instance.setArguments(bundle);
return instance;
}
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ LogUtil.i("RttChatFragment.onCreate", null);
+ inCallButtonUiDelegate =
+ FragmentUtils.getParent(this, InCallButtonUiDelegateFactory.class)
+ .newInCallButtonUiDelegate();
+ if (savedInstanceState != null) {
+ inCallButtonUiDelegate.onRestoreInstanceState(savedInstanceState);
+ }
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle bundle) {
+ super.onViewCreated(view, bundle);
+ LogUtil.i("RttChatFragment.onViewCreated", null);
+
+ inCallScreenDelegate =
+ FragmentUtils.getParentUnsafe(this, InCallScreenDelegateFactory.class)
+ .newInCallScreenDelegate();
+ rttCallScreenDelegate =
+ FragmentUtils.getParentUnsafe(this, RttCallScreenDelegateFactory.class)
+ .newRttCallScreenDelegate(this);
+
+ rttCallScreenDelegate.initRttCallScreenDelegate(getContext(), this);
+
+ inCallScreenDelegate.onInCallScreenDelegateInit(this);
+ inCallScreenDelegate.onInCallScreenReady();
+ inCallButtonUiDelegate.onInCallButtonUiReady(this);
+ }
+
@Nullable
@Override
public View onCreateView(
@@ -101,8 +156,20 @@ public class RttChatFragment extends Fragment
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(onScrollListener);
submitButton = view.findViewById(R.id.rtt_chat_submit_button);
- submitButton.setOnClickListener(this);
+ submitButton.setOnClickListener(
+ v -> {
+ adapter.submitLocalMessage();
+ isClearingInput = true;
+ editText.setText("");
+ isClearingInput = false;
+ });
submitButton.setEnabled(false);
+ endCallButton = view.findViewById(R.id.rtt_end_call_button);
+ endCallButton.setOnClickListener(
+ v -> {
+ LogUtil.i("RttChatFragment.onClick", "end call button clicked");
+ inCallButtonUiDelegate.onEndCallClicked();
+ });
String nameOrNumber = null;
Bundle bundle = getArguments();
@@ -123,16 +190,6 @@ public class RttChatFragment extends Fragment
}
@Override
- public void onClick(View v) {
- if (v.getId() == R.id.rtt_chat_submit_button) {
- adapter.submitLocalMessage();
- isClearingInput = true;
- editText.setText("");
- isClearingInput = false;
- }
- }
-
- @Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
submitButton.performClick();
@@ -166,6 +223,20 @@ public class RttChatFragment extends Fragment
recyclerView.smoothScrollToPosition(adapter.getItemCount());
}
+ @Override
+ public void onStart() {
+ LogUtil.enterBlock("RttChatFragment.onStart");
+ super.onStart();
+ onRttScreenStart();
+ }
+
+ @Override
+ public void onStop() {
+ LogUtil.enterBlock("RttChatFragment.onStop");
+ super.onStop();
+ onRttScreenStop();
+ }
+
private void hideKeyboard() {
InputMethodManager inputMethodManager = getContext().getSystemService(InputMethodManager.class);
if (inputMethodManager.isAcceptingText()) {
@@ -173,4 +244,116 @@ public class RttChatFragment extends Fragment
getActivity().getCurrentFocus().getWindowToken(), 0);
}
}
+
+ @Override
+ public void onRttScreenStart() {
+ rttCallScreenDelegate.onRttCallScreenUiReady();
+ Activity activity = getActivity();
+ Window window = getActivity().getWindow();
+ window.setStatusBarColor(activity.getColor(R.color.rtt_status_bar_color));
+ window.setNavigationBarColor(activity.getColor(R.color.rtt_navigation_bar_color));
+ window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
+ }
+
+ @Override
+ public void onRttScreenStop() {
+ rttCallScreenDelegate.onRttCallScreenUiUnready();
+ }
+
+ @Override
+ public Fragment getRttCallScreenFragment() {
+ return this;
+ }
+
+ @Override
+ public String getCallId() {
+ return Assert.isNotNull(getArguments().getString(ARG_CALL_ID));
+ }
+
+ @Override
+ public void setPrimary(@NonNull PrimaryInfo primaryInfo) {
+ LogUtil.i("RttChatFragment.setPrimary", primaryInfo.toString());
+ }
+
+ @Override
+ public void setSecondary(@NonNull SecondaryInfo secondaryInfo) {}
+
+ @Override
+ public void setCallState(@NonNull PrimaryCallState primaryCallState) {}
+
+ @Override
+ public void setEndCallButtonEnabled(boolean enabled, boolean animate) {}
+
+ @Override
+ public void showManageConferenceCallButton(boolean visible) {}
+
+ @Override
+ public boolean isManageConferenceVisible() {
+ return false;
+ }
+
+ @Override
+ public void dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {}
+
+ @Override
+ public void showNoteSentToast() {}
+
+ @Override
+ public void updateInCallScreenColors() {}
+
+ @Override
+ public void onInCallScreenDialpadVisibilityChange(boolean isShowing) {}
+
+ @Override
+ public int getAnswerAndDialpadContainerResourceId() {
+ return 0;
+ }
+
+ @Override
+ public void showLocationUi(Fragment locationUi) {}
+
+ @Override
+ public boolean isShowingLocationUi() {
+ return false;
+ }
+
+ @Override
+ public Fragment getInCallScreenFragment() {
+ return this;
+ }
+
+ @Override
+ public void showButton(int buttonId, boolean show) {}
+
+ @Override
+ public void enableButton(int buttonId, boolean enable) {}
+
+ @Override
+ public void setEnabled(boolean on) {}
+
+ @Override
+ public void setHold(boolean on) {}
+
+ @Override
+ public void setCameraSwitched(boolean isBackFacingCamera) {}
+
+ @Override
+ public void setVideoPaused(boolean isPaused) {}
+
+ @Override
+ public void setAudioState(CallAudioState audioState) {}
+
+ @Override
+ public void updateButtonStates() {}
+
+ @Override
+ public void updateInCallButtonUiColors(int color) {}
+
+ @Override
+ public Fragment getInCallButtonUiFragment() {
+ return this;
+ }
+
+ @Override
+ public void showAudioRouteSelector() {}
}