summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuzhou Jia <jiayuzhou@google.com>2018-05-22 19:56:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-05-22 19:56:10 +0000
commite08e94d68133a37e3aa751b4eb75d14090752055 (patch)
tree440ca6f7d455bfca9de2ecaf10c11428b84dd1cc
parentb76e4095e6fd9ae459cfe7a5cb5ce95557447d38 (diff)
parente8901d7dac94f2dcbbecdfbdf484b9d0cff5783e (diff)
downloadDialer-e08e94d68133a37e3aa751b4eb75d14090752055.tar.gz
Merge "DO NOT MERGE Add a screen to accept or reject incoming call." into pi-dev
-rw-r--r--res/layout/ringing_call_controller_bar_fragment.xml49
-rw-r--r--src/com/android/car/dialer/TelecomActivity.java6
-rw-r--r--src/com/android/car/dialer/ui/InCallFragment.java20
-rw-r--r--src/com/android/car/dialer/ui/RingingCallControllerBarFragment.java51
4 files changed, 118 insertions, 8 deletions
diff --git a/res/layout/ringing_call_controller_bar_fragment.xml b/res/layout/ringing_call_controller_bar_fragment.xml
new file mode 100644
index 00000000..2dcced83
--- /dev/null
+++ b/res/layout/ringing_call_controller_bar_fragment.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<android.support.constraint.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_action_bar_height"
+ android:background="@color/phone_theme"
+ android:elevation = "@dimen/in_call_card_elevation">
+
+ <ImageView
+ android:id="@+id/answer_call_button"
+ android:layout_width="@dimen/fab_button_size"
+ android:layout_height="@dimen/fab_button_size"
+ android:scaleType="center"
+ android:src="@drawable/ic_phone"
+ android:tint="@color/phone_theme_light"
+ app:layout_constraintHorizontal_chainStyle="packed"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/end_call_button"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <ImageView
+ android:id="@+id/end_call_button"
+ android:layout_width="@dimen/fab_button_size"
+ android:layout_height="@dimen/fab_button_size"
+ android:layout_marginStart="@dimen/car_padding_6"
+ android:scaleType="center"
+ android:src="@drawable/ic_call_end"
+ android:tint="@color/phone_theme_light"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/answer_call_button"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+</android.support.constraint.ConstraintLayout>
diff --git a/src/com/android/car/dialer/TelecomActivity.java b/src/com/android/car/dialer/TelecomActivity.java
index 336192f1..0608990b 100644
--- a/src/com/android/car/dialer/TelecomActivity.java
+++ b/src/com/android/car/dialer/TelecomActivity.java
@@ -232,7 +232,7 @@ public class TelecomActivity extends CarDrawerActivity implements CallListener {
+ getCurrentFragment());
}
- if (ongoingCall == null && getCurrentFragment() instanceof OngoingCallFragment) {
+ if (ongoingCall == null && getCurrentFragment() instanceof InCallFragment) {
showSpeedDialFragment();
} else if (ongoingCall != null) {
showOngoingCallFragment();
@@ -263,14 +263,14 @@ public class TelecomActivity extends CarDrawerActivity implements CallListener {
if (vdebug()) {
Log.d(TAG, "showOngoingCallFragment");
}
- if (!mAllowFragmentCommits || getCurrentFragment() instanceof OngoingCallFragment) {
+ if (!mAllowFragmentCommits || getCurrentFragment() instanceof InCallFragment) {
// in case the dialer is still open, (e.g. when dialing the second phone during
// a phone call), close it
maybeHideDialer();
getDrawerController().closeDrawer();
return;
}
- Fragment fragment = OngoingCallFragment.newInstance(mUiCallManager, mUiBluetoothMonitor);
+ Fragment fragment = InCallFragment.newInstance();
setContentFragmentWithFadeAnimation(fragment);
getDrawerController().closeDrawer();
}
diff --git a/src/com/android/car/dialer/ui/InCallFragment.java b/src/com/android/car/dialer/ui/InCallFragment.java
index 4d88f1a2..2ad04ce2 100644
--- a/src/com/android/car/dialer/ui/InCallFragment.java
+++ b/src/com/android/car/dialer/ui/InCallFragment.java
@@ -66,11 +66,7 @@ public class InCallFragment extends Fragment implements
mUserProfileBodyText = mUserProfileContainerView.findViewById(R.id.body);
mDialerFragment = new DialerFragment();
- Fragment onGoingCallControllerBarFragment = OnGoingCallControllerBarFragment.newInstance();
-
- getChildFragmentManager().beginTransaction()
- .replace(R.id.controller_bar_container, onGoingCallControllerBarFragment)
- .commit();
+ updateControllerBarFragment(UiCallManager.get().getPrimaryCall().getState());
bindUserProfileView(fragmentView.findViewById(R.id.user_profile_container));
return fragmentView;
}
@@ -111,6 +107,19 @@ public class InCallFragment extends Fragment implements
mCallInfoLabel = TelecomUtils.getTypeFromNumber(getContext(), primaryCall.getNumber());
}
+ private void updateControllerBarFragment(int callState) {
+ Fragment controllerBarFragment;
+ if (callState == Call.STATE_RINGING) {
+ controllerBarFragment = RingingCallControllerBarFragment.newInstance();
+ } else {
+ controllerBarFragment = OnGoingCallControllerBarFragment.newInstance();
+ }
+
+ getChildFragmentManager().beginTransaction()
+ .replace(R.id.controller_bar_container, controllerBarFragment)
+ .commit();
+ }
+
@Override
public void onAudioStateChanged(boolean isMuted, int route, int supportedRouteMask) {
@@ -131,6 +140,7 @@ public class InCallFragment extends Fragment implements
break;
case Call.STATE_ACTIVE:
mHandler.post(mUpdateDurationRunnable);
+ updateControllerBarFragment(call.getState());
break;
}
}
diff --git a/src/com/android/car/dialer/ui/RingingCallControllerBarFragment.java b/src/com/android/car/dialer/ui/RingingCallControllerBarFragment.java
new file mode 100644
index 00000000..bedfe87a
--- /dev/null
+++ b/src/com/android/car/dialer/ui/RingingCallControllerBarFragment.java
@@ -0,0 +1,51 @@
+package com.android.car.dialer.ui;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import com.android.car.apps.common.FabDrawable;
+import com.android.car.dialer.R;
+import com.android.car.dialer.telecom.UiCall;
+import com.android.car.dialer.telecom.UiCallManager;
+
+public class RingingCallControllerBarFragment extends Fragment {
+
+ public static RingingCallControllerBarFragment newInstance() {
+ return new RingingCallControllerBarFragment();
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ View fragmentView = inflater.inflate(R.layout.ringing_call_controller_bar_fragment,
+ container, false);
+
+ ImageView endCallButton = fragmentView.findViewById(R.id.end_call_button);
+ FabDrawable endCallDrawable = new FabDrawable(getContext());
+ endCallDrawable.setFabAndStrokeColor(getContext().getColor(R.color.phone_end_call));
+ endCallButton.setBackground(endCallDrawable);
+ endCallButton.setOnClickListener((v) -> {
+ UiCallManager uiCallManager = UiCallManager.get();
+ UiCall primaryCall = uiCallManager.getPrimaryCall();
+ uiCallManager.rejectCall(primaryCall, false, null);
+ });
+
+ ImageView answerCallButton = fragmentView.findViewById(R.id.answer_call_button);
+ FabDrawable answerCallDrawable = new FabDrawable(getContext());
+ answerCallDrawable.setFabAndStrokeColor(getContext().getColor(R.color.phone_call));
+ answerCallButton.setBackground(answerCallDrawable);
+ answerCallButton.setOnClickListener((v) -> {
+ UiCallManager uiCallManager = UiCallManager.get();
+ UiCall primaryCall = uiCallManager.getPrimaryCall();
+ uiCallManager.answerCall(primaryCall);
+ });
+ return fragmentView;
+ }
+}