Faster Emergency Dialer new UI design
- Change the layout parameter to match UI guideline.
- Emergency info button need double tap to launch Emergency information.
- Emergency info button vertical margin will changed when emergency
shortcut button more than 2.
Test: Manually
Bug: 112168722
Bug: 111967652
Change-Id: Ibdd105e6da9f4c9b548b83420ba1b27ef88c82b9
Merged-In: Ibdd105e6da9f4c9b548b83420ba1b27ef88c82b9
diff --git a/res/drawable-hdpi/ic_emergency_number_24.png b/res/drawable-hdpi/ic_emergency_number_24.png
deleted file mode 100644
index d5c0b28..0000000
--- a/res/drawable-hdpi/ic_emergency_number_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_fire_white_24.png b/res/drawable-hdpi/ic_fire_white_24.png
deleted file mode 100644
index 0c0c6ed..0000000
--- a/res/drawable-hdpi/ic_fire_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_shield_white_24.png b/res/drawable-hdpi/ic_shield_white_24.png
deleted file mode 100644
index bf23794..0000000
--- a/res/drawable-hdpi/ic_shield_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_emergency_number_24.png b/res/drawable-mdpi/ic_emergency_number_24.png
deleted file mode 100644
index 3db2d19..0000000
--- a/res/drawable-mdpi/ic_emergency_number_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_fire_white_24.png b/res/drawable-mdpi/ic_fire_white_24.png
deleted file mode 100644
index de8fda9..0000000
--- a/res/drawable-mdpi/ic_fire_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_shield_white_24.png b/res/drawable-mdpi/ic_shield_white_24.png
deleted file mode 100644
index 9a5d958..0000000
--- a/res/drawable-mdpi/ic_shield_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_emergency_number_24.png b/res/drawable-xhdpi/ic_emergency_number_24.png
deleted file mode 100644
index b538c02..0000000
--- a/res/drawable-xhdpi/ic_emergency_number_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_fire_white_24.png b/res/drawable-xhdpi/ic_fire_white_24.png
deleted file mode 100644
index 750072e..0000000
--- a/res/drawable-xhdpi/ic_fire_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_shield_white_24.png b/res/drawable-xhdpi/ic_shield_white_24.png
deleted file mode 100644
index e886233..0000000
--- a/res/drawable-xhdpi/ic_shield_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_emergency_number_24.png b/res/drawable-xxhdpi/ic_emergency_number_24.png
deleted file mode 100644
index 13f253b..0000000
--- a/res/drawable-xxhdpi/ic_emergency_number_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_fire_white_24.png b/res/drawable-xxhdpi/ic_fire_white_24.png
deleted file mode 100644
index 37c6ecd..0000000
--- a/res/drawable-xxhdpi/ic_fire_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_shield_white_24.png b/res/drawable-xxhdpi/ic_shield_white_24.png
deleted file mode 100644
index 1621836..0000000
--- a/res/drawable-xxhdpi/ic_shield_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_fire_white_24.png b/res/drawable-xxxhdpi/ic_fire_white_24.png
deleted file mode 100644
index fb1d630..0000000
--- a/res/drawable-xxxhdpi/ic_fire_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_shield_white_24.png b/res/drawable-xxxhdpi/ic_shield_white_24.png
deleted file mode 100644
index 8b9f129..0000000
--- a/res/drawable-xxxhdpi/ic_shield_white_24.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/btn_emergency_confirm_information.xml b/res/drawable/btn_emergency_confirm_information.xml
new file mode 100644
index 0000000..22b3069
--- /dev/null
+++ b/res/drawable/btn_emergency_confirm_information.xml
@@ -0,0 +1,20 @@
+<?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"
+ android:shape="rectangle">
+ <corners android:radius="8dp"/>
+ <solid android:color="@color/emergency_shortcut_confirm_button_background_color"/>
+</shape>
\ No newline at end of file
diff --git a/res/drawable/btn_emergency_confirm_shortcuts.xml b/res/drawable/btn_emergency_confirm_shortcuts.xml
new file mode 100644
index 0000000..22b3069
--- /dev/null
+++ b/res/drawable/btn_emergency_confirm_shortcuts.xml
@@ -0,0 +1,20 @@
+<?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"
+ android:shape="rectangle">
+ <corners android:radius="8dp"/>
+ <solid android:color="@color/emergency_shortcut_confirm_button_background_color"/>
+</shape>
\ No newline at end of file
diff --git a/res/drawable/btn_emergency_information.xml b/res/drawable/btn_emergency_information.xml
new file mode 100644
index 0000000..29b4a7a
--- /dev/null
+++ b/res/drawable/btn_emergency_information.xml
@@ -0,0 +1,22 @@
+<?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"
+ android:shape="rectangle">
+ <corners android:radius="8dp"/>
+ <!-- White, Opacity 16% -->
+ <stroke android:width="1dp"
+ android:color="#40FFFFFF"/>
+</shape>
\ No newline at end of file
diff --git a/res/drawable/btn_emergency_shortcuts.xml b/res/drawable/btn_emergency_shortcuts.xml
index 063a824..449e4e0 100644
--- a/res/drawable/btn_emergency_shortcuts.xml
+++ b/res/drawable/btn_emergency_shortcuts.xml
@@ -16,4 +16,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="8dp"/>
+ <solid android:color="@color/emergency_shortcut_button_background_color"/>
</shape>
\ No newline at end of file
diff --git a/res/drawable/emergency_shortcuts_divider.xml b/res/drawable/emergency_shortcuts_divider.xml
index 988ffc5..930d563 100644
--- a/res/drawable/emergency_shortcuts_divider.xml
+++ b/res/drawable/emergency_shortcuts_divider.xml
@@ -15,6 +15,6 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
- <size android:height="1px"/>
- <solid android:color="#33FFFFFF"/>
+ <size android:height="8dp"/>
+ <solid android:color="@android:color/transparent"/>
</shape>
diff --git a/res/drawable/ic_local_fire_department_gm2_24px.xml b/res/drawable/ic_local_fire_department_gm2_24px.xml
new file mode 100644
index 0000000..a99792c
--- /dev/null
+++ b/res/drawable/ic_local_fire_department_gm2_24px.xml
@@ -0,0 +1,28 @@
+<!--
+ 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"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12.06,3.74c0.26,1.65 1.03,3.21 2.26,4.46c0.53,0.53 1.09,0.95 1.59,1.33c0.38,0.29 0.74,0.55 1.04,0.83c0.3,0.28 0.54,0.55 0.74,0.82l0.03,0.03l0.03,0.03c0.27,0.34 0.52,0.74 0.72,1.15l0.05,0.1c0.02,0.04 0.03,0.07 0.05,0.11l0.02,0.04l0.02,0.04c0.88,2.11 0.31,4.6 -1.4,6.19c-1.45,1.34 -3.35,1.62 -4.69,1.62c-0.42,0 -0.86,-0.03 -1.29,-0.08c-1.87,-0.24 -3.67,-1.45 -4.71,-3.18c-0.31,-0.51 -0.56,-1.08 -0.74,-1.72c-0.11,-0.38 -0.18,-0.79 -0.22,-1.23c0.03,0.05 0.07,0.09 0.1,0.14c0.14,0.2 0.29,0.34 0.38,0.43l0.02,0.02l0.02,0.02c0.53,0.5 1.21,0.78 1.91,0.78c0.2,0 0.72,-0.02 1.17,-0.23c0.99,-0.43 1.63,-1.41 1.63,-2.49c0,-0.37 -0.08,-0.67 -0.14,-0.88l-0.03,-0.13l-0.05,-0.12C9.48,9.01 10.1,5.89 12.06,3.74M13.88,0c-0.06,0 -0.11,0.01 -0.17,0.04c-0.78,0.34 -1.43,0.83 -2.08,1.36C8.37,4.05 7.16,8.51 8.67,12.53c0.03,0.14 0.09,0.29 0.09,0.43c0,0.29 -0.18,0.55 -0.43,0.66c-0.09,0.04 -0.27,0.06 -0.37,0.06c-0.19,0 -0.38,-0.09 -0.53,-0.23c-0.07,-0.07 -0.13,-0.13 -0.19,-0.21C6.2,11.86 5.8,10 6.1,8.28c0.05,-0.29 -0.18,-0.5 -0.41,-0.5c-0.12,0 -0.23,0.05 -0.32,0.16c-1.32,1.72 -1.98,4.03 -1.85,6.2c0.04,0.65 0.14,1.29 0.32,1.92c0.22,0.78 0.54,1.54 0.96,2.23c1.32,2.21 3.65,3.8 6.16,4.11c0.51,0.07 1.03,0.1 1.54,0.1c2.19,0 4.38,-0.62 6.05,-2.15c2.29,-2.12 3.12,-5.49 1.89,-8.43c-0.04,-0.12 -0.1,-0.23 -0.15,-0.35c-0.27,-0.57 -0.6,-1.11 -1,-1.59c-0.3,-0.39 -0.62,-0.75 -0.97,-1.08c-0.82,-0.77 -1.78,-1.32 -2.58,-2.12c-1.63,-1.66 -2.19,-3.99 -1.47,-6.21C14.37,0.28 14.15,0 13.88,0L13.88,0z"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12.93,18.32c-0.56,0 -1.12,-0.16 -1.67,-0.49c-0.08,-0.05 -0.13,-0.13 -0.12,-0.22c0,-0.09 0.06,-0.17 0.14,-0.21c0.98,-0.49 1.67,-1.37 1.9,-2.42c0.17,-0.76 0,-1.44 -0.16,-2.09c-0.07,-0.28 -0.13,-0.52 -0.17,-0.78c-0.06,-0.38 -0.09,-0.72 -0.07,-1.03c0,-0.1 0.07,-0.2 0.17,-0.23c0.1,-0.03 0.21,0 0.27,0.08c0.33,0.42 0.73,0.8 1.12,1.16c0.74,0.69 1.49,1.38 1.68,2.35c0.03,0.18 0.05,0.33 0.05,0.47c0.03,0.97 -0.38,1.99 -1.05,2.59c-0.31,0.27 -0.83,0.56 -1.24,0.69C13.5,18.27 13.22,18.32 12.93,18.32z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_local_hospital_gm2_24px.xml b/res/drawable/ic_local_hospital_gm2_24px.xml
new file mode 100644
index 0000000..2e535f2
--- /dev/null
+++ b/res/drawable/ic_local_hospital_gm2_24px.xml
@@ -0,0 +1,28 @@
+<!--
+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"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M19,3H5C3.9,3 3.01,3.9 3.01,5L3,19c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5C21,3.9 20.1,3 19,3zM19,19L5,19V5h14V19z"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M10.5,17l3,0l0,-3.5l3.5,0l0,-3l-3.5,0l0,-3.5l-3,0l0,3.5l-3.5,0l0,3l3.5,0z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_local_police_gm2_24px.xml b/res/drawable/ic_local_police_gm2_24px.xml
new file mode 100644
index 0000000..c65d0b1
--- /dev/null
+++ b/res/drawable/ic_local_police_gm2_24px.xml
@@ -0,0 +1,28 @@
+<!--
+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"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M19,6.3c0,1.57 0,3.13 0,4.7c0,4.52 -2.98,8.69 -7,9.93C7.98,19.69 5,15.52 5,11V6.3c2.33,-1.04 4.67,-2.07 7,-3.11C14.33,4.23 16.67,5.26 19,6.3zM12,1L3,5v6c0,5.55 3.84,10.74 9,12c5.16,-1.26 9,-6.45 9,-12V5L12,1z"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M13.54,9.66l-1.54,-3.64l-1.54,3.65l-3.96,0.34l3,2.59l-0.9,3.87l3.4,-2.05l3.4,2.05l-0.9,-3.88l3,-2.59z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/place_gm2_24px.xml b/res/drawable/place_gm2_24px.xml
new file mode 100644
index 0000000..4fd2274
--- /dev/null
+++ b/res/drawable/place_gm2_24px.xml
@@ -0,0 +1,28 @@
+<!--
+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"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13C19,5.13 15.87,2 12,2zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9z"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12,9m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout/emergency_dialer.xml b/res/layout/emergency_dialer.xml
index cdb9530..6633a6f 100644
--- a/res/layout/emergency_dialer.xml
+++ b/res/layout/emergency_dialer.xml
@@ -37,8 +37,8 @@
android:id="@+id/dialpad_button_container"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:layout_gravity="bottom|end"
- android:layout_margin="@dimen/emergency_dialer_dialpad_button_margin">
+ android:layout_gravity="bottom|center"
+ android:layout_marginBottom="@dimen/emergency_dialer_dialpad_button_margin">
<ImageButton
android:id="@+id/floating_action_button_dialpad"
android:layout_width="@dimen/dialpad_button_width"
diff --git a/res/layout/emergency_information.xml b/res/layout/emergency_information.xml
index c4ab74b..e925479 100644
--- a/res/layout/emergency_information.xml
+++ b/res/layout/emergency_information.xml
@@ -16,62 +16,92 @@
<com.android.phone.EmergencyInfoGroup
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/emergency_info_button"
- android:layout_height="@dimen/emergency_info_button_singleline_height"
+ android:layout_height="@dimen/emergency_info_button_height"
android:layout_width="match_parent"
- android:layout_marginTop="@dimen/emergency_info_button_margin_top">
- <LinearLayout
+ android:layout_marginHorizontal="@dimen/emergency_shortcut_buttons_margin_horizontal"
+ android:layout_marginVertical="@dimen/emergency_info_button_margin_vertical">
+ <FrameLayout
+ android:id="@+id/emergency_info_view"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:layout_marginEnd="56dp"
- android:orientation="horizontal">
- <FrameLayout
- android:id="@+id/emergency_info_image_container"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_gravity="center_vertical|start"
- android:layout_marginHorizontal="@dimen/emergency_dialer_image_margin_horizontal">
+ android:background="@drawable/btn_emergency_information"
+ android:focusable="true"
+ android:clickable="true" >
+ <LinearLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="horizontal">
<ImageView
android:id="@+id/emergency_info_image"
+ android:layout_gravity="center_vertical|start"
+ android:layout_marginStart="@dimen/emergency_dialer_image_margin_start"
+ android:layout_marginEnd="@dimen/emergency_dialer_image_margin_end"
android:layout_height="@dimen/emergency_info_image_height"
android:layout_width="@dimen/emergency_info_image_width"
android:scaleType="centerCrop"/>
- </FrameLayout>
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:orientation="vertical"
- android:layout_gravity="center_vertical">
- <TextView
- android:id="@+id/emergency_info_name"
+ <LinearLayout
android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:includeFontPadding="false"
- android:maxLines="1"
- android:ellipsize="end"
- android:textAppearance="@style/HeadlineTextAppearance"/>
- <TextView
- android:id="@+id/emergency_info_hint"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:maxLines="2"
- android:ellipsize="end"
- android:lineHeight="@dimen/emergency_info_hint_line_height"
- android:alpha="0.7"
- android:textAppearance="@style/SubtitleTextAppearance"
- android:text="@string/emergency_information_hint"/>
+ android:layout_width="match_parent"
+ android:layout_marginEnd="@dimen/emergency_info_text_margin_end"
+ android:orientation="vertical"
+ android:layout_gravity="center_vertical">
+ <TextView
+ android:id="@+id/emergency_info_name"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:includeFontPadding="false"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:lineHeight="@dimen/emergency_info_name_line_height"
+ android:fontFamily="google-sans"
+ android:textAppearance="@style/HeadlineTextAppearance"/>
+ <TextView
+ android:id="@+id/emergency_info_hint"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:lineHeight="@dimen/emergency_info_hint_line_height"
+ android:alpha="0.7"
+ android:textAppearance="@style/SubtitleTextAppearance"
+ android:text="@string/emergency_information_hint"/>
+ </LinearLayout>
</LinearLayout>
- </LinearLayout>
+ </FrameLayout>
<FrameLayout
- android:id="@+id/arrow_go_next_container"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_gravity="center_vertical|end"
- android:layout_marginHorizontal="@dimen/emergency_dialer_image_margin_horizontal">
- <ImageView
- android:id="@+id/arrow_go_next"
- android:layout_height="@dimen/emergency_shortcuts_function_icon_height"
- android:layout_width="@dimen/emergency_shortcuts_function_icon_width"
- android:src="@drawable/ic_arrow_go_next_18"/>
+ android:id="@+id/emergency_info_confirm_view"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:background="@drawable/btn_emergency_confirm_information"
+ android:focusable="true"
+ android:clickable="true"
+ android:visibility="invisible" >
+ <LinearLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="horizontal">
+ <ImageView
+ android:id="@+id/confirmed_emergency_info_image"
+ android:layout_gravity="center_vertical|start"
+ android:layout_height="@dimen/emergency_info_image_height"
+ android:layout_width="@dimen/emergency_info_image_width"
+ android:layout_marginStart="@dimen/emergency_dialer_image_margin_start"
+ android:layout_marginEnd="@dimen/emergency_dialer_image_margin_end"
+ android:scaleType="centerCrop"/>
+ <TextView
+ android:id="@+id/confirmed_emergency_info"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="@dimen/emergency_info_text_margin_end"
+ android:includeFontPadding="false"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:lineHeight="@dimen/confirmed_emergency_info_line_height"
+ android:fontFamily="google-sans"
+ android:textAppearance="@style/PhoneCallHintTextAppearance"
+ android:text="@string/emergency_information_confirm_hint"/>
+ </LinearLayout>
</FrameLayout>
</com.android.phone.EmergencyInfoGroup>
diff --git a/res/layout/emergency_shortcut_button.xml b/res/layout/emergency_shortcut_button.xml
index 6087dba..136db0c 100644
--- a/res/layout/emergency_shortcut_button.xml
+++ b/res/layout/emergency_shortcut_button.xml
@@ -22,20 +22,21 @@
android:id="@+id/emergency_call_number_info_view"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:background="@color/emergency_shortcut_button_background_color"
+ android:background="@drawable/btn_emergency_shortcuts"
android:focusable="true"
android:clickable="true">
<LinearLayout
android:layout_height="match_parent"
- android:layout_width="wrap_content"
- android:layout_marginEnd="@dimen/emergency_info_image_width"
+ android:layout_width="match_parent"
+ android:layout_marginEnd="@dimen/emergency_shortcuts_margin_end"
android:layout_gravity="center_vertical|start"
android:orientation="horizontal">
<FrameLayout
android:layout_height="@dimen/phone_number_type_circle_image_height"
android:layout_width="@dimen/phone_number_type_circle_image_width"
android:layout_gravity="center_vertical"
- android:layout_marginHorizontal="@dimen/emergency_dialer_image_margin_horizontal"
+ android:layout_marginStart="@dimen/emergency_dialer_image_margin_start"
+ android:layout_marginEnd="@dimen/emergency_dialer_image_margin_end"
android:background="@drawable/phone_type_icon_background">
<ImageView
android:id="@+id/phone_type_icon"
@@ -55,21 +56,24 @@
android:includeFontPadding="false"
android:maxLines="1"
android:ellipsize="end"
- android:textAppearance="@style/HeadlineTextAppearance"/>
+ android:lineHeight="@dimen/phone_number_line_height"
+ android:fontFamily="google-sans"
+ android:textAppearance="@style/PhoneNumberTextAppearance"/>
<TextView
android:id="@+id/phone_number_description"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:alpha="0.8"
+ android:alpha="0.7"
android:maxLines="1"
android:ellipsize="end"
+ android:fontFamily="sans-serif-medium"
android:textAppearance="@style/SubtitleTextAppearance"/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:layout_marginHorizontal="@dimen/emergency_dialer_image_margin_horizontal"
+ android:layout_marginEnd="@dimen/emergency_dialer_image_margin_end"
android:layout_gravity="center_vertical|end">
<ImageView
android:id="@+id/microphone_icon"
@@ -84,21 +88,22 @@
android:id="@+id/emergency_call_confirm_view"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:background="@color/emergency_shortcut_confirm_button_background_color"
+ android:background="@drawable/btn_emergency_confirm_shortcuts"
android:focusable="true"
android:clickable="true"
android:visibility="invisible">
<LinearLayout
android:layout_height="match_parent"
- android:layout_width="wrap_content"
- android:layout_marginEnd="@dimen/emergency_info_image_width"
+ android:layout_width="match_parent"
+ android:layout_marginEnd="@dimen/emergency_shortcuts_margin_end"
android:layout_gravity="center_vertical|start"
android:gravity="center_vertical"
android:orientation="horizontal">
<FrameLayout
android:layout_height="@dimen/phone_number_type_circle_image_height"
android:layout_width="@dimen/phone_number_type_circle_image_width"
- android:layout_marginHorizontal="@dimen/emergency_dialer_image_margin_horizontal"
+ android:layout_marginStart="@dimen/emergency_dialer_image_margin_start"
+ android:layout_marginEnd="@dimen/emergency_dialer_image_margin_end"
android:background="@drawable/phone_type_icon_background"
android:backgroundTint="@android:color/white">
<ImageView
@@ -119,13 +124,15 @@
android:maxLines="2"
android:ellipsize="end"
android:lineHeight="@dimen/phone_call_hint_line_height"
- android:textAppearance="@style/ShortcutsHintTextAppearance"/>
+ android:fontFamily="google-sans"
+ android:textAppearance="@style/PhoneCallHintTextAppearance"/>
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:layout_marginHorizontal="@dimen/emergency_dialer_image_margin_horizontal"
+ android:layout_marginStart="@dimen/emergency_dialer_image_margin_start"
+ android:layout_marginEnd="@dimen/emergency_dialer_image_margin_end"
android:layout_gravity="center_vertical|end">
<ImageView
android:layout_height="@dimen/phone_icon_height"
diff --git a/res/layout/emergency_shortcut_buttons_group.xml b/res/layout/emergency_shortcut_buttons_group.xml
index 619eac6..bafedd1 100644
--- a/res/layout/emergency_shortcut_buttons_group.xml
+++ b/res/layout/emergency_shortcut_buttons_group.xml
@@ -18,13 +18,12 @@
android:id="@+id/emergency_shortcut_buttons_group"
android:layout_height="wrap_content"
android:layout_width="match_parent"
- android:layout_marginTop="@dimen/emergency_shortcuts_group_margin_top"
android:orientation="vertical">
<FrameLayout
android:id="@+id/emergency_number_title_group"
android:layout_height="@dimen/emergency_number_title_height"
android:layout_width="match_parent"
- android:paddingHorizontal="@dimen/emergency_number_title_group_padding_horizontal">
+ android:layout_marginHorizontal="@dimen/emergency_number_title_group_padding_horizontal">
<FrameLayout
android:id="@+id/emergency_number_title_container"
android:layout_height="wrap_content"
@@ -35,8 +34,10 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="start"
- android:maxLines="1"
+ android:maxLines="2"
android:ellipsize="end"
+ android:lineHeight="@dimen/emergency_number_title_line_height"
+ android:fontFamily="sans-serif-medium"
android:textAppearance="@style/SubtitleTextAppearance"
android:text="@string/single_emergency_number_title"/>
</FrameLayout>
@@ -53,14 +54,15 @@
android:id="@+id/location_icon"
android:layout_width="@dimen/location_image_width"
android:layout_height="@dimen/location_image_height"
- android:src="@drawable/ic_location_on_white_18"/>
+ android:src="@drawable/place_gm2_24px"/>
<TextView
android:id="@+id/location_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:paddingStart="4dp"
- android:maxLines="1"
+ android:layout_marginStart="@dimen/location_text_margin_start"
+ android:maxLines="2"
android:ellipsize="end"
+ android:lineHeight="@dimen/location_text_line_height"
android:textAppearance="@style/SubtitleTextAppearance"/>
</LinearLayout>
</FrameLayout>
@@ -71,7 +73,6 @@
android:layout_marginHorizontal="@dimen/emergency_shortcut_buttons_margin_horizontal"
android:orientation="vertical"
android:divider="@drawable/emergency_shortcuts_divider"
- android:showDividers="middle"
- android:background="@drawable/btn_emergency_shortcuts">
+ android:showDividers="middle">
</LinearLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 7136819..cc6f727 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -54,6 +54,6 @@
<color name="dialer_dialpad_touch_tint">#330288d1</color>
<color name="floating_action_button_touch_tint">#80ffffff</color>
- <color name="emergency_shortcut_button_background_color">#1FFFFFFF</color>
+ <color name="emergency_shortcut_button_background_color">#40FFFFFF</color>
<color name="emergency_shortcut_confirm_button_background_color">#E25142</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 97417bd..b657e64 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -115,28 +115,29 @@
<dimen name="emergency_call_warning_size">16sp</dimen>
<!-- Horizontal margin for the image on emergency dialer.-->
- <dimen name="emergency_dialer_image_margin_horizontal">16dp</dimen>
+ <dimen name="emergency_dialer_image_margin_start">20dp</dimen>
+ <dimen name="emergency_dialer_image_margin_end">16dp</dimen>
<!-- Margin of dialpad button -->
- <dimen name="emergency_dialer_dialpad_button_margin">16dp</dimen>
+ <dimen name="emergency_dialer_dialpad_button_margin">40dp</dimen>
<!-- Horizontal margin for button of emergency shortcut. -->
<dimen name="emergency_shortcut_buttons_margin_horizontal">16dp</dimen>
- <!-- Margin top of emergency shortcuts group -->
- <dimen name="emergency_shortcuts_group_margin_top">48dp</dimen>
-
<!-- Horizontal padding for group of emergency number title-->
<dimen name="emergency_number_title_group_padding_horizontal">16dp</dimen>
- <!-- Height and top margin for the emergency information button. -->
- <dimen name="emergency_info_button_singleline_height">72dp</dimen>
- <dimen name="emergency_info_button_margin_top">56dp</dimen>
- <dimen name="emergency_info_button_multiline_height">90dp</dimen>
+ <!-- Height and vertical margin for the emergency information button. -->
+ <dimen name="emergency_info_button_height">96dp</dimen>
+ <dimen name="emergency_info_button_margin_vertical">56dp</dimen>
+ <dimen name="emergency_info_button_fix_margin_vertical">40dp</dimen>
+
+ <!-- Margin for the emergency information button text. -->
+ <dimen name="emergency_info_text_margin_end">20dp</dimen>
<!-- The height and width for the image of emergency information. -->
- <dimen name="emergency_info_image_height">56dp</dimen>
- <dimen name="emergency_info_image_width">56dp</dimen>
+ <dimen name="emergency_info_image_height">40dp</dimen>
+ <dimen name="emergency_info_image_width">40dp</dimen>
<!-- The height and width for the function icon of emergency shortcuts. -->
<dimen name="emergency_shortcuts_function_icon_height">24dp</dimen>
@@ -150,11 +151,11 @@
<dimen name="emergency_number_title_height">48dp</dimen>
<!-- The height and width for the image of location info.-->
- <dimen name="location_image_height">15dp</dimen>
- <dimen name="location_image_width">15dp</dimen>
+ <dimen name="location_image_height">16dp</dimen>
+ <dimen name="location_image_width">16dp</dimen>
<!-- The height for button of emergency shortcut. -->
- <dimen name="emergency_shortcut_button_height">80dp</dimen>
+ <dimen name="emergency_shortcut_button_height">96dp</dimen>
<!-- The height and width for the circle image of phone number type.-->
<dimen name="phone_number_type_circle_image_height">40dp</dimen>
@@ -168,9 +169,30 @@
<dimen name="phone_icon_height">24dp</dimen>
<dimen name="phone_icon_width">24dp</dimen>
- <!-- The line height for emergency info hint and phone call hint.-->
- <dimen name="emergency_info_hint_line_height">17dp</dimen>
- <dimen name="phone_call_hint_line_height">20dp</dimen>
+ <!-- Margin for the emergency shortcut button.-->
+ <dimen name="emergency_shortcuts_margin_end">60dp</dimen>
+
+ <!-- The line height and margin start for location text.-->
+ <dimen name="location_text_line_height">20sp</dimen>
+ <dimen name="location_text_margin_start">4dp</dimen>
+
+ <!-- The line height for emergency number title.-->
+ <dimen name="emergency_number_title_line_height">20sp</dimen>
+
+ <!-- The line height for phone number.-->
+ <dimen name="phone_number_line_height">40sp</dimen>
+
+ <!-- The line height for phone call hint.-->
+ <dimen name="phone_call_hint_line_height">24sp</dimen>
+
+ <!-- The line height for emergency info name.-->
+ <dimen name="emergency_info_name_line_height">28sp</dimen>
+
+ <!-- The line height for emergency info hint.-->
+ <dimen name="emergency_info_hint_line_height">20sp</dimen>
+
+ <!-- The line height for confirmed emergency info.-->
+ <dimen name="confirmed_emergency_info_line_height">24sp</dimen>
<!-- The width for emergency number title container.-->
<dimen name="emergency_number_title_container_width">210dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 88873b3..9f15098 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1131,6 +1131,8 @@
<string name="emergency_information_hint">Emergency information</string>
<!-- Hint for the owner of emergency information -->
<string name="emergency_information_owner_hint">Owner</string>
+ <!-- Hint for confirm the emergency information -->
+ <string name="emergency_information_confirm_hint">Tap again to view info</string>
<!-- Dialog title for the "radio enable" UI for emergency calls -->
<string name="emergency_enable_radio_dialog_title">Emergency call</string>
<!-- Title for the emergency dialpad UI -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 73b5c40..6093cee 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -316,13 +316,22 @@
<style name="HeadlineTextAppearance">
<item name="android:textColor">@android:color/white</item>
- <item name="android:textSize">24sp</item>
+ <item name="android:textSize">22sp</item>
</style>
<style name="SubtitleTextAppearance" parent="@style/HeadlineTextAppearance">
<item name="android:textSize">14sp</item>
</style>
+ <style name="PhoneNumberTextAppearance">
+ <item name="android:textColor">@android:color/white</item>
+ <item name="android:textSize">32sp</item>
+ </style>
+
+ <style name="PhoneCallHintTextAppearance" parent="@style/PhoneNumberTextAppearance">
+ <item name="android:textSize">18sp</item>
+ </style>
+
<style name="ShortcutsHintTextAppearance" parent="@style/HeadlineTextAppearance">
<item name="android:textSize">16sp</item>
</style>
diff --git a/src/com/android/phone/EccShortcutAdapter.java b/src/com/android/phone/EccShortcutAdapter.java
index bd7252c..19e8380 100644
--- a/src/com/android/phone/EccShortcutAdapter.java
+++ b/src/com/android/phone/EccShortcutAdapter.java
@@ -185,15 +185,15 @@
switch (type) {
case POLICE:
description = mPoliceDescription;
- material.iconRes = R.drawable.ic_shield_white_24;
+ material.iconRes = R.drawable.ic_local_police_gm2_24px;
break;
case AMBULANCE:
description = mAmbulanceDescription;
- material.iconRes = R.drawable.ic_emergency_number_24;
+ material.iconRes = R.drawable.ic_local_hospital_gm2_24px;
break;
case FIRE:
description = mFireDescription;
- material.iconRes = R.drawable.ic_fire_white_24;
+ material.iconRes = R.drawable.ic_local_fire_department_gm2_24px;
break;
default:
// ignore unknown types
@@ -203,7 +203,7 @@
material.description = description;
} else {
// concatenate multiple types
- material.iconRes = R.drawable.ic_emergency_number_24;
+ material.iconRes = R.drawable.ic_local_hospital_gm2_24px;
material.description = context.getString(R.string.description_concat_format,
material.description, description);
}
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index ddc6f09..9e5061c 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -105,17 +105,12 @@
* moved into a shared base class that would live in the framework?
* Or could we figure out some way to move *this* class into apps/Contacts
* also?
- *
- * TODO: Implement emergency dialer shortcut.
- * Emergency dialer shortcut offer a local emergency number list. Directly clicking a call button
- * to place an emergency phone call without entering numbers from dialpad.
- * TODO item:
- * 1.integrate emergency phone number table.
*/
public class EmergencyDialer extends Activity implements View.OnClickListener,
View.OnLongClickListener, View.OnKeyListener, TextWatcher,
DialpadKeyButton.OnPressedListener, ColorExtractor.OnColorsChangedListener,
- EmergencyShortcutButton.OnConfirmClickListener, SensorEventListener {
+ EmergencyShortcutButton.OnConfirmClickListener, SensorEventListener,
+ EmergencyInfoGroup.OnConfirmClickListener {
private class MetricsWriter {
// Metrics constants indicating the entry type that user opened emergency dialer.
@@ -238,6 +233,8 @@
private EmergencyActionGroup mEmergencyActionGroup;
+ private EmergencyInfoGroup mEmergencyInfoGroup;
+
// close activity when screen turns off
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
@@ -412,6 +409,8 @@
mEmergencyActionGroup = (EmergencyActionGroup) findViewById(R.id.emergency_action_group);
+ mEmergencyInfoGroup = (EmergencyInfoGroup) findViewById(R.id.emergency_info_button);
+
mEccInfoHelper = new EccInfoHelper(new IsoToEccProtobufRepository());
setupEmergencyShortcutsView();
}
@@ -564,6 +563,17 @@
}
@Override
+ public void onConfirmClick(EmergencyInfoGroup button) {
+ if (button == null) return;
+
+ mUserActions |= MetricsWriter.USER_ACTION_OPEN_EMERGENCY_INFO;
+ Intent intent = (Intent) button.getTag(R.id.tag_intent);
+ if (intent != null) {
+ startActivity(intent);
+ }
+ }
+
+ @Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.deleteButton: {
@@ -587,14 +597,6 @@
switchView(mDialpadView, mEmergencyShortcutView, true);
return;
}
- case R.id.emergency_info_button: {
- mUserActions |= MetricsWriter.USER_ACTION_OPEN_EMERGENCY_INFO;
- Intent intent = (Intent) view.getTag(R.id.tag_intent);
- if (intent != null) {
- startActivity(intent);
- }
- return;
- }
}
}
@@ -1043,8 +1045,7 @@
final View dialpadButton = findViewById(R.id.floating_action_button_dialpad);
dialpadButton.setOnClickListener(this);
- final View emergencyInfoButton = findViewById(R.id.emergency_info_button);
- emergencyInfoButton.setOnClickListener(this);
+ mEmergencyInfoGroup.setOnConfirmClickListener(this);
// EmergencyActionGroup is replaced by EmergencyInfoGroup.
mEmergencyActionGroup.setVisibility(View.GONE);
@@ -1123,10 +1124,15 @@
shortcutButtonContainer.addView(button);
}
- // update emergency numbers title for numerous buttons.
+ // Update emergency numbers title for numerous buttons.
if (mEmergencyShortcutButtonList.size() > 1) {
emergencyNumberTitle.setText(getString(
R.string.numerous_emergency_numbers_title));
+ // Update mEmergencyInfoGroup margin to avoid UI overlay when
+ // emergency shortcut button more than 2.
+ if (mEmergencyShortcutButtonList.size() > 2) {
+ mEmergencyInfoGroup.updateLayoutMargin();
+ }
} else {
emergencyNumberTitle.setText(getText(R.string.single_emergency_number_title));
}
@@ -1149,6 +1155,7 @@
*/
private void onPreTouchEvent(MotionEvent event) {
mEmergencyActionGroup.onPreTouchEvent(event);
+ mEmergencyInfoGroup.onPreTouchEvent(event);
if (mEmergencyShortcutButtonList != null) {
for (EmergencyShortcutButton button : mEmergencyShortcutButtonList) {
@@ -1162,6 +1169,7 @@
*/
private void onPostTouchEvent(MotionEvent event) {
mEmergencyActionGroup.onPostTouchEvent(event);
+ mEmergencyInfoGroup.onPostTouchEvent(event);
if (mEmergencyShortcutButtonList != null) {
for (EmergencyShortcutButton button : mEmergencyShortcutButtonList) {
diff --git a/src/com/android/phone/EmergencyInfoGroup.java b/src/com/android/phone/EmergencyInfoGroup.java
index 828ae88..3eb4de8 100644
--- a/src/com/android/phone/EmergencyInfoGroup.java
+++ b/src/com/android/phone/EmergencyInfoGroup.java
@@ -16,6 +16,8 @@
package com.android.phone;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
@@ -29,7 +31,10 @@
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewAnimationUtils;
+import android.view.accessibility.AccessibilityManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -43,23 +48,60 @@
* EmergencyInfoGroup display user icon and user name. And it is an entry point to
* Emergency Information.
*/
-public class EmergencyInfoGroup extends FrameLayout {
- private ImageView mEmergencyInfoImage;
+public class EmergencyInfoGroup extends FrameLayout implements View.OnClickListener {
+ // Time to hide view of confirmation.
+ private static final long HIDE_DELAY_MS = 3000;
+ private static final int[] ICON_VIEWS =
+ {R.id.emergency_info_image, R.id.confirmed_emergency_info_image};
+
private TextView mEmergencyInfoName;
- private TextView mEmergencyInfoHint;
private View mEmergencyInfoButton;
+ private View mEmergencyInfoConfirmButton;
+
+ private MotionEvent mPendingTouchEvent;
+ private OnConfirmClickListener mOnConfirmClickListener;
+
+ private boolean mConfirmViewHiding;
public EmergencyInfoGroup(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
+ /**
+ * Interface definition for a callback to be invoked when the view of confirmation on emergency
+ * info button is clicked.
+ */
+ public interface OnConfirmClickListener {
+ /**
+ * Called when the view of confirmation on emergency info button has been clicked.
+ *
+ * @param button The shortcut button that was clicked.
+ */
+ void onConfirmClick(EmergencyInfoGroup button);
+ }
+
+ /**
+ * Register a callback {@link OnConfirmClickListener} to be invoked when view of confirmation
+ * is clicked.
+ *
+ * @param onConfirmClickListener The callback that will run.
+ */
+ public void setOnConfirmClickListener(OnConfirmClickListener onConfirmClickListener) {
+ mOnConfirmClickListener = onConfirmClickListener;
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- mEmergencyInfoButton = findViewById(R.id.emergency_info_button);
- mEmergencyInfoImage = (ImageView) findViewById(R.id.emergency_info_image);
+ mEmergencyInfoButton = findViewById(R.id.emergency_info_view);
mEmergencyInfoName = (TextView) findViewById(R.id.emergency_info_name);
- mEmergencyInfoHint = (TextView) findViewById(R.id.emergency_info_hint);
+
+ mEmergencyInfoConfirmButton = findViewById(R.id.emergency_info_confirm_view);
+
+ mEmergencyInfoButton.setOnClickListener(this);
+ mEmergencyInfoConfirmButton.setOnClickListener(this);
+
+ mConfirmViewHiding = true;
}
@Override
@@ -70,12 +112,6 @@
}
}
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- updateLayoutHeight();
- }
-
private void setupButtonInfo() {
List<ResolveInfo> infos;
@@ -91,8 +127,8 @@
final String packageName = infos.get(0).activityInfo.packageName;
final Intent intent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
.setPackage(packageName);
- mEmergencyInfoButton.setTag(R.id.tag_intent, intent);
- mEmergencyInfoImage.setImageDrawable(getCircularUserIcon());
+ setTag(R.id.tag_intent, intent);
+ setUserIcon();
visible = true;
}
@@ -101,6 +137,13 @@
setVisibility(visible ? View.VISIBLE : View.GONE);
}
+ private void setUserIcon() {
+ for (int iconView : ICON_VIEWS) {
+ ImageView userIcon = findViewById(iconView);
+ userIcon.setImageDrawable(getCircularUserIcon());
+ }
+ }
+
/**
* Get user icon.
*
@@ -133,15 +176,124 @@
R.string.emergency_information_owner_hint) : userName;
}
- private void updateLayoutHeight() {
+ /**
+ * Called by the activity before a touch event is dispatched to the view hierarchy.
+ */
+ public void onPreTouchEvent(MotionEvent event) {
+ mPendingTouchEvent = event;
+ }
+
+ /**
+ * Called by the activity after a touch event is dispatched to the view hierarchy.
+ */
+ public void onPostTouchEvent(MotionEvent event) {
+ // Hide the confirmation button if a touch event was delivered to the activity but not to
+ // this view.
+ if (mPendingTouchEvent != null) {
+ hideSelectedButton();
+ }
+ mPendingTouchEvent = null;
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent event) {
+ boolean handled = super.dispatchTouchEvent(event);
+ if (mPendingTouchEvent == event && handled) {
+ mPendingTouchEvent = null;
+ }
+ return handled;
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.emergency_info_view:
+ if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) {
+ if (mOnConfirmClickListener != null) {
+ mOnConfirmClickListener.onConfirmClick(this);
+ }
+ } else {
+ revealSelectedButton();
+ }
+ break;
+ case R.id.emergency_info_confirm_view:
+ if (mOnConfirmClickListener != null) {
+ mOnConfirmClickListener.onConfirmClick(this);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void revealSelectedButton() {
+ mConfirmViewHiding = false;
+
+ mEmergencyInfoConfirmButton.setVisibility(View.VISIBLE);
+ int centerX = mEmergencyInfoButton.getLeft() + mEmergencyInfoButton.getWidth() / 2;
+ int centerY = mEmergencyInfoButton.getTop() + mEmergencyInfoButton.getHeight() / 2;
+ Animator reveal = ViewAnimationUtils.createCircularReveal(
+ mEmergencyInfoConfirmButton,
+ centerX,
+ centerY,
+ 0,
+ Math.max(centerX, mEmergencyInfoConfirmButton.getWidth() - centerX)
+ + Math.max(centerY, mEmergencyInfoConfirmButton.getHeight() - centerY));
+ reveal.start();
+
+ postDelayed(mCancelSelectedButtonRunnable, HIDE_DELAY_MS);
+ mEmergencyInfoConfirmButton.requestFocus();
+ }
+
+ private void hideSelectedButton() {
+ if (mConfirmViewHiding || mEmergencyInfoConfirmButton.getVisibility() != VISIBLE) {
+ return;
+ }
+
+ mConfirmViewHiding = true;
+
+ removeCallbacks(mCancelSelectedButtonRunnable);
+ int centerX =
+ mEmergencyInfoConfirmButton.getLeft() + mEmergencyInfoConfirmButton.getWidth() / 2;
+ int centerY =
+ mEmergencyInfoConfirmButton.getTop() + mEmergencyInfoConfirmButton.getHeight() / 2;
+ Animator reveal = ViewAnimationUtils.createCircularReveal(
+ mEmergencyInfoConfirmButton,
+ centerX,
+ centerY,
+ Math.max(centerX, mEmergencyInfoButton.getWidth() - centerX)
+ + Math.max(centerY, mEmergencyInfoButton.getHeight() - centerY),
+ 0);
+ reveal.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mEmergencyInfoConfirmButton.setVisibility(INVISIBLE);
+ }
+ });
+ reveal.start();
+
+ mEmergencyInfoButton.requestFocus();
+ }
+
+ private final Runnable mCancelSelectedButtonRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (!isAttachedToWindow()) return;
+ hideSelectedButton();
+ }
+ };
+
+ /**
+ * Update layout margin when emergency shortcut button more than 2.
+ */
+ public void updateLayoutMargin() {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) getLayoutParams();
- // Update height if mEmergencyInfoHint text line more than 1.
- // EmergencyInfoGroup max line is 2, eclipse type "end" will be adopt if string too long.
- params.height =
- mEmergencyInfoHint.getLineCount() > 1 ? getResources().getDimensionPixelSize(
- R.dimen.emergency_info_button_multiline_height)
- : getResources().getDimensionPixelSize(
- R.dimen.emergency_info_button_singleline_height);
+
+ params.topMargin = getResources().getDimensionPixelSize(
+ R.dimen.emergency_info_button_fix_margin_vertical);
+ params.bottomMargin = getResources().getDimensionPixelSize(
+ R.dimen.emergency_info_button_fix_margin_vertical);
+
setLayoutParams(params);
}
}
\ No newline at end of file