Merge "Use a custom character map instead of name normalizer"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7c39ee5..502184c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -51,10 +51,8 @@
 
     <application
         android:label="@string/applicationLabel"
-        android:icon="@mipmap/ic_launcher_contacts"
-        android:taskAffinity="android.task.contacts"
-        android:hardwareAccelerated="true"
-    >
+        android:icon="@mipmap/ic_launcher_phone"
+        android:hardwareAccelerated="true">
 
         <!-- The entrance point for Phone UI.
              stateAlwaysHidden is set to suppress keyboard show up on
@@ -68,7 +66,6 @@
             android:icon="@mipmap/ic_launcher_phone"
             android:screenOrientation="nosensor"
             android:enabled="@*android:bool/config_voice_capable"
-            android:taskAffinity="android.task.contacts.phone"
             android:windowSoftInputMode="stateAlwaysHidden|adjustNothing">
             <intent-filter>
                 <action android:name="android.intent.action.DIAL" />
@@ -130,7 +127,6 @@
                   android:theme="@style/CallDetailActivityTheme"
                   android:screenOrientation="portrait"
                   android:icon="@mipmap/ic_launcher_phone"
-                  android:taskAffinity="android.task.contacts.phone"
             >
             <intent-filter>
                 <action android:name="android.intent.action.VIEW"/>
diff --git a/res/mipmap-hdpi/ic_launcher_phone.png b/res/mipmap-hdpi/ic_launcher_phone.png
new file mode 100644
index 0000000..5a3dff1
--- /dev/null
+++ 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
new file mode 100644
index 0000000..9ea0d8c
--- /dev/null
+++ 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
new file mode 100644
index 0000000..e97836c
--- /dev/null
+++ b/res/mipmap-xhdpi/ic_launcher_phone.png
Binary files differ
diff --git a/res/mipmap-xxhdpi/ic_launcher_phone.png b/res/mipmap-xxhdpi/ic_launcher_phone.png
new file mode 100644
index 0000000..1594e4e
--- /dev/null
+++ b/res/mipmap-xxhdpi/ic_launcher_phone.png
Binary files differ
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index eb0b371..86a383a 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -77,8 +77,6 @@
 
     /** Whether there is at least one voicemail source installed. */
     private boolean mVoicemailSourcesAvailable = false;
-    /** Whether we are currently filtering over voicemail. */
-    private boolean mShowingVoicemailOnly = false;
 
     private VoicemailStatusHelper mVoicemailStatusHelper;
     private View mStatusMessageView;
@@ -317,10 +315,6 @@
     public void startCallsQuery() {
         mAdapter.setLoading(true);
         mCallLogQueryHandler.fetchCalls(mCallTypeFilter);
-        if (mShowingVoicemailOnly) {
-            mShowingVoicemailOnly = false;
-            getActivity().invalidateOptionsMenu();
-        }
     }
 
     private void startVoicemailStatusQuery() {
@@ -340,10 +334,49 @@
         // menu items are ready if the first item is non-null.
         if (itemDeleteAll != null) {
             itemDeleteAll.setEnabled(mAdapter != null && !mAdapter.isEmpty());
-            menu.findItem(R.id.show_voicemails_only).setVisible(mVoicemailSourcesAvailable);
+
+            showAllFilterMenuOptions(menu);
+            hideCurrentFilterMenuOption(menu);
+
+            // Only hide if not available.  Let the above calls handle showing.
+            if (!mVoicemailSourcesAvailable) {
+                menu.findItem(R.id.show_voicemails_only).setVisible(false);
+            }
         }
     }
 
+    private void hideCurrentFilterMenuOption(Menu menu) {
+        MenuItem item = null;
+        switch (mCallTypeFilter) {
+            case CallLogQueryHandler.CALL_TYPE_ALL:
+                item = menu.findItem(R.id.show_all_calls);
+                break;
+            case Calls.INCOMING_TYPE:
+                item = menu.findItem(R.id.show_incoming_only);
+                break;
+            case Calls.OUTGOING_TYPE:
+                item = menu.findItem(R.id.show_outgoing_only);
+                break;
+            case Calls.MISSED_TYPE:
+                item = menu.findItem(R.id.show_missed_only);
+                break;
+            case Calls.VOICEMAIL_TYPE:
+                menu.findItem(R.id.show_voicemails_only);
+                break;
+        }
+        if (item != null) {
+            item.setVisible(false);
+        }
+    }
+
+    private void showAllFilterMenuOptions(Menu menu) {
+        menu.findItem(R.id.show_all_calls).setVisible(true);
+        menu.findItem(R.id.show_incoming_only).setVisible(true);
+        menu.findItem(R.id.show_outgoing_only).setVisible(true);
+        menu.findItem(R.id.show_missed_only).setVisible(true);
+        menu.findItem(R.id.show_voicemails_only).setVisible(true);
+    }
+
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
@@ -375,7 +408,6 @@
                 registerPhoneCallReceiver();
                 mCallLogQueryHandler.fetchCalls(Calls.VOICEMAIL_TYPE);
                 updateFilterTypeAndHeader(Calls.VOICEMAIL_TYPE);
-                mShowingVoicemailOnly = true;
                 return true;
 
             case R.id.show_all_calls:
@@ -383,7 +415,6 @@
                 unregisterPhoneCallReceiver();
                 mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL);
                 updateFilterTypeAndHeader(CallLogQueryHandler.CALL_TYPE_ALL);
-                mShowingVoicemailOnly = false;
                 return true;
 
             default: