summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-01-09 16:40:28 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-01-09 16:40:28 +0000
commit8c19b0ac8f79eb7f653ee3e07018ca7342f4e190 (patch)
tree92e2a480370fd53fdb210d1035a6c3d666628819
parent455a7c27d5c5d4c25236d940f088a25a5bf57c2a (diff)
parent517fbff5c15c9270323b4099a39514d2487eec99 (diff)
Merge changes Iddf5ef33,I1b718e30,I0c7386f6,I81069948,I3bec477d, ...
* changes: Update strings for Duo "Set up" and "Invite" buttons Hide emergency calls in the call log Simplifying implementation of the coalescing logic in the new call log. Updating Dialer v16 licenses. Use ContactsContract.PhoneLookup for invalid numbers in Cp2PhoneLookup. Add RTT call chat window. Updated T9 search bolding to include wrapping to the next word. Initial setup of voicemail error messages Automated rollback of changelist 178323108 Add "delete" option in the 3-dot menu of the new call log
-rw-r--r--assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml25
-rw-r--r--assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml25
-rwxr-xr-xjava/com/android/dialer/about/res/raw/third_party_license_metadata19
-rwxr-xr-xjava/com/android/dialer/about/res/raw/third_party_licenses1744
-rw-r--r--java/com/android/dialer/app/calllog/CallLogAdapter.java13
-rw-r--r--java/com/android/dialer/app/res/values/strings.xml4
-rw-r--r--java/com/android/dialer/calllog/database/Coalescer.java51
-rw-r--r--java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java123
-rw-r--r--java/com/android/dialer/calllog/ui/menu/Modules.java2
-rw-r--r--java/com/android/dialer/calllog/ui/menu/res/values/strings.xml3
-rw-r--r--java/com/android/dialer/common/concurrent/DialerFutureSerializer.java73
-rw-r--r--java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java895
-rw-r--r--java/com/android/dialer/phonelookup/phone_lookup_info.proto6
-rw-r--r--java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java26
-rw-r--r--java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java25
-rw-r--r--java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java42
-rw-r--r--java/com/android/dialer/simulator/impl/SimulatorMainMenu.java6
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java64
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java36
-rw-r--r--java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml30
-rw-r--r--java/com/android/incallui/rtt/impl/AndroidManifest.xml26
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatActivity.java41
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatAdapter.java218
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatFragment.java176
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatMessage.java132
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java65
-rw-r--r--java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml21
-rw-r--r--java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml21
-rw-r--r--java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml21
-rw-r--r--java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml74
-rw-r--r--java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml21
-rw-r--r--java/com/android/incallui/rtt/impl/res/drawable/pill_background.xml22
-rw-r--r--java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml26
-rw-r--r--java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml69
-rw-r--r--java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml91
-rw-r--r--java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml48
-rw-r--r--java/com/android/incallui/rtt/impl/res/values/colors.xml19
-rw-r--r--java/com/android/incallui/rtt/impl/res/values/dimens.xml20
-rw-r--r--java/com/android/incallui/rtt/impl/res/values/strings.xml29
-rw-r--r--java/com/android/incallui/rtt/impl/res/values/styles.xml35
-rw-r--r--packages.mk1
41 files changed, 3324 insertions, 1064 deletions
diff --git a/assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml
new file mode 100644
index 000000000..bd1887e5c
--- /dev/null
+++ b/assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml
@@ -0,0 +1,25 @@
+<!--
+ ~ Copyright (C) 2018 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
+</vector> \ No newline at end of file
diff --git a/assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml
new file mode 100644
index 000000000..0519c555c
--- /dev/null
+++ b/assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml
@@ -0,0 +1,25 @@
+<!--
+ ~ Copyright (C) 2018 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M19,11h-1.7c0,0.74 -0.16,1.43 -0.43,2.05l1.23,1.23c0.56,-0.98 0.9,-2.09 0.9,-3.28zM14.98,11.17c0,-0.06 0.02,-0.11 0.02,-0.17L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v0.18l5.98,5.99zM4.27,3L3,4.27l6.01,6.01L9.01,11c0,1.66 1.33,3 2.99,3 0.22,0 0.44,-0.03 0.65,-0.08l1.66,1.66c-0.71,0.33 -1.5,0.52 -2.31,0.52 -2.76,0 -5.3,-2.1 -5.3,-5.1L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c0.91,-0.13 1.77,-0.45 2.54,-0.9L19.73,21 21,19.73 4.27,3z"/>
+</vector> \ No newline at end of file
diff --git a/java/com/android/dialer/about/res/raw/third_party_license_metadata b/java/com/android/dialer/about/res/raw/third_party_license_metadata
index 49c22731f..73b34437a 100755
--- a/java/com/android/dialer/about/res/raw/third_party_license_metadata
+++ b/java/com/android/dialer/about/res/raw/third_party_license_metadata
@@ -31,12 +31,13 @@
332972:11358 Volley
344341:10695 bubble
355050:11358 gRPC Java
-366427:10173 libphonenumber
-376619:10699 shortcutbadger
-387334:16013 Android SDK
-403366:1096 Animal Sniffer
-404472:4771 Glide
-409255:1602 JSR 305
-410875:12847 jibercsclient
-423733:18982 mime4j
-442732:12847 rcsclientlib
+366426:12847 jibercsclient
+379292:10173 libphonenumber
+389476:18982 mime4j
+408475:12847 rcsclientlib
+421341:10699 shortcutbadger
+432056:16013 Android SDK
+448079:4771 Glide
+452869:1096 Animal Sniffer
+453987:22655 Checker Framework
+476654:1602 JSR 305
diff --git a/java/com/android/dialer/about/res/raw/third_party_licenses b/java/com/android/dialer/about/res/raw/third_party_licenses
index 64f7dc780..8fb021a87 100755
--- a/java/com/android/dialer/about/res/raw/third_party_licenses
+++ b/java/com/android/dialer/about/res/raw/third_party_licenses
@@ -6625,187 +6625,19 @@ gRPC Java:
limitations under the License.
-libphonenumber:
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
+jibercsclient:
-shortcutbadger:
+These components
+ com.google.android.rcs.core,
+ com.google.android.rcs.core.utils.CaseInsensitiveMap,
+ com.google.android.rcs.core.utils.DateTime,
+ com.google.android.rcs.core.utils.InetAddresses,
+ com.google.android.rcs.core.network.ConnectivityMonitor,
+ com.google.android.rcs.client.PrivateDataStorage,
+ com.google.android.rcs.client.utils.FastXmlSerializer,
+ com.google.android.rcs.client.utils.XmlUtils,
+ com.google.android.rcs.client.utils.QueuedWork
+are licensed under Apache v2.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -6997,461 +6829,42 @@ limitations under the License.
END OF TERMS AND CONDITIONS
+===============================================================================
-Android SDK:
-
-ANDROID SOFTWARE DEVELOPMENT KIT
-
-Terms and Conditions
-
-This is the Android Software Development Kit License Agreement.
-
-1. Introduction
-
-1.1 The Android Software Development Kit (referred to in this License Agreement as the "SDK" and
-specifically including the Android system files, packaged APIs, and Google APIs add-ons) is
-licensed to you subject to the terms of this License Agreement. This License Agreement forms a
-legally binding contract between you and Google in relation to your use of the SDK.
-
-1.2 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600
-Amphitheatre Parkway, Mountain View, CA 94043, United States.
-
-2. Accepting this License Agreement
-
-2.1 In order to use the SDK, you must first agree to this License Agreement. You may not use the
-SDK if you do not accept this License Agreement.
-
-2.2 You can accept this License Agreement by:
-
-(A) clicking to accept or agree to this License Agreement, where this option is made available to
-you; or
-
-(B) by actually using the SDK. In this case, you agree that use of the SDK constitutes acceptance of
-the Licensing Agreement from that point onwards.
-
-2.3 You may not use the SDK and may not accept the Licensing Agreement if you are a person barred
-from receiving the SDK under the laws of the United States or other countries including the country
-in which you are resident or from which you use the SDK.
-
-2.4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other
-entity, you represent and warrant that you have full legal authority to bind your employer or such
-entity to this License Agreement. If you do not have the requisite authority, you may not accept
-the Licensing Agreement or use the SDK on behalf of your employer or other entity.
-
-3. SDK License from Google
-
-3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide,
-royalty-free, non- assignable and non-exclusive license to use the SDK solely to develop
-applications to run on the Android platform.
-
-3.2 You agree that Google or third parties own all legal right, title and interest in and to the
-SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property
-Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law,
-and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
-
-3.3 Except to the extent required by applicable third party licenses, you may not copy (except for
-backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create
-derivative works of the SDK or any part of the SDK. Except to the extent required by applicable
-third party licenses, you may not load any part of the SDK onto a mobile handset or any other
-hardware device except a personal computer, combine any part of the SDK with other software, or
-distribute any software or device incorporating a part of the SDK.
-
-3.4 Use, reproduction and distribution of components of the SDK licensed under an open source
-software license are governed solely by the terms of that open source software license and not
-this License Agreement.
-
-3.5 You agree that the form and nature of the SDK that Google provides may change without prior
-notice to you and that future versions of the SDK may be incompatible with applications developed
-on previous versions of the SDK. You agree that Google may stop (permanently or temporarily)
-providing the SDK (or any features within the SDK) to you or to users generally at Google's sole
-discretion, without prior notice to you.
-
-3.6 Nothing in this License Agreement gives you a right to use any of Google's trade names,
-trademarks, service marks, logos, domain names, or other distinctive brand features.
-
-3.7 You agree that you will not remove, obscure, or alter any proprietary rights notices (including
-copyright and trademark notices) that may be affixed to or contained within the SDK.
-
-4. Use of the SDK by You
-
-4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under
-this License Agreement in or to any software applications that you develop using the SDK, including
-any intellectual property rights that subsist in those applications.
-
-4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) this
-License Agreement and (b) any applicable law, regulation or generally accepted practices or
-guidelines in the relevant jurisdictions (including any laws regarding the export of data or
-software to and from the United States or other relevant countries).
-
-4.3 You agree that if you use the SDK to develop applications for general public users, you will
-protect the privacy and legal rights of those users. If the users provide you with user names,
-passwords, or other login information or personal information, your must make the users aware that
-the information will be available to your application, and you must provide legally adequate privacy
-notice and protection for those users. If your application stores personal or sensitive information
-provided by users, it must do so securely. If the user provides your application with Google Account
-information, your application may only use that information to access the user's Google Account
-when, and for the limited purposes for which, the user has given you permission to do so.
-
-4.4 You agree that you will not engage in any activity with the SDK, including the development or
-distribution of an application, that interferes with, disrupts, damages, or accesses in an
-unauthorized manner the servers, networks, or other properties or services of any third party
-including, but not limited to, Google or any mobile communications carrier.
-
-4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or
-to any third party for) any data, content, or resources that you create, transmit or display through
-the Android platform and/or applications for the Android platform, and for the consequences of your
-actions (including any loss or damage which Google may suffer) by doing so.
-
-4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or
-to any third party for) any breach of your obligations under this License Agreement, any applicable
-third party contract or Terms of Service, or any applicable law or regulation, and for the
-consequences (including any loss or damage which Google or any third party may suffer) of any such
-breach.
-
-5. Your Developer Credentials
-
-5.1 You agree that you are responsible for maintaining the confidentiality of any developer
-credentials that may be issued to you by Google or which you may choose yourself and that you will
-be solely responsible for all applications that are developed under your developer credentials.
-
-6. Privacy and Information
-
-6.1 In order to continually innovate and improve the SDK, Google may collect certain usage
-statistics from the software including but not limited to a unique identifier, associated IP
-address, version number of the software, and information on which tools and/or services in the SDK
-are being used and how they are being used. Before any of this information is collected, the SDK
-will notify you and seek your consent. If you withhold consent, the information will not be
-collected.
-
-6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in
-accordance with Google's Privacy Policy.
-
-7. Third Party Applications for the Android Platform
-
-7.1 If you use the SDK to run applications developed by a third party or that access data, content
-or resources provided by a third party, you agree that Google is not responsible for those
-applications, data, content, or resources. You understand that all data, content or resources which
-you may access through such third party applications are the sole responsibility of the person from
-which they originated and that Google is not liable for any loss or damage that you may experience
-as a result of the use or access of any of those third party applications, data, content, or
-resources.
-
-7.2 You should be aware the data, content, and resources presented to you through such a third party
-application may be protected by intellectual property rights which are owned by the providers (or by
-other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute
-or create derivative works based on these data, content, or resources (either in whole or in part)
-unless you have been specifically given permission to do so by the relevant owners.
-
-7.3 You acknowledge that your use of such third party applications, data, content, or resources may
-be subject to separate terms between you and the relevant third party. In that case, this License
-Agreement does not affect your legal relationship with these third parties.
-
-8. Using Android APIs
-
-8.1 Google Data APIs
-
-8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be
-protected by intellectual property rights which are owned by Google or those parties that provide
-the data (or by other persons or companies on their behalf). Your use of any such API may be subject
-to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create
-derivative works based on this data (either in whole or in part) unless allowed by the relevant
-Terms of Service.
-
-8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you
-shall retrieve data only with the user's explicit consent and only when, and for the limited
-purposes for which, the user has given you permission to do so.
-
-9. Terminating this License Agreement
-
-9.1 This License Agreement will continue to apply until terminated by either you or Google as set
-out below.
-
-9.2 If you want to terminate this License Agreement, you may do so by ceasing your use of the SDK
-and any relevant developer credentials.
-
-9.3 Google may at any time, terminate this License Agreement with you if:
-
-(A) you have breached any provision of this License Agreement; or
-
-(B) Google is required to do so by law; or
-
-(C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated
-its relationship with Google or ceased to offer certain parts of the SDK to you; or
-
-(D) Google decides to no longer providing the SDK or certain parts of the SDK to users in the
-country in which you are resident or from which you use the service, or the provision of the SDK or
-certain SDK services to you by Google is, in Google's sole discretion, no longer commercially
-viable.
-
-9.4 When this License Agreement comes to an end, all of the legal rights, obligations and
-liabilities that you and Google have benefited from, been subject to (or which have accrued over
-time whilst this License Agreement has been in force) or which are expressed to continue
-indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall
-continue to apply to such rights, obligations and liabilities indefinitely.
-
-10. DISCLAIMER OF WARRANTIES
-
-10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE
-SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
-
-10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE
-SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR
-COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.
-
-10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-
-11. LIMITATION OF LIABILITY
-
-11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS
-LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY
-LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN
-AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
-
-12. Indemnification
-
-12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless
-Google, its affiliates and their respective directors, officers, employees and agents from and
-against any and all claims, actions, suits or proceedings, as well as any and all losses,
-liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or
-accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any
-copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any
-person or defames any person or violates their rights of publicity or privacy, and (c) any
-non-compliance by you with this License Agreement.
-
-13. Changes to the License Agreement
-
-13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK.
-When these changes are made, Google will make a new version of the License Agreement available on
-the website where the SDK is made available.
-
-14. General Legal Terms
-
-14.1 This License Agreement constitute the whole legal agreement between you and Google and govern
-your use of the SDK (excluding any services which Google may provide to you under a separate written
-agreement), and completely replace any prior agreements between you and Google in relation to the
-SDK.
-
-14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is
-contained in this License Agreement (or which Google has the benefit of under any applicable law),
-this will not be taken to be a formal waiver of Google's rights and that those rights or remedies
-will still be available to Google.
-
-14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision
-of this License Agreement is invalid, then that provision will be removed from this License
-Agreement without affecting the rest of this License Agreement. The remaining provisions of this
-License Agreement will continue to be valid and enforceable.
-
-14.4 You acknowledge and agree that each member of the group of companies of which Google is the
-parent shall be third party beneficiaries to this License Agreement and that such other companies
-shall be entitled to directly enforce, and rely upon, any provision of this License Agreement that
-confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall
-be third party beneficiaries to this License Agreement.
-
-14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST
-COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE
-LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
-
-14.6 The rights granted in this License Agreement may not be assigned or transferred by either you
-or Google without the prior written approval of the other party. Neither you nor Google shall be
-permitted to delegate their responsibilities or obligations under this License Agreement without the
-prior written approval of the other party.
-
-14.7 This License Agreement, and your relationship with Google under this License Agreement, shall
-be governed by the laws of the State of California without regard to its conflict of laws
-provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located
-within the county of Santa Clara, California to resolve any legal matter arising from this License
-Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for
-injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
-
-April 10, 2009
-
-
-Animal Sniffer:
-
-The MIT License
-
-Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-
-Glide:
-
-Covers library/
-
-Copyright 2014 Google, Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are
-permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this list of
- conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice, this list
- of conditions and the following disclaimer in the documentation and/or other materials
- provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-The views and conclusions contained in the software and documentation are those of the
-authors and should not be interpreted as representing official policies, either expressed
-or implied, of Google, Inc.
-
---------------------------------------------------------------------------
-Covers third_party/gif_decoder
-
-Copyright (c) 2013 Xcellent Creations, Inc.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
---------------------------------------------------------------------------
-Covers third_party/disklrucache
-
-Copyright 2012 Jake Wharton
-Copyright 2011 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.
---------------------------------------------------------------------------
-Covers third_party/gif_encoder/AnimatedGifEncoder.java and
-third_party/gif_encoder/LZWEncoder.java:
-
-No copyright asserted on the source code of this class. May be used for any
-purpose, however, refer to the Unisys LZW patent for restrictions on use of
-the associated LZWEncoder class. Please forward any corrections to
-kweiner@fmsware.com.
-
------------------------------------------------------------------------------
-Covers third_party/gif_encoder/NeuQuant.java
-
-Copyright (c) 1994 Anthony Dekker
-
-NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See
-"Kohonen neural networks for optimal colour quantization" in "Network:
-Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of
-the algorithm.
-
-Any party obtaining a copy of these files from the author, directly or
-indirectly, is granted, free of charge, a full and unrestricted irrevocable,
-world-wide, paid up, royalty-free, nonexclusive right and license to deal in
-this software and documentation files (the "Software"), including without
-limitation the rights to use, copy, modify, merge, publish, distribute,
-sublicense, and/or sell copies of the Software, and to permit persons who
-receive copies from any such party to do so, with the only requirement being
-that this copyright notice remain intact.
-
-
-JSR 305:
-
-Copyright (c) 2007-2009, JSR305 expert group
-All rights reserved.
-
-http://www.opensource.org/licenses/bsd-license.php
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the JSR305 expert group nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
+These components
+ com.google.android.rcs.core.utils.FastBase64,
+ com.google.android.rcs.core.utils.LibraryLoaderHelper
+are licensed under BSD.
-jibercsclient:
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
-These components
- com.google.android.rcs.core,
- com.google.android.rcs.core.utils.CaseInsensitiveMap,
- com.google.android.rcs.core.utils.DateTime,
- com.google.android.rcs.core.utils.InetAddresses,
- com.google.android.rcs.core.network.ConnectivityMonitor,
- com.google.android.rcs.client.PrivateDataStorage,
- com.google.android.rcs.client.utils.FastXmlSerializer,
- com.google.android.rcs.client.utils.XmlUtils,
- com.google.android.rcs.client.utils.QueuedWork
-are licensed under Apache v2.
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
-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
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
- http://www.apache.org/licenses/LICENSE-2.0
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-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.
+libphonenumber:
Apache License
Version 2.0, January 2004
@@ -7630,40 +7043,6 @@ limitations under the License.
END OF TERMS AND CONDITIONS
-===============================================================================
-
-These components
- com.google.android.rcs.core.utils.FastBase64,
- com.google.android.rcs.core.utils.LibraryLoaderHelper
-are licensed under BSD.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
mime4j:
@@ -8267,3 +7646,1044 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+shortcutbadger:
+
+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.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+
+Android SDK:
+
+ANDROID SOFTWARE DEVELOPMENT KIT
+
+Terms and Conditions
+
+This is the Android Software Development Kit License Agreement.
+
+1. Introduction
+
+1.1 The Android Software Development Kit (referred to in this License Agreement as the "SDK" and
+specifically including the Android system files, packaged APIs, and Google APIs add-ons) is
+licensed to you subject to the terms of this License Agreement. This License Agreement forms a
+legally binding contract between you and Google in relation to your use of the SDK.
+
+1.2 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600
+Amphitheatre Parkway, Mountain View, CA 94043, United States.
+
+2. Accepting this License Agreement
+
+2.1 In order to use the SDK, you must first agree to this License Agreement. You may not use the
+SDK if you do not accept this License Agreement.
+
+2.2 You can accept this License Agreement by:
+
+(A) clicking to accept or agree to this License Agreement, where this option is made available to
+you; or
+
+(B) by actually using the SDK. In this case, you agree that use of the SDK constitutes acceptance of
+the Licensing Agreement from that point onwards.
+
+2.3 You may not use the SDK and may not accept the Licensing Agreement if you are a person barred
+from receiving the SDK under the laws of the United States or other countries including the country
+in which you are resident or from which you use the SDK.
+
+2.4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other
+entity, you represent and warrant that you have full legal authority to bind your employer or such
+entity to this License Agreement. If you do not have the requisite authority, you may not accept
+the Licensing Agreement or use the SDK on behalf of your employer or other entity.
+
+3. SDK License from Google
+
+3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide,
+royalty-free, non- assignable and non-exclusive license to use the SDK solely to develop
+applications to run on the Android platform.
+
+3.2 You agree that Google or third parties own all legal right, title and interest in and to the
+SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property
+Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law,
+and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
+
+3.3 Except to the extent required by applicable third party licenses, you may not copy (except for
+backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create
+derivative works of the SDK or any part of the SDK. Except to the extent required by applicable
+third party licenses, you may not load any part of the SDK onto a mobile handset or any other
+hardware device except a personal computer, combine any part of the SDK with other software, or
+distribute any software or device incorporating a part of the SDK.
+
+3.4 Use, reproduction and distribution of components of the SDK licensed under an open source
+software license are governed solely by the terms of that open source software license and not
+this License Agreement.
+
+3.5 You agree that the form and nature of the SDK that Google provides may change without prior
+notice to you and that future versions of the SDK may be incompatible with applications developed
+on previous versions of the SDK. You agree that Google may stop (permanently or temporarily)
+providing the SDK (or any features within the SDK) to you or to users generally at Google's sole
+discretion, without prior notice to you.
+
+3.6 Nothing in this License Agreement gives you a right to use any of Google's trade names,
+trademarks, service marks, logos, domain names, or other distinctive brand features.
+
+3.7 You agree that you will not remove, obscure, or alter any proprietary rights notices (including
+copyright and trademark notices) that may be affixed to or contained within the SDK.
+
+4. Use of the SDK by You
+
+4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under
+this License Agreement in or to any software applications that you develop using the SDK, including
+any intellectual property rights that subsist in those applications.
+
+4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) this
+License Agreement and (b) any applicable law, regulation or generally accepted practices or
+guidelines in the relevant jurisdictions (including any laws regarding the export of data or
+software to and from the United States or other relevant countries).
+
+4.3 You agree that if you use the SDK to develop applications for general public users, you will
+protect the privacy and legal rights of those users. If the users provide you with user names,
+passwords, or other login information or personal information, your must make the users aware that
+the information will be available to your application, and you must provide legally adequate privacy
+notice and protection for those users. If your application stores personal or sensitive information
+provided by users, it must do so securely. If the user provides your application with Google Account
+information, your application may only use that information to access the user's Google Account
+when, and for the limited purposes for which, the user has given you permission to do so.
+
+4.4 You agree that you will not engage in any activity with the SDK, including the development or
+distribution of an application, that interferes with, disrupts, damages, or accesses in an
+unauthorized manner the servers, networks, or other properties or services of any third party
+including, but not limited to, Google or any mobile communications carrier.
+
+4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or
+to any third party for) any data, content, or resources that you create, transmit or display through
+the Android platform and/or applications for the Android platform, and for the consequences of your
+actions (including any loss or damage which Google may suffer) by doing so.
+
+4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or
+to any third party for) any breach of your obligations under this License Agreement, any applicable
+third party contract or Terms of Service, or any applicable law or regulation, and for the
+consequences (including any loss or damage which Google or any third party may suffer) of any such
+breach.
+
+5. Your Developer Credentials
+
+5.1 You agree that you are responsible for maintaining the confidentiality of any developer
+credentials that may be issued to you by Google or which you may choose yourself and that you will
+be solely responsible for all applications that are developed under your developer credentials.
+
+6. Privacy and Information
+
+6.1 In order to continually innovate and improve the SDK, Google may collect certain usage
+statistics from the software including but not limited to a unique identifier, associated IP
+address, version number of the software, and information on which tools and/or services in the SDK
+are being used and how they are being used. Before any of this information is collected, the SDK
+will notify you and seek your consent. If you withhold consent, the information will not be
+collected.
+
+6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in
+accordance with Google's Privacy Policy.
+
+7. Third Party Applications for the Android Platform
+
+7.1 If you use the SDK to run applications developed by a third party or that access data, content
+or resources provided by a third party, you agree that Google is not responsible for those
+applications, data, content, or resources. You understand that all data, content or resources which
+you may access through such third party applications are the sole responsibility of the person from
+which they originated and that Google is not liable for any loss or damage that you may experience
+as a result of the use or access of any of those third party applications, data, content, or
+resources.
+
+7.2 You should be aware the data, content, and resources presented to you through such a third party
+application may be protected by intellectual property rights which are owned by the providers (or by
+other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute
+or create derivative works based on these data, content, or resources (either in whole or in part)
+unless you have been specifically given permission to do so by the relevant owners.
+
+7.3 You acknowledge that your use of such third party applications, data, content, or resources may
+be subject to separate terms between you and the relevant third party. In that case, this License
+Agreement does not affect your legal relationship with these third parties.
+
+8. Using Android APIs
+
+8.1 Google Data APIs
+
+8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be
+protected by intellectual property rights which are owned by Google or those parties that provide
+the data (or by other persons or companies on their behalf). Your use of any such API may be subject
+to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create
+derivative works based on this data (either in whole or in part) unless allowed by the relevant
+Terms of Service.
+
+8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you
+shall retrieve data only with the user's explicit consent and only when, and for the limited
+purposes for which, the user has given you permission to do so.
+
+9. Terminating this License Agreement
+
+9.1 This License Agreement will continue to apply until terminated by either you or Google as set
+out below.
+
+9.2 If you want to terminate this License Agreement, you may do so by ceasing your use of the SDK
+and any relevant developer credentials.
+
+9.3 Google may at any time, terminate this License Agreement with you if:
+
+(A) you have breached any provision of this License Agreement; or
+
+(B) Google is required to do so by law; or
+
+(C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated
+its relationship with Google or ceased to offer certain parts of the SDK to you; or
+
+(D) Google decides to no longer providing the SDK or certain parts of the SDK to users in the
+country in which you are resident or from which you use the service, or the provision of the SDK or
+certain SDK services to you by Google is, in Google's sole discretion, no longer commercially
+viable.
+
+9.4 When this License Agreement comes to an end, all of the legal rights, obligations and
+liabilities that you and Google have benefited from, been subject to (or which have accrued over
+time whilst this License Agreement has been in force) or which are expressed to continue
+indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall
+continue to apply to such rights, obligations and liabilities indefinitely.
+
+10. DISCLAIMER OF WARRANTIES
+
+10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE
+SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
+
+10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE
+SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR
+COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.
+
+10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+
+11. LIMITATION OF LIABILITY
+
+11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS
+LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY
+LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN
+AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
+
+12. Indemnification
+
+12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless
+Google, its affiliates and their respective directors, officers, employees and agents from and
+against any and all claims, actions, suits or proceedings, as well as any and all losses,
+liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or
+accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any
+copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any
+person or defames any person or violates their rights of publicity or privacy, and (c) any
+non-compliance by you with this License Agreement.
+
+13. Changes to the License Agreement
+
+13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK.
+When these changes are made, Google will make a new version of the License Agreement available on
+the website where the SDK is made available.
+
+14. General Legal Terms
+
+14.1 This License Agreement constitute the whole legal agreement between you and Google and govern
+your use of the SDK (excluding any services which Google may provide to you under a separate written
+agreement), and completely replace any prior agreements between you and Google in relation to the
+SDK.
+
+14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is
+contained in this License Agreement (or which Google has the benefit of under any applicable law),
+this will not be taken to be a formal waiver of Google's rights and that those rights or remedies
+will still be available to Google.
+
+14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision
+of this License Agreement is invalid, then that provision will be removed from this License
+Agreement without affecting the rest of this License Agreement. The remaining provisions of this
+License Agreement will continue to be valid and enforceable.
+
+14.4 You acknowledge and agree that each member of the group of companies of which Google is the
+parent shall be third party beneficiaries to this License Agreement and that such other companies
+shall be entitled to directly enforce, and rely upon, any provision of this License Agreement that
+confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall
+be third party beneficiaries to this License Agreement.
+
+14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST
+COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE
+LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
+
+14.6 The rights granted in this License Agreement may not be assigned or transferred by either you
+or Google without the prior written approval of the other party. Neither you nor Google shall be
+permitted to delegate their responsibilities or obligations under this License Agreement without the
+prior written approval of the other party.
+
+14.7 This License Agreement, and your relationship with Google under this License Agreement, shall
+be governed by the laws of the State of California without regard to its conflict of laws
+provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located
+within the county of Santa Clara, California to resolve any legal matter arising from this License
+Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for
+injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
+
+April 10, 2009
+
+
+Glide:
+
+Covers library/
+
+Copyright 2014 Google, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this list of
+ conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ of conditions and the following disclaimer in the documentation and/or other materials
+ provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those of the
+authors and should not be interpreted as representing official policies, either expressed
+or implied, of Google, Inc.
+
+--------------------------------------------------------------------------
+Covers third_party/gif_decoder
+
+Copyright (c) 2013 Xcellent Creations, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+--------------------------------------------------------------------------
+Covers third_party/disklrucache
+
+Copyright 2012 Jake Wharton
+Copyright 2011 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.
+--------------------------------------------------------------------------
+Covers third_party/gif_encoder/AnimatedGifEncoder.java and
+third_party/gif_encoder/LZWEncoder.java:
+
+No copyright asserted on the source code of this class. May be used for any
+purpose, however, refer to the Unisys LZW patent for restrictions on use of
+the associated LZWEncoder class. Please forward any corrections to
+kweiner@fmsware.com.
+
+-----------------------------------------------------------------------------
+Covers third_party/gif_encoder/NeuQuant.java
+
+Copyright (c) 1994 Anthony Dekker
+
+NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See
+"Kohonen neural networks for optimal colour quantization" in "Network:
+Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of
+the algorithm.
+
+Any party obtaining a copy of these files from the author, directly or
+indirectly, is granted, free of charge, a full and unrestricted irrevocable,
+world-wide, paid up, royalty-free, nonexclusive right and license to deal in
+this software and documentation files (the "Software"), including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons who
+receive copies from any such party to do so, with the only requirement being
+that this copyright notice remain intact.
+
+
+Animal Sniffer:
+
+The MIT License
+
+Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+
+Checker Framework:
+
+The Checker Framework is licensed under the GNU General Public License,
+version 2 (GPL2), with the classpath exception. The text of this license
+appears below. This is the same license used for OpenJDK.
+
+A few parts of the Checker Framework have more permissive licenses.
+
+ * The annotations are licensed under the MIT License. (The text of this
+ license appears below.) More specifically, all the parts of the Checker
+ Framework that you might want to include with your own program use the
+ MIT License. This is the checker-qual.jar file and all the files that
+ appear in it: every file in a qual/ directory, plus NullnessUtils.java
+ and RegexUtil.java. In addition, the cleanroom implementations of
+ third-party annotations, which the Checker Framework recognizes as
+ aliases for its own annotations, are licensed under the MIT License.
+
+ * The Maven plugin is dual-licensed (you may use whichever you prefer)
+ under GPL2 and the Apache License, version 2.0 (Apache2). The text of
+ Apache2 appears in file maven-plugin/LICENSE.txt. Maven itself uses
+ Apache2.
+
+ * The Eclipse plugin is dual-licensed (you may use whichever you prefer)
+ under GPL2 and the Eclipse Public License Version 1.0 (EPL). EPL
+ appears http://www.eclipse.org/org/documents/epl-v10.php. Eclipse
+ itself uses EPL.
+
+Some external libraries that are included with the Checker Framework have
+different licenses.
+
+ * javaparser is licensed under the LGPL. (The javaparser source code
+ contains a file with the text of the GPL, but it is not clear why, since
+ javaparser does not use the GPL.) See file javaparser/COPYING.LESSER
+ and the source code of all its files.
+
+ * junit is licensed under the Common Public License v1.0 (see
+ http://www.junit.org/license), with parts (Hamcrest) licensed under the
+ BSD License (see LICENSE.txt in checkers/tests/junit.jar ).
+
+ * plume-lib is licensed under the MIT License.
+
+The Checker Framework includes annotations for several libraries, in
+directory checkers/jdk/. The only one that uses a different license than
+the GPL is Google Guava, which uses Apache2.
+
+===========================================================================
+
+The GNU General Public License (GPL)
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license
+document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share
+and change it. By contrast, the GNU General Public License is intended to
+guarantee your freedom to share and change free software--to make sure the
+software is free for all its users. This General Public License applies to
+most of the Free Software Foundation's software and to any other program whose
+authors commit to using it. (Some other Free Software Foundation software is
+covered by the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the freedom to
+distribute copies of free software (and charge for this service if you wish),
+that you receive source code or can get it if you want it, that you can change
+the software or use pieces of it in new free programs; and that you know you
+can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny
+you these rights or to ask you to surrender the rights. These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have. You must
+make sure that they, too, receive or can get the source code. And you must
+show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients to
+know that what they have is not the original, so that any problems introduced
+by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program proprietary.
+To prevent this, we have made it clear that any patent must be licensed for
+everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms of
+this General Public License. The "Program", below, refers to any such program
+or work, and a "work based on the Program" means either the Program or any
+derivative work under copyright law: that is to say, a work containing the
+Program or a portion of it, either verbatim or with modifications and/or
+translated into another language. (Hereinafter, translation is included
+without limitation in the term "modification".) Each licensee is addressed as
+"you".
+
+Activities other than copying, distribution and modification are not covered by
+this License; they are outside its scope. The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made by
+running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as
+you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may
+at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus
+forming a work based on the Program, and copy and distribute such modifications
+or work under the terms of Section 1 above, provided that you also meet all of
+these conditions:
+
+ a) You must cause the modified files to carry prominent notices stating
+ that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in whole or
+ in part contains or is derived from the Program or any part thereof, to be
+ licensed as a whole at no charge to all third parties under the terms of
+ this License.
+
+ c) If the modified program normally reads commands interactively when run,
+ you must cause it, when started running for such interactive use in the
+ most ordinary way, to print or display an announcement including an
+ appropriate copyright notice and a notice that there is no warranty (or
+ else, saying that you provide a warranty) and that users may redistribute
+ the program under these conditions, and telling the user how to view a copy
+ of this License. (Exception: if the Program itself is interactive but does
+ not normally print such an announcement, your work based on the Program is
+ not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be reasonably
+considered independent and separate works in themselves, then this License, and
+its terms, do not apply to those sections when you distribute them as separate
+works. But when you distribute the same sections as part of a whole which is a
+work based on the Program, the distribution of the whole must be on the terms
+of this License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your
+rights to work written entirely by you; rather, the intent is to exercise the
+right to control the distribution of derivative or collective works based on
+the Program.
+
+In addition, mere aggregation of another work not based on the Program with the
+Program (or with a work based on the Program) on a volume of a storage or
+distribution medium does not bring the other work under the scope of this
+License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1 and
+2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable source
+ code, which must be distributed under the terms of Sections 1 and 2 above
+ on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three years, to
+ give any third party, for a charge no more than your cost of physically
+ performing source distribution, a complete machine-readable copy of the
+ corresponding source code, to be distributed under the terms of Sections 1
+ and 2 above on a medium customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer to
+ distribute corresponding source code. (This alternative is allowed only
+ for noncommercial distribution and only if you received the program in
+ object code or executable form with such an offer, in accord with
+ Subsection b above.)
+
+The source code for a work means the preferred form of the work for making
+modifications to it. For an executable work, complete source code means all
+the source code for all modules it contains, plus any associated interface
+definition files, plus the scripts used to control compilation and installation
+of the executable. However, as a special exception, the source code
+distributed need not include anything that is normally distributed (in either
+source or binary form) with the major components (compiler, kernel, and so on)
+of the operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the source
+code from the same place counts as distribution of the source code, even though
+third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy, modify,
+sublicense or distribute the Program is void, and will automatically terminate
+your rights under this License. However, parties who have received copies, or
+rights, from you under this License will not have their licenses terminated so
+long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the Program
+or its derivative works. These actions are prohibited by law if you do not
+accept this License. Therefore, by modifying or distributing the Program (or
+any work based on the Program), you indicate your acceptance of this License to
+do so, and all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program),
+the recipient automatically receives a license from the original licensor to
+copy, distribute or modify the Program subject to these terms and conditions.
+You may not impose any further restrictions on the recipients' exercise of the
+rights granted herein. You are not responsible for enforcing compliance by
+third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose that
+choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original
+copyright holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In
+such case, this License incorporates the limitation as if written in the body
+of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the
+General Public License from time to time. Such new versions will be similar in
+spirit to the present version, but may differ in detail to address new problems
+or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any later
+version", you have the option of following the terms and conditions either of
+that version or of any later version published by the Free Software Foundation.
+If the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software Foundation,
+write to the Free Software Foundation; we sometimes make exceptions for this.
+Our decision will be guided by the two goals of preserving the free status of
+all derivatives of our free software and of promoting the sharing and reuse of
+software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
+PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
+YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
+ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
+PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
+BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
+OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible
+use to the public, the best way to achieve this is to make it free software
+which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach
+them to the start of each source file to most effectively convey the exclusion
+of warranty; and each file should have at least the "copyright" line and a
+pointer to where the full notice is found.
+
+ One line to give the program's name and a brief idea of what it does.
+
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc., 59
+ Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it
+starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
+ with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free
+ software, and you are welcome to redistribute it under certain conditions;
+ type 'show c' for details.
+
+The hypothetical commands 'show w' and 'show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may be
+called something other than 'show w' and 'show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school,
+if any, to sign a "copyright disclaimer" for the program, if necessary. Here
+is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ 'Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ signature of Ty Coon, 1 April 1989
+
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General Public
+License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL
+
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
+
+ Linking this library statically or dynamically with other modules is making
+ a combined work based on this library. Thus, the terms and conditions of
+ the GNU General Public License cover the whole combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent modules,
+ and to copy and distribute the resulting executable under terms of your
+ choice, provided that you also meet, for each linked independent module,
+ the terms and conditions of the license of that module. An independent
+ module is a module which is not derived from or based on this library. If
+ you modify this library, you may extend this exception to your version of
+ the library, but you are not obligated to do so. If you do not wish to do
+ so, delete this exception statement from your version.
+
+===========================================================================
+
+MIT License:
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+===========================================================================
+
+
+JSR 305:
+
+Copyright (c) 2007-2009, JSR305 expert group
+All rights reserved.
+
+http://www.opensource.org/licenses/bsd-license.php
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the JSR305 expert group nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index 261b0ec94..963967ffc 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -39,6 +39,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.telecom.PhoneAccountHandle;
+import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -802,7 +803,7 @@ public class CallLogAdapter extends GroupingListAdapter
int groupSize = getGroupSize(position);
CallDetailsEntries callDetailsEntries = createCallDetailsEntries(c, groupSize);
PhoneCallDetails details = createPhoneCallDetails(c, groupSize, views);
- if (hiddenRowIds.contains(c.getLong(CallLogQuery.ID))) {
+ if (isHiddenRow(views.number, c.getLong(CallLogQuery.ID))) {
views.callLogEntryView.setVisibility(View.GONE);
views.dayGroupHeader.setVisibility(View.GONE);
return;
@@ -827,6 +828,16 @@ public class CallLogAdapter extends GroupingListAdapter
}
}
+ private boolean isHiddenRow(@Nullable String number, long rowId) {
+ if (number != null && PhoneNumberUtils.isEmergencyNumber(number)) {
+ return true;
+ }
+ if (hiddenRowIds.contains(rowId)) {
+ return true;
+ }
+ return false;
+ }
+
private void loadAndRender(
final CallLogListItemViewHolder viewHolder,
final long rowId,
diff --git a/java/com/android/dialer/app/res/values/strings.xml b/java/com/android/dialer/app/res/values/strings.xml
index 99720c2a6..9554fc21b 100644
--- a/java/com/android/dialer/app/res/values/strings.xml
+++ b/java/com/android/dialer/app/res/values/strings.xml
@@ -351,12 +351,12 @@
<!-- Button text for the "Set up" video calling option displayed underneath an entry in the call log.
Tapping causes a the user to be taken to set up video calling.
[CHAR LIMIT=30] -->
- <string name="call_log_action_set_up_video">Set up</string>
+ <string name="call_log_action_set_up_video">Set up video calling</string>
<!-- Button text for the "Invite" option displayed underneath an entry in the call log.
Tapping causes a the user to be taken to the messaging app with a message ready to invite them to set up video calling.
[CHAR LIMIT=30] -->
- <string name="call_log_action_invite_video">Invite</string>
+ <string name="call_log_action_invite_video">Invite to video call</string>
<!-- Button text for a button displayed underneath an entry in the call log, which opens up a
messaging app to send a SMS to the number represented by the call log entry.
diff --git a/java/com/android/dialer/calllog/database/Coalescer.java b/java/com/android/dialer/calllog/database/Coalescer.java
index f4ef02a25..9b788140a 100644
--- a/java/com/android/dialer/calllog/database/Coalescer.java
+++ b/java/com/android/dialer/calllog/database/Coalescer.java
@@ -80,40 +80,45 @@ public class Coalescer {
CoalescedAnnotatedCallLog.ALL_COLUMNS,
Assert.isNotNull(allAnnotatedCallLogRowsSortedByTimestampDesc).getCount());
- if (allAnnotatedCallLogRowsSortedByTimestampDesc.moveToFirst()) {
- int coalescedRowId = 0;
-
- List<ContentValues> currentRowGroup = new ArrayList<>();
+ if (!allAnnotatedCallLogRowsSortedByTimestampDesc.moveToFirst()) {
+ return allCoalescedRowsMatrixCursor;
+ }
- do {
- ContentValues currentRow =
- cursorRowToContentValues(allAnnotatedCallLogRowsSortedByTimestampDesc);
+ int coalescedRowId = 0;
+ List<ContentValues> currentRowGroup = new ArrayList<>();
- if (currentRowGroup.isEmpty()) {
- currentRowGroup.add(currentRow);
- continue;
- }
+ ContentValues firstRow = cursorRowToContentValues(allAnnotatedCallLogRowsSortedByTimestampDesc);
+ currentRowGroup.add(firstRow);
- ContentValues previousRow = currentRowGroup.get(currentRowGroup.size() - 1);
+ while (!currentRowGroup.isEmpty()) {
+ // Group consecutive rows
+ ContentValues firstRowInGroup = currentRowGroup.get(0);
+ ContentValues currentRow = null;
+ while (allAnnotatedCallLogRowsSortedByTimestampDesc.moveToNext()) {
+ currentRow = cursorRowToContentValues(allAnnotatedCallLogRowsSortedByTimestampDesc);
- if (!rowsShouldBeCombined(dialerPhoneNumberUtil, previousRow, currentRow)) {
- ContentValues coalescedRow = coalesceRowsForAllDataSources(currentRowGroup);
- coalescedRow.put(
- CoalescedAnnotatedCallLog.COALESCED_IDS,
- getCoalescedIds(currentRowGroup).toByteArray());
- addContentValuesToMatrixCursor(
- coalescedRow, allCoalescedRowsMatrixCursor, coalescedRowId++);
- currentRowGroup.clear();
+ if (!rowsShouldBeCombined(dialerPhoneNumberUtil, firstRowInGroup, currentRow)) {
+ break;
}
+
currentRowGroup.add(currentRow);
- } while (allAnnotatedCallLogRowsSortedByTimestampDesc.moveToNext());
+ }
- // Deal with leftover rows.
+ // Coalesce the group into a single row
ContentValues coalescedRow = coalesceRowsForAllDataSources(currentRowGroup);
coalescedRow.put(
CoalescedAnnotatedCallLog.COALESCED_IDS, getCoalescedIds(currentRowGroup).toByteArray());
- addContentValuesToMatrixCursor(coalescedRow, allCoalescedRowsMatrixCursor, coalescedRowId);
+ addContentValuesToMatrixCursor(coalescedRow, allCoalescedRowsMatrixCursor, coalescedRowId++);
+
+ // Clear the current group after the rows are coalesced.
+ currentRowGroup.clear();
+
+ // Add the first of the remaining rows to the current group.
+ if (!allAnnotatedCallLogRowsSortedByTimestampDesc.isAfterLast()) {
+ currentRowGroup.add(currentRow);
+ }
}
+
return allCoalescedRowsMatrixCursor;
}
diff --git a/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java
new file mode 100644
index 000000000..ac2e3b3da
--- /dev/null
+++ b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.calllog.ui.menu;
+
+import android.Manifest.permission;
+import android.content.Context;
+import android.provider.CallLog;
+import android.provider.CallLog.Calls;
+import android.support.annotation.Nullable;
+import android.support.annotation.RequiresPermission;
+import com.android.dialer.CoalescedIds;
+import com.android.dialer.common.Assert;
+import com.android.dialer.common.LogUtil;
+import com.android.dialer.common.concurrent.DialerExecutor.Worker;
+import com.android.dialer.common.concurrent.DialerExecutorComponent;
+import com.android.dialer.common.database.Selection;
+import com.android.dialer.contactactions.ContactActionModule;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.List;
+
+/** {@link ContactActionModule} for deleting a call log item in the new call log. */
+public final class DeleteCallLogItemModule implements ContactActionModule {
+ private static final String TAG = DeleteCallLogItemModule.class.getName();
+
+ private final Context context;
+ private final CoalescedIds coalescedIds;
+
+ public DeleteCallLogItemModule(Context context, CoalescedIds coalescedIds) {
+ this.context = context;
+ this.coalescedIds = coalescedIds;
+ }
+
+ @Override
+ public int getStringId() {
+ return R.string.delete;
+ }
+
+ @Override
+ public int getDrawableId() {
+ return R.drawable.quantum_ic_delete_vd_theme_24;
+ }
+
+ @Override
+ public boolean onClick() {
+ DialerExecutorComponent.get(context)
+ .dialerExecutorFactory()
+ .createNonUiTaskBuilder(new CallLogItemDeletionWorker(context))
+ .build()
+ .executeSerial(coalescedIds);
+ return true;
+ }
+
+ /**
+ * A {@link Worker} that deletes a call log item.
+ *
+ * <p>It takes as input the IDs of all call log records that are coalesced into the item to be
+ * deleted.
+ */
+ private static class CallLogItemDeletionWorker implements Worker<CoalescedIds, Void> {
+ private final WeakReference<Context> contextWeakReference;
+
+ CallLogItemDeletionWorker(Context context) {
+ contextWeakReference = new WeakReference<>(context);
+ }
+
+ @Nullable
+ @Override
+ @RequiresPermission(value = permission.WRITE_CALL_LOG)
+ public Void doInBackground(CoalescedIds coalescedIds) throws Throwable {
+ Context context = contextWeakReference.get();
+ if (context == null) {
+ LogUtil.e(TAG, "Unable to delete an call log item due to null context.");
+ return null;
+ }
+
+ Selection selection =
+ Selection.builder()
+ .and(Selection.column(CallLog.Calls._ID).in(getCallLogIdsAsStrings(coalescedIds)))
+ .build();
+ int numRowsDeleted =
+ context
+ .getContentResolver()
+ .delete(Calls.CONTENT_URI, selection.getSelection(), selection.getSelectionArgs());
+
+ if (numRowsDeleted != coalescedIds.getCoalescedIdCount()) {
+ LogUtil.e(
+ TAG,
+ "Deleting call log item is unsuccessful. %d of %d rows are deleted.",
+ numRowsDeleted,
+ coalescedIds.getCoalescedIdCount());
+ }
+
+ return null;
+ }
+
+ private static List<String> getCallLogIdsAsStrings(CoalescedIds coalescedIds) {
+ Assert.checkArgument(coalescedIds.getCoalescedIdCount() > 0);
+
+ List<String> idStrings = new ArrayList<>(coalescedIds.getCoalescedIdCount());
+
+ for (long callLogId : coalescedIds.getCoalescedIdList()) {
+ idStrings.add(String.valueOf(callLogId));
+ }
+
+ return idStrings;
+ }
+ }
+}
diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java
index d62cc2082..3d667fc79 100644
--- a/java/com/android/dialer/calllog/ui/menu/Modules.java
+++ b/java/com/android/dialer/calllog/ui/menu/Modules.java
@@ -64,6 +64,8 @@ final class Modules {
// it use a ContactPrimaryActionInfo instead?
addModuleForAccessingCallDetails(context, modules, row);
+ modules.add(new DeleteCallLogItemModule(context, row.coalescedIds()));
+
return modules;
}
diff --git a/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml b/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml
index 46fbae3bc..7c1835f1b 100644
--- a/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml
+++ b/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml
@@ -21,4 +21,7 @@
can view details for the call log entry. [CHAR LIMIT=30] -->
<string name="call_details_menu_label">Call details</string>
+ <!-- Option displayed in call log to delete a call log item. [CHAR LIMIT=30] -->
+ <string name="delete">Delete</string>
+
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java b/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java
index de37a2915..2629abbbe 100644
--- a/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java
+++ b/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java
@@ -16,24 +16,83 @@
package com.android.dialer.common.concurrent;
+import static com.google.common.util.concurrent.Futures.immediateCancelledFuture;
+import static com.google.common.util.concurrent.Futures.immediateFuture;
+import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+
import com.google.common.util.concurrent.AsyncCallable;
+import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
/**
* Serializes execution of a set of operations. This class guarantees that a submitted callable will
* not be called before previously submitted callables have completed.
*/
public final class DialerFutureSerializer {
+ /** This reference acts as a pointer tracking the head of a linked list of ListenableFutures. */
+ private final AtomicReference<ListenableFuture<?>> ref =
+ new AtomicReference<>(immediateFuture(null));
/** Enqueues a task to run when the previous task (if any) completes. */
+ public <T> ListenableFuture<T> submit(final Callable<T> callable, Executor executor) {
+ return submitAsync(() -> immediateFuture(callable.call()), executor);
+ }
+
+ /**
+ * Enqueues a task to run when the previous task (if any) completes.
+ *
+ * <p>Cancellation does not propagate from the output future to the future returned from {@code
+ * callable}, but if the output future is cancelled before {@link AsyncCallable#call()} is
+ * invoked, {@link AsyncCallable#call()} will not be invoked.
+ */
public <T> ListenableFuture<T> submitAsync(final AsyncCallable<T> callable, Executor executor) {
- // TODO(zachh): This is just a dummy implementation until we fix guava API level issues.
- try {
- return callable.call();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
+ AtomicBoolean wasCancelled = new AtomicBoolean(false);
+ final AsyncCallable<T> task =
+ () -> {
+ if (wasCancelled.get()) {
+ return immediateCancelledFuture();
+ }
+ return callable.call();
+ };
+ /*
+ * Three futures are at play here:
+ * taskFuture is the future that comes from the callable.
+ * newFuture is the future we use to track the serialization of our task.
+ * oldFuture is the previous task's newFuture.
+ *
+ * newFuture is guaranteed to only complete once all tasks previously submitted to this instance
+ * once the futures returned from those submissions have completed.
+ */
+ final SettableFuture<Object> newFuture = SettableFuture.create();
+
+ final ListenableFuture<?> oldFuture = ref.getAndSet(newFuture);
+
+ // Invoke our task once the previous future completes.
+ final ListenableFuture<T> taskFuture =
+ Futures.nonCancellationPropagating(
+ Futures.submitAsync(task, runnable -> oldFuture.addListener(runnable, executor)));
+ // newFuture's lifetime is determined by taskFuture, unless taskFuture is cancelled, in which
+ // case it falls back to oldFuture's. This is to ensure that if the future we return is
+ // cancelled, we don't begin execution of the next task until after oldFuture completes.
+ taskFuture.addListener(
+ () -> {
+ if (taskFuture.isCancelled()) {
+ // Since the value of oldFuture can only ever be immediateFuture(null) or setFuture of a
+ // future that eventually came from immediateFuture(null), this doesn't leak throwables
+ // or completion values.
+ wasCancelled.set(true);
+ newFuture.setFuture(oldFuture);
+ } else {
+ newFuture.set(null);
+ }
+ },
+ directExecutor());
+
+ return taskFuture;
}
}
diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java
index 307e0a434..0d312cbbe 100644
--- a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java
+++ b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java
@@ -19,6 +19,8 @@ package com.android.dialer.phonelookup.cp2;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
+import android.net.Uri;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.DeletedContacts;
@@ -31,6 +33,7 @@ import com.android.dialer.DialerPhoneNumber;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
+import com.android.dialer.common.concurrent.Annotations.LightweightExecutor;
import com.android.dialer.inject.ApplicationContext;
import com.android.dialer.phonelookup.PhoneLookup;
import com.android.dialer.phonelookup.PhoneLookupInfo;
@@ -43,12 +46,18 @@ import com.android.dialer.telecom.TelecomCallUtil;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
import com.google.protobuf.InvalidProtocolBufferException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.Callable;
import javax.inject.Inject;
/** PhoneLookup implementation for local contacts. */
@@ -57,7 +66,8 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
private static final String PREF_LAST_TIMESTAMP_PROCESSED =
"cp2PhoneLookupLastTimestampProcessed";
- private static final String[] CP2_INFO_PROJECTION =
+ /** Projection for performing batch lookups based on E164 numbers using the PHONE table. */
+ private static final String[] PHONE_PROJECTION =
new String[] {
Phone.DISPLAY_NAME_PRIMARY, // 0
Phone.PHOTO_THUMBNAIL_URI, // 1
@@ -65,24 +75,44 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
Phone.TYPE, // 3
Phone.LABEL, // 4
Phone.NORMALIZED_NUMBER, // 5
- Phone.NUMBER, // 6
- Phone.CONTACT_ID, // 7
- Phone.LOOKUP_KEY // 8
+ Phone.CONTACT_ID, // 6
+ Phone.LOOKUP_KEY // 7
};
+ /**
+ * Projection for performing individual lookups of non-E164 numbers using the PHONE_LOOKUP table.
+ */
+ private static final String[] PHONE_LOOKUP_PROJECTION =
+ new String[] {
+ ContactsContract.PhoneLookup.DISPLAY_NAME_PRIMARY, // 0
+ ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI, // 1
+ ContactsContract.PhoneLookup.PHOTO_ID, // 2
+ ContactsContract.PhoneLookup.TYPE, // 3
+ ContactsContract.PhoneLookup.LABEL, // 4
+ ContactsContract.PhoneLookup.NORMALIZED_NUMBER, // 5
+ ContactsContract.PhoneLookup.CONTACT_ID, // 6
+ ContactsContract.PhoneLookup.LOOKUP_KEY // 7
+ };
+
+ // The following indexes should match both PHONE_PROJECTION and PHONE_LOOKUP_PROJECTION above.
private static final int CP2_INFO_NAME_INDEX = 0;
private static final int CP2_INFO_PHOTO_URI_INDEX = 1;
private static final int CP2_INFO_PHOTO_ID_INDEX = 2;
private static final int CP2_INFO_TYPE_INDEX = 3;
private static final int CP2_INFO_LABEL_INDEX = 4;
private static final int CP2_INFO_NORMALIZED_NUMBER_INDEX = 5;
- private static final int CP2_INFO_NUMBER_INDEX = 6;
- private static final int CP2_INFO_CONTACT_ID_INDEX = 7;
- private static final int CP2_INFO_LOOKUP_KEY_INDEX = 8;
+ private static final int CP2_INFO_CONTACT_ID_INDEX = 6;
+ private static final int CP2_INFO_LOOKUP_KEY_INDEX = 7;
+
+ // We cannot efficiently process invalid numbers because batch queries cannot be constructed which
+ // accomplish the necessary loose matching. We'll attempt to process a limited number of them,
+ // but if there are too many we fall back to querying CP2 at render time.
+ private static final int MAX_SUPPORTED_INVALID_NUMBERS = 5;
private final Context appContext;
private final SharedPreferences sharedPreferences;
private final ListeningExecutorService backgroundExecutorService;
+ private final ListeningExecutorService lightweightExecutorService;
@Nullable private Long currentLastTimestampProcessed;
@@ -90,10 +120,12 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
Cp2PhoneLookup(
@ApplicationContext Context appContext,
@Unencrypted SharedPreferences sharedPreferences,
- @BackgroundExecutor ListeningExecutorService backgroundExecutorService) {
+ @BackgroundExecutor ListeningExecutorService backgroundExecutorService,
+ @LightweightExecutor ListeningExecutorService lightweightExecutorService) {
this.appContext = appContext;
this.sharedPreferences = sharedPreferences;
this.backgroundExecutorService = backgroundExecutorService;
+ this.lightweightExecutorService = lightweightExecutorService;
}
@Override
@@ -108,10 +140,12 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
}
Optional<String> e164 = TelecomCallUtil.getE164Number(appContext, call);
Set<Cp2ContactInfo> cp2ContactInfos = new ArraySet<>();
+ // Note: It would make sense to use PHONE_LOOKUP for E164 numbers as well, but we use PHONE to
+ // ensure consistency when the batch methods are used to update data.
try (Cursor cursor =
e164.isPresent()
- ? queryPhoneTableBasedOnE164(CP2_INFO_PROJECTION, ImmutableSet.of(e164.get()))
- : queryPhoneTableBasedOnRawNumber(CP2_INFO_PROJECTION, ImmutableSet.of(rawNumber))) {
+ ? queryPhoneTableBasedOnE164(PHONE_PROJECTION, ImmutableSet.of(e164.get()))
+ : queryPhoneLookup(PHONE_LOOKUP_PROJECTION, rawNumber)) {
if (cursor == null) {
LogUtil.w("Cp2PhoneLookup.lookupInternal", "null cursor");
return Cp2Info.getDefaultInstance();
@@ -125,133 +159,203 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
@Override
public ListenableFuture<Boolean> isDirty(ImmutableSet<DialerPhoneNumber> phoneNumbers) {
- return backgroundExecutorService.submit(() -> isDirtyInternal(phoneNumbers));
- }
-
- private boolean isDirtyInternal(ImmutableSet<DialerPhoneNumber> phoneNumbers) {
- long lastModified = sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L);
- // We are always going to need to do this check and it is pretty cheap so do it first.
- if (anyContactsDeletedSince(lastModified)) {
- return true;
- }
- // Hopefully the most common case is there are no contacts updated; we can detect this cheaply.
- if (noContactsModifiedSince(lastModified)) {
- return false;
- }
- // This method is more expensive but is probably the most likely scenario; we are looking for
- // changes to contacts which have been called.
- if (contactsUpdated(queryPhoneTableForContactIds(phoneNumbers), lastModified)) {
- return true;
- }
- // This is the most expensive method so do it last; the scenario is that a contact which has
- // been called got disassociated with a number and we need to clear their information.
- if (contactsUpdated(queryPhoneLookupHistoryForContactIds(), lastModified)) {
- return true;
- }
- return false;
+ PartitionedNumbers partitionedNumbers = new PartitionedNumbers(phoneNumbers);
+ if (partitionedNumbers.unformattableNumbers().size() > MAX_SUPPORTED_INVALID_NUMBERS) {
+ // If there are N invalid numbers, we can't determine determine dirtiness without running N
+ // queries; since running this many queries is not feasible for the (lightweight) isDirty
+ // check, simply return true. The expectation is that this should rarely be the case as the
+ // vast majority of numbers in call logs should be valid.
+ return Futures.immediateFuture(true);
+ }
+
+ ListenableFuture<Long> lastModifiedFuture =
+ backgroundExecutorService.submit(
+ () -> sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L));
+ return Futures.transformAsync(
+ lastModifiedFuture,
+ lastModified -> {
+ // We are always going to need to do this check and it is pretty cheap so do it first.
+ ListenableFuture<Boolean> anyContactsDeletedFuture =
+ anyContactsDeletedSince(lastModified);
+ return Futures.transformAsync(
+ anyContactsDeletedFuture,
+ anyContactsDeleted -> {
+ if (anyContactsDeleted) {
+ return Futures.immediateFuture(true);
+ }
+ // Hopefully the most common case is there are no contacts updated; we can detect
+ // this cheaply.
+ ListenableFuture<Boolean> noContactsModifiedSinceFuture =
+ noContactsModifiedSince(lastModified);
+ return Futures.transformAsync(
+ noContactsModifiedSinceFuture,
+ noContactsModifiedSince -> {
+ if (noContactsModifiedSince) {
+ return Futures.immediateFuture(false);
+ }
+ // This method is more expensive but is probably the most likely scenario; we
+ // are looking for changes to contacts which have been called.
+ ListenableFuture<Set<Long>> contactIdsFuture =
+ queryPhoneTableForContactIds(phoneNumbers);
+ ListenableFuture<Boolean> contactsUpdatedFuture =
+ Futures.transformAsync(
+ contactIdsFuture,
+ contactIds -> contactsUpdated(contactIds, lastModified),
+ MoreExecutors.directExecutor());
+ return Futures.transformAsync(
+ contactsUpdatedFuture,
+ contactsUpdated -> {
+ if (contactsUpdated) {
+ return Futures.immediateFuture(true);
+ }
+ // This is the most expensive method so do it last; the scenario is that
+ // a contact which has been called got disassociated with a number and
+ // we need to clear their information.
+ ListenableFuture<Set<Long>> phoneLookupContactIdsFuture =
+ queryPhoneLookupHistoryForContactIds();
+ return Futures.transformAsync(
+ phoneLookupContactIdsFuture,
+ phoneLookupContactIds ->
+ contactsUpdated(phoneLookupContactIds, lastModified),
+ MoreExecutors.directExecutor());
+ },
+ MoreExecutors.directExecutor());
+ },
+ MoreExecutors.directExecutor());
+ },
+ MoreExecutors.directExecutor());
+ },
+ MoreExecutors.directExecutor());
}
/**
* Returns set of contact ids that correspond to {@code dialerPhoneNumbers} if the contact exists.
*/
- private Set<Long> queryPhoneTableForContactIds(
+ private ListenableFuture<Set<Long>> queryPhoneTableForContactIds(
ImmutableSet<DialerPhoneNumber> dialerPhoneNumbers) {
- Set<Long> contactIds = new ArraySet<>();
-
PartitionedNumbers partitionedNumbers = new PartitionedNumbers(dialerPhoneNumbers);
+ List<ListenableFuture<Set<Long>>> queryFutures = new ArrayList<>();
+
// First use the E164 numbers to query the NORMALIZED_NUMBER column.
- contactIds.addAll(
+ queryFutures.add(
queryPhoneTableForContactIdsBasedOnE164(partitionedNumbers.validE164Numbers()));
- // Then run a separate query using the NUMBER column to handle numbers that can't be formatted.
- contactIds.addAll(
- queryPhoneTableForContactIdsBasedOnRawNumber(partitionedNumbers.unformattableNumbers()));
-
- return contactIds;
+ // Then run a separate query for each invalid number. Separate queries are done to accomplish
+ // loose matching which couldn't be accomplished with a batch query.
+ Assert.checkState(
+ partitionedNumbers.unformattableNumbers().size() <= MAX_SUPPORTED_INVALID_NUMBERS);
+ for (String invalidNumber : partitionedNumbers.unformattableNumbers()) {
+ queryFutures.add(queryPhoneLookupTableForContactIdsBasedOnRawNumber(invalidNumber));
+ }
+ return Futures.transform(
+ Futures.allAsList(queryFutures),
+ listOfSets -> {
+ Set<Long> contactIds = new ArraySet<>();
+ for (Set<Long> ids : listOfSets) {
+ contactIds.addAll(ids);
+ }
+ return contactIds;
+ },
+ lightweightExecutorService);
}
/** Gets all of the contact ids from PhoneLookupHistory. */
- private Set<Long> queryPhoneLookupHistoryForContactIds() {
- Set<Long> contactIds = new ArraySet<>();
- try (Cursor cursor =
- appContext
- .getContentResolver()
- .query(
- PhoneLookupHistory.CONTENT_URI,
- new String[] {
- PhoneLookupHistory.PHONE_LOOKUP_INFO,
- },
- null,
- null,
- null)) {
-
- if (cursor == null) {
- LogUtil.w("Cp2PhoneLookup.queryPhoneLookupHistoryForContactIds", "null cursor");
- return contactIds;
- }
-
- if (cursor.moveToFirst()) {
- int phoneLookupInfoColumn =
- cursor.getColumnIndexOrThrow(PhoneLookupHistory.PHONE_LOOKUP_INFO);
- do {
- PhoneLookupInfo phoneLookupInfo;
- try {
- phoneLookupInfo = PhoneLookupInfo.parseFrom(cursor.getBlob(phoneLookupInfoColumn));
- } catch (InvalidProtocolBufferException e) {
- throw new IllegalStateException(e);
- }
- for (Cp2ContactInfo info : phoneLookupInfo.getCp2Info().getCp2ContactInfoList()) {
- contactIds.add(info.getContactId());
+ private ListenableFuture<Set<Long>> queryPhoneLookupHistoryForContactIds() {
+ return backgroundExecutorService.submit(
+ () -> {
+ Set<Long> contactIds = new ArraySet<>();
+ try (Cursor cursor =
+ appContext
+ .getContentResolver()
+ .query(
+ PhoneLookupHistory.CONTENT_URI,
+ new String[] {
+ PhoneLookupHistory.PHONE_LOOKUP_INFO,
+ },
+ null,
+ null,
+ null)) {
+
+ if (cursor == null) {
+ LogUtil.w("Cp2PhoneLookup.queryPhoneLookupHistoryForContactIds", "null cursor");
+ return contactIds;
+ }
+
+ if (cursor.moveToFirst()) {
+ int phoneLookupInfoColumn =
+ cursor.getColumnIndexOrThrow(PhoneLookupHistory.PHONE_LOOKUP_INFO);
+ do {
+ PhoneLookupInfo phoneLookupInfo;
+ try {
+ phoneLookupInfo =
+ PhoneLookupInfo.parseFrom(cursor.getBlob(phoneLookupInfoColumn));
+ } catch (InvalidProtocolBufferException e) {
+ throw new IllegalStateException(e);
+ }
+ for (Cp2ContactInfo info : phoneLookupInfo.getCp2Info().getCp2ContactInfoList()) {
+ contactIds.add(info.getContactId());
+ }
+ } while (cursor.moveToNext());
+ }
}
- } while (cursor.moveToNext());
- }
- }
-
- return contactIds;
+ return contactIds;
+ });
}
- private Set<Long> queryPhoneTableForContactIdsBasedOnE164(Set<String> validE164Numbers) {
- Set<Long> contactIds = new ArraySet<>();
- if (validE164Numbers.isEmpty()) {
- return contactIds;
- }
- try (Cursor cursor =
- queryPhoneTableBasedOnE164(new String[] {Phone.CONTACT_ID}, validE164Numbers)) {
- if (cursor == null) {
- LogUtil.w("Cp2PhoneLookup.queryPhoneTableForContactIdsBasedOnE164", "null cursor");
- return contactIds;
- }
- while (cursor.moveToNext()) {
- contactIds.add(cursor.getLong(0 /* columnIndex */));
- }
- }
- return contactIds;
+ private ListenableFuture<Set<Long>> queryPhoneTableForContactIdsBasedOnE164(
+ Set<String> validE164Numbers) {
+ return backgroundExecutorService.submit(
+ () -> {
+ Set<Long> contactIds = new ArraySet<>();
+ if (validE164Numbers.isEmpty()) {
+ return contactIds;
+ }
+ try (Cursor cursor =
+ queryPhoneTableBasedOnE164(new String[] {Phone.CONTACT_ID}, validE164Numbers)) {
+ if (cursor == null) {
+ LogUtil.w("Cp2PhoneLookup.queryPhoneTableForContactIdsBasedOnE164", "null cursor");
+ return contactIds;
+ }
+ while (cursor.moveToNext()) {
+ contactIds.add(cursor.getLong(0 /* columnIndex */));
+ }
+ }
+ return contactIds;
+ });
}
- private Set<Long> queryPhoneTableForContactIdsBasedOnRawNumber(Set<String> unformattableNumbers) {
- Set<Long> contactIds = new ArraySet<>();
- if (unformattableNumbers.isEmpty()) {
- return contactIds;
- }
- try (Cursor cursor =
- queryPhoneTableBasedOnRawNumber(new String[] {Phone.CONTACT_ID}, unformattableNumbers)) {
- if (cursor == null) {
- LogUtil.w("Cp2PhoneLookup.queryPhoneTableForContactIdsBasedOnE164", "null cursor");
- return contactIds;
- }
- while (cursor.moveToNext()) {
- contactIds.add(cursor.getLong(0 /* columnIndex */));
- }
- }
- return contactIds;
+ private ListenableFuture<Set<Long>> queryPhoneLookupTableForContactIdsBasedOnRawNumber(
+ String rawNumber) {
+ return backgroundExecutorService.submit(
+ () -> {
+ Set<Long> contactIds = new ArraySet<>();
+ try (Cursor cursor =
+ queryPhoneLookup(
+ new String[] {android.provider.ContactsContract.PhoneLookup.CONTACT_ID},
+ rawNumber)) {
+ if (cursor == null) {
+ LogUtil.w(
+ "Cp2PhoneLookup.queryPhoneLookupTableForContactIdsBasedOnRawNumber",
+ "null cursor");
+ return contactIds;
+ }
+ while (cursor.moveToNext()) {
+ contactIds.add(cursor.getLong(0 /* columnIndex */));
+ }
+ }
+ return contactIds;
+ });
}
/** Returns true if any contacts were modified after {@code lastModified}. */
- private boolean contactsUpdated(Set<Long> contactIds, long lastModified) {
- try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) {
- return cursor.getCount() > 0;
- }
+ private ListenableFuture<Boolean> contactsUpdated(Set<Long> contactIds, long lastModified) {
+ return backgroundExecutorService.submit(
+ () -> {
+ try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) {
+ return cursor.getCount() > 0;
+ }
+ });
}
private Cursor queryContactsTableForContacts(Set<Long> contactIds, long lastModified) {
@@ -282,47 +386,47 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
null);
}
- private boolean noContactsModifiedSince(long lastModified) {
- try (Cursor cursor =
- appContext
- .getContentResolver()
- .query(
- Contacts.CONTENT_URI,
- new String[] {Contacts._ID},
- Contacts.CONTACT_LAST_UPDATED_TIMESTAMP + " > ?",
- new String[] {Long.toString(lastModified)},
- Contacts._ID + " limit 1")) {
- if (cursor == null) {
- LogUtil.w("Cp2PhoneLookup.noContactsModifiedSince", "null cursor");
- return false;
- }
- return cursor.getCount() == 0;
- }
+ private ListenableFuture<Boolean> noContactsModifiedSince(long lastModified) {
+ return backgroundExecutorService.submit(
+ () -> {
+ try (Cursor cursor =
+ appContext
+ .getContentResolver()
+ .query(
+ Contacts.CONTENT_URI,
+ new String[] {Contacts._ID},
+ Contacts.CONTACT_LAST_UPDATED_TIMESTAMP + " > ?",
+ new String[] {Long.toString(lastModified)},
+ Contacts._ID + " limit 1")) {
+ if (cursor == null) {
+ LogUtil.w("Cp2PhoneLookup.noContactsModifiedSince", "null cursor");
+ return false;
+ }
+ return cursor.getCount() == 0;
+ }
+ });
}
/** Returns true if any contacts were deleted after {@code lastModified}. */
- private boolean anyContactsDeletedSince(long lastModified) {
- try (Cursor cursor =
- appContext
- .getContentResolver()
- .query(
- DeletedContacts.CONTENT_URI,
- new String[] {DeletedContacts.CONTACT_DELETED_TIMESTAMP},
- DeletedContacts.CONTACT_DELETED_TIMESTAMP + " > ?",
- new String[] {Long.toString(lastModified)},
- DeletedContacts.CONTACT_DELETED_TIMESTAMP + " limit 1")) {
- if (cursor == null) {
- LogUtil.w("Cp2PhoneLookup.anyContactsDeletedSince", "null cursor");
- return false;
- }
- return cursor.getCount() > 0;
- }
- }
-
- @Override
- public ListenableFuture<ImmutableMap<DialerPhoneNumber, Cp2Info>> getMostRecentInfo(
- ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap) {
- return backgroundExecutorService.submit(() -> getMostRecentInfoInternal(existingInfoMap));
+ private ListenableFuture<Boolean> anyContactsDeletedSince(long lastModified) {
+ return backgroundExecutorService.submit(
+ () -> {
+ try (Cursor cursor =
+ appContext
+ .getContentResolver()
+ .query(
+ DeletedContacts.CONTENT_URI,
+ new String[] {DeletedContacts.CONTACT_DELETED_TIMESTAMP},
+ DeletedContacts.CONTACT_DELETED_TIMESTAMP + " > ?",
+ new String[] {Long.toString(lastModified)},
+ DeletedContacts.CONTACT_DELETED_TIMESTAMP + " limit 1")) {
+ if (cursor == null) {
+ LogUtil.w("Cp2PhoneLookup.anyContactsDeletedSince", "null cursor");
+ return false;
+ }
+ return cursor.getCount() > 0;
+ }
+ });
}
@Override
@@ -335,46 +439,96 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
return phoneLookupInfo.getCp2Info();
}
- private ImmutableMap<DialerPhoneNumber, Cp2Info> getMostRecentInfoInternal(
+ @Override
+ public ListenableFuture<ImmutableMap<DialerPhoneNumber, Cp2Info>> getMostRecentInfo(
ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap) {
currentLastTimestampProcessed = null;
- long lastModified = sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L);
-
- // Build a set of each DialerPhoneNumber that was associated with a contact, and is no longer
- // associated with that same contact.
- Set<DialerPhoneNumber> deletedPhoneNumbers =
- getDeletedPhoneNumbers(existingInfoMap, lastModified);
-
- // For each DialerPhoneNumber that was associated with a contact or added to a contact,
- // build a map of those DialerPhoneNumbers to a set Cp2ContactInfos, where each Cp2ContactInfo
- // represents a contact.
- Map<DialerPhoneNumber, Set<Cp2ContactInfo>> updatedContacts =
- buildMapForUpdatedOrAddedContacts(existingInfoMap, lastModified, deletedPhoneNumbers);
-
- // Start build a new map of updated info. This will replace existing info.
- ImmutableMap.Builder<DialerPhoneNumber, Cp2Info> newInfoMapBuilder = ImmutableMap.builder();
- // For each DialerPhoneNumber in existing info...
- for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) {
- DialerPhoneNumber dialerPhoneNumber = entry.getKey();
- Cp2Info existingInfo = entry.getValue();
-
- // Build off the existing info
- Cp2Info.Builder infoBuilder = Cp2Info.newBuilder(existingInfo);
-
- // If the contact was updated, replace the Cp2ContactInfo list
- if (updatedContacts.containsKey(dialerPhoneNumber)) {
- infoBuilder.clear().addAllCp2ContactInfo(updatedContacts.get(dialerPhoneNumber));
+ ListenableFuture<Long> lastModifiedFuture =
+ backgroundExecutorService.submit(
+ () -> sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L));
+ return Futures.transformAsync(
+ lastModifiedFuture,
+ lastModified -> {
+ // Build a set of each DialerPhoneNumber that was associated with a contact, and is no
+ // longer associated with that same contact.
+ ListenableFuture<Set<DialerPhoneNumber>> deletedPhoneNumbersFuture =
+ getDeletedPhoneNumbers(existingInfoMap, lastModified);
+
+ return Futures.transformAsync(
+ deletedPhoneNumbersFuture,
+ deletedPhoneNumbers -> {
+
+ // If there are too many invalid numbers, just defer the work to render time.
+ ArraySet<DialerPhoneNumber> unprocessableNumbers =
+ findUnprocessableNumbers(existingInfoMap);
+ Map<DialerPhoneNumber, Cp2Info> existingInfoMapToProcess = existingInfoMap;
+ if (!unprocessableNumbers.isEmpty()) {
+ existingInfoMapToProcess =
+ Maps.filterKeys(
+ existingInfoMap, number -> !unprocessableNumbers.contains(number));
+ }
+
+ // For each DialerPhoneNumber that was associated with a contact or added to a
+ // contact, build a map of those DialerPhoneNumbers to a set Cp2ContactInfos, where
+ // each Cp2ContactInfo represents a contact.
+ ListenableFuture<Map<DialerPhoneNumber, Set<Cp2ContactInfo>>>
+ updatedContactsFuture =
+ buildMapForUpdatedOrAddedContacts(
+ existingInfoMapToProcess, lastModified, deletedPhoneNumbers);
+
+ return Futures.transform(
+ updatedContactsFuture,
+ updatedContacts -> {
+
+ // Start build a new map of updated info. This will replace existing info.
+ ImmutableMap.Builder<DialerPhoneNumber, Cp2Info> newInfoMapBuilder =
+ ImmutableMap.builder();
+
+ // For each DialerPhoneNumber in existing info...
+ for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) {
+ DialerPhoneNumber dialerPhoneNumber = entry.getKey();
+ Cp2Info existingInfo = entry.getValue();
+
+ // Build off the existing info
+ Cp2Info.Builder infoBuilder = Cp2Info.newBuilder(existingInfo);
+
+ // If the contact was updated, replace the Cp2ContactInfo list
+ if (updatedContacts.containsKey(dialerPhoneNumber)) {
+ infoBuilder
+ .clear()
+ .addAllCp2ContactInfo(updatedContacts.get(dialerPhoneNumber));
+ // If it was deleted and not added to a new contact, clear all the CP2
+ // information.
+ } else if (deletedPhoneNumbers.contains(dialerPhoneNumber)) {
+ infoBuilder.clear();
+ } else if (unprocessableNumbers.contains(dialerPhoneNumber)) {
+ infoBuilder.clear().setIsIncomplete(true);
+ }
+
+ // If the DialerPhoneNumber didn't change, add the unchanged existing info.
+ newInfoMapBuilder.put(dialerPhoneNumber, infoBuilder.build());
+ }
+ return newInfoMapBuilder.build();
+ },
+ lightweightExecutorService);
+ },
+ lightweightExecutorService);
+ },
+ lightweightExecutorService);
+ }
- // If it was deleted and not added to a new contact, clear all the CP2 information.
- } else if (deletedPhoneNumbers.contains(dialerPhoneNumber)) {
- infoBuilder.clear();
+ private ArraySet<DialerPhoneNumber> findUnprocessableNumbers(
+ ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap) {
+ ArraySet<DialerPhoneNumber> unprocessableNumbers = new ArraySet<>();
+ PartitionedNumbers partitionedNumbers = new PartitionedNumbers(existingInfoMap.keySet());
+ if (partitionedNumbers.unformattableNumbers().size() > MAX_SUPPORTED_INVALID_NUMBERS) {
+ for (String invalidNumber : partitionedNumbers.unformattableNumbers()) {
+ unprocessableNumbers.addAll(
+ partitionedNumbers.dialerPhoneNumbersForUnformattable(invalidNumber));
}
-
- // If the DialerPhoneNumber didn't change, add the unchanged existing info.
- newInfoMapBuilder.put(dialerPhoneNumber, infoBuilder.build());
}
- return newInfoMapBuilder.build();
+ return unprocessableNumbers;
}
@Override
@@ -391,6 +545,77 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
});
}
+ private ListenableFuture<Set<DialerPhoneNumber>> findNumbersToUpdate(
+ Map<DialerPhoneNumber, Cp2Info> existingInfoMap,
+ long lastModified,
+ Set<DialerPhoneNumber> deletedPhoneNumbers) {
+ return backgroundExecutorService.submit(
+ () -> {
+ Set<DialerPhoneNumber> updatedNumbers = new ArraySet<>();
+ Set<Long> contactIds = new ArraySet<>();
+ for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) {
+ DialerPhoneNumber dialerPhoneNumber = entry.getKey();
+ Cp2Info existingInfo = entry.getValue();
+
+ // If the number was deleted, we need to check if it was added to a new contact.
+ if (deletedPhoneNumbers.contains(dialerPhoneNumber)) {
+ updatedNumbers.add(dialerPhoneNumber);
+ continue;
+ }
+
+ // When the PhoneLookupHistory contains no information for a number, because for
+ // example the user just upgraded to the new UI, or cleared data, we need to check for
+ // updated info.
+ if (existingInfo.getCp2ContactInfoCount() == 0) {
+ updatedNumbers.add(dialerPhoneNumber);
+ } else {
+ // For each Cp2ContactInfo for each existing DialerPhoneNumber...
+ // Store the contact id if it exist, else automatically add the DialerPhoneNumber to
+ // our set of DialerPhoneNumbers we want to update.
+ for (Cp2ContactInfo cp2ContactInfo : existingInfo.getCp2ContactInfoList()) {
+ long existingContactId = cp2ContactInfo.getContactId();
+ if (existingContactId == 0) {
+ // If the number doesn't have a contact id, for various reasons, we need to look
+ // up the number to check if any exists. The various reasons this might happen
+ // are:
+ // - An existing contact that wasn't in the call log is now in the call log.
+ // - A number was in the call log before but has now been added to a contact.
+ // - A number is in the call log, but isn't associated with any contact.
+ updatedNumbers.add(dialerPhoneNumber);
+ } else {
+ contactIds.add(cp2ContactInfo.getContactId());
+ }
+ }
+ }
+ }
+
+ // Query the contacts table and get those that whose
+ // Contacts.CONTACT_LAST_UPDATED_TIMESTAMP is after lastModified, such that Contacts._ID
+ // is in our set of contact IDs we build above.
+ if (!contactIds.isEmpty()) {
+ try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) {
+ int contactIdIndex = cursor.getColumnIndex(Contacts._ID);
+ int lastUpdatedIndex = cursor.getColumnIndex(Contacts.CONTACT_LAST_UPDATED_TIMESTAMP);
+ cursor.moveToPosition(-1);
+ while (cursor.moveToNext()) {
+ // Find the DialerPhoneNumber for each contact id and add it to our updated numbers
+ // set. These, along with our number not associated with any Cp2ContactInfo need to
+ // be updated.
+ long contactId = cursor.getLong(contactIdIndex);
+ updatedNumbers.addAll(
+ findDialerPhoneNumbersContainingContactId(existingInfoMap, contactId));
+ long lastUpdatedTimestamp = cursor.getLong(lastUpdatedIndex);
+ if (currentLastTimestampProcessed == null
+ || currentLastTimestampProcessed < lastUpdatedTimestamp) {
+ currentLastTimestampProcessed = lastUpdatedTimestamp;
+ }
+ }
+ }
+ }
+ return updatedNumbers;
+ });
+ }
+
@Override
public void registerContentObservers(
Context appContext, ContentObserverCallbacks contentObserverCallbacks) {
@@ -406,131 +631,139 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
* @return Map of {@link DialerPhoneNumber} to {@link Cp2Info} with updated {@link
* Cp2ContactInfo}.
*/
- private Map<DialerPhoneNumber, Set<Cp2ContactInfo>> buildMapForUpdatedOrAddedContacts(
- ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap,
- long lastModified,
- Set<DialerPhoneNumber> deletedPhoneNumbers) {
-
- // Start building a set of DialerPhoneNumbers that we want to update.
- Set<DialerPhoneNumber> updatedNumbers = new ArraySet<>();
+ private ListenableFuture<Map<DialerPhoneNumber, Set<Cp2ContactInfo>>>
+ buildMapForUpdatedOrAddedContacts(
+ Map<DialerPhoneNumber, Cp2Info> existingInfoMap,
+ long lastModified,
+ Set<DialerPhoneNumber> deletedPhoneNumbers) {
+ // Start by building a set of DialerPhoneNumbers that we want to update.
+ ListenableFuture<Set<DialerPhoneNumber>> updatedNumbersFuture =
+ findNumbersToUpdate(existingInfoMap, lastModified, deletedPhoneNumbers);
+
+ return Futures.transformAsync(
+ updatedNumbersFuture,
+ updatedNumbers -> {
+ if (updatedNumbers.isEmpty()) {
+ return Futures.immediateFuture(new ArrayMap<>());
+ }
- Set<Long> contactIds = new ArraySet<>();
- for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) {
- DialerPhoneNumber dialerPhoneNumber = entry.getKey();
- Cp2Info existingInfo = entry.getValue();
+ // Divide the numbers into those we can format to E164 and those we can't. Issue a single
+ // batch query for the E164 numbers against the PHONE table, and in parallel issue
+ // individual queries against PHONE_LOOKUP for each non-E164 number.
+ // TODO(zachh): These queries are inefficient without a lastModified column to filter on.
+ PartitionedNumbers partitionedNumbers =
+ new PartitionedNumbers(ImmutableSet.copyOf(updatedNumbers));
- // If the number was deleted, we need to check if it was added to a new contact.
- if (deletedPhoneNumbers.contains(dialerPhoneNumber)) {
- updatedNumbers.add(dialerPhoneNumber);
- continue;
- }
+ ListenableFuture<Map<String, Set<Cp2ContactInfo>>> e164Future =
+ batchQueryForValidNumbers(partitionedNumbers.validE164Numbers());
- /// When the PhoneLookupHistory contains no information for a number, because for example the
- // user just upgraded to the new UI, or cleared data, we need to check for updated info.
- if (existingInfo.getCp2ContactInfoCount() == 0) {
- updatedNumbers.add(dialerPhoneNumber);
- } else {
- // For each Cp2ContactInfo for each existing DialerPhoneNumber...
- // Store the contact id if it exist, else automatically add the DialerPhoneNumber to our
- // set of DialerPhoneNumbers we want to update.
- for (Cp2ContactInfo cp2ContactInfo : existingInfo.getCp2ContactInfoList()) {
- long existingContactId = cp2ContactInfo.getContactId();
- if (existingContactId == 0) {
- // If the number doesn't have a contact id, for various reasons, we need to look up the
- // number to check if any exists. The various reasons this might happen are:
- // - An existing contact that wasn't in the call log is now in the call log.
- // - A number was in the call log before but has now been added to a contact.
- // - A number is in the call log, but isn't associated with any contact.
- updatedNumbers.add(dialerPhoneNumber);
- } else {
- contactIds.add(cp2ContactInfo.getContactId());
+ List<ListenableFuture<Set<Cp2ContactInfo>>> nonE164FuturesList = new ArrayList<>();
+ for (String invalidNumber : partitionedNumbers.unformattableNumbers()) {
+ nonE164FuturesList.add(individualQueryForInvalidNumber(invalidNumber));
}
- }
- }
- }
- // Query the contacts table and get those that whose Contacts.CONTACT_LAST_UPDATED_TIMESTAMP is
- // after lastModified, such that Contacts._ID is in our set of contact IDs we build above.
- if (!contactIds.isEmpty()) {
- try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) {
- int contactIdIndex = cursor.getColumnIndex(Contacts._ID);
- int lastUpdatedIndex = cursor.getColumnIndex(Contacts.CONTACT_LAST_UPDATED_TIMESTAMP);
- cursor.moveToPosition(-1);
- while (cursor.moveToNext()) {
- // Find the DialerPhoneNumber for each contact id and add it to our updated numbers set.
- // These, along with our number not associated with any Cp2ContactInfo need to be updated.
- long contactId = cursor.getLong(contactIdIndex);
- updatedNumbers.addAll(
- findDialerPhoneNumbersContainingContactId(existingInfoMap, contactId));
- long lastUpdatedTimestamp = cursor.getLong(lastUpdatedIndex);
- if (currentLastTimestampProcessed == null
- || currentLastTimestampProcessed < lastUpdatedTimestamp) {
- currentLastTimestampProcessed = lastUpdatedTimestamp;
- }
- }
- }
- }
+ ListenableFuture<List<Set<Cp2ContactInfo>>> nonE164Future =
+ Futures.allAsList(nonE164FuturesList);
+
+ Callable<Map<DialerPhoneNumber, Set<Cp2ContactInfo>>> computeMap =
+ () -> {
+ // These get() calls are safe because we are using whenAllSucceed below.
+ Map<String, Set<Cp2ContactInfo>> e164Result = e164Future.get();
+ List<Set<Cp2ContactInfo>> non164Results = nonE164Future.get();
+
+ Map<DialerPhoneNumber, Set<Cp2ContactInfo>> map = new ArrayMap<>();
+
+ // First update the map with the E164 results.
+ for (Entry<String, Set<Cp2ContactInfo>> entry : e164Result.entrySet()) {
+ String e164Number = entry.getKey();
+ Set<Cp2ContactInfo> cp2ContactInfos = entry.getValue();
+
+ Set<DialerPhoneNumber> dialerPhoneNumbers =
+ partitionedNumbers.dialerPhoneNumbersForE164(e164Number);
+
+ addInfo(map, dialerPhoneNumbers, cp2ContactInfos);
+
+ // We are going to remove the numbers that we've handled so that we later can
+ // detect numbers that weren't handled and therefore need to have their contact
+ // information removed.
+ updatedNumbers.removeAll(dialerPhoneNumbers);
+ }
+
+ // Next update the map with the non-E164 results.
+ int i = 0;
+ for (String unformattableNumber : partitionedNumbers.unformattableNumbers()) {
+ Set<Cp2ContactInfo> cp2Infos = non164Results.get(i++);
+ Set<DialerPhoneNumber> dialerPhoneNumbers =
+ partitionedNumbers.dialerPhoneNumbersForUnformattable(unformattableNumber);
+
+ addInfo(map, dialerPhoneNumbers, cp2Infos);
+
+ // We are going to remove the numbers that we've handled so that we later can
+ // detect numbers that weren't handled and therefore need to have their contact
+ // information removed.
+ updatedNumbers.removeAll(dialerPhoneNumbers);
+ }
+
+ // The leftovers in updatedNumbers that weren't removed are numbers that were
+ // previously associated with contacts, but are no longer. Remove the contact
+ // information for them.
+ for (DialerPhoneNumber dialerPhoneNumber : updatedNumbers) {
+ map.put(dialerPhoneNumber, ImmutableSet.of());
+ }
+ return map;
+ };
+ return Futures.whenAllSucceed(e164Future, nonE164Future)
+ .call(computeMap, lightweightExecutorService);
+ },
+ lightweightExecutorService);
+ }
- if (updatedNumbers.isEmpty()) {
- return new ArrayMap<>();
- }
+ private ListenableFuture<Map<String, Set<Cp2ContactInfo>>> batchQueryForValidNumbers(
+ Set<String> e164Numbers) {
+ return backgroundExecutorService.submit(
+ () -> {
+ Map<String, Set<Cp2ContactInfo>> cp2ContactInfosByNumber = new ArrayMap<>();
+ if (e164Numbers.isEmpty()) {
+ return cp2ContactInfosByNumber;
+ }
+ try (Cursor cursor = queryPhoneTableBasedOnE164(PHONE_PROJECTION, e164Numbers)) {
+ if (cursor == null) {
+ LogUtil.w("Cp2PhoneLookup.batchQueryForValidNumbers", "null cursor");
+ } else {
+ while (cursor.moveToNext()) {
+ String e164Number = cursor.getString(CP2_INFO_NORMALIZED_NUMBER_INDEX);
+ Set<Cp2ContactInfo> cp2ContactInfos = cp2ContactInfosByNumber.get(e164Number);
+ if (cp2ContactInfos == null) {
+ cp2ContactInfos = new ArraySet<>();
+ cp2ContactInfosByNumber.put(e164Number, cp2ContactInfos);
+ }
+ cp2ContactInfos.add(buildCp2ContactInfoFromPhoneCursor(appContext, cursor));
+ }
+ }
+ }
+ return cp2ContactInfosByNumber;
+ });
+ }
- Map<DialerPhoneNumber, Set<Cp2ContactInfo>> map = new ArrayMap<>();
-
- // Divide the numbers into those we can format to E164 and those we can't. Then run separate
- // queries against the contacts table using the NORMALIZED_NUMBER and NUMBER columns.
- // TODO(zachh): These queries are inefficient without a lastModified column to filter on.
- PartitionedNumbers partitionedNumbers =
- new PartitionedNumbers(ImmutableSet.copyOf(updatedNumbers));
- if (!partitionedNumbers.validE164Numbers().isEmpty()) {
- try (Cursor cursor =
- queryPhoneTableBasedOnE164(CP2_INFO_PROJECTION, partitionedNumbers.validE164Numbers())) {
- if (cursor == null) {
- LogUtil.w("Cp2PhoneLookup.buildMapForUpdatedOrAddedContacts", "null cursor");
- } else {
- while (cursor.moveToNext()) {
- String e164Number = cursor.getString(CP2_INFO_NORMALIZED_NUMBER_INDEX);
- Set<DialerPhoneNumber> dialerPhoneNumbers =
- partitionedNumbers.dialerPhoneNumbersForE164(e164Number);
- Cp2ContactInfo info = buildCp2ContactInfoFromPhoneCursor(appContext, cursor);
- addInfo(map, dialerPhoneNumbers, info);
-
- // We are going to remove the numbers that we've handled so that we later can detect
- // numbers that weren't handled and therefore need to have their contact information
- // removed.
- updatedNumbers.removeAll(dialerPhoneNumbers);
+ private ListenableFuture<Set<Cp2ContactInfo>> individualQueryForInvalidNumber(
+ String invalidNumber) {
+ return backgroundExecutorService.submit(
+ () -> {
+ Set<Cp2ContactInfo> cp2ContactInfos = new ArraySet<>();
+ if (invalidNumber.isEmpty()) {
+ return cp2ContactInfos;
}
- }
- }
- }
- if (!partitionedNumbers.unformattableNumbers().isEmpty()) {
- try (Cursor cursor =
- queryPhoneTableBasedOnRawNumber(
- CP2_INFO_PROJECTION, partitionedNumbers.unformattableNumbers())) {
- if (cursor == null) {
- LogUtil.w("Cp2PhoneLookup.buildMapForUpdatedOrAddedContacts", "null cursor");
- } else {
- while (cursor.moveToNext()) {
- String unformattableNumber = cursor.getString(CP2_INFO_NUMBER_INDEX);
- Set<DialerPhoneNumber> dialerPhoneNumbers =
- partitionedNumbers.dialerPhoneNumbersForUnformattable(unformattableNumber);
- Cp2ContactInfo info = buildCp2ContactInfoFromPhoneCursor(appContext, cursor);
- addInfo(map, dialerPhoneNumbers, info);
-
- // We are going to remove the numbers that we've handled so that we later can detect
- // numbers that weren't handled and therefore need to have their contact information
- // removed.
- updatedNumbers.removeAll(dialerPhoneNumbers);
+ try (Cursor cursor = queryPhoneLookup(PHONE_LOOKUP_PROJECTION, invalidNumber)) {
+ if (cursor == null) {
+ LogUtil.w("Cp2PhoneLookup.individualQueryForInvalidNumber", "null cursor");
+ } else {
+ while (cursor.moveToNext()) {
+ cp2ContactInfos.add(buildCp2ContactInfoFromPhoneCursor(appContext, cursor));
+ }
+ }
}
- }
- }
- }
- // The leftovers in updatedNumbers that weren't removed are numbers that were previously
- // associated with contacts, but are no longer. Remove the contact information for them.
- for (DialerPhoneNumber dialerPhoneNumber : updatedNumbers) {
- map.put(dialerPhoneNumber, ImmutableSet.of());
- }
- return map;
+ return cp2ContactInfos;
+ });
}
/**
@@ -540,15 +773,14 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
private static void addInfo(
Map<DialerPhoneNumber, Set<Cp2ContactInfo>> map,
Set<DialerPhoneNumber> dialerPhoneNumbers,
- Cp2ContactInfo cp2ContactInfo) {
+ Set<Cp2ContactInfo> cp2ContactInfos) {
for (DialerPhoneNumber dialerPhoneNumber : dialerPhoneNumbers) {
- if (map.containsKey(dialerPhoneNumber)) {
- map.get(dialerPhoneNumber).add(cp2ContactInfo);
- } else {
- Set<Cp2ContactInfo> cp2ContactInfos = new ArraySet<>();
- cp2ContactInfos.add(cp2ContactInfo);
- map.put(dialerPhoneNumber, cp2ContactInfos);
+ Set<Cp2ContactInfo> existingInfos = map.get(dialerPhoneNumber);
+ if (existingInfos == null) {
+ existingInfos = new ArraySet<>();
+ map.put(dialerPhoneNumber, existingInfos);
}
+ existingInfos.addAll(cp2ContactInfos);
}
}
@@ -563,20 +795,15 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
null);
}
- private Cursor queryPhoneTableBasedOnRawNumber(
- String[] projection, Set<String> unformattableNumbers) {
- return appContext
- .getContentResolver()
- .query(
- Phone.CONTENT_URI,
- projection,
- Phone.NUMBER + " IN (" + questionMarks(unformattableNumbers.size()) + ")",
- unformattableNumbers.toArray(new String[unformattableNumbers.size()]),
- null);
+ private Cursor queryPhoneLookup(String[] projection, String rawNumber) {
+ Uri uri =
+ Uri.withAppendedPath(
+ ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(rawNumber));
+ return appContext.getContentResolver().query(uri, projection, null, null, null);
}
/**
- * @param cursor with projection {@link #CP2_INFO_PROJECTION}.
+ * @param cursor with projection {@link #PHONE_PROJECTION}.
* @return new {@link Cp2ContactInfo} based on current row of {@code cursor}.
*/
private static Cp2ContactInfo buildCp2ContactInfoFromPhoneCursor(
@@ -613,17 +840,21 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
}
/** Returns set of DialerPhoneNumbers that were associated with now deleted contacts. */
- private Set<DialerPhoneNumber> getDeletedPhoneNumbers(
+ private ListenableFuture<Set<DialerPhoneNumber>> getDeletedPhoneNumbers(
ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap, long lastModified) {
- // Build set of all contact IDs from our existing data. We're going to use this set to query
- // against the DeletedContacts table and see if any of them were deleted.
- Set<Long> contactIds = findContactIdsIn(existingInfoMap);
-
- // Start building a set of DialerPhoneNumbers that were associated with now deleted contacts.
- try (Cursor cursor = queryDeletedContacts(contactIds, lastModified)) {
- // We now have a cursor/list of contact IDs that were associated with deleted contacts.
- return findDeletedPhoneNumbersIn(existingInfoMap, cursor);
- }
+ return backgroundExecutorService.submit(
+ () -> {
+ // Build set of all contact IDs from our existing data. We're going to use this set to
+ // query against the DeletedContacts table and see if any of them were deleted.
+ Set<Long> contactIds = findContactIdsIn(existingInfoMap);
+
+ // Start building a set of DialerPhoneNumbers that were associated with now deleted
+ // contacts.
+ try (Cursor cursor = queryDeletedContacts(contactIds, lastModified)) {
+ // We now have a cursor/list of contact IDs that were associated with deleted contacts.
+ return findDeletedPhoneNumbersIn(existingInfoMap, cursor);
+ }
+ });
}
private Set<Long> findContactIdsIn(ImmutableMap<DialerPhoneNumber, Cp2Info> map) {
@@ -683,7 +914,7 @@ public final class Cp2PhoneLookup implements PhoneLookup<Cp2Info> {
}
private static Set<DialerPhoneNumber> findDialerPhoneNumbersContainingContactId(
- ImmutableMap<DialerPhoneNumber, Cp2Info> existingInfoMap, long contactId) {
+ Map<DialerPhoneNumber, Cp2Info> existingInfoMap, long contactId) {
Set<DialerPhoneNumber> matches = new ArraySet<>();
for (Entry<DialerPhoneNumber, Cp2Info> entry : existingInfoMap.entrySet()) {
for (Cp2ContactInfo cp2ContactInfo : entry.getValue().getCp2ContactInfoList()) {
diff --git a/java/com/android/dialer/phonelookup/phone_lookup_info.proto b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
index 75423b9ee..6662646aa 100644
--- a/java/com/android/dialer/phonelookup/phone_lookup_info.proto
+++ b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
@@ -43,6 +43,12 @@ message PhoneLookupInfo {
//
// Empty if there is no CP2 contact information for the number.
repeated Cp2ContactInfo cp2_contact_info = 1;
+
+ // The information for this number is incomplete. This can happen when the
+ // call log is requested to be updated but there are many invalid numbers
+ // and the update cannot be performed efficiently. In this case, the call
+ // log needs to query for the CP2 information at render time.
+ optional bool is_incomplete = 2;
}
optional Cp2Info cp2_info = 1;
diff --git a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java
index d23b5a19d..8cb4557cb 100644
--- a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java
+++ b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java
@@ -20,6 +20,7 @@ import android.support.annotation.AnyThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
+import android.telephony.PhoneNumberUtils;
import com.android.dialer.DialerInternalPhoneNumber;
import com.android.dialer.DialerPhoneNumber;
import com.android.dialer.DialerPhoneNumber.RawInput;
@@ -128,29 +129,38 @@ public class DialerPhoneNumberUtil {
}
/**
- * Formats the provided number to e164 format or return raw number if number is unparseable.
+ * Formats the provided number to E164 format or return a normalized version of the raw number if
+ * the number is not valid according to {@link PhoneNumberUtil#isValidNumber(PhoneNumber)}.
*
- * @see PhoneNumberUtil#format(PhoneNumber, PhoneNumberFormat)
+ * @see #formatToE164(DialerPhoneNumber)
+ * @see PhoneNumberUtils#normalizeNumber(String)
*/
@WorkerThread
public String normalizeNumber(DialerPhoneNumber number) {
Assert.isWorkerThread();
- return formatToE164(number).or(number.getRawInput().getNumber());
+ return formatToE164(number)
+ .or(PhoneNumberUtils.normalizeNumber(number.getRawInput().getNumber()));
}
/**
- * Formats the provided number to e164 format if possible.
+ * If the provided number is "valid" (see {@link PhoneNumberUtil#isValidNumber(PhoneNumber)}),
+ * formats it to E.164. Otherwise, returns {@link Optional#absent()}.
+ *
+ * <p>This method is analogous to {@link PhoneNumberUtils#formatNumberToE164(String, String)} (but
+ * works with an already parsed {@link DialerPhoneNumber} object).
*
+ * @see PhoneNumberUtil#isValidNumber(PhoneNumber)
* @see PhoneNumberUtil#format(PhoneNumber, PhoneNumberFormat)
+ * @see PhoneNumberUtils#formatNumberToE164(String, String)
*/
@WorkerThread
public Optional<String> formatToE164(DialerPhoneNumber number) {
Assert.isWorkerThread();
if (number.hasDialerInternalPhoneNumber()) {
- return Optional.of(
- phoneNumberUtil.format(
- Converter.protoToPojo(number.getDialerInternalPhoneNumber()),
- PhoneNumberFormat.E164));
+ PhoneNumber phoneNumber = Converter.protoToPojo(number.getDialerInternalPhoneNumber());
+ if (phoneNumberUtil.isValidNumber(phoneNumber)) {
+ return Optional.fromNullable(phoneNumberUtil.format(phoneNumber, PhoneNumberFormat.E164));
+ }
}
return Optional.absent();
}
diff --git a/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java b/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java
index 9ac6e7c5e..5fbcc97fe 100644
--- a/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java
+++ b/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java
@@ -24,6 +24,7 @@ import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.StyleSpan;
+import com.android.dialer.common.LogUtil;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -39,6 +40,7 @@ public class QueryBoldingUtil {
* <li>"query" would bold "John [query] Smith"
* <li>"222" would bold "[AAA] Mom"
* <li>"222" would bold "[A]llen [A]lex [A]aron"
+ * <li>"2226" would bold "[AAA M]om"
* </ul>
*
* <p>Some examples of non-matches:
@@ -71,15 +73,18 @@ public class QueryBoldingUtil {
}
}
- Pattern pattern = Pattern.compile("(^|\\s)" + Pattern.quote(query.toLowerCase()));
- Matcher matcher = pattern.matcher(QueryFilteringUtil.getT9Representation(name, context));
- if (matcher.find()) {
+ int indexOfT9Match = QueryFilteringUtil.getIndexOfT9Substring(query, name, context);
+ if (indexOfT9Match != -1) {
// query matches the start of a T9 name (i.e. 75 -> "Jessica [Jo]nes")
- int index = matcher.start();
- // TODO(calderwoodra): investigate why this is consistently off by one.
- index = index == 0 ? 0 : index + 1;
- return getBoldedString(name, index, query.length());
+ int numBolded = query.length();
+ // Bold an extra character for each non-letter
+ for (int i = indexOfT9Match; i <= indexOfT9Match + numBolded && i < name.length(); i++) {
+ if (!Character.isLetter(name.charAt(i))) {
+ numBolded++;
+ }
+ }
+ return getBoldedString(name, indexOfT9Match, numBolded);
} else {
// query match the T9 initials (i.e. 222 -> "[A]l [B]ob [C]harlie")
return getNameWithInitialsBolded(query, name, context);
@@ -148,6 +153,12 @@ public class QueryBoldingUtil {
}
private static SpannableString getBoldedString(String s, int index, int numBolded) {
+ if (numBolded + index > s.length()) {
+ LogUtil.e(
+ "QueryBoldingUtil#getBoldedString",
+ "number of bolded characters exceeded length of string.");
+ numBolded = s.length() - index;
+ }
SpannableString span = new SpannableString(s);
span.setSpan(
new StyleSpan(Typeface.BOLD), index, index + numBolded, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
diff --git a/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java b/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java
index c4ff27545..9add44c8a 100644
--- a/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java
+++ b/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java
@@ -69,9 +69,7 @@ public class QueryFilteringUtil {
}
query = digitsOnly(query);
- Pattern pattern = Pattern.compile("(^|\\s)" + Pattern.quote(query));
- if (pattern.matcher(getT9Representation(name, context)).find()) {
- // query matches the start of a T9 name (i.e. 75 -> "Jessica [Jo]nes")
+ if (getIndexOfT9Substring(query, name, context) != -1) {
return true;
}
@@ -94,6 +92,44 @@ public class QueryFilteringUtil {
}
/**
+ * Returns the index where query is contained in the T9 representation of the name.
+ *
+ * <p>Examples:
+ *
+ * <ul>
+ * <li>#getIndexOfT9Substring("76", "John Smith") returns 5, 76 -> 'Sm'
+ * <li>#nameMatchesT9Query("2226", "AAA Mom") returns 0, 2226 -> 'AAAM'
+ * <li>#nameMatchesT9Query("2", "Jessica Jones") returns -1, Neither 'Jessica' nor 'Jones' start
+ * with A, B or C
+ * </ul>
+ */
+ public static int getIndexOfT9Substring(String query, String name, Context context) {
+ query = digitsOnly(query);
+ String t9Name = getT9Representation(name, context);
+ String t9NameDigitsOnly = digitsOnly(t9Name);
+ if (t9NameDigitsOnly.startsWith(query)) {
+ return 0;
+ }
+
+ int nonLetterCount = 0;
+ for (int i = 1; i < t9NameDigitsOnly.length(); i++) {
+ char cur = t9Name.charAt(i);
+ if (!Character.isDigit(cur)) {
+ nonLetterCount++;
+ continue;
+ }
+
+ // If the previous character isn't a digit and the current is, check for a match
+ char prev = t9Name.charAt(i - 1);
+ int offset = i - nonLetterCount;
+ if (!Character.isDigit(prev) && t9NameDigitsOnly.startsWith(query, offset)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
* Returns true if the subparts of the name (split by white space) begin with the query.
*
* <p>Examples:
diff --git a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java
index c48e2836e..4ef579f06 100644
--- a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java
+++ b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java
@@ -31,6 +31,7 @@ import com.android.dialer.databasepopulator.VoicemailPopulator;
import com.android.dialer.enrichedcall.simulator.EnrichedCallSimulatorActivity;
import com.android.dialer.persistentlog.PersistentLogger;
import com.android.dialer.preferredsim.PreferredSimFallbackContract;
+import com.android.incallui.rtt.impl.RttChatActivity;
/** Implements the top level simulator menu. */
final class SimulatorMainMenu {
@@ -40,6 +41,7 @@ final class SimulatorMainMenu {
.addItem("Voice call", SimulatorVoiceCall.getActionProvider(activity))
.addItem(
"IMS video", SimulatorVideoCall.getActionProvider(activity.getApplicationContext()))
+ .addItem("Rtt call mock", () -> simulateRttCallMock(activity.getApplicationContext()))
.addItem(
"Notifications",
SimulatorNotifications.getActionProvider(activity.getApplicationContext()))
@@ -61,6 +63,10 @@ final class SimulatorMainMenu {
EnrichedCallSimulatorActivity.newIntent(activity.getApplicationContext())));
}
+ private static void simulateRttCallMock(@NonNull Context context) {
+ context.startActivity(new Intent(context, RttChatActivity.class));
+ }
+
private static void populateDatabase(@NonNull Context context) {
DialerExecutorComponent.get(context)
.dialerExecutorFactory()
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
index 93d5cda3e..32c5b6991 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
@@ -55,12 +55,14 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
/** IntDef for the different types of rows that can be shown in the call log. */
@Retention(RetentionPolicy.SOURCE)
- @IntDef({RowType.HEADER, RowType.VOICEMAIL_ENTRY})
+ @IntDef({RowType.HEADER, RowType.VOICEMAIL_ENTRY, RowType.VOICEMAIL_ALERT})
@interface RowType {
+ /** A row representing a voicemail alert. */
+ int VOICEMAIL_ALERT = 1;
/** Header that displays "Today" or "Older". */
- int HEADER = 1;
+ int HEADER = 2;
/** A row representing a voicemail entry. */
- int VOICEMAIL_ENTRY = 2;
+ int VOICEMAIL_ENTRY = 3;
}
private Cursor cursor;
@@ -70,6 +72,8 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
private int todayHeaderPosition = Integer.MAX_VALUE;
/** {@link Integer#MAX_VALUE} when the "Older" header should not be displayed. */
private int olderHeaderPosition = Integer.MAX_VALUE;
+ /** {@link Integer#MAX_VALUE} when the voicemail alert message should not be displayed. */
+ private int voicemailAlertPosition = Integer.MAX_VALUE;
private final FragmentManager fragmentManager;
/** A valid id for {@link VoicemailEntry} is greater than 0 */
@@ -113,16 +117,26 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
private void updateHeaderPositions() {
LogUtil.i(
"NewVoicemailAdapter.updateHeaderPositions",
- "before updating todayPos:%d, olderPos:%d",
+ "before updating todayPos:%d, olderPos:%d, alertPos:%d",
todayHeaderPosition,
- olderHeaderPosition);
+ olderHeaderPosition,
+ voicemailAlertPosition);
+
+ int alertOffSet = 0;
+ if (voicemailAlertPosition != Integer.MAX_VALUE) {
+ Assert.checkArgument(
+ voicemailAlertPosition == 0, "voicemail alert can only be 0, when showing");
+ alertOffSet = 1;
+ }
+
// Calculate header adapter positions by reading cursor.
long currentTimeMillis = clock.currentTimeMillis();
if (cursor.moveToNext()) {
long firstTimestamp = VoicemailCursorLoader.getTimestamp(cursor);
if (CallLogDates.isSameDay(currentTimeMillis, firstTimestamp)) {
- this.todayHeaderPosition = 0;
- int adapterPosition = 2; // Accounted for "Today" header and first row.
+ this.todayHeaderPosition = 0 + alertOffSet;
+ int adapterPosition =
+ 2 + alertOffSet; // Accounted for the "Alert", "Today" header and first row.
while (cursor.moveToNext()) {
long timestamp = VoicemailCursorLoader.getTimestamp(cursor);
@@ -144,9 +158,11 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
}
LogUtil.i(
"NewVoicemailAdapter.updateHeaderPositions",
- "after updating todayPos:%d, olderPos:%d",
+ "after updating todayPos:%d, olderPos:%d, alertOffSet:%d, alertPos:%d",
todayHeaderPosition,
- olderHeaderPosition);
+ olderHeaderPosition,
+ alertOffSet,
+ voicemailAlertPosition);
}
private void initializeMediaPlayerListeners() {
@@ -169,6 +185,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
View view;
switch (viewType) {
+ case RowType.VOICEMAIL_ALERT:
+ view = inflater.inflate(R.layout.new_voicemail_entry_alert, viewGroup, false);
+ return new NewVoicemailAlertViewHolder(view);
case RowType.HEADER:
view = inflater.inflate(R.layout.new_voicemail_entry_header, viewGroup, false);
return new NewVoicemailHeaderViewHolder(view);
@@ -223,14 +242,33 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
return;
}
+ if (viewHolder instanceof NewVoicemailAlertViewHolder) {
+ LogUtil.i(
+ "NewVoicemailAdapter.onBindViewHolder", "view holder at pos:%d is a alert", position);
+ NewVoicemailAlertViewHolder alertViewHolder = (NewVoicemailAlertViewHolder) viewHolder;
+ @RowType int viewType = getItemViewType(position);
+ Assert.checkArgument(position == 0);
+ if (position == voicemailAlertPosition) {
+ // TODO(a bug): Update this with the alert messages
+ alertViewHolder.setHeader("Temporary placeholder, update this with the alert messages");
+ } else {
+ throw Assert.createIllegalStateFailException(
+ "Unexpected view type " + viewType + " at position: " + position);
+ }
+ return;
+ }
+
LogUtil.i(
"NewVoicemailAdapter.onBindViewHolder",
- "view holder at pos:%d is a not a header",
+ "view holder at pos:%d is a not a header or an alert",
position);
NewVoicemailViewHolder newVoicemailViewHolder = (NewVoicemailViewHolder) viewHolder;
int previousHeaders = 0;
+ if (voicemailAlertPosition != Integer.MAX_VALUE && position > voicemailAlertPosition) {
+ previousHeaders++;
+ }
if (todayHeaderPosition != Integer.MAX_VALUE && position > todayHeaderPosition) {
previousHeaders++;
}
@@ -826,6 +864,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
// TODO(uabdullah): a bug Remove logging, temporarily here for debugging.
LogUtil.enterBlock("NewVoicemailAdapter.getItemCount");
int numberOfHeaders = 0;
+ if (voicemailAlertPosition != Integer.MAX_VALUE) {
+ numberOfHeaders++;
+ }
if (todayHeaderPosition != Integer.MAX_VALUE) {
numberOfHeaders++;
}
@@ -846,6 +887,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
@Override
public int getItemViewType(int position) {
LogUtil.enterBlock("NewVoicemailAdapter.getItemViewType");
+ if (voicemailAlertPosition != Integer.MAX_VALUE && position == voicemailAlertPosition) {
+ return RowType.VOICEMAIL_ALERT;
+ }
if (todayHeaderPosition != Integer.MAX_VALUE && position == todayHeaderPosition) {
return RowType.HEADER;
}
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java
new file mode 100644
index 000000000..ec603b5c8
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java
@@ -0,0 +1,36 @@
+/*
+ * 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.dialer.voicemail.listui;
+
+import android.support.v7.widget.RecyclerView.ViewHolder;
+import android.view.View;
+import android.widget.TextView;
+
+/** ViewHolder for {@link NewVoicemailAdapter} to display voicemail error states. */
+final class NewVoicemailAlertViewHolder extends ViewHolder {
+
+ private final TextView errorTextView;
+
+ NewVoicemailAlertViewHolder(View view) {
+ super(view);
+ errorTextView = view.findViewById(R.id.new_voicemail_alert_text);
+ }
+
+ void setHeader(String error) {
+ errorTextView.setText(error);
+ }
+}
diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml
new file mode 100644
index 000000000..e8dcd02d6
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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
+ -->
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="48dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <!-- TODO(uabdullah): Confirm with UX on mocks -->
+ <TextView
+ android:id="@+id/new_voicemail_alert_text"
+ style="@style/SecondaryText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/voicemail_header_margin_start"
+ android:layout_centerVertical="true"/>
+</RelativeLayout>
diff --git a/java/com/android/incallui/rtt/impl/AndroidManifest.xml b/java/com/android/incallui/rtt/impl/AndroidManifest.xml
new file mode 100644
index 000000000..fc0705d7e
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ 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
+ -->
+<manifest
+ package="com.android.incallui.rtt.impl"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <application android:theme="@style/Theme.AppCompat">
+ <activity
+ android:name=".RttChatActivity"
+ android:exported="false"
+ android:theme="@style/DialerThemeBase.NoActionBar"
+ android:windowSoftInputMode="adjustResize"/>
+ </application>
+</manifest>
diff --git a/java/com/android/incallui/rtt/impl/RttChatActivity.java b/java/com/android/incallui/rtt/impl/RttChatActivity.java
new file mode 100644
index 000000000..96056f746
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/RttChatActivity.java
@@ -0,0 +1,41 @@
+/*
+ * 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.incallui.rtt.impl;
+
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.support.annotation.Nullable;
+import android.support.v4.app.FragmentActivity;
+import android.view.View;
+
+/** Activity to for RTT chat window. */
+public class RttChatActivity extends FragmentActivity {
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_rtt);
+ getSupportFragmentManager()
+ .beginTransaction()
+ .add(
+ R.id.fragment_rtt,
+ RttChatFragment.newInstance("", "Jane Williamson", SystemClock.elapsedRealtime()))
+ .commit();
+ getWindow().setStatusBarColor(getColor(R.color.rtt_status_bar_color));
+ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
+}
diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java
new file mode 100644
index 000000000..1db4c6bad
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java
@@ -0,0 +1,218 @@
+/*
+ * 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.incallui.rtt.impl;
+
+import android.content.Context;
+import android.support.annotation.MainThread;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.android.dialer.common.Assert;
+import com.android.dialer.common.LogUtil;
+import com.android.dialer.common.concurrent.ThreadUtil;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+
+/** Adapter class for holding RTT chat data. */
+public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolder> {
+
+ interface MessageListener {
+ void newMessageAdded();
+ }
+
+ private final Context context;
+ private final List<RttChatMessage> rttMessages = new ArrayList<>();
+ private int lastIndexOfLocalMessage = -1;
+ private int lastIndexOfRemoteMessage = -1;
+ private final TypeBot typeBot;
+ private final MessageListener messageListener;
+
+ RttChatAdapter(Context context, MessageListener listener) {
+ this.context = context;
+ this.messageListener = listener;
+ typeBot = new TypeBot(text -> ThreadUtil.postOnUiThread(() -> addRemoteMessage(text)));
+ }
+
+ @Override
+ public RttChatMessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ LayoutInflater layoutInflater = LayoutInflater.from(context);
+ View view = layoutInflater.inflate(R.layout.rtt_chat_list_item, parent, false);
+ return new RttChatMessageViewHolder(view);
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ return super.getItemViewType(position);
+ }
+
+ @Override
+ public void onBindViewHolder(RttChatMessageViewHolder rttChatMessageViewHolder, int i) {
+ boolean isSameGroup = false;
+ if (i > 0) {
+ isSameGroup = rttMessages.get(i).isRemote == rttMessages.get(i - 1).isRemote;
+ }
+ rttChatMessageViewHolder.setMessage(rttMessages.get(i), isSameGroup);
+ }
+
+ @Override
+ public int getItemCount() {
+ return rttMessages.size();
+ }
+
+ private void updateCurrentRemoteMessage(String newText) {
+ RttChatMessage rttChatMessage = null;
+ if (lastIndexOfRemoteMessage >= 0) {
+ rttChatMessage = rttMessages.get(lastIndexOfRemoteMessage);
+ }
+ RttChatMessage[] newMessages = RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText);
+
+ if (rttChatMessage == null) {
+ lastIndexOfRemoteMessage = rttMessages.size();
+ rttMessages.add(lastIndexOfRemoteMessage, newMessages[0]);
+ rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length));
+ notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.length);
+ lastIndexOfRemoteMessage = rttMessages.size() - 1;
+ } else {
+ rttMessages.set(lastIndexOfRemoteMessage, newMessages[0]);
+ int lastIndex = rttMessages.size();
+ rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length));
+
+ notifyItemChanged(lastIndexOfRemoteMessage);
+ notifyItemRangeInserted(lastIndex, newMessages.length);
+ }
+ if (rttMessages.get(lastIndexOfRemoteMessage).isFinished()) {
+ lastIndexOfRemoteMessage = -1;
+ }
+ }
+
+ private void updateCurrentLocalMessage(String newMessage) {
+ RttChatMessage rttChatMessage = null;
+ if (lastIndexOfLocalMessage >= 0) {
+ rttChatMessage = rttMessages.get(lastIndexOfLocalMessage);
+ }
+ if (rttChatMessage == null || rttChatMessage.isFinished()) {
+ rttChatMessage = new RttChatMessage();
+ rttChatMessage.append(newMessage);
+ rttMessages.add(rttChatMessage);
+ lastIndexOfLocalMessage = rttMessages.size() - 1;
+ notifyItemInserted(lastIndexOfLocalMessage);
+ } else {
+ rttChatMessage.append(newMessage);
+ notifyItemChanged(lastIndexOfLocalMessage);
+ }
+ }
+
+ void addLocalMessage(String message) {
+ LogUtil.enterBlock("RttChatAdapater.addLocalMessage");
+ updateCurrentLocalMessage(message);
+ if (messageListener != null) {
+ messageListener.newMessageAdded();
+ }
+ }
+
+ void submitLocalMessage() {
+ LogUtil.enterBlock("RttChatAdapater.submitLocalMessage");
+ rttMessages.get(lastIndexOfLocalMessage).finish();
+ notifyItemChanged(lastIndexOfLocalMessage);
+ lastIndexOfLocalMessage = -1;
+ startChatBot();
+ }
+
+ void addRemoteMessage(String message) {
+ LogUtil.enterBlock("RttChatAdapater.addRemoteMessage");
+ if (TextUtils.isEmpty(message)) {
+ return;
+ }
+ updateCurrentRemoteMessage(message);
+ if (messageListener != null) {
+ messageListener.newMessageAdded();
+ }
+ }
+
+ private void startChatBot() {
+ typeBot.scheduleMessage();
+ }
+
+ // TODO(wangqi): Move this out of this class once a bug is fixed.
+ private static class TypeBot {
+ interface Callback {
+ void type(String text);
+ }
+
+ private static final String[] CANDIDATE_MESSAGES =
+ new String[] {
+ "To RTT or not to RTT, that is the question...",
+ "Making TTY great again!",
+ "I would be more comfortable with real \"Thyme\" chatting."
+ + " I don't know how to end this pun",
+ "お疲れ様でした",
+ "The FCC has mandated that I respond... I will do so begrudgingly",
+ "😂😂😂💯"
+ };
+ private final Random random = new Random();
+ private final Callback callback;
+ private final List<String> messageQueue = new ArrayList<>();
+ private int currentTypingPosition = -1;
+ private String currentTypingMessage = null;
+
+ TypeBot(Callback callback) {
+ this.callback = callback;
+ }
+
+ @MainThread
+ public void scheduleMessage() {
+ Assert.isMainThread();
+ if (random.nextDouble() < 0.5) {
+ return;
+ }
+
+ String text = CANDIDATE_MESSAGES[random.nextInt(CANDIDATE_MESSAGES.length)];
+ messageQueue.add(text);
+ typeMessage();
+ }
+
+ @MainThread
+ private void typeMessage() {
+ Assert.isMainThread();
+ if (currentTypingPosition < 0 || currentTypingMessage == null) {
+ if (messageQueue.size() <= 0) {
+ return;
+ }
+ currentTypingMessage = messageQueue.remove(0);
+ currentTypingPosition = 0;
+ }
+ if (currentTypingPosition < currentTypingMessage.length()) {
+ int size = random.nextInt(currentTypingMessage.length() - currentTypingPosition + 1);
+ callback.type(
+ currentTypingMessage.substring(currentTypingPosition, currentTypingPosition + size));
+ currentTypingPosition = currentTypingPosition + size;
+ // Wait up to 2s between typing.
+ ThreadUtil.postDelayedOnUiThread(this::typeMessage, 200 * random.nextInt(10));
+ } else {
+ callback.type(RttChatMessage.BUBBLE_BREAKER);
+ currentTypingPosition = -1;
+ currentTypingMessage = null;
+ // Wait 1-11s between two messages.
+ ThreadUtil.postDelayedOnUiThread(this::typeMessage, 1000 * (1 + random.nextInt(10)));
+ }
+ }
+ }
+}
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java
new file mode 100644
index 000000000..0b0ad2a8e
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java
@@ -0,0 +1,176 @@
+/*
+ * 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.incallui.rtt.impl;
+
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.RecyclerView.OnScrollListener;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Chronometer;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.TextView;
+import android.widget.TextView.OnEditorActionListener;
+import com.android.incallui.rtt.impl.RttChatAdapter.MessageListener;
+
+/** RTT chat fragment to show chat bubbles. */
+public class RttChatFragment extends Fragment
+ implements OnClickListener, OnEditorActionListener, TextWatcher, MessageListener {
+
+ private static final String ARG_CALL_ID = "call_id";
+ private static final String ARG_NAME_OR_NUMBER = "name_or_number";
+ private static final String ARG_SESSION_START_TIME = "session_start_time";
+
+ private RecyclerView recyclerView;
+ private RttChatAdapter adapter;
+ private EditText editText;
+ private ImageButton submitButton;
+ private boolean isClearingInput;
+
+ private final OnScrollListener onScrollListener =
+ new OnScrollListener() {
+ @Override
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ if (dy < 0) {
+ hideKeyboard();
+ }
+ }
+ };
+
+ /**
+ * Create a new instance of RttChatFragment.
+ *
+ * @param callId call id of the RTT call.
+ * @param nameOrNumber name or number of the caller to be displayed
+ * @param sessionStartTimeMillis start time of RTT session in terms of {@link
+ * SystemClock#elapsedRealtime}.
+ * @return new RttChatFragment
+ */
+ public static RttChatFragment newInstance(
+ String callId, String nameOrNumber, long sessionStartTimeMillis) {
+ Bundle bundle = new Bundle();
+ bundle.putString(ARG_CALL_ID, callId);
+ bundle.putString(ARG_NAME_OR_NUMBER, nameOrNumber);
+ bundle.putLong(ARG_SESSION_START_TIME, sessionStartTimeMillis);
+ RttChatFragment instance = new RttChatFragment();
+ instance.setArguments(bundle);
+ return instance;
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.frag_rtt_chat, container, false);
+ editText = view.findViewById(R.id.rtt_chat_input);
+ editText.setOnEditorActionListener(this);
+ editText.addTextChangedListener(this);
+ recyclerView = view.findViewById(R.id.rtt_recycler_view);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
+ layoutManager.setStackFromEnd(true);
+ recyclerView.setLayoutManager(layoutManager);
+ recyclerView.setHasFixedSize(false);
+ adapter = new RttChatAdapter(getContext(), this);
+ recyclerView.setAdapter(adapter);
+ recyclerView.addOnScrollListener(onScrollListener);
+ submitButton = view.findViewById(R.id.rtt_chat_submit_button);
+ submitButton.setOnClickListener(this);
+ submitButton.setEnabled(false);
+
+ String nameOrNumber = null;
+ Bundle bundle = getArguments();
+ if (bundle != null) {
+ nameOrNumber = bundle.getString(ARG_NAME_OR_NUMBER, getString(R.string.unknown));
+ }
+ TextView nameTextView = view.findViewById(R.id.rtt_name_or_number);
+ nameTextView.setText(nameOrNumber);
+
+ long sessionStartTime = SystemClock.elapsedRealtime();
+ if (bundle != null) {
+ sessionStartTime = bundle.getLong(ARG_SESSION_START_TIME, sessionStartTime);
+ }
+ Chronometer chronometer = view.findViewById(R.id.rtt_timer);
+ chronometer.setBase(sessionStartTime);
+ chronometer.start();
+ return view;
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.rtt_chat_submit_button) {
+ adapter.submitLocalMessage();
+ isClearingInput = true;
+ editText.setText("");
+ isClearingInput = false;
+ }
+ }
+
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ submitButton.performClick();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ if (isClearingInput) {
+ return;
+ }
+ adapter.addLocalMessage(RttChatMessage.getChangedString(s, start, before, count));
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (TextUtils.isEmpty(s)) {
+ submitButton.setEnabled(false);
+ } else {
+ submitButton.setEnabled(true);
+ }
+ }
+
+ @Override
+ public void newMessageAdded() {
+ recyclerView.smoothScrollToPosition(adapter.getItemCount());
+ }
+
+ private void hideKeyboard() {
+ InputMethodManager inputMethodManager = getContext().getSystemService(InputMethodManager.class);
+ if (inputMethodManager.isAcceptingText()) {
+ inputMethodManager.hideSoftInputFromWindow(
+ getActivity().getCurrentFocus().getWindowToken(), 0);
+ }
+ }
+}
diff --git a/java/com/android/incallui/rtt/impl/RttChatMessage.java b/java/com/android/incallui/rtt/impl/RttChatMessage.java
new file mode 100644
index 000000000..85b045183
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/RttChatMessage.java
@@ -0,0 +1,132 @@
+/*
+ * 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.incallui.rtt.impl;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextWatcher;
+import com.google.common.base.Splitter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/** Message class that holds one RTT chat content. */
+final class RttChatMessage {
+
+ static final String BUBBLE_BREAKER = "\n\n";
+ private static final Splitter SPLITTER = Splitter.on(BUBBLE_BREAKER);
+
+ boolean isRemote;
+ public boolean hasAvatar;
+ private final StringBuilder content = new StringBuilder();
+ private boolean isFinished;
+
+ public boolean isFinished() {
+ return isFinished;
+ }
+
+ public void finish() {
+ isFinished = true;
+ }
+
+ public void append(String text) {
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ if (c != '\b') {
+ content.append(c);
+ } else if (content.length() > 0) {
+ content.deleteCharAt(content.length() - 1);
+ }
+ }
+ }
+
+ public String getContent() {
+ return content.toString();
+ }
+
+ /**
+ * Generates delta change to a text.
+ *
+ * <p>This is used to track text change of input. See more details in {@link
+ * TextWatcher#onTextChanged}
+ *
+ * <p>e.g. "hello world" -> "hello" : "\b\b\b\b\b\b"
+ *
+ * <p>"hello world" -> "hello mom!" : "\b\b\b\b\bmom!"
+ *
+ * <p>"hello world" -> "hello d" : "\b\b\b\b\bd"
+ *
+ * <p>"hello world" -> "hello new world" : "\b\b\b\b\bnew world"
+ */
+ static String getChangedString(CharSequence s, int start, int before, int count) {
+ StringBuilder modify = new StringBuilder();
+ if (before > count) {
+ int deleteStart = start + count;
+ int deleted = before - count;
+ int numberUnModifiedCharsAfterDeleted = s.length() - start - count;
+ char c = '\b';
+ for (int i = 0; i < deleted + numberUnModifiedCharsAfterDeleted; i++) {
+ modify.append(c);
+ }
+ modify.append(s, deleteStart, s.length());
+ } else {
+ int insertStart = start + before;
+ int numberUnModifiedCharsAfterInserted = s.length() - start - count;
+ char c = '\b';
+ for (int i = 0; i < numberUnModifiedCharsAfterInserted; i++) {
+ modify.append(c);
+ }
+ modify.append(s, insertStart, s.length());
+ }
+ return modify.toString();
+ }
+
+ /** Convert remote input text into an array of {@code RttChatMessage}. */
+ static RttChatMessage[] getRemoteRttChatMessage(
+ @Nullable RttChatMessage currentMessage, @NonNull String text) {
+ Iterator<String> splitText = SPLITTER.split(text).iterator();
+ List<RttChatMessage> messageList = new ArrayList<>();
+
+ String firstMessageContent = splitText.next();
+ RttChatMessage firstMessage = currentMessage;
+ if (firstMessage == null) {
+ firstMessage = new RttChatMessage();
+ firstMessage.isRemote = true;
+ }
+ firstMessage.append(firstMessageContent);
+ if (splitText.hasNext() || text.endsWith(BUBBLE_BREAKER)) {
+ firstMessage.finish();
+ }
+ messageList.add(firstMessage);
+
+ while (splitText.hasNext()) {
+ String singleMessageContent = splitText.next();
+ if (singleMessageContent.isEmpty()) {
+ continue;
+ }
+ RttChatMessage message = new RttChatMessage();
+ message.append(singleMessageContent);
+ message.isRemote = true;
+ if (splitText.hasNext()) {
+ message.finish();
+ }
+ messageList.add(message);
+ }
+
+ return messageList.toArray(new RttChatMessage[0]);
+ }
+}
diff --git a/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java b/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java
new file mode 100644
index 000000000..c88786aa4
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java
@@ -0,0 +1,65 @@
+/*
+ * 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.incallui.rtt.impl;
+
+import android.content.res.Resources;
+import android.support.v7.widget.RecyclerView.ViewHolder;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.LinearLayout.LayoutParams;
+import android.widget.TextView;
+
+/** ViewHolder class for RTT chat message bubble. */
+public class RttChatMessageViewHolder extends ViewHolder {
+
+ private final TextView messageTextView;
+ private final Resources resources;
+ private final ImageView avatarImageView;
+ private final View container;
+
+ RttChatMessageViewHolder(View view) {
+ super(view);
+ container = view.findViewById(R.id.rtt_chat_message_container);
+ messageTextView = view.findViewById(R.id.rtt_chat_message);
+ avatarImageView = view.findViewById(R.id.rtt_chat_avatar);
+ resources = view.getResources();
+ }
+
+ void setMessage(RttChatMessage message, boolean isSameGroup) {
+ messageTextView.setText(message.getContent());
+ LinearLayout.LayoutParams params = (LayoutParams) container.getLayoutParams();
+ params.gravity = message.isRemote ? Gravity.START : Gravity.END;
+ params.topMargin =
+ isSameGroup
+ ? resources.getDimensionPixelSize(R.dimen.rtt_same_group_message_margin_top)
+ : resources.getDimensionPixelSize(R.dimen.rtt_message_margin_top);
+ container.setLayoutParams(params);
+ messageTextView.setEnabled(message.isRemote);
+ if (message.isRemote) {
+ if (isSameGroup) {
+ avatarImageView.setVisibility(View.INVISIBLE);
+ } else {
+ avatarImageView.setVisibility(View.VISIBLE);
+ avatarImageView.setImageResource(R.drawable.product_logo_avatar_anonymous_white_color_120);
+ }
+ } else {
+ avatarImageView.setVisibility(View.GONE);
+ }
+ }
+}
diff --git a/java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml b/java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml
new file mode 100644
index 000000000..b3729ee20
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml
@@ -0,0 +1,21 @@
+<?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
+ -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_enabled="false"
+ android:color="#E0E0E0" />
+ <item android:color="@android:color/white" />
+</selector> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml b/java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml
new file mode 100644
index 000000000..0da2c374a
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml
@@ -0,0 +1,21 @@
+<?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
+ -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_enabled="false"
+ android:color="#BDBDBD" />
+ <item android:color="#FFFFFF" />
+</selector> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml b/java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml
new file mode 100644
index 000000000..2fe748f77
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml
@@ -0,0 +1,21 @@
+<?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
+ -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_enabled="false"
+ android:color="#EEEEEE" />
+ <item android:color="#2A56C6" />
+</selector> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml b/java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml
new file mode 100644
index 000000000..ae372332e
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml
@@ -0,0 +1,74 @@
+<?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
+ -->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/pill_stroke">
+ <shape android:shape="rectangle">
+ <padding
+ android:bottom="0dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="0dp"/>
+ <solid android:color="@android:color/transparent"/>
+ <corners android:radius="24dp"/>
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp"/>
+ <solid android:color="#102C3558"/>
+ <corners android:radius="24dp"/>
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="0dp"/>
+ <solid android:color="#202C3558"/>
+ <corners android:radius="24dp"/>
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp"/>
+ <solid android:color="#382C3558"/>
+ <corners android:radius="24dp"/>
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <padding
+ android:bottom="1dp"
+ android:left="0dp"
+ android:right="0dp"
+ android:top="0dp"/>
+ <solid android:color="#582C3558"/>
+ <corners android:radius="24dp"/>
+ </shape>
+ </item>
+ <item android:drawable="@drawable/pill_background"/>
+</layer-list> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml b/java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml
new file mode 100644
index 000000000..2b01f62f9
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml
@@ -0,0 +1,21 @@
+<?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">
+ <solid android:color="@android:color/white"/>
+ <corners android:radius="20dp"/>
+</shape> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/drawable/pill_background.xml b/java/com/android/incallui/rtt/impl/res/drawable/pill_background.xml
new file mode 100644
index 000000000..cfad8df57
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/drawable/pill_background.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">
+ <!-- Color is theme dependent and will be overridden in code. -->
+ <solid android:color="@android:color/white"/>
+ <corners android:radius="24dp"/>
+</shape> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml b/java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml
new file mode 100644
index 000000000..b48e8d43f
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml
@@ -0,0 +1,26 @@
+<?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:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <FrameLayout
+ android:id="@+id/fragment_rtt"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+</LinearLayout> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml
new file mode 100644
index 000000000..7ba6a09e3
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml
@@ -0,0 +1,69 @@
+<?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
+ -->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/dialer_theme_color">
+
+ <include layout="@layout/rtt_banner"/>
+
+ <android.support.v7.widget.RecyclerView
+ android:id="@+id/rtt_recycler_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="70dp"
+ android:clipToPadding="false"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="4dp"
+ android:layout_marginStart="5dp"
+ android:layout_marginEnd="4dp"
+ android:layout_gravity="bottom"
+ android:orientation="horizontal">
+ <EditText
+ android:id="@+id/rtt_chat_input"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingTop="10dp"
+ android:paddingBottom="12dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:background="@drawable/input_bubble_background"
+ android:hint="@string/rtt_input_hint"
+ android:imeOptions="actionDone"
+ android:inputType="textMultiLine|text"
+ android:maxLines="4"
+ android:minHeight="53dp"
+ android:textSize="16sp"/>
+ <ImageButton
+ android:id="@+id/rtt_chat_submit_button"
+ android:layout_width="55dp"
+ android:layout_height="53dp"
+ android:layout_gravity="bottom"
+ android:background="@drawable/input_bubble_background"
+ android:backgroundTint="@color/submit_button_background_color"
+ android:backgroundTintMode="multiply"
+ android:contentDescription="@string/content_description_rtt_check_button"
+ android:src="@drawable/quantum_ic_done_vd_theme_24"
+ android:tint="@color/submit_button_color"/>
+ </LinearLayout>
+
+</FrameLayout> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml b/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml
new file mode 100644
index 000000000..7d9cd6fc8
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml
@@ -0,0 +1,91 @@
+<?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
+ -->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="56dp"
+ android:background="#FAFAFA"
+ android:elevation="3dp">
+ <ImageButton
+ android:id="@+id/rtt_back"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:background="@android:color/transparent"
+ android:contentDescription="@string/content_description_rtt_back_button"
+ android:src="@drawable/quantum_ic_close_vd_theme_24"
+ android:tint="#DF000000"/>
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:layout_marginStart="32dp"
+ android:layout_toEndOf="@id/rtt_back"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/rtt_name_or_number"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:includeFontPadding="false"
+ android:textAppearance="@style/Dialer.Incall.TextAppearance.RttTitle"
+ tools:text="Bruce Graham"/>
+ <Chronometer
+ android:id="@+id/rtt_timer"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:includeFontPadding="false"
+ android:textAppearance="@style/Dialer.Incall.TextAppearance.RttTimer"
+ tools:text="00:09"/>
+ </LinearLayout>
+ <ImageButton
+ android:id="@+id/rtt_hang_up_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="16dp"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:background="@android:color/transparent"
+ android:contentDescription="@string/incall_content_description_end_call"
+ android:src="@drawable/quantum_ic_call_end_vd_theme_24"
+ android:tint="#FFDF0000"/>
+ <ImageButton
+ android:id="@+id/rtt_speaker_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="24dp"
+ android:layout_centerVertical="true"
+ android:layout_toStartOf="@id/rtt_hang_up_button"
+ android:background="@android:color/transparent"
+ android:contentDescription="@string/incall_content_description_speaker"
+ android:src="@drawable/quantum_ic_volume_up_vd_theme_24"
+ android:tint="#DD000000"/>
+ <ImageButton
+ android:id="@+id/rtt_mic_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="24dp"
+ android:layout_centerVertical="true"
+ android:layout_toStartOf="@id/rtt_speaker_button"
+ android:background="@android:color/transparent"
+ android:contentDescription="@string/incall_content_description_unmuted"
+ android:src="@drawable/quantum_ic_mic_off_vd_theme_24"
+ android:tint="#DD000000"/>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml b/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml
new file mode 100644
index 000000000..54b0f4f6a
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml
@@ -0,0 +1,48 @@
+<?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:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:orientation="vertical">
+ <LinearLayout
+ android:id="@+id/rtt_chat_message_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <ImageView
+ android:id="@+id/rtt_chat_avatar"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ android:contentDescription="@string/content_description_rtt_chat_avatar"/>
+ <TextView
+ android:id="@+id/rtt_chat_message"
+ style="@style/Dialer.Incall.TextAppearance.RttMessage"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingStart="12dp"
+ android:paddingEnd="12dp"
+ android:paddingTop="9dp"
+ android:paddingBottom="9dp"
+ android:background="@drawable/message_bubble"
+ android:backgroundTint="@color/message_bubble_color"
+ android:maxWidth="292dp"/>
+ </LinearLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/values/colors.xml b/java/com/android/incallui/rtt/impl/res/values/colors.xml
new file mode 100644
index 000000000..402cac4a0
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/values/colors.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
+ -->
+<resources>
+ <color name="rtt_status_bar_color">#E0E0E0</color>
+</resources> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/values/dimens.xml b/java/com/android/incallui/rtt/impl/res/values/dimens.xml
new file mode 100644
index 000000000..a3f230c08
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/values/dimens.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
+ -->
+<resources>
+ <dimen name="rtt_message_margin_top">16dp</dimen>
+ <dimen name="rtt_same_group_message_margin_top">2dp</dimen>
+</resources> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/values/strings.xml b/java/com/android/incallui/rtt/impl/res/values/strings.xml
new file mode 100644
index 000000000..79377acda
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/values/strings.xml
@@ -0,0 +1,29 @@
+<?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
+ -->
+<resources>
+ <!-- Content description for submit chat input button. [CHAR LIMIT=NONE] -->
+ <string name="content_description_rtt_check_button">Go ahead</string>
+
+ <!-- Content description for button of closing RTT chat window. [CHAR LIMIT=NONE] -->
+ <string name="content_description_rtt_back_button">Close RTT chat</string>
+
+ <!-- Hint text for input box. [CHAR LIMIT=NONE] -->
+ <string name="rtt_input_hint">Type a message</string>
+
+ <!-- Content description for avatar of RTT chat message. [CHAR LIMIT=NONE] -->
+ <string name="content_description_rtt_chat_avatar">Avatar</string>
+</resources> \ No newline at end of file
diff --git a/java/com/android/incallui/rtt/impl/res/values/styles.xml b/java/com/android/incallui/rtt/impl/res/values/styles.xml
new file mode 100644
index 000000000..b4bb91474
--- /dev/null
+++ b/java/com/android/incallui/rtt/impl/res/values/styles.xml
@@ -0,0 +1,35 @@
+<?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
+ -->
+<resources>
+ <style name="Dialer.Incall.TextAppearance.RttTitle" parent="Dialer.Incall.TextAppearance">
+ <item name="android:fontFamily">sans-serif</item>
+ <item name="android:textColor">#DD000000</item>
+ <item name="android:textSize">20sp</item>
+ </style>
+
+ <style name="Dialer.Incall.TextAppearance.RttMessage" parent="Dialer.Incall.TextAppearance">
+ <item name="android:fontFamily">sans-serif</item>
+ <item name="android:textColor">#DD000000</item>
+ <item name="android:textSize">16sp</item>
+ </style>
+
+ <style name="Dialer.Incall.TextAppearance.RttTimer" parent="Dialer.Incall.TextAppearance">
+ <item name="android:fontFamily">sans-serif</item>
+ <item name="android:textColor">#DD000000</item>
+ <item name="android:textSize">14sp</item>
+ </style>
+</resources> \ No newline at end of file
diff --git a/packages.mk b/packages.mk
index 03268fd57..d01b3f15a 100644
--- a/packages.mk
+++ b/packages.mk
@@ -75,6 +75,7 @@ LOCAL_AAPT_FLAGS := \
com.android.incallui.hold \
com.android.incallui.incall.impl \
com.android.incallui.maps.impl \
+ com.android.incallui.rtt.impl \
com.android.incallui.sessiondata \
com.android.incallui.spam \
com.android.incallui.speakerbuttonlogic \