Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26bc51ec authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "UI adjustment to RTT screen."

parents d3d4066f 2789d6a0
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
        });
  }
+5 −3
Original line number Diff line number Diff line
@@ -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));
    }
  }

+41 −12
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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--;
+1 −3
Original line number Diff line number Diff line
@@ -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) {
Loading