Disable phone icon for unknown numbers in NUI Voicemail

The phone icon should be disabled for unknown numbers in the NUI Voicemail, so that those numbers may not be called. This should have the same logic as as what we do for the call log.

Bug: 72449247
Test: Unit Test
PiperOrigin-RevId: 183428831
Change-Id: If1ecc3b4d47de04bccf69ae735a619f6b33c3bbd
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java
index 0234f64..dd59712 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java
@@ -150,7 +150,9 @@
 
     Assert.isNotNull(voicemailEntryFromAdapter);
     Uri uri = Uri.parse(voicemailEntryFromAdapter.voicemailUri());
+
     numberVoicemailFrom = voicemailEntryFromAdapter.number().getRawInput().getNumber();
+
     Assert.isNotNull(viewHolder);
     Assert.isNotNull(uri);
     Assert.isNotNull(listener);
@@ -179,6 +181,8 @@
     seekBarView.setEnabled(false);
     seekBarView.setThumb(voicemailSeekHandleDisabled);
 
+    updatePhoneIcon(numberVoicemailFrom);
+
     // During the binding we only send a request to the adapter to tell us what the
     // state of the media player should be and call that function.
     // This could be the paused state, or the playing state of the resume state.
@@ -231,6 +235,23 @@
     }
   }
 
+  /**
+   * Updates the phone icon depending if we can dial it or not.
+   *
+   * <p>Note: This must be called after the onClickListeners have been set, otherwise isClickable()
+   * state is not maintained.
+   */
+  private void updatePhoneIcon(@Nullable String numberVoicemailFrom) {
+    // TODO(uabdullah): Handle restricted/blocked numbers (a bug)
+    if (TextUtils.isEmpty(numberVoicemailFrom)) {
+      phoneButton.setEnabled(false);
+      phoneButton.setClickable(false);
+    } else {
+      phoneButton.setEnabled(true);
+      phoneButton.setClickable(true);
+    }
+  }
+
   private final OnSeekBarChangeListener seekbarChangeListener =
       new OnSeekBarChangeListener() {
         @Override
@@ -478,11 +499,11 @@
           audioManager.setMode(AudioManager.STREAM_MUSIC);
           if (audioManager.isSpeakerphoneOn()) {
             LogUtil.i(
-                "NewVoicemailMediaPlayer.phoneButtonListener", "speaker was on, turning it off");
+                "NewVoicemailMediaPlayer.speakerButtonListener", "speaker was on, turning it off");
             audioManager.setSpeakerphoneOn(false);
           } else {
             LogUtil.i(
-                "NewVoicemailMediaPlayer.phoneButtonListener", "speaker was off, turning it on");
+                "NewVoicemailMediaPlayer.speakerButtonListener", "speaker was off, turning it on");
             audioManager.setSpeakerphoneOn(true);
           }
           // TODO(uabdullah): Handle colors of speaker icon when speaker is on and off.
@@ -490,8 +511,6 @@
       };
 
   // TODO(uabdullah): Add phone account handle (a bug)
-  // TODO(uabdullah): If the call cannot be made then the phone icon should be greyed out
-  // (a bug)
   private final View.OnClickListener phoneButtonListener =
       new View.OnClickListener() {
         @Override