diff options
author | Yuzhou Jia <jiayuzhou@google.com> | 2018-04-20 17:27:22 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-20 17:27:22 +0000 |
commit | 94d5c5e9a9a49977da0d9de2851e8901b2f398b8 (patch) | |
tree | c20f7eeb395035af715296e59c21d30b0f8c8ddf | |
parent | 5ac6c2bd11f3353edde0389c3eeda4775e1107ed (diff) | |
parent | e2a2ef40b2493367402e658c5e8f285124399e82 (diff) | |
download | platform_packages_apps_Car_Dialer-94d5c5e9a9a49977da0d9de2851e8901b2f398b8.tar.gz platform_packages_apps_Car_Dialer-94d5c5e9a9a49977da0d9de2851e8901b2f398b8.tar.bz2 platform_packages_apps_Car_Dialer-94d5c5e9a9a49977da0d9de2851e8901b2f398b8.zip |
Merge "Implement the fragment of in call control bar." into pi-dev
-rw-r--r-- | Android.mk | 3 | ||||
-rw-r--r-- | res/drawable/ic_bluetooth.xml | 24 | ||||
-rw-r--r-- | res/drawable/ic_pause.xml | 24 | ||||
-rw-r--r-- | res/drawable/in_call_card_background.xml | 15 | ||||
-rw-r--r-- | res/layout/on_going_call_controller_bar_fragment.xml | 89 | ||||
-rw-r--r-- | res/values/dimens.xml | 3 | ||||
-rw-r--r-- | src/com/android/car/dialer/ui/OnGoingCallControllerBarFragment.java | 123 |
7 files changed, 280 insertions, 1 deletions
@@ -36,7 +36,10 @@ LOCAL_STATIC_ANDROID_LIBRARIES += \ car-apps-common \ car-stream-ui-lib \ android-arch-lifecycle-extensions \ + android-support-constraint-layout \ +LOCAL_STATIC_JAVA_LIBRARIES := \ + android-support-constraint-layout-solver LOCAL_PROGUARD_ENABLED := disabled diff --git a/res/drawable/ic_bluetooth.xml b/res/drawable/ic_bluetooth.xml new file mode 100644 index 00000000..f1f5dcc3 --- /dev/null +++ b/res/drawable/ic_bluetooth.xml @@ -0,0 +1,24 @@ +<?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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FF000000" + android:pathData="M14.24,12.01l2.32,2.32c0.28,-0.72 0.44,-1.51 0.44,-2.33 0,-0.82 -0.16,-1.59 -0.43,-2.31l-2.33,2.32zM19.53,6.71l-1.26,1.26c0.63,1.21 0.98,2.57 0.98,4.02s-0.36,2.82 -0.98,4.02l1.2,1.2c0.97,-1.54 1.54,-3.36 1.54,-5.31 -0.01,-1.89 -0.55,-3.67 -1.48,-5.19zM15.71,7.71L10,2L9,2v7.59L4.41,5 3,6.41 8.59,12 3,17.59 4.41,19 9,14.41L9,22h1l5.71,-5.71 -4.3,-4.29 4.3,-4.29zM11,5.83l1.88,1.88L11,9.59L11,5.83zM12.88,16.29L11,18.17v-3.76l1.88,1.88z"/> +</vector> diff --git a/res/drawable/ic_pause.xml b/res/drawable/ic_pause.xml new file mode 100644 index 00000000..8cdf142d --- /dev/null +++ b/res/drawable/ic_pause.xml @@ -0,0 +1,24 @@ +<?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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FF000000" + android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/> +</vector> diff --git a/res/drawable/in_call_card_background.xml b/res/drawable/in_call_card_background.xml index db61e98e..f1e45400 100644 --- a/res/drawable/in_call_card_background.xml +++ b/res/drawable/in_call_card_background.xml @@ -1,3 +1,18 @@ +<?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. +--> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/car_card" /> <corners diff --git a/res/layout/on_going_call_controller_bar_fragment.xml b/res/layout/on_going_call_controller_bar_fragment.xml new file mode 100644 index 00000000..e3a42278 --- /dev/null +++ b/res/layout/on_going_call_controller_bar_fragment.xml @@ -0,0 +1,89 @@ +<?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" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/rail" + android:layout_width="match_parent" + android:layout_height="@dimen/in_call_card_height" + android:elevation = "@dimen/in_call_card_elevation" + android:background="@drawable/in_call_card_background"> + <ImageView + android:id="@+id/mute_button" + android:layout_width="@dimen/in_call_button_size" + android:layout_height="@dimen/in_call_button_size" + android:scaleType="centerCrop" + android:src="@drawable/ic_mute" + android:tint="@android:color/white" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toStartOf="@+id/toggle_dialpad_button" + app:layout_constraintTop_toTopOf="parent" + tools:src="@color/contact_badge"/> + + <ImageView + android:id="@+id/toggle_dialpad_button" + android:layout_width="@dimen/in_call_button_size" + android:layout_height="@dimen/in_call_button_size" + android:scaleType="centerCrop" + android:src="@drawable/ic_dialpad" + android:tint="@android:color/white" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/mute_button" + app:layout_constraintEnd_toStartOf="@+id/end_call_button" + app:layout_constraintTop_toTopOf="parent" + tools:src="@color/contact_badge"/> + + <ImageView + android:id="@+id/end_call_button" + android:layout_width="@dimen/in_call_button_size" + android:layout_height="@dimen/in_call_button_size" + android:scaleType="centerCrop" + android:src="@drawable/ic_call_end" + android:tint="@android:color/holo_red_dark" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/toggle_dialpad_button" + app:layout_constraintEnd_toStartOf="@+id/voice_channel_button" + app:layout_constraintTop_toTopOf="parent" + tools:src="@color/contact_badge"/> + + <ImageView + android:id="@+id/voice_channel_button" + android:layout_width="@dimen/in_call_button_size" + android:layout_height="@dimen/in_call_button_size" + android:scaleType="centerCrop" + android:src="@drawable/ic_bluetooth" + android:tint="@android:color/white" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/end_call_button" + app:layout_constraintEnd_toStartOf="@+id/pause_button" + app:layout_constraintTop_toTopOf="parent" + tools:src="@color/contact_badge"/> + + <ImageView + android:id="@+id/pause_button" + android:layout_width="@dimen/in_call_button_size" + android:layout_height="@dimen/in_call_button_size" + android:scaleType="centerCrop" + android:src="@drawable/ic_pause" + android:tint="@android:color/white" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toEndOf="@+id/voice_channel_button" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:src="@color/contact_badge"/> +</android.support.constraint.ConstraintLayout>
\ No newline at end of file diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 22e63d45..7aba71c6 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -36,6 +36,7 @@ <dimen name="in_call_toggle_button_image_offset">30dp</dimen> <dimen name="in_call_info_margin_top">72dp</dimen> <dimen name="in_call_card_elevation">12dp</dimen> + <dimen name="in_call_card_height">200dp</dimen> <!-- This should be -1 * in_call_card_right_margin --> <dimen name="in_call_card_dialpad_translation_x">-308dp</dimen> @@ -63,7 +64,7 @@ <dimen name="call_log_icon_margin">4dp</dimen> <dimen name="call_log_item_height">91dp</dimen> <dimen name="call_log_icon_size">@dimen/car_primary_icon_size</dimen> - <dimen name="car_card_view_corner_radius">0dp</dimen> + <dimen name="car_card_view_corner_radius">2dp</dimen> <dimen name="icon_container_height">@dimen/car_primary_icon_size</dimen> diff --git a/src/com/android/car/dialer/ui/OnGoingCallControllerBarFragment.java b/src/com/android/car/dialer/ui/OnGoingCallControllerBarFragment.java new file mode 100644 index 00000000..f34b936f --- /dev/null +++ b/src/com/android/car/dialer/ui/OnGoingCallControllerBarFragment.java @@ -0,0 +1,123 @@ +/* + * 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. + */ +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 com.android.car.dialer.R; + +/** + * A Fragment of the bar which controls on going call. Its host or parent Fragment is expected to + * implement {@link OnGoingCallControllerBarCallback}. + */ +public class OnGoingCallControllerBarFragment extends Fragment { + + public static OnGoingCallControllerBarFragment newInstance() { + return new OnGoingCallControllerBarFragment(); + } + + /** + * Callback for control bar buttons. + */ + public interface OnGoingCallControllerBarCallback { + void onEndCall(); + + void onOpenDialpad(); + + void onCloseDialpad(); + + void onMuteMic(); + + void onUnmuteMic(); + + void onPauseCall(); + + void onResumeCall(); + + void onVoiceOutputChannelChanged(int channel); + } + + private OnGoingCallControllerBarCallback mOnGoingCallControllerBarCallback; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getParentFragment() != null + && getParentFragment() instanceof OnGoingCallControllerBarCallback) { + mOnGoingCallControllerBarCallback = + (OnGoingCallControllerBarCallback) getParentFragment(); + } else if (getHost() instanceof OnGoingCallControllerBarCallback) { + mOnGoingCallControllerBarCallback = (OnGoingCallControllerBarCallback) getHost(); + } + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + View fragmentView = inflater.inflate(R.layout.on_going_call_controller_bar_fragment, + container, false); + fragmentView.findViewById(R.id.mute_button).setOnClickListener((v) -> { + if (mOnGoingCallControllerBarCallback == null) { + return; + } + if (v.isActivated()) { + mOnGoingCallControllerBarCallback.onMuteMic(); + } else { + mOnGoingCallControllerBarCallback.onUnmuteMic(); + } + }); + + fragmentView.findViewById(R.id.toggle_dialpad_button).setOnClickListener((v) -> { + if (mOnGoingCallControllerBarCallback == null) { + return; + } + if (v.isActivated()) { + mOnGoingCallControllerBarCallback.onCloseDialpad(); + } else { + mOnGoingCallControllerBarCallback.onOpenDialpad(); + } + }); + + fragmentView.findViewById(R.id.end_call_button).setOnClickListener((v) -> { + if (mOnGoingCallControllerBarCallback == null) { + return; + } + mOnGoingCallControllerBarCallback.onEndCall(); + }); + + fragmentView.findViewById(R.id.voice_channel_button).setOnClickListener((v) -> { + }); + + fragmentView.findViewById(R.id.pause_button).setOnClickListener((v) -> { + if (mOnGoingCallControllerBarCallback == null) { + return; + } + if (v.isActivated()) { + mOnGoingCallControllerBarCallback.onPauseCall(); + } else { + mOnGoingCallControllerBarCallback.onResumeCall(); + } + }); + return fragmentView; + } +} |