Merge "Update enabled networks entries on rotation"
diff --git a/res/drawable-hdpi/fab_red.png b/res/drawable-hdpi/fab_red.png
new file mode 100644
index 0000000..ce672f2
--- /dev/null
+++ b/res/drawable-hdpi/fab_red.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_arrow_go_next_18.png b/res/drawable-hdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..37cd6df
--- /dev/null
+++ b/res/drawable-hdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_dialpad_white_24.png b/res/drawable-hdpi/ic_dialpad_white_24.png
new file mode 100644
index 0000000..9037f94
--- /dev/null
+++ b/res/drawable-hdpi/ic_dialpad_white_24.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_emergency_number_24.png b/res/drawable-hdpi/ic_emergency_number_24.png
new file mode 100644
index 0000000..d5c0b28
--- /dev/null
+++ b/res/drawable-hdpi/ic_emergency_number_24.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_location_on_white_18.png b/res/drawable-hdpi/ic_location_on_white_18.png
new file mode 100644
index 0000000..8f93ec9
--- /dev/null
+++ b/res/drawable-hdpi/ic_location_on_white_18.png
Binary files differ
diff --git a/res/drawable-hdpi/logo_avatar_anonymous_120.png b/res/drawable-hdpi/logo_avatar_anonymous_120.png
new file mode 100644
index 0000000..70d3011
--- /dev/null
+++ b/res/drawable-hdpi/logo_avatar_anonymous_120.png
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/ic_arrow_go_next_18.png b/res/drawable-ldrtl-hdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..b8cef90
--- /dev/null
+++ b/res/drawable-ldrtl-hdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/ic_arrow_go_next_18.png b/res/drawable-ldrtl-mdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..fc0a292
--- /dev/null
+++ b/res/drawable-ldrtl-mdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/ic_arrow_go_next_18.png b/res/drawable-ldrtl-xhdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..76c1e7f
--- /dev/null
+++ b/res/drawable-ldrtl-xhdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-ldrtl-xxhdpi/ic_arrow_go_next_18.png b/res/drawable-ldrtl-xxhdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..5914ace
--- /dev/null
+++ b/res/drawable-ldrtl-xxhdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-mdpi/fab_red.png b/res/drawable-mdpi/fab_red.png
new file mode 100644
index 0000000..094a606
--- /dev/null
+++ b/res/drawable-mdpi/fab_red.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_arrow_go_next_18.png b/res/drawable-mdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..d487ae0
--- /dev/null
+++ b/res/drawable-mdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_dialpad_white_24.png b/res/drawable-mdpi/ic_dialpad_white_24.png
new file mode 100644
index 0000000..6c405f9
--- /dev/null
+++ b/res/drawable-mdpi/ic_dialpad_white_24.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_emergency_number_24.png b/res/drawable-mdpi/ic_emergency_number_24.png
new file mode 100644
index 0000000..3db2d19
--- /dev/null
+++ b/res/drawable-mdpi/ic_emergency_number_24.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_location_on_white_18.png b/res/drawable-mdpi/ic_location_on_white_18.png
new file mode 100644
index 0000000..5c5b0fb
--- /dev/null
+++ b/res/drawable-mdpi/ic_location_on_white_18.png
Binary files differ
diff --git a/res/drawable-mdpi/logo_avatar_anonymous_120.png b/res/drawable-mdpi/logo_avatar_anonymous_120.png
new file mode 100644
index 0000000..60d3c3a
--- /dev/null
+++ b/res/drawable-mdpi/logo_avatar_anonymous_120.png
Binary files differ
diff --git a/res/drawable-xhdpi/fab_red.png b/res/drawable-xhdpi/fab_red.png
new file mode 100644
index 0000000..ab1425e
--- /dev/null
+++ b/res/drawable-xhdpi/fab_red.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_arrow_go_next_18.png b/res/drawable-xhdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..766a889
--- /dev/null
+++ b/res/drawable-xhdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_dialpad_white_24.png b/res/drawable-xhdpi/ic_dialpad_white_24.png
new file mode 100644
index 0000000..0e89f6c
--- /dev/null
+++ b/res/drawable-xhdpi/ic_dialpad_white_24.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_emergency_number_24.png b/res/drawable-xhdpi/ic_emergency_number_24.png
new file mode 100644
index 0000000..b538c02
--- /dev/null
+++ b/res/drawable-xhdpi/ic_emergency_number_24.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_location_on_white_18.png b/res/drawable-xhdpi/ic_location_on_white_18.png
new file mode 100644
index 0000000..7c281c3
--- /dev/null
+++ b/res/drawable-xhdpi/ic_location_on_white_18.png
Binary files differ
diff --git a/res/drawable-xhdpi/logo_avatar_anonymous_120.png b/res/drawable-xhdpi/logo_avatar_anonymous_120.png
new file mode 100644
index 0000000..ec99ca6
--- /dev/null
+++ b/res/drawable-xhdpi/logo_avatar_anonymous_120.png
Binary files differ
diff --git a/res/drawable-xxhdpi/fab_red.png b/res/drawable-xxhdpi/fab_red.png
new file mode 100644
index 0000000..899a578
--- /dev/null
+++ b/res/drawable-xxhdpi/fab_red.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_arrow_go_next_18.png b/res/drawable-xxhdpi/ic_arrow_go_next_18.png
new file mode 100644
index 0000000..bb4d45e
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_arrow_go_next_18.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_dialpad_white_24.png b/res/drawable-xxhdpi/ic_dialpad_white_24.png
new file mode 100644
index 0000000..1750005
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_dialpad_white_24.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_emergency_number_24.png b/res/drawable-xxhdpi/ic_emergency_number_24.png
new file mode 100644
index 0000000..13f253b
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_emergency_number_24.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_location_on_white_18.png b/res/drawable-xxhdpi/ic_location_on_white_18.png
new file mode 100644
index 0000000..b345cff
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_location_on_white_18.png
Binary files differ
diff --git a/res/drawable-xxhdpi/logo_avatar_anonymous_120.png b/res/drawable-xxhdpi/logo_avatar_anonymous_120.png
new file mode 100644
index 0000000..2b009a3
--- /dev/null
+++ b/res/drawable-xxhdpi/logo_avatar_anonymous_120.png
Binary files differ
diff --git a/res/drawable/btn_emergency_shortcuts.xml b/res/drawable/btn_emergency_shortcuts.xml
new file mode 100644
index 0000000..063a824
--- /dev/null
+++ b/res/drawable/btn_emergency_shortcuts.xml
@@ -0,0 +1,19 @@
+<?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"/>
+</shape>
\ No newline at end of file
diff --git a/res/drawable/emergency_shortcuts_divider.xml b/res/drawable/emergency_shortcuts_divider.xml
new file mode 100644
index 0000000..988ffc5
--- /dev/null
+++ b/res/drawable/emergency_shortcuts_divider.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">
+ <size android:height="1px"/>
+ <solid android:color="#33FFFFFF"/>
+</shape>
diff --git a/res/drawable/floating_action_button_red.xml b/res/drawable/floating_action_button_red.xml
new file mode 100644
index 0000000..5fe74a3
--- /dev/null
+++ b/res/drawable/floating_action_button_red.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.
+-->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="@color/floating_action_button_touch_tint">
+ <item android:drawable="@drawable/fab_red" />
+</ripple>
\ No newline at end of file
diff --git a/res/drawable/phone_type_icon_background.xml b/res/drawable/phone_type_icon_background.xml
new file mode 100644
index 0000000..b51c3b2
--- /dev/null
+++ b/res/drawable/phone_type_icon_background.xml
@@ -0,0 +1,19 @@
+<?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="oval">
+ <solid android:color="@color/emergency_shortcut_confirm_button_background_color"/>
+</shape>
\ No newline at end of file
diff --git a/res/layout/emergency_dialer.xml b/res/layout/emergency_dialer.xml
index 2a45433..cdb9530 100644
--- a/res/layout/emergency_dialer.xml
+++ b/res/layout/emergency_dialer.xml
@@ -16,51 +16,105 @@
<!-- Layout for the emergency dialer; see EmergencyDialer.java. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <!-- Emergency dialer shortcuts layout-->
+ <FrameLayout
+ android:id="@+id/emergency_dialer_shortcuts"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+ <include layout="@layout/emergency_information"/>
+ <include layout="@layout/emergency_shortcut_buttons_group"/>
+ </LinearLayout>
+
+ <FrameLayout
+ 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">
+ <ImageButton
+ android:id="@+id/floating_action_button_dialpad"
+ android:layout_width="@dimen/dialpad_button_width"
+ android:layout_height="@dimen/dialpad_button_height"
+ android:background="@drawable/floating_action_button_red"
+ android:contentDescription="@string/description_dialpad_button"
+ android:src="@drawable/ic_dialpad_white_24"/>
+ </FrameLayout>
+ </FrameLayout>
+
+ <!--Emergency Dialer Layout-->
+ <FrameLayout
+ android:id="@+id/emergency_dialer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="36dp"
android:paddingRight="36dp"
- android:paddingBottom="@dimen/dialpad_bottom_padding">
-
- <LinearLayout
+ android:paddingBottom="@dimen/dialpad_bottom_padding"
+ android:visibility="visible">
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:orientation="vertical">
- <!-- FrameLayout -->
- <com.android.phone.EmergencyActionGroup
+ <!--Emergency dialer shortcuts implement EmergencyInfoGroup to replace
+ EmergencyActionGroup. Using a title to indicate the dialpad is emergency calls only.-->
+ <FrameLayout
+ android:id="@+id/emergency_dialpad_title_container"
+ android:layout_height="64dp"
+ android:layout_width="match_parent"
+ android:layout_marginTop="16dp"
+ android:layout_marginBottom="24dp"
+ android:visibility="gone">
+ <TextView
+ android:id="@+id/emergency_dialpad_title"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center"
+ android:textStyle="bold"
+ android:maxLines="1"
+ android:text="@string/emergency_dialpad_title"/>
+ </FrameLayout>
+
+ <!-- FrameLayout -->
+ <com.android.phone.EmergencyActionGroup
android:id="@+id/emergency_action_group"
android:layout_height="64dp"
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:layout_marginBottom="24dp">
- <!-- Button that says: Emergency Information -->
- <LinearLayout
+ <!-- Button that says: Emergency Information -->
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
- <Button android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="@drawable/btn_emergency"
- android:id="@+id/action1" />
- <Button android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="@drawable/btn_emergency"
- android:id="@+id/action2" />
- <Button android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="@drawable/btn_emergency"
- android:id="@+id/action3" />
- </LinearLayout>
+ <Button android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/btn_emergency"
+ android:id="@+id/action1" />
+ <Button android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/btn_emergency"
+ android:id="@+id/action2" />
+ <Button android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/btn_emergency"
+ android:id="@+id/action3" />
+ </LinearLayout>
- <!-- View that shows up on top of "emergency information" button
- and asks you to tap again to confirm the action -->
- <FrameLayout
+ <!-- View that shows up on top of "emergency information" button
+ and asks you to tap again to confirm the action -->
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/selected_container"
@@ -68,7 +122,7 @@
android:focusable="true"
android:clickable="true">
- <View
+ <View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#ffe53935"
@@ -76,7 +130,7 @@
android:clickable="false"
style="?android:attr/buttonStyle"/>
- <View
+ <View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ripple_view"
@@ -86,7 +140,7 @@
android:clickable="false"
style="?android:attr/buttonStyle"/>
- <LinearLayout
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -94,7 +148,7 @@
android:clickable="false"
android:backgroundTint="#00000000"
style="?android:attr/buttonStyle">
- <TextView
+ <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
@@ -102,7 +156,7 @@
android:id="@+id/selected_label"
android:textColor="@android:color/white"
android:textAppearance="?android:attr/textAppearanceButton" />
- <TextView
+ <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/launch_hint"
@@ -111,37 +165,39 @@
android:text="@string/emergency_action_launch_hint"
android:textColor="@android:color/white"
android:textStyle="italic" />
- </LinearLayout>
+ </LinearLayout>
- </FrameLayout>
+ </FrameLayout>
- </com.android.phone.EmergencyActionGroup>
+ </com.android.phone.EmergencyActionGroup>
- <include layout="@layout/dialpad_view_unthemed"
- android:theme="?attr/dialpadTheme" />
+ <include layout="@layout/dialpad_view_unthemed"
+ android:theme="?attr/dialpadTheme" />
- </LinearLayout>
+ </LinearLayout>
- <Space
- android:id="@+id/floating_action_button_margin_bottom"
- android:layout_width="match_parent"
- android:layout_height="@dimen/floating_action_button_margin_bottom"
- android:layout_alignParentBottom="true"/>
+ <Space
+ android:id="@+id/floating_action_button_margin_bottom"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/floating_action_button_margin_bottom"
+ android:layout_alignParentBottom="true"/>
- <FrameLayout
- android:id="@+id/floating_action_button_container"
- android:layout_width="@dimen/floating_action_button_width"
- android:layout_height="@dimen/floating_action_button_height"
- android:layout_gravity="center_horizontal|bottom" >
+ <FrameLayout
+ android:id="@+id/floating_action_button_container"
+ android:layout_width="@dimen/floating_action_button_width"
+ android:layout_height="@dimen/floating_action_button_height"
+ android:layout_gravity="center_horizontal|bottom" >
- <ImageButton
- android:id="@+id/floating_action_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:background="@drawable/floating_action_button"
- android:contentDescription="@string/description_dial_button"
- android:src="@drawable/fab_ic_call"/>
+ <ImageButton
+ android:id="@+id/floating_action_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:background="@drawable/floating_action_button"
+ android:contentDescription="@string/description_dial_button"
+ android:src="@drawable/fab_ic_call"/>
+ </FrameLayout>
+
</FrameLayout>
</FrameLayout>
diff --git a/res/layout/emergency_information.xml b/res/layout/emergency_information.xml
new file mode 100644
index 0000000..c4ab74b
--- /dev/null
+++ b/res/layout/emergency_information.xml
@@ -0,0 +1,77 @@
+<?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.
+-->
+<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_width="match_parent"
+ android:layout_marginTop="@dimen/emergency_info_button_margin_top">
+ <LinearLayout
+ 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">
+ <ImageView
+ android:id="@+id/emergency_info_image"
+ 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"
+ 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"/>
+ </LinearLayout>
+ </LinearLayout>
+
+ <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"/>
+ </FrameLayout>
+</com.android.phone.EmergencyInfoGroup>
diff --git a/res/layout/emergency_shortcut_button.xml b/res/layout/emergency_shortcut_button.xml
new file mode 100644
index 0000000..6087dba
--- /dev/null
+++ b/res/layout/emergency_shortcut_button.xml
@@ -0,0 +1,136 @@
+<?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.
+-->
+<com.android.phone.EmergencyShortcutButton
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="@dimen/emergency_shortcut_button_height"
+ android:layout_width="match_parent">
+ <!-- Normal emergency call button view -->
+ <FrameLayout
+ 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: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_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:background="@drawable/phone_type_icon_background">
+ <ImageView
+ android:id="@+id/phone_type_icon"
+ android:layout_width="@dimen/phone_number_type_image_height"
+ android:layout_height="@dimen/phone_number_type_image_width"
+ android:layout_gravity="center"/>
+ </FrameLayout>
+ <LinearLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/phone_number"
+ 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/phone_number_description"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:alpha="0.8"
+ android:maxLines="1"
+ android:ellipsize="end"
+ 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_gravity="center_vertical|end">
+ <ImageView
+ android:id="@+id/microphone_icon"
+ android:layout_height="@dimen/phone_icon_height"
+ android:layout_width="@dimen/phone_icon_width"
+ android:src="@drawable/ic_emergency_callback_mode"/>
+ </FrameLayout>
+ </FrameLayout>
+
+ <!-- "Tap again to call" view -->
+ <FrameLayout
+ 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: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_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:background="@drawable/phone_type_icon_background"
+ android:backgroundTint="@android:color/white">
+ <ImageView
+ android:id="@+id/confirmed_phone_type_icon"
+ android:layout_width="@dimen/phone_number_type_image_height"
+ android:layout_height="@dimen/phone_number_type_image_width"
+ android:layout_gravity="center"
+ android:tint="@color/emergency_shortcut_confirm_button_background_color"/>
+ </FrameLayout>
+ <FrameLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:gravity="center_vertical">
+ <TextView
+ android:id="@+id/phone_call_hint"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:lineHeight="@dimen/phone_call_hint_line_height"
+ android:textAppearance="@style/ShortcutsHintTextAppearance"/>
+ </FrameLayout>
+ </LinearLayout>
+ <FrameLayout
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_marginHorizontal="@dimen/emergency_dialer_image_margin_horizontal"
+ android:layout_gravity="center_vertical|end">
+ <ImageView
+ android:layout_height="@dimen/phone_icon_height"
+ android:layout_width="@dimen/phone_icon_width"
+ android:src="@drawable/ic_emergency_callback_mode"/>
+ </FrameLayout>
+ </FrameLayout>
+</com.android.phone.EmergencyShortcutButton>
\ No newline at end of file
diff --git a/res/layout/emergency_shortcut_buttons_group.xml b/res/layout/emergency_shortcut_buttons_group.xml
new file mode 100644
index 0000000..619eac6
--- /dev/null
+++ b/res/layout/emergency_shortcut_buttons_group.xml
@@ -0,0 +1,77 @@
+<?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.
+-->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ 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">
+ <FrameLayout
+ android:id="@+id/emergency_number_title_container"
+ android:layout_height="wrap_content"
+ android:layout_width="@dimen/emergency_number_title_container_width"
+ android:layout_gravity="center_vertical|start">
+ <TextView
+ android:id="@+id/emergency_number_title"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_gravity="start"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:textAppearance="@style/SubtitleTextAppearance"
+ android:text="@string/single_emergency_number_title"/>
+ </FrameLayout>
+ <LinearLayout
+ android:id="@+id/location_info"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_marginStart="@dimen/emergency_number_title_container_width"
+ android:layout_gravity="center_vertical|end"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:alpha="0.7">
+ <ImageView
+ 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"/>
+ <TextView
+ android:id="@+id/location_text"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:paddingStart="4dp"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:textAppearance="@style/SubtitleTextAppearance"/>
+ </LinearLayout>
+ </FrameLayout>
+ <LinearLayout
+ android:id="@+id/emergency_shortcut_buttons_container"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ 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">
+ </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 870d692..7136819 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -54,4 +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_confirm_button_background_color">#E25142</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 42f9563..97417bd 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -113,4 +113,66 @@
<!-- The size of the "emergency calling unavailable" message shown in the emergency dialer -->
<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>
+
+ <!-- Margin of dialpad button -->
+ <dimen name="emergency_dialer_dialpad_button_margin">16dp</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>
+
+ <!-- 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>
+
+ <!-- The height and width for the function icon of emergency shortcuts. -->
+ <dimen name="emergency_shortcuts_function_icon_height">24dp</dimen>
+ <dimen name="emergency_shortcuts_function_icon_width">24dp</dimen>
+
+ <!-- The height and width for the dialpad button -->
+ <dimen name="dialpad_button_height">56dp</dimen>
+ <dimen name="dialpad_button_width">56dp</dimen>
+
+ <!-- The height for title of emergency number and location info. -->
+ <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>
+
+ <!-- The height for button of emergency shortcut. -->
+ <dimen name="emergency_shortcut_button_height">80dp</dimen>
+
+ <!-- The height and width for the circle image of phone number type.-->
+ <dimen name="phone_number_type_circle_image_height">40dp</dimen>
+ <dimen name="phone_number_type_circle_image_width">40dp</dimen>
+
+ <!-- The height and width for the image of phone number type.-->
+ <dimen name="phone_number_type_image_height">24dp</dimen>
+ <dimen name="phone_number_type_image_width">24dp</dimen>
+
+ <!-- The height and width of phone icon.-->
+ <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>
+
+ <!-- The width for emergency number title container.-->
+ <dimen name="emergency_number_title_container_width">210dp</dimen>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8f192ae..b60d85f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1122,8 +1122,20 @@
<!-- In-call screen: call failure message displayed in an error dialog when the user is connected to a wireless network, but wifi calling is turned off. [CHAR_LIMIT=NONE] -->
<string name="incall_error_promote_wfc">Enable Wi-Fi calling to make a call.</string>
+ <!-- Hint for the button of emergency information -->
+ <string name="emergency_information_hint">Emergency information</string>
+ <!-- Hint for the owner of emergency information -->
+ <string name="emergency_information_owner_hint">Owner</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 -->
+ <string name="emergency_dialpad_title">Emergency calls only</string>
+ <!-- Emergency dialer: Title of single emergency shortcut button -->
+ <string name="single_emergency_number_title">Emergency number</string>
+ <!-- Emergency dialer: Title of numerous emergency shortcut buttons -->
+ <string name="numerous_emergency_numbers_title">Emergency numbers</string>
+ <!-- Emergency dialer: Hint of selected emergency shortcut button -->
+ <string name="emergency_call_shortcut_hint">Tap again to call <xliff:g id="emergency_number">%s</xliff:g></string>
<!-- Status message for the "radio enable" UI for emergency calls -->
<string name="emergency_enable_radio_dialog_message">Turning on radio\u2026</string>
<!-- Status message for the "radio enable" UI for emergency calls -->
@@ -1367,6 +1379,13 @@
-->
<string name="description_dial_button">dial</string>
+ <!-- String describing the Dialpad ImageButton
+
+ Used by AccessibilityService to announce the purpose of the button.
+ [CHAR LIMIT=NONE]
+ -->
+ <string name="description_dialpad_button">show dialpad</string>
+
<!-- Visual voicemail on/off title [CHAR LIMIT=40] -->
<string name="voicemail_visual_voicemail_switch_title">Visual Voicemail</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index d003aec..73b5c40 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -313,4 +313,17 @@
<style name="CallSettingsWithoutDividerTheme" parent="SettingsLight">
<item name="android:listDivider">@null</item>
</style>
+
+ <style name="HeadlineTextAppearance">
+ <item name="android:textColor">@android:color/white</item>
+ <item name="android:textSize">24sp</item>
+ </style>
+
+ <style name="SubtitleTextAppearance" parent="@style/HeadlineTextAppearance">
+ <item name="android:textSize">14sp</item>
+ </style>
+
+ <style name="ShortcutsHintTextAppearance" parent="@style/HeadlineTextAppearance">
+ <item name="android:textSize">16sp</item>
+ </style>
</resources>
diff --git a/src/com/android/phone/EmergencyActionGroup.java b/src/com/android/phone/EmergencyActionGroup.java
index b647623..d72c265 100644
--- a/src/com/android/phone/EmergencyActionGroup.java
+++ b/src/com/android/phone/EmergencyActionGroup.java
@@ -22,11 +22,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.Layout;
import android.text.TextUtils;
@@ -125,15 +121,13 @@
mPendingTouchEvent = null;
}
-
-
private void setupAssistActions() {
int[] buttonIds = new int[] {R.id.action1, R.id.action2, R.id.action3};
List<ResolveInfo> infos;
if (TelephonyManager.EMERGENCY_ASSISTANCE_ENABLED) {
- infos = resolveAssistPackageAndQueryActivites();
+ infos = EmergencyAssistanceHelper.resolveAssistPackageAndQueryActivities(getContext());
} else {
infos = null;
}
@@ -146,7 +140,7 @@
if (infos != null && infos.size() > i && infos.get(i) != null) {
ResolveInfo info = infos.get(i);
- ComponentName name = getComponentName(info);
+ ComponentName name = EmergencyAssistanceHelper.getComponentName(info);
button.setTag(R.id.tag_intent,
new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
@@ -159,69 +153,6 @@
}
}
- private List<ResolveInfo> resolveAssistPackageAndQueryActivites() {
- List<ResolveInfo> infos = queryAssistActivities();
-
- if (infos == null || infos.isEmpty()) {
- PackageManager packageManager = getContext().getPackageManager();
- Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE);
- infos = packageManager.queryIntentActivities(queryIntent, 0);
-
- PackageInfo bestMatch = null;
- for (int i = 0; i < infos.size(); i++) {
- if (infos.get(i).activityInfo == null) continue;
- String packageName = infos.get(i).activityInfo.packageName;
- PackageInfo packageInfo;
- try {
- packageInfo = packageManager.getPackageInfo(packageName, 0);
- } catch (PackageManager.NameNotFoundException e) {
- continue;
- }
- // Get earliest installed system app.
- if (isSystemApp(packageInfo) && (bestMatch == null ||
- bestMatch.firstInstallTime > packageInfo.firstInstallTime)) {
- bestMatch = packageInfo;
- }
- }
-
- if (bestMatch != null) {
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION,
- bestMatch.packageName);
- return queryAssistActivities();
- } else {
- return null;
- }
- } else {
- return infos;
- }
- }
-
- private List<ResolveInfo> queryAssistActivities() {
- String assistPackage = Settings.Secure.getString(
- getContext().getContentResolver(),
- Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION);
- List<ResolveInfo> infos = null;
-
- if (!TextUtils.isEmpty(assistPackage)) {
- Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
- .setPackage(assistPackage);
- infos = getContext().getPackageManager().queryIntentActivities(queryIntent, 0);
- }
- return infos;
- }
-
- private boolean isSystemApp(PackageInfo info) {
- return info.applicationInfo != null
- && (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
- }
-
- private ComponentName getComponentName(ResolveInfo resolveInfo) {
- if (resolveInfo == null || resolveInfo.activityInfo == null) return null;
- return new ComponentName(resolveInfo.activityInfo.packageName,
- resolveInfo.activityInfo.name);
- }
-
@Override
public void onClick(View v) {
Intent intent = (Intent) v.getTag(R.id.tag_intent);
@@ -405,6 +336,4 @@
startRipple();
}
};
-
-
}
diff --git a/src/com/android/phone/EmergencyAssistanceHelper.java b/src/com/android/phone/EmergencyAssistanceHelper.java
new file mode 100644
index 0000000..3053125
--- /dev/null
+++ b/src/com/android/phone/EmergencyAssistanceHelper.java
@@ -0,0 +1,107 @@
+/*
+ * 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.phone;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.provider.Settings;
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
+
+import java.util.List;
+
+/**
+ * A helper to query activities of emergency assistance.
+ */
+public class EmergencyAssistanceHelper {
+
+ /**
+ * Query activities of emergency assistance.
+ *
+ * @param context The context of the application.
+ * @return A list of {@link ResolveInfo} which is queried from default assistance package,
+ * or null if there is no installed system application of emergency assistance.
+ */
+ public static List<ResolveInfo> resolveAssistPackageAndQueryActivities(Context context) {
+ List<ResolveInfo> infos = queryAssistActivities(context);
+
+ if (infos == null || infos.isEmpty()) {
+ PackageManager packageManager = context.getPackageManager();
+ Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE);
+ infos = packageManager.queryIntentActivities(queryIntent, 0);
+
+ PackageInfo bestMatch = null;
+ for (int i = 0; i < infos.size(); i++) {
+ if (infos.get(i).activityInfo == null) continue;
+ String packageName = infos.get(i).activityInfo.packageName;
+ PackageInfo packageInfo;
+ try {
+ packageInfo = packageManager.getPackageInfo(packageName, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ continue;
+ }
+ // Get earliest installed system app.
+ if (isSystemApp(packageInfo) && (bestMatch == null
+ || bestMatch.firstInstallTime > packageInfo.firstInstallTime)) {
+ bestMatch = packageInfo;
+ }
+ }
+
+ if (bestMatch != null) {
+ Settings.Secure.putString(context.getContentResolver(),
+ Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION, bestMatch.packageName);
+ return queryAssistActivities(context);
+ } else {
+ return null;
+ }
+ } else {
+ return infos;
+ }
+ }
+
+ /**
+ * Compose {@link ComponentName} from {@link ResolveInfo}.
+ */
+ public static ComponentName getComponentName(ResolveInfo resolveInfo) {
+ if (resolveInfo == null || resolveInfo.activityInfo == null) return null;
+ return new ComponentName(resolveInfo.activityInfo.packageName,
+ resolveInfo.activityInfo.name);
+ }
+
+ private static List<ResolveInfo> queryAssistActivities(Context context) {
+ final String assistPackage = Settings.Secure.getString(context.getContentResolver(),
+ Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION);
+ List<ResolveInfo> infos = null;
+
+ if (!TextUtils.isEmpty(assistPackage)) {
+ Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
+ .setPackage(assistPackage);
+ infos = context.getPackageManager().queryIntentActivities(queryIntent, 0);
+ }
+ return infos;
+ }
+
+ private static boolean isSystemApp(PackageInfo info) {
+ return info.applicationInfo != null
+ && (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
+ }
+}
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index 157cf1d..fc4ef6a 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -18,6 +18,8 @@
import static android.telephony.ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -26,6 +28,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.graphics.Color;
import android.graphics.Point;
import android.media.AudioManager;
import android.media.ToneGenerator;
@@ -38,6 +41,7 @@
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneNumberUtils;
+import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -56,7 +60,9 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.view.WindowManager;
+import android.widget.TextView;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.colorextraction.ColorExtractor.GradientColors;
@@ -65,6 +71,9 @@
import com.android.phone.common.util.ViewUtil;
import com.android.phone.common.widget.ResizingTextEditText;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* EmergencyDialer is a special dialer that is used ONLY for dialing emergency calls.
*
@@ -81,10 +90,17 @@
* 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 {
+ DialpadKeyButton.OnPressedListener, ColorExtractor.OnColorsChangedListener,
+ EmergencyShortcutButton.OnConfirmClickListener {
// Keys used with onSaveInstanceState().
private static final String LAST_NUMBER = "lastNumber";
@@ -116,9 +132,16 @@
/** 90% opacity, different from other gradients **/
private static final int BACKGROUND_GRADIENT_ALPHA = 230;
+ /** 85% opacity for black background **/
+ private static final int BLACK_BACKGROUND_GRADIENT_ALPHA = 217;
+
ResizingTextEditText mDigits;
private View mDialButton;
private View mDelete;
+ private View mEmergencyShortcutView;
+ private View mDialpadView;
+
+ private List<EmergencyShortcutButton> mEmergencyShortcutButtonList;
private ToneGenerator mToneGenerator;
private Object mToneGeneratorLock = new Object();
@@ -148,6 +171,8 @@
private boolean mIsWfcEmergencyCallingWarningEnabled;
private float mDefaultDigitsTextSize;
+ private boolean mAreEmergencyDialerShortcutsEnabled;
+
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
@@ -187,10 +212,20 @@
// Allow turning screen on
setTurnScreenOn(true);
+ mAreEmergencyDialerShortcutsEnabled = Settings.Global.getInt(getContentResolver(),
+ Settings.Global.FASTER_EMERGENCY_PHONE_CALL_ENABLED, 0) != 0;
+
mColorExtractor = new ColorExtractor(this);
- GradientColors lockScreenColors = mColorExtractor.getColors(WallpaperManager.FLAG_LOCK,
- ColorExtractor.TYPE_EXTRA_DARK);
- updateTheme(lockScreenColors.supportsDarkText());
+
+ // It does not support dark text theme, when emergency dialer shortcuts are enabled.
+ // And the background color is black with 85% opacity.
+ if (mAreEmergencyDialerShortcutsEnabled) {
+ updateTheme(false);
+ } else {
+ GradientColors lockScreenColors = mColorExtractor.getColors(WallpaperManager.FLAG_LOCK,
+ ColorExtractor.TYPE_EXTRA_DARK);
+ updateTheme(lockScreenColors.supportsDarkText());
+ }
setContentView(R.layout.emergency_dialer);
@@ -208,7 +243,8 @@
((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay().getSize(displaySize);
mBackgroundGradient.setScreenSize(displaySize.x, displaySize.y);
- mBackgroundGradient.setAlpha(BACKGROUND_GRADIENT_ALPHA);
+ mBackgroundGradient.setAlpha(mAreEmergencyDialerShortcutsEnabled
+ ? BLACK_BACKGROUND_GRADIENT_ALPHA : BACKGROUND_GRADIENT_ALPHA);
getWindow().setBackgroundDrawable(mBackgroundGradient);
// Check for the presence of the keypad
@@ -273,6 +309,10 @@
registerReceiver(mBroadcastReceiver, intentFilter);
mEmergencyActionGroup = (EmergencyActionGroup) findViewById(R.id.emergency_action_group);
+
+ if (mAreEmergencyDialerShortcutsEnabled) {
+ setupEmergencyShortcutsView();
+ }
}
@Override
@@ -328,6 +368,19 @@
view.setOnLongClickListener(this);
}
+ @Override
+ public void onBackPressed() {
+ // If emergency dialer shortcut is enabled and Dialpad view is visible, pressing the
+ // back key will back to display EmergencyShortcutView view.
+ // Otherwise, it would finish the activity.
+ if (mAreEmergencyDialerShortcutsEnabled && mDialpadView != null
+ && mDialpadView.getVisibility() == View.VISIBLE) {
+ switchView(mEmergencyShortcutView, mDialpadView, true);
+ return;
+ }
+ super.onBackPressed();
+ }
+
/**
* handle key events
*/
@@ -375,13 +428,28 @@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
- mEmergencyActionGroup.onPreTouchEvent(ev);
+ onPreTouchEvent(ev);
boolean handled = super.dispatchTouchEvent(ev);
- mEmergencyActionGroup.onPostTouchEvent(ev);
+ onPostTouchEvent(ev);
return handled;
}
@Override
+ public void onConfirmClick(EmergencyShortcutButton button) {
+ if (button == null) return;
+
+ String phoneNumber = button.getPhoneNumber();
+
+ if (!TextUtils.isEmpty(phoneNumber)) {
+ if (DBG) Log.d(LOG_TAG, "dial emergency number: " + Rlog.pii(LOG_TAG, phoneNumber));
+ TelecomManager tm = (TelecomManager) getSystemService(TELECOM_SERVICE);
+ tm.placeCall(Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null), null);
+ } else {
+ Log.d(LOG_TAG, "emergency number is empty");
+ }
+ }
+
+ @Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.deleteButton: {
@@ -399,6 +467,18 @@
}
return;
}
+ case R.id.floating_action_button_dialpad: {
+ mDigits.getText().clear();
+ switchView(mDialpadView, mEmergencyShortcutView, true);
+ return;
+ }
+ case R.id.emergency_info_button: {
+ Intent intent = (Intent) view.getTag(R.id.tag_intent);
+ if (intent != null) {
+ startActivity(intent);
+ }
+ return;
+ }
}
}
@@ -494,13 +574,19 @@
@Override
protected void onStart() {
super.onStart();
-
- mColorExtractor.addOnColorsChangedListener(this);
- GradientColors lockScreenColors = mColorExtractor.getColors(WallpaperManager.FLAG_LOCK,
- ColorExtractor.TYPE_EXTRA_DARK);
- // Do not animate when view isn't visible yet, just set an initial state.
- mBackgroundGradient.setColors(lockScreenColors, false);
- updateTheme(lockScreenColors.supportsDarkText());
+ // It does not support dark text theme, when emergency dialer shortcuts are enabled.
+ // And set background color to black.
+ if (mAreEmergencyDialerShortcutsEnabled) {
+ mBackgroundGradient.setColors(Color.BLACK, Color.BLACK, false);
+ updateTheme(false);
+ } else {
+ mColorExtractor.addOnColorsChangedListener(this);
+ GradientColors lockScreenColors = mColorExtractor.getColors(WallpaperManager.FLAG_LOCK,
+ ColorExtractor.TYPE_EXTRA_DARK);
+ // Do not animate when view isn't visible yet, just set an initial state.
+ mBackgroundGradient.setColors(lockScreenColors, false);
+ updateTheme(lockScreenColors.supportsDarkText());
+ }
}
@Override
@@ -536,7 +622,6 @@
@Override
protected void onStop() {
super.onStop();
-
mColorExtractor.removeOnColorsChangedListener(this);
}
@@ -792,4 +877,150 @@
Log.i(LOG_TAG, "hint - setting to " + mDigits.getScaledTextSize());
}
}
+
+ private void setupEmergencyShortcutsView() {
+ mEmergencyShortcutView = findViewById(R.id.emergency_dialer_shortcuts);
+ mDialpadView = findViewById(R.id.emergency_dialer);
+
+ 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);
+
+ // EmergencyActionGroup is replaced by EmergencyInfoGroup.
+ mEmergencyActionGroup.setVisibility(View.GONE);
+
+ // Setup dialpad title.
+ final View emergencyDialpadTitle = findViewById(R.id.emergency_dialpad_title_container);
+ emergencyDialpadTitle.setVisibility(View.VISIBLE);
+
+ // TODO: Integrating emergency phone number table will get location information.
+ // Using null to present no location status.
+ setLocationInfo(null);
+
+ mEmergencyShortcutButtonList = new ArrayList<>();
+ setupEmergencyCallShortcutButton();
+
+ switchView(mEmergencyShortcutView, mDialpadView, false);
+ }
+
+ private void setLocationInfo(String country) {
+ final View locationInfo = findViewById(R.id.location_info);
+
+ if (TextUtils.isEmpty(country)) {
+ locationInfo.setVisibility(View.INVISIBLE);
+ } else {
+ final TextView location = (TextView) locationInfo.findViewById(R.id.location_text);
+ location.setText(country);
+ locationInfo.setVisibility(View.VISIBLE);
+ }
+ }
+
+ // TODO: Integrate emergency phone number table.
+ // Using default layout(no location, phone number is 112, description is Emergency,
+ // and icon is cross shape) until integrating emergency phone number table.
+ private void setupEmergencyCallShortcutButton() {
+ final ViewGroup shortcutButtonContainer = findViewById(
+ R.id.emergency_shortcut_buttons_container);
+ shortcutButtonContainer.setClipToOutline(true);
+
+ final EmergencyShortcutButton button =
+ (EmergencyShortcutButton) getLayoutInflater().inflate(
+ R.layout.emergency_shortcut_button,
+ shortcutButtonContainer, false);
+
+ button.setPhoneNumber("112");
+ button.setPhoneDescription("Emergency");
+ button.setPhoneTypeIcon(R.drawable.ic_emergency_number_24);
+ button.setOnConfirmClickListener(this);
+
+ shortcutButtonContainer.addView(button);
+ mEmergencyShortcutButtonList.add(button);
+
+ //Set emergency number title for numerous buttons.
+ if (shortcutButtonContainer.getChildCount() > 1) {
+ final TextView emergencyNumberTitle = findViewById(R.id.emergency_number_title);
+ emergencyNumberTitle.setText(getString(R.string.numerous_emergency_numbers_title));
+ }
+ }
+
+ /**
+ * Called by the activity before a touch event is dispatched to the view hierarchy.
+ */
+ private void onPreTouchEvent(MotionEvent event) {
+ mEmergencyActionGroup.onPreTouchEvent(event);
+
+ if (mEmergencyShortcutButtonList != null) {
+ for (EmergencyShortcutButton button : mEmergencyShortcutButtonList) {
+ button.onPreTouchEvent(event);
+ }
+ }
+ }
+
+ /**
+ * Called by the activity after a touch event is dispatched to the view hierarchy.
+ */
+ private void onPostTouchEvent(MotionEvent event) {
+ mEmergencyActionGroup.onPostTouchEvent(event);
+
+ if (mEmergencyShortcutButtonList != null) {
+ for (EmergencyShortcutButton button : mEmergencyShortcutButtonList) {
+ button.onPostTouchEvent(event);
+ }
+ }
+ }
+
+ /**
+ * Switch two view.
+ *
+ * @param displayView the view would be displayed.
+ * @param hideView the view would be hidden.
+ * @param hasAnimation is {@code true} when the view should be displayed with animation.
+ */
+ private void switchView(View displayView, View hideView, boolean hasAnimation) {
+ if (displayView == null || hideView == null) {
+ return;
+ }
+
+ if (displayView.getVisibility() == View.VISIBLE) {
+ return;
+ }
+
+ if (hasAnimation) {
+ crossfade(hideView, displayView);
+ } else {
+ hideView.setVisibility(View.GONE);
+ displayView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ /**
+ * Fade out and fade in animation between two view transition.
+ */
+ private void crossfade(View fadeOutView, View fadeInView) {
+ if (fadeOutView == null || fadeInView == null) {
+ return;
+ }
+ final int shortAnimationDuration = getResources().getInteger(
+ android.R.integer.config_shortAnimTime);
+
+ fadeInView.setAlpha(0f);
+ fadeInView.setVisibility(View.VISIBLE);
+
+ fadeInView.animate()
+ .alpha(1f)
+ .setDuration(shortAnimationDuration)
+ .setListener(null);
+
+ fadeOutView.animate()
+ .alpha(0f)
+ .setDuration(shortAnimationDuration)
+ .setListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ fadeOutView.setVisibility(View.GONE);
+ }
+ });
+ }
}
diff --git a/src/com/android/phone/EmergencyInfoGroup.java b/src/com/android/phone/EmergencyInfoGroup.java
new file mode 100644
index 0000000..d0dc322
--- /dev/null
+++ b/src/com/android/phone/EmergencyInfoGroup.java
@@ -0,0 +1,148 @@
+/*
+ * 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.phone;
+
+import android.annotation.Nullable;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.core.graphics.drawable.RoundedBitmapDrawable;
+import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
+
+import com.android.internal.util.UserIcons;
+
+import java.util.List;
+
+/**
+ * EmergencyInfoGroup display user icon and user name. And it is an entry point to
+ * Emergency Information.
+ */
+public class EmergencyInfoGroup extends FrameLayout {
+ private ImageView mEmergencyInfoImage;
+ private TextView mEmergencyInfoName;
+ private TextView mEmergencyInfoHint;
+ private View mEmergencyInfoButton;
+
+ public EmergencyInfoGroup(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mEmergencyInfoButton = findViewById(R.id.emergency_info_button);
+ mEmergencyInfoImage = (ImageView) findViewById(R.id.emergency_info_image);
+ mEmergencyInfoName = (TextView) findViewById(R.id.emergency_info_name);
+ mEmergencyInfoHint = (TextView) findViewById(R.id.emergency_info_hint);
+ }
+
+ @Override
+ protected void onWindowVisibilityChanged(int visibility) {
+ super.onWindowVisibilityChanged(visibility);
+ if (visibility == View.VISIBLE) {
+ setupButtonInfo();
+ }
+ }
+
+ @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;
+
+ if (TelephonyManager.EMERGENCY_ASSISTANCE_ENABLED) {
+ infos = EmergencyAssistanceHelper.resolveAssistPackageAndQueryActivities(getContext());
+ } else {
+ infos = null;
+ }
+
+ boolean visible = false;
+
+ if (infos != null && infos.size() > 0) {
+ 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());
+
+ visible = true;
+ }
+ mEmergencyInfoName.setText(getUserName());
+
+ setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+
+ /**
+ * Get user icon.
+ *
+ * @return user icon, or default user icon if user do not set photo.
+ */
+ private Drawable getCircularUserIcon() {
+ final UserManager userManager = (UserManager) getContext().getSystemService(
+ Context.USER_SERVICE);
+ Bitmap bitmapUserIcon = userManager.getUserIcon(UserHandle.getCallingUserId());
+
+ if (bitmapUserIcon == null) {
+ // get default user icon.
+ final Drawable defaultUserIcon = UserIcons.getDefaultUserIcon(
+ getContext().getResources(), UserHandle.myUserId(), false);
+ bitmapUserIcon = UserIcons.convertToBitmap(defaultUserIcon);
+ }
+ RoundedBitmapDrawable drawableUserIcon = RoundedBitmapDrawableFactory.create(
+ getContext().getResources(), bitmapUserIcon);
+ drawableUserIcon.setCircular(true);
+
+ return drawableUserIcon;
+ }
+
+ private CharSequence getUserName() {
+ final UserManager userManager = (UserManager) getContext().getSystemService(
+ Context.USER_SERVICE);
+ final String userName = userManager.getUserName();
+
+ return TextUtils.isEmpty(userName) ? getContext().getText(
+ R.string.emergency_information_owner_hint) : userName;
+ }
+
+ private void updateLayoutHeight() {
+ 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);
+ setLayoutParams(params);
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/phone/EmergencyShortcutButton.java b/src/com/android/phone/EmergencyShortcutButton.java
new file mode 100644
index 0000000..92877c7
--- /dev/null
+++ b/src/com/android/phone/EmergencyShortcutButton.java
@@ -0,0 +1,257 @@
+/*
+ * 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.phone;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.content.Context;
+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.TextView;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Emergency shortcut button displays a local emergency phone number information(including phone
+ * number, and phone type). To decrease false clicking, it need to click twice to confirm to place
+ * an emergency phone call.
+ *
+ * <p> The button need to be set an {@link OnConfirmClickListener} from activity to handle dial
+ * function.
+ *
+ * <p> First clicking on the button, it would change the view of call number information to
+ * the view of confirmation. And then clicking on the view of confirmation, it will place an
+ * emergency call.
+ *
+ * <p> For screen reader, it changed to click twice on the view of call number information to
+ * place an emergency call. The view of confirmation will not display.
+ */
+public class EmergencyShortcutButton extends FrameLayout implements View.OnClickListener {
+ // Time to hide view of confirmation.
+ private static final long HIDE_DELAY = 3000;
+
+ private static final int[] ICON_VIEWS = {R.id.phone_type_icon, R.id.confirmed_phone_type_icon};
+ private View mCallNumberInfoView;
+ private View mConfirmView;
+
+ private TextView mPhoneNumber;
+ private TextView mPhoneTypeDescription;
+ private TextView mPhoneCallHint;
+ private MotionEvent mPendingTouchEvent;
+ private OnConfirmClickListener mOnConfirmClickListener;
+
+ private boolean mConfirmViewHiding;
+
+ public EmergencyShortcutButton(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when the view of confirmation on shortcut
+ * button is clicked.
+ */
+ public interface OnConfirmClickListener {
+ /**
+ * Called when the view of confirmation on shortcut button has been clicked.
+ *
+ * @param button The shortcut button that was clicked.
+ */
+ void onConfirmClick(EmergencyShortcutButton 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;
+ }
+
+ /**
+ * Set icon for different phone number type.
+ *
+ * @param resId The resource identifier of the drawable.
+ */
+ public void setPhoneTypeIcon(int resId) {
+ for (int iconView : ICON_VIEWS) {
+ ImageView phoneTypeIcon = findViewById(iconView);
+ phoneTypeIcon.setImageResource(resId);
+ }
+ }
+
+ /**
+ * Set emergency phone number description.
+ */
+ public void setPhoneDescription(@NonNull String description) {
+ mPhoneTypeDescription.setText(description);
+ }
+
+ /**
+ * Set emergency phone number.
+ */
+ public void setPhoneNumber(@NonNull String number) {
+ mPhoneNumber.setText(number);
+ mPhoneCallHint.setText(
+ getContext().getString(R.string.emergency_call_shortcut_hint, number));
+
+ // Set content description for phone number.
+ if (number.length() > 1) {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (char c : number.toCharArray()) {
+ stringBuilder.append(c).append(" ");
+ }
+ mPhoneNumber.setContentDescription(stringBuilder.toString().trim());
+ }
+ }
+
+ /**
+ * Get emergency phone number.
+ *
+ * @return phone number, or {@code null} if {@code mPhoneNumber} does not be set.
+ */
+ public String getPhoneNumber() {
+ return mPhoneNumber != null ? mPhoneNumber.getText().toString() : null;
+ }
+
+ /**
+ * Called by the activity before a touch event is dispatched to the view hierarchy.
+ */
+ public void onPreTouchEvent(MotionEvent event) {
+ mPendingTouchEvent = event;
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent event) {
+ boolean handled = super.dispatchTouchEvent(event);
+ if (mPendingTouchEvent == event && handled) {
+ mPendingTouchEvent = null;
+ }
+ return handled;
+ }
+
+ /**
+ * 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
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mCallNumberInfoView = findViewById(R.id.emergency_call_number_info_view);
+ mConfirmView = findViewById(R.id.emergency_call_confirm_view);
+
+ mCallNumberInfoView.setOnClickListener(this);
+ mConfirmView.setOnClickListener(this);
+
+ mPhoneNumber = (TextView) mCallNumberInfoView.findViewById(R.id.phone_number);
+ mPhoneTypeDescription = (TextView) mCallNumberInfoView.findViewById(
+ R.id.phone_number_description);
+
+ mPhoneCallHint = (TextView) mConfirmView.findViewById(R.id.phone_call_hint);
+
+ mConfirmViewHiding = true;
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.emergency_call_number_info_view:
+ if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) {
+ if (mOnConfirmClickListener != null) {
+ mOnConfirmClickListener.onConfirmClick(this);
+ }
+ } else {
+ revealSelectedButton();
+ }
+ break;
+ case R.id.emergency_call_confirm_view:
+ if (mOnConfirmClickListener != null) {
+ mOnConfirmClickListener.onConfirmClick(this);
+ }
+ break;
+ }
+ }
+
+ private void revealSelectedButton() {
+ mConfirmViewHiding = false;
+
+ mConfirmView.setVisibility(View.VISIBLE);
+ int centerX = mCallNumberInfoView.getLeft() + mCallNumberInfoView.getWidth() / 2;
+ int centerY = mCallNumberInfoView.getTop() + mCallNumberInfoView.getHeight() / 2;
+ Animator reveal = ViewAnimationUtils.createCircularReveal(
+ mConfirmView,
+ centerX,
+ centerY,
+ 0,
+ Math.max(centerX, mConfirmView.getWidth() - centerX)
+ + Math.max(centerY, mConfirmView.getHeight() - centerY));
+ reveal.start();
+
+ postDelayed(mCancelSelectedButtonRunnable, HIDE_DELAY);
+ mConfirmView.requestFocus();
+ }
+
+ private void hideSelectedButton() {
+ if (mConfirmViewHiding || mConfirmView.getVisibility() != VISIBLE) {
+ return;
+ }
+
+ mConfirmViewHiding = true;
+
+ removeCallbacks(mCancelSelectedButtonRunnable);
+ int centerX = mConfirmView.getLeft() + mConfirmView.getWidth() / 2;
+ int centerY = mConfirmView.getTop() + mConfirmView.getHeight() / 2;
+ Animator reveal = ViewAnimationUtils.createCircularReveal(
+ mConfirmView,
+ centerX,
+ centerY,
+ Math.max(centerX, mCallNumberInfoView.getWidth() - centerX)
+ + Math.max(centerY, mCallNumberInfoView.getHeight() - centerY),
+ 0);
+ reveal.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mConfirmView.setVisibility(INVISIBLE);
+ }
+ });
+ reveal.start();
+
+ mCallNumberInfoView.requestFocus();
+ }
+
+ private final Runnable mCancelSelectedButtonRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (!isAttachedToWindow()) return;
+ hideSelectedButton();
+ }
+ };
+}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 2df3bbe..444eae0 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -102,6 +102,7 @@
import com.android.internal.telephony.NetworkScanRequestTracker;
import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConfigurationManager;
import com.android.internal.telephony.PhoneConstantConversions;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
@@ -216,6 +217,7 @@
private MainThreadHandler mMainThreadHandler;
private SubscriptionController mSubscriptionController;
private SharedPreferences mTelephonySharedPreferences;
+ private PhoneConfigurationManager mPhoneConfigurationManager;
private static final String PREF_CARRIERS_ALPHATAG_PREFIX = "carrier_alphtag_";
private static final String PREF_CARRIERS_NUMBER_PREFIX = "carrier_number_";
@@ -1091,6 +1093,7 @@
PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
mSubscriptionController = SubscriptionController.getInstance();
mNetworkScanRequestTracker = new NetworkScanRequestTracker();
+ mPhoneConfigurationManager = PhoneConfigurationManager.getInstance();
publish();
}
@@ -5173,4 +5176,19 @@
Binder.restoreCallingIdentity(identity);
}
}
+
+ @Override
+ public int getNumberOfModemsWithSimultaneousDataConnections(int subId, String callingPackage) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
+ mApp, subId, callingPackage, "getNumberOfModemsWithSimultaneousDataConnections")) {
+ return -1;
+ }
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return mPhoneConfigurationManager.getNumberOfModemsWithSimultaneousDataConnections();
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
}
diff --git a/src/com/android/phone/settings/AccessibilitySettingsFragment.java b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
index 57b6d8e..0eb3845 100644
--- a/src/com/android/phone/settings/AccessibilitySettingsFragment.java
+++ b/src/com/android/phone/settings/AccessibilitySettingsFragment.java
@@ -57,10 +57,17 @@
if (DBG) Log.d(LOG_TAG, "PhoneStateListener.onCallStateChanged: state=" + state);
Preference pref = getPreferenceScreen().findPreference(BUTTON_TTY_KEY);
if (pref != null) {
- final boolean isVolteTtySupported = ImsManager.isVolteEnabledByPlatform(mContext)
- && getVolteTtySupported();
- pref.setEnabled((isVolteTtySupported && !isVideoCallOrConferenceInProgress()) ||
- (state == TelephonyManager.CALL_STATE_IDLE));
+ // Use TelephonyManager#getCallState instead of 'state' parameter because
+ // needs to check the current state of all phone calls to
+ // support multi sim configuration.
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ final boolean isVolteTtySupported = getVolteTtySupported();
+ final boolean isVolteCurrentlyEnabled =
+ ImsManager.isVolteEnabledByPlatform(mContext);
+ pref.setEnabled((isVolteTtySupported && isVolteCurrentlyEnabled &&
+ !isVideoCallOrConferenceInProgress()) ||
+ (telephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE));
}
}
};
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 6c8dcaa..642af85 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -107,9 +107,31 @@
}
/**
+ * Trigger re-registration of this account.
+ */
+ public void reRegisterPstnPhoneAccount() {
+ PhoneAccount newAccount = buildPstnPhoneAccount(mIsEmergency, mIsDummy);
+ if (!newAccount.equals(mAccount)) {
+ Log.i(this, "reRegisterPstnPhoneAccount: subId: " + getSubId()
+ + " - re-register due to account change.");
+ mTelecomManager.registerPhoneAccount(newAccount);
+ mAccount = newAccount;
+ } else {
+ Log.i(this, "reRegisterPstnPhoneAccount: subId: " + getSubId() + " - no change");
+ }
+ }
+
+ private PhoneAccount registerPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) {
+ PhoneAccount account = buildPstnPhoneAccount(mIsEmergency, mIsDummy);
+ // Register with Telecom and put into the account entry.
+ mTelecomManager.registerPhoneAccount(account);
+ return account;
+ }
+
+ /**
* Registers the specified account with Telecom as a PhoneAccountHandle.
*/
- private PhoneAccount registerPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) {
+ private PhoneAccount buildPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) {
String dummyPrefix = isDummyAccount ? "Dummy " : "";
// Build the Phone account handle.
@@ -312,9 +334,6 @@
.setGroupId(groupId)
.build();
- // Register with Telecom and put into the account entry.
- mTelecomManager.registerPhoneAccount(account);
-
return account;
}
@@ -322,6 +341,10 @@
return mAccount != null ? mAccount.getAccountHandle() : null;
}
+ public int getSubId() {
+ return mPhone.getSubId();
+ }
+
/**
* Determines from carrier configuration whether pausing of IMS video calls is supported.
*
@@ -579,19 +602,27 @@
}
};
- private final BroadcastReceiver mUserSwitchedReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- Log.i(this, "User changed, re-registering phone accounts.");
+ if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
+ Log.i(this, "User changed, re-registering phone accounts.");
- int userHandleId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
- UserHandle currentUserHandle = new UserHandle(userHandleId);
- mIsPrimaryUser = UserManager.get(mContext).getPrimaryUser().getUserHandle()
- .equals(currentUserHandle);
+ int userHandleId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
+ UserHandle currentUserHandle = new UserHandle(userHandleId);
+ mIsPrimaryUser = UserManager.get(mContext).getPrimaryUser().getUserHandle()
+ .equals(currentUserHandle);
- // Any time the user changes, re-register the accounts.
- tearDownAccounts();
- setupAccounts();
+ // Any time the user changes, re-register the accounts.
+ tearDownAccounts();
+ setupAccounts();
+ } else if (CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED.equals(
+ intent.getAction())) {
+ Log.i(this, "Carrier-config changed, checking for phone account updates.");
+ int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ handleCarrierConfigChange(subId);
+ }
}
};
@@ -814,8 +845,10 @@
// Listen for user switches. When the user switches, we need to ensure that if the current
// use is not the primary user we disable video calling.
- mContext.registerReceiver(mUserSwitchedReceiver,
- new IntentFilter(Intent.ACTION_USER_SWITCHED));
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_USER_SWITCHED);
+ filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
+ mContext.registerReceiver(mReceiver, filter);
// Listen to the RTT system setting so that we update it when the user flips it.
ContentObserver rttUiSettingObserver = new ContentObserver(
@@ -951,4 +984,27 @@
mAccounts.clear();
}
}
+
+ /**
+ * Handles changes to the carrier configuration which may impact a phone account. There are
+ * some extras defined in the {@link PhoneAccount} which are based on carrier config options.
+ * Only checking for carrier config changes when the subscription is configured runs the risk of
+ * missing carrier config changes which happen later.
+ * @param subId The subid the carrier config changed for, if applicable. Will be
+ * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} if not specified.
+ */
+ private void handleCarrierConfigChange(int subId) {
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return;
+ }
+ synchronized (mAccountsLock) {
+ for (AccountEntry entry : mAccounts) {
+ if (entry.getSubId() == subId) {
+ Log.d(this, "handleCarrierConfigChange: subId=%d, accountSubId=%d", subId,
+ entry.getSubId());
+ entry.reRegisterPstnPhoneAccount();
+ }
+ }
+ }
+ }
}