Showing "clear defaults" only if there are multiple choices

Bug: 3447220
Change-Id: I8a80fb59e881fec0b10295f112d40a4953960869
diff --git a/src/com/android/contacts/quickcontact/QuickContactWindow.java b/src/com/android/contacts/quickcontact/QuickContactWindow.java
index 3a1bc9d..bbb928d 100644
--- a/src/com/android/contacts/quickcontact/QuickContactWindow.java
+++ b/src/com/android/contacts/quickcontact/QuickContactWindow.java
@@ -32,7 +32,6 @@
 import android.animation.AnimatorListenerAdapter;
 import android.animation.ObjectAnimator;
 import android.content.ActivityNotFoundException;
-import android.content.ContentUris;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -720,7 +719,17 @@
             }
         }
 
-        if (mDefaultsMap.size() != 0) {
+        // Make sure that we only display the "clear default" action if there
+        // are actually several items to chose from
+        boolean shouldDisplayClearDefaults = false;
+        for (String mimetype : mDefaultsMap.keySet()) {
+            if (mActions.get(mimetype).size() > 1) {
+                shouldDisplayClearDefaults = true;
+                break;
+            }
+        }
+
+        if (shouldDisplayClearDefaults) {
             final Action action = new ClearDefaultsAction();
             mActions.put(action.getMimeType(), action);
         }