Merge "Update UI for Caller ID by Google is enabled badge." into lmp-dev
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index 7645736..761f352 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -119,6 +119,7 @@
                         android:layout_height="@dimen/call_provider_small_icon_size"
                         android:layout_marginEnd="@dimen/call_log_icon_margin"
                         android:layout_gravity="center_vertical"
+                        android:tint="?attr/call_log_secondary_text_color"
                         android:scaleType="centerInside"
                         />
                     <TextView
diff --git a/res/values/styles.xml b/res/values/styles.xml
index d0836a5..9d0fcd0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -29,6 +29,7 @@
         <item name="android:windowContentOverlay">@null</item>
         <item name="android:listViewStyle">@style/ListViewStyle</item>
         <item name="android:overlapAnchor">true</item>
+        <item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
         <item name="activated_background">@drawable/list_item_activated_background</item>
         <item name="section_header_background">@drawable/list_title_holo</item>
         <item name="list_section_header_height">32dip</item>
@@ -164,5 +165,13 @@
         <!-- Setting description. -->
         <item name="android:textColorTertiary">@color/setting_secondary_color</item>
         <item name="android:windowBackground">@color/setting_background_color</item>
+        <item name="android:colorAccent">@color/dialtacts_theme_color</item>
+        <item name="android:textColorLink">@color/dialtacts_theme_color</item>
+    </style>
+
+    <!-- Inherit from Theme.Material.Light.Dialog instead of Theme.Material.Light.Dialog.Alert
+    since the Alert dialog is private. They are identical anyway. -->
+    <style name="AlertDialogTheme" parent="@android:style/Theme.Material.Light.Dialog">
+        <item name="android:colorAccent">@color/dialtacts_theme_color</item>
     </style>
 </resources>
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index 5e960f9..c5f2fb6 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -85,8 +85,7 @@
 
         // Show the video icon if the call had video enabled.
         views.callTypeIcons.setShowVideo(
-                (details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO
-                        && CallUtil.isVideoEnabled());
+                (details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO);
         views.callTypeIcons.requestLayout();
         views.callTypeIcons.setVisibility(View.VISIBLE);
 
diff --git a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
index 3c07955..d53f77f 100644
--- a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
+++ b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
@@ -124,7 +124,7 @@
 
         int callType = details.callTypes[0];
         boolean isVideoCall = (details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO
-                && CallUtil.isVideoEnabled();
+                && CallUtil.isVideoEnabled(mContext);
 
         callTypeIconView.clear();
         callTypeIconView.add(callType);
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index b12bbec..e009dda 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -775,7 +775,7 @@
                     null, accountIcon, features, dataUsage, transcription);
         }
 
-        mCallLogViewsHelper.setPhoneCallDetails(views, details);
+        mCallLogViewsHelper.setPhoneCallDetails(mContext, views, details);
 
         int contactType = ContactPhotoManager.TYPE_DEFAULT;
 
diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java
index 23b70d9..68ca7a8 100644
--- a/src/com/android/dialer/calllog/CallLogListItemHelper.java
+++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java
@@ -16,6 +16,7 @@
 
 package com.android.dialer.calllog;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.provider.CallLog.Calls;
 import android.text.TextUtils;
@@ -52,17 +53,19 @@
     /**
      * Sets the name, label, and number for a contact.
      *
+     * @param context The application context.
      * @param views the views to populate
      * @param details the details of a phone call needed to fill in the data
      */
-    public void setPhoneCallDetails(CallLogListItemViews views, PhoneCallDetails details) {
+    public void setPhoneCallDetails(
+            Context context, CallLogListItemViews views, PhoneCallDetails details) {
         mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details);
 
         // Set the accessibility text for the contact badge
         views.quickContactView.setContentDescription(getContactBadgeDescription(details));
 
         // Set the primary action accessibility description
-        views.primaryActionView.setContentDescription(getCallDescription(details));
+        views.primaryActionView.setContentDescription(getCallDescription(context, details));
 
         // Cache name or number of caller.  Used when setting the content descriptions of buttons
         // when the actions ViewStub is inflated.
@@ -124,10 +127,12 @@
      * Examples:
      * 3 calls.  New Voicemail.  Missed call from Joe Smith mobile 2 hours ago.
      * 2 calls.  Answered call from John Doe mobile.  Last called 1 hour ago.
+     *
+     * @param context The application context.
      * @param details Details of call.
      * @return Return call action description.
      */
-    public CharSequence getCallDescription(PhoneCallDetails details) {
+    public CharSequence getCallDescription(Context context, PhoneCallDetails details) {
         int lastCallType = getLastCallType(details.callTypes);
         boolean isVoiceMail = lastCallType == Calls.VOICEMAIL_TYPE;
 
@@ -155,7 +160,7 @@
 
         // If call had video capabilities, add the "Video Call" string.
         if ((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO &&
-                CallUtil.isVideoEnabled()) {
+                CallUtil.isVideoEnabled(context)) {
             callDescription.append(mResources.getString(R.string.description_video_call));
         }
 
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index ce6c46d..84f1c64 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -650,11 +650,14 @@
 
         mSmsPackageComponentName = DialerUtils.getSmsComponent(activity);
 
+        // Populate the overflow menu in onResume instead of onCreate, so that if the SMS activity
+        // is disabled while Dialer is paused, the "Send a text message" option can be correctly
+        // removed when resumed.
         mOverflowMenuButton = mDialpadView.getOverflowMenuButton();
         mOverflowPopupMenu = buildOptionsMenu(mOverflowMenuButton);
         mOverflowMenuButton.setOnTouchListener(mOverflowPopupMenu.getDragToOpenListener());
         mOverflowMenuButton.setOnClickListener(this);
-        mOverflowMenuButton.setVisibility(View.INVISIBLE);
+        mOverflowMenuButton.setVisibility(isDigitsEmpty() ? View.INVISIBLE : View.VISIBLE);
     }
 
     @Override
diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java
index b1223b7..3ce4bea 100644
--- a/src/com/android/dialer/list/RegularSearchListAdapter.java
+++ b/src/com/android/dialer/list/RegularSearchListAdapter.java
@@ -75,7 +75,7 @@
         // Otherwise, it should add it to a new contact as a name.
         setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts);
         setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL,
-                showNumberShortcuts && CallUtil.isVideoEnabled());
+                showNumberShortcuts && CallUtil.isVideoEnabled(getContext()));
         super.setQueryString(queryString);
     }
 }
diff --git a/src/com/android/dialer/list/SmartDialNumberListAdapter.java b/src/com/android/dialer/list/SmartDialNumberListAdapter.java
index 898115a..b2e0310 100644
--- a/src/com/android/dialer/list/SmartDialNumberListAdapter.java
+++ b/src/com/android/dialer/list/SmartDialNumberListAdapter.java
@@ -120,7 +120,7 @@
         final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString());
         setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts);
         setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL,
-                showNumberShortcuts && CallUtil.isVideoEnabled());
+                showNumberShortcuts && CallUtil.isVideoEnabled(getContext()));
         super.setQueryString(queryString);
     }
 }
diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
index c001165..85dbf8c 100644
--- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
@@ -233,7 +233,7 @@
                 TEST_FORMATTED_NUMBER,
                 TEST_COUNTRY_ISO, TEST_GEOCODE,
                 new int[]{Calls.OUTGOING_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
-        CharSequence description = mHelper.getCallDescription(details);
+        CharSequence description = mHelper.getCallDescription(getContext(), details);
         assertFalse(description.toString()
                 .contains(this.mResources.getString(R.string.description_new_voicemail)));
     }
@@ -247,7 +247,7 @@
                 TEST_FORMATTED_NUMBER,
                 TEST_COUNTRY_ISO, TEST_GEOCODE,
                 new int[]{Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
-        CharSequence description = mHelper.getCallDescription(details);
+        CharSequence description = mHelper.getCallDescription(getContext(), details);
         assertFalse(description.toString()
                 .contains(this.mResources.getString(R.string.description_new_voicemail)));
     }
@@ -261,7 +261,7 @@
                 TEST_FORMATTED_NUMBER,
                 TEST_COUNTRY_ISO, TEST_GEOCODE,
                 new int[]{Calls.MISSED_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
-        CharSequence description = mHelper.getCallDescription(details);
+        CharSequence description = mHelper.getCallDescription(getContext(), details);
         assertFalse(description.toString()
                 .contains(this.mResources.getString(R.string.description_new_voicemail)));
     }
@@ -275,7 +275,7 @@
                 TEST_FORMATTED_NUMBER,
                 TEST_COUNTRY_ISO, TEST_GEOCODE,
                 new int[]{Calls.VOICEMAIL_TYPE, Calls.OUTGOING_TYPE}, TEST_DATE, TEST_DURATION);
-        CharSequence description = mHelper.getCallDescription(details);
+        CharSequence description = mHelper.getCallDescription(getContext(), details);
         assertTrue(description.toString()
                 .contains(this.mResources.getString(R.string.description_new_voicemail)));
     }
@@ -289,7 +289,7 @@
                 TEST_FORMATTED_NUMBER,
                 TEST_COUNTRY_ISO, TEST_GEOCODE,
                 new int[]{Calls.VOICEMAIL_TYPE}, TEST_DATE, TEST_DURATION);
-        CharSequence description = mHelper.getCallDescription(details);
+        CharSequence description = mHelper.getCallDescription(getContext(), details);
 
         // Rather than hard coding the "X calls" string message, we'll generate it with an empty
         // number of calls, and trim the resulting string.  This gets us just the word "calls",
@@ -308,7 +308,7 @@
                 TEST_FORMATTED_NUMBER,
                 TEST_COUNTRY_ISO, TEST_GEOCODE,
                 new int[]{Calls.VOICEMAIL_TYPE, Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION);
-        CharSequence description = mHelper.getCallDescription(details);
+        CharSequence description = mHelper.getCallDescription(getContext(), details);
         assertTrue(description.toString()
                 .contains(this.mResources.getString(R.string.description_num_calls, 2)));
     }
@@ -324,7 +324,7 @@
                 new int[]{Calls.INCOMING_TYPE, Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION,
                 null, null, Calls.FEATURES_VIDEO, null, null);
 
-        CharSequence description = mHelper.getCallDescription(details);
+        CharSequence description = mHelper.getCallDescription(getContext(), details);
         assertTrue(description.toString()
                 .contains(this.mResources.getString(R.string.description_video_call, 2)));
     }
@@ -346,7 +346,7 @@
     /** Sets the details of a phone call using the specified phone number. */
     private void setPhoneCallDetailsWithNumberAndType(String number,
             int presentation, String formattedNumber, int callType) {
-        mHelper.setPhoneCallDetails(mViews,
+        mHelper.setPhoneCallDetails(getContext(), mViews,
                 new PhoneCallDetails(number, presentation, formattedNumber,
                         TEST_COUNTRY_ISO, TEST_GEOCODE,
                         new int[]{ callType }, TEST_DATE, TEST_DURATION)
@@ -355,7 +355,7 @@
 
     /** Sets the details of a phone call using the specified call type. */
     private void setPhoneCallDetailsWithTypes(int... types) {
-        mHelper.setPhoneCallDetails(mViews,
+        mHelper.setPhoneCallDetails(getContext() ,mViews,
                 new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
                         TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
                         types, TEST_DATE, TEST_DURATION)
@@ -364,7 +364,7 @@
 
     /** Sets the details of an unread phone call using the specified call type. */
     private void setUnreadPhoneCallDetailsWithTypes(int... types) {
-        mHelper.setPhoneCallDetails(mViews,
+        mHelper.setPhoneCallDetails(getContext(), mViews,
                 new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
                         TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
                         types, TEST_DATE, TEST_DURATION)