Clean up some resources and change switch-case to if-else block.

Preparatory CL for upcoming shared lib change.

Test: basic sanity
Bug: 144806641
Merged-in: I8f81195b72c6329844a450ce28d76f949f41e2d8
Change-Id: I8f81195b72c6329844a450ce28d76f949f41e2d8
(cherry picked from commit 28a499cd7154e1aba7eaa8bd592c143e56e118c1)
diff --git a/src/com/android/phone/EmergencyActionGroup.java b/src/com/android/phone/EmergencyActionGroup.java
index c090af7..53ec1eb 100644
--- a/src/com/android/phone/EmergencyActionGroup.java
+++ b/src/com/android/phone/EmergencyActionGroup.java
@@ -157,24 +157,19 @@
     public void onClick(View v) {
         Intent intent = (Intent) v.getTag(R.id.tag_intent);
 
-        switch (v.getId()) {
-            case R.id.action1:
-            case R.id.action2:
-            case R.id.action3:
-                AccessibilityManager accessibilityMgr =
-                        (AccessibilityManager) mContext.getSystemService(
-                                Context.ACCESSIBILITY_SERVICE);
-                if (accessibilityMgr.isTouchExplorationEnabled()) {
-                    getContext().startActivity(intent);
-                } else {
-                    revealTheButton(v);
-                }
-                break;
-            case R.id.selected_container:
-                if (!mHiding) {
-                    getContext().startActivity(intent);
-                }
-                break;
+        if (v.getId() == R.id.action1 || v.getId() == R.id.action2 || v.getId() == R.id.action3) {
+            AccessibilityManager accessibilityMgr =
+                    (AccessibilityManager) mContext.getSystemService(
+                            Context.ACCESSIBILITY_SERVICE);
+            if (accessibilityMgr.isTouchExplorationEnabled()) {
+                getContext().startActivity(intent);
+            } else {
+                revealTheButton(v);
+            }
+        } else if (v.getId() == R.id.selected_container) {
+            if (!mHiding) {
+                getContext().startActivity(intent);
+            }
         }
     }
 
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index c20281a..7531aca 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -461,16 +461,15 @@
 
     @Override
     public boolean onKey(View view, int keyCode, KeyEvent event) {
-        switch (view.getId()) {
-            case R.id.digits:
-                // Happen when "Done" button of the IME is pressed. This can happen when this
-                // Activity is forced into landscape mode due to a desk dock.
-                if (keyCode == KeyEvent.KEYCODE_ENTER
-                        && event.getAction() == KeyEvent.ACTION_UP) {
-                    placeCall();
-                    return true;
-                }
-                break;
+        if (view.getId()
+                == R.id.digits) { // Happen when "Done" button of the IME is pressed. This can
+            // happen when this
+            // Activity is forced into landscape mode due to a desk dock.
+            if (keyCode == KeyEvent.KEYCODE_ENTER
+                    && event.getAction() == KeyEvent.ACTION_UP) {
+                placeCall();
+                return true;
+            }
         }
         return false;
     }
@@ -510,27 +509,22 @@
 
     @Override
     public void onClick(View view) {
-        switch (view.getId()) {
-            case R.id.deleteButton: {
-                keyPressed(KeyEvent.KEYCODE_DEL);
-                return;
+        if (view.getId() == R.id.deleteButton) {
+            keyPressed(KeyEvent.KEYCODE_DEL);
+            return;
+        } else if (view.getId() == R.id.floating_action_button) {
+            view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+            placeCall();
+            return;
+        } else if (view.getId() == R.id.digits) {
+            if (mDigits.length() != 0) {
+                mDigits.setCursorVisible(true);
             }
-            case R.id.floating_action_button: {
-                view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
-                placeCall();
-                return;
-            }
-            case R.id.digits: {
-                if (mDigits.length() != 0) {
-                    mDigits.setCursorVisible(true);
-                }
-                return;
-            }
-            case R.id.floating_action_button_dialpad: {
-                mDigits.getText().clear();
-                switchView(mDialpadView, mEmergencyShortcutView, true);
-                return;
-            }
+            return;
+        } else if (view.getId() == R.id.floating_action_button_dialpad) {
+            mDigits.getText().clear();
+            switchView(mDialpadView, mEmergencyShortcutView, true);
+            return;
         }
     }
 
@@ -539,67 +533,54 @@
         if (!pressed) {
             return;
         }
-        switch (view.getId()) {
-            case R.id.one: {
-                playTone(ToneGenerator.TONE_DTMF_1);
-                keyPressed(KeyEvent.KEYCODE_1);
-                return;
-            }
-            case R.id.two: {
-                playTone(ToneGenerator.TONE_DTMF_2);
-                keyPressed(KeyEvent.KEYCODE_2);
-                return;
-            }
-            case R.id.three: {
-                playTone(ToneGenerator.TONE_DTMF_3);
-                keyPressed(KeyEvent.KEYCODE_3);
-                return;
-            }
-            case R.id.four: {
-                playTone(ToneGenerator.TONE_DTMF_4);
-                keyPressed(KeyEvent.KEYCODE_4);
-                return;
-            }
-            case R.id.five: {
-                playTone(ToneGenerator.TONE_DTMF_5);
-                keyPressed(KeyEvent.KEYCODE_5);
-                return;
-            }
-            case R.id.six: {
-                playTone(ToneGenerator.TONE_DTMF_6);
-                keyPressed(KeyEvent.KEYCODE_6);
-                return;
-            }
-            case R.id.seven: {
-                playTone(ToneGenerator.TONE_DTMF_7);
-                keyPressed(KeyEvent.KEYCODE_7);
-                return;
-            }
-            case R.id.eight: {
-                playTone(ToneGenerator.TONE_DTMF_8);
-                keyPressed(KeyEvent.KEYCODE_8);
-                return;
-            }
-            case R.id.nine: {
-                playTone(ToneGenerator.TONE_DTMF_9);
-                keyPressed(KeyEvent.KEYCODE_9);
-                return;
-            }
-            case R.id.zero: {
-                playTone(ToneGenerator.TONE_DTMF_0);
-                keyPressed(KeyEvent.KEYCODE_0);
-                return;
-            }
-            case R.id.pound: {
-                playTone(ToneGenerator.TONE_DTMF_P);
-                keyPressed(KeyEvent.KEYCODE_POUND);
-                return;
-            }
-            case R.id.star: {
-                playTone(ToneGenerator.TONE_DTMF_S);
-                keyPressed(KeyEvent.KEYCODE_STAR);
-                return;
-            }
+        if (view.getId() == R.id.one) {
+            playTone(ToneGenerator.TONE_DTMF_1);
+            keyPressed(KeyEvent.KEYCODE_1);
+            return;
+        } else if (view.getId() == R.id.two) {
+            playTone(ToneGenerator.TONE_DTMF_2);
+            keyPressed(KeyEvent.KEYCODE_2);
+            return;
+        } else if (view.getId() == R.id.three) {
+            playTone(ToneGenerator.TONE_DTMF_3);
+            keyPressed(KeyEvent.KEYCODE_3);
+            return;
+        } else if (view.getId() == R.id.four) {
+            playTone(ToneGenerator.TONE_DTMF_4);
+            keyPressed(KeyEvent.KEYCODE_4);
+            return;
+        } else if (view.getId() == R.id.five) {
+            playTone(ToneGenerator.TONE_DTMF_5);
+            keyPressed(KeyEvent.KEYCODE_5);
+            return;
+        } else if (view.getId() == R.id.six) {
+            playTone(ToneGenerator.TONE_DTMF_6);
+            keyPressed(KeyEvent.KEYCODE_6);
+            return;
+        } else if (view.getId() == R.id.seven) {
+            playTone(ToneGenerator.TONE_DTMF_7);
+            keyPressed(KeyEvent.KEYCODE_7);
+            return;
+        } else if (view.getId() == R.id.eight) {
+            playTone(ToneGenerator.TONE_DTMF_8);
+            keyPressed(KeyEvent.KEYCODE_8);
+            return;
+        } else if (view.getId() == R.id.nine) {
+            playTone(ToneGenerator.TONE_DTMF_9);
+            keyPressed(KeyEvent.KEYCODE_9);
+            return;
+        } else if (view.getId() == R.id.zero) {
+            playTone(ToneGenerator.TONE_DTMF_0);
+            keyPressed(KeyEvent.KEYCODE_0);
+            return;
+        } else if (view.getId() == R.id.pound) {
+            playTone(ToneGenerator.TONE_DTMF_P);
+            keyPressed(KeyEvent.KEYCODE_POUND);
+            return;
+        } else if (view.getId() == R.id.star) {
+            playTone(ToneGenerator.TONE_DTMF_S);
+            keyPressed(KeyEvent.KEYCODE_STAR);
+            return;
         }
     }
 
@@ -609,16 +590,13 @@
     @Override
     public boolean onLongClick(View view) {
         int id = view.getId();
-        switch (id) {
-            case R.id.deleteButton: {
-                mDigits.getText().clear();
-                return true;
-            }
-            case R.id.zero: {
-                removePreviousDigitIfPossible();
-                keyPressed(KeyEvent.KEYCODE_PLUS);
-                return true;
-            }
+        if (id == R.id.deleteButton) {
+            mDigits.getText().clear();
+            return true;
+        } else if (id == R.id.zero) {
+            removePreviousDigitIfPossible();
+            keyPressed(KeyEvent.KEYCODE_PLUS);
+            return true;
         }
         return false;
     }
diff --git a/src/com/android/phone/EmergencyInfoGroup.java b/src/com/android/phone/EmergencyInfoGroup.java
index 186de03..f5aca7f 100644
--- a/src/com/android/phone/EmergencyInfoGroup.java
+++ b/src/com/android/phone/EmergencyInfoGroup.java
@@ -207,26 +207,21 @@
 
     @Override
     public void onClick(View view) {
-        switch (view.getId()) {
-            case R.id.emergency_info_view:
-                AccessibilityManager accessibilityMgr =
-                        (AccessibilityManager) mContext.getSystemService(
-                                Context.ACCESSIBILITY_SERVICE);
-                if (accessibilityMgr.isTouchExplorationEnabled()) {
-                    if (mOnConfirmClickListener != null) {
-                        mOnConfirmClickListener.onConfirmClick(this);
-                    }
-                } else {
-                    revealSelectedButton();
-                }
-                break;
-            case R.id.emergency_info_confirm_view:
+        if (view.getId() == R.id.emergency_info_view) {
+            AccessibilityManager accessibilityMgr =
+                    (AccessibilityManager) mContext.getSystemService(
+                            Context.ACCESSIBILITY_SERVICE);
+            if (accessibilityMgr.isTouchExplorationEnabled()) {
                 if (mOnConfirmClickListener != null) {
                     mOnConfirmClickListener.onConfirmClick(this);
                 }
-                break;
-            default:
-                break;
+            } else {
+                revealSelectedButton();
+            }
+        } else if (view.getId() == R.id.emergency_info_confirm_view) {
+            if (mOnConfirmClickListener != null) {
+                mOnConfirmClickListener.onConfirmClick(this);
+            }
         }
     }
 
diff --git a/src/com/android/phone/EmergencyShortcutButton.java b/src/com/android/phone/EmergencyShortcutButton.java
index 9e51e82..d147ce4 100644
--- a/src/com/android/phone/EmergencyShortcutButton.java
+++ b/src/com/android/phone/EmergencyShortcutButton.java
@@ -182,26 +182,23 @@
 
     @Override
     public void onClick(View view) {
-        switch (view.getId()) {
-            case R.id.emergency_call_number_info_view:
-                AccessibilityManager accessibilityMgr =
-                        (AccessibilityManager) mContext.getSystemService(
-                                Context.ACCESSIBILITY_SERVICE);
-                if (accessibilityMgr.isTouchExplorationEnabled()) {
-                    // TalkBack itself includes a prompt to confirm click action implicitly,
-                    // so we don't need an additional confirmation with second tap on button.
-                    if (mOnConfirmClickListener != null) {
-                        mOnConfirmClickListener.onConfirmClick(this);
-                    }
-                } else {
-                    revealSelectedButton();
-                }
-                break;
-            case R.id.emergency_call_confirm_view:
+        if (view.getId() == R.id.emergency_call_number_info_view) {
+            AccessibilityManager accessibilityMgr =
+                    (AccessibilityManager) mContext.getSystemService(
+                            Context.ACCESSIBILITY_SERVICE);
+            if (accessibilityMgr.isTouchExplorationEnabled()) {
+                // TalkBack itself includes a prompt to confirm click action implicitly,
+                // so we don't need an additional confirmation with second tap on button.
                 if (mOnConfirmClickListener != null) {
                     mOnConfirmClickListener.onConfirmClick(this);
                 }
-                break;
+            } else {
+                revealSelectedButton();
+            }
+        } else if (view.getId() == R.id.emergency_call_confirm_view) {
+            if (mOnConfirmClickListener != null) {
+                mOnConfirmClickListener.onConfirmClick(this);
+            }
         }
     }