Merge "Disable "Clear call log" if empty."
diff --git a/res/mipmap-hdpi/ic_launcher_contacts.png b/res/mipmap-hdpi/ic_launcher_contacts.png
index d730319..5ebe2e0 100644
--- a/res/mipmap-hdpi/ic_launcher_contacts.png
+++ b/res/mipmap-hdpi/ic_launcher_contacts.png
Binary files differ
diff --git a/res/mipmap-hdpi/ic_launcher_phone.png b/res/mipmap-hdpi/ic_launcher_phone.png
index 0943ce5..e56c507 100644
--- a/res/mipmap-hdpi/ic_launcher_phone.png
+++ b/res/mipmap-hdpi/ic_launcher_phone.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_phone.png b/res/mipmap-mdpi/ic_launcher_phone.png
index 724f94a..1f40fd0 100644
--- a/res/mipmap-mdpi/ic_launcher_phone.png
+++ b/res/mipmap-mdpi/ic_launcher_phone.png
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_launcher_phone.png b/res/mipmap-xhdpi/ic_launcher_phone.png
index 6a454da..e23a58c 100644
--- a/res/mipmap-xhdpi/ic_launcher_phone.png
+++ b/res/mipmap-xhdpi/ic_launcher_phone.png
Binary files differ
diff --git a/res/xml/social_widget_info.xml b/res/xml/social_widget_info.xml
index a7bece6..1003c62 100644
--- a/res/xml/social_widget_info.xml
+++ b/res/xml/social_widget_info.xml
@@ -17,8 +17,8 @@
  <!-- It is enough to update once per day, as the widget watches the database for changes -->
  
 <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
-    android:minWidth="294dip"
-    android:minHeight="72dip"
+    android:minWidth="260dip"
+    android:minHeight="40dip"
     android:updatePeriodMillis="86400000"
     android:initialLayout="@layout/social_widget"
     android:previewImage="@drawable/contacts_widget_preview"
diff --git a/src/com/android/contacts/SpecialCharSequenceMgr.java b/src/com/android/contacts/SpecialCharSequenceMgr.java
index 9f9f40d..b5deab8 100644
--- a/src/com/android/contacts/SpecialCharSequenceMgr.java
+++ b/src/com/android/contacts/SpecialCharSequenceMgr.java
@@ -42,6 +42,10 @@
  * Helper class to listen for some magic character sequences
  * that are handled specially by the dialer.
  *
+ * Note the Phone app also handles these sequences too (in a couple of
+ * relativly obscure places in the UI), so there's a separate version of
+ * this class under apps/Phone.
+ *
  * TODO: there's lots of duplicated code between this class and the
  * corresponding class under apps/Phone.  Let's figure out a way to
  * unify these two classes (in the framework? in a common shared library?)
@@ -198,6 +202,12 @@
         return false;
     }
 
+    // TODO: Combine showIMEIPanel() and showMEIDPanel() into a single
+    // generic "showDeviceIdPanel()" method, like in the apps/Phone
+    // version of SpecialCharSequenceMgr.java.  (This will require moving
+    // the phone app's TelephonyCapabilities.getDeviceIdLabel() method
+    // into the telephony framework, though.)
+
     static void showIMEIPanel(Context context, boolean useSystemWindow) {
         String imeiStr = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE))
                 .getDeviceId();
@@ -208,7 +218,6 @@
                 .setPositiveButton(android.R.string.ok, null)
                 .setCancelable(false)
                 .show();
-        alert.getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE);
     }
 
     static void showMEIDPanel(Context context, boolean useSystemWindow) {
@@ -221,7 +230,6 @@
                 .setPositiveButton(android.R.string.ok, null)
                 .setCancelable(false)
                 .show();
-        alert.getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE);
     }
 
     /*******
diff --git a/src/com/android/contacts/dialpad/DialpadFragment.java b/src/com/android/contacts/dialpad/DialpadFragment.java
index 1ff16d2..45cb03b 100644
--- a/src/com/android/contacts/dialpad/DialpadFragment.java
+++ b/src/com/android/contacts/dialpad/DialpadFragment.java
@@ -294,6 +294,10 @@
         return fragmentView;
     }
 
+    private boolean isLayoutReady() {
+        return mDigits != null;
+    }
+
     public EditText getDigitsWidget() {
         return mDigits;
     }
@@ -393,6 +397,16 @@
      * the screen to enter "Add Call" mode, this method will show correct UI for the mode.
      */
     public void configureScreenFromIntent(Intent intent) {
+        if (!isLayoutReady()) {
+            // This happens typically when parent's Activity#onNewIntent() is called while
+            // Fragment#onCreateView() isn't called yet, and thus we cannot configure Views at
+            // this point. onViewCreate() should call this method after preparing layouts, so
+            // just ignore this call now.
+            Log.i(TAG,
+                    "Screen configuration is requested before onCreateView() is called. Ignored");
+            return;
+        }
+
         boolean needToShowDialpadChooser = false;
 
         final boolean isAddCallMode = isAddCallMode(intent);
@@ -535,7 +549,7 @@
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         super.onCreateOptionsMenu(menu, inflater);
         if (mShowOptionsMenu && ViewConfiguration.get(getActivity()).hasPermanentMenuKey() &&
-                mDialpadChooser != null && mDigits != null) {
+                isLayoutReady() && mDialpadChooser != null) {
             inflater.inflate(R.menu.dialpad_options, menu);
         }
     }
@@ -544,7 +558,7 @@
     public void onPrepareOptionsMenu(Menu menu) {
         // Hardware menu key should be available and Views should already be ready.
         if (mShowOptionsMenu && ViewConfiguration.get(getActivity()).hasPermanentMenuKey() &&
-                mDialpadChooser != null && mDigits != null) {
+                isLayoutReady() && mDialpadChooser != null) {
              setupMenuItems(menu);
         }
     }
@@ -896,7 +910,7 @@
      */
     private void showDialpadChooser(boolean enabled) {
         // Check if onCreateView() is already called by checking one of View objects.
-        if (mDigits == null) {
+        if (!isLayoutReady()) {
             return;
         }
 
diff --git a/src/com/android/contacts/list/CustomContactListFilterActivity.java b/src/com/android/contacts/list/CustomContactListFilterActivity.java
index bbfbf32..638a28e 100644
--- a/src/com/android/contacts/list/CustomContactListFilterActivity.java
+++ b/src/com/android/contacts/list/CustomContactListFilterActivity.java
@@ -160,7 +160,8 @@
                     }
                     // Create single entry handling ungrouped status
                     accountDisplay.mUngrouped =
-                        GroupDelta.fromSettings(resolver, account.name, account.type, hasGroups);
+                        GroupDelta.fromSettings(resolver, account.name, account.type,
+                                account.dataSet, hasGroups);
                     accountDisplay.addGroup(accountDisplay.mUngrouped);
                 } finally {
                     iterator.close();
@@ -246,14 +247,18 @@
 
         /**
          * Build {@link GroupDelta} from the {@link Settings} row for the given
-         * {@link Settings#ACCOUNT_NAME} and {@link Settings#ACCOUNT_TYPE}.
+         * {@link Settings#ACCOUNT_NAME}, {@link Settings#ACCOUNT_TYPE}, and
+         * {@link Settings#DATA_SET}.
          */
         public static GroupDelta fromSettings(ContentResolver resolver, String accountName,
-                String accountType, boolean accountHasGroups) {
-            final Uri settingsUri = Settings.CONTENT_URI.buildUpon()
+                String accountType, String dataSet, boolean accountHasGroups) {
+            final Uri.Builder settingsUri = Settings.CONTENT_URI.buildUpon()
                     .appendQueryParameter(Settings.ACCOUNT_NAME, accountName)
-                    .appendQueryParameter(Settings.ACCOUNT_TYPE, accountType).build();
-            final Cursor cursor = resolver.query(settingsUri, new String[] {
+                    .appendQueryParameter(Settings.ACCOUNT_TYPE, accountType);
+            if (dataSet != null) {
+                settingsUri.appendQueryParameter(Settings.DATA_SET, dataSet);
+            }
+            final Cursor cursor = resolver.query(settingsUri.build(), new String[] {
                     Settings.SHOULD_SYNC, Settings.UNGROUPED_VISIBLE
             }, null, null, null);
 
@@ -261,6 +266,7 @@
                 final ContentValues values = new ContentValues();
                 values.put(Settings.ACCOUNT_NAME, accountName);
                 values.put(Settings.ACCOUNT_TYPE, accountType);
+                values.put(Settings.DATA_SET, dataSet);
 
                 if (cursor != null && cursor.moveToFirst()) {
                     // Read existing values when present