Merge "Add hours of operation info to incall business context." into ub-contactsdialer-a-dev
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index 0987cac..1d32d8f 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -51,6 +51,7 @@
         extends BaseFragment<CallButtonPresenter, CallButtonPresenter.CallButtonUi>
         implements CallButtonPresenter.CallButtonUi, OnMenuItemClickListener, OnDismissListener,
         View.OnClickListener {
+
     private static final int INVALID_INDEX = -1;
     private int mButtonMaxVisible;
     // The button is currently visible in the UI
@@ -61,6 +62,7 @@
     private static final int BUTTON_MENU = 3;
 
     public interface Buttons {
+
         public static final int BUTTON_AUDIO = 0;
         public static final int BUTTON_MUTE = 1;
         public static final int BUTTON_DIALPAD = 2;
@@ -153,7 +155,7 @@
         mOverflowButton = (ImageButton) parent.findViewById(R.id.overflowButton);
         mOverflowButton.setOnClickListener(this);
         mManageVideoCallConferenceButton = (ImageButton) parent.findViewById(
-            R.id.manageVideoCallConferenceButton);
+                R.id.manageVideoCallConferenceButton);
         mManageVideoCallConferenceButton.setOnClickListener(this);
         return parent;
     }
@@ -181,7 +183,7 @@
         int id = view.getId();
         Log.d(this, "onClick(View " + view + ", id " + id + ")...");
 
-        switch(id) {
+        switch (id) {
             case R.id.audioButton:
                 onAudioButtonClicked();
                 break;
@@ -258,11 +260,11 @@
         }
 
         ImageButton[] normalButtons = {
-            mSwapButton,
-            mChangeToVideoButton,
-            mAddCallButton,
-            mMergeButton,
-            mOverflowButton
+                mSwapButton,
+                mChangeToVideoButton,
+                mAddCallButton,
+                mMergeButton,
+                mOverflowButton
         };
 
         for (ImageButton button : normalButtons) {
@@ -472,7 +474,7 @@
                     }
                     addToOverflowMenu(i, button, menu);
                 }
-            } else if (visibility == BUTTON_HIDDEN){
+            } else if (visibility == BUTTON_HIDDEN) {
                 button.setVisibility(View.GONE);
             }
         }
@@ -781,9 +783,11 @@
 
     @Override
     public void displayDialpad(boolean value, boolean animate) {
-        mShowDialpadButton.setSelected(value);
         if (getActivity() != null && getActivity() instanceof InCallActivity) {
-            ((InCallActivity) getActivity()).showDialpadFragment(value, animate);
+            boolean changed = ((InCallActivity) getActivity()).showDialpadFragment(value, animate);
+            if (changed) {
+                mShowDialpadButton.setSelected(value);
+            }
         }
     }
 
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index 6b80fe0..aa150ad 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -87,16 +87,24 @@
 
     private AlertDialog mDialog;
 
-    /** Use to pass 'showDialpad' from {@link #onNewIntent} to {@link #onResume} */
+    /**
+     * Use to pass 'showDialpad' from {@link #onNewIntent} to {@link #onResume}
+     */
     private boolean mShowDialpadRequested;
 
-    /** Use to determine if the dialpad should be animated on show. */
+    /**
+     * Use to determine if the dialpad should be animated on show.
+     */
     private boolean mAnimateDialpadOnShow;
 
-    /** Use to determine the DTMF Text which should be pre-populated in the dialpad. */
+    /**
+     * Use to determine the DTMF Text which should be pre-populated in the dialpad.
+     */
     private String mDtmfText;
 
-    /** Use to pass parameters for showing the PostCharDialog to {@link #onResume} */
+    /**
+     * Use to pass parameters for showing the PostCharDialog to {@link #onResume}
+     */
     private boolean mShowPostCharWaitDialogOnResume;
     private String mShowPostCharWaitDialogCallId;
     private String mShowPostCharWaitDialogChars;
@@ -120,13 +128,16 @@
             InCallPresenter.getInstance().handleAccountSelection(selectedAccountHandle,
                     setDefault);
         }
+
         @Override
         public void onDialogDismissed() {
             InCallPresenter.getInstance().cancelAccountSelection();
         }
     };
 
-    /** Listener for orientation changes. */
+    /**
+     * Listener for orientation changes.
+     */
     private OrientationEventListener mOrientationEventListener;
 
     /**
@@ -195,7 +206,7 @@
             mDtmfText = icicle.getString(DIALPAD_TEXT_EXTRA);
 
             SelectPhoneAccountDialogFragment dialogFragment = (SelectPhoneAccountDialogFragment)
-                getFragmentManager().findFragmentByTag(TAG_SELECT_ACCT_FRAGMENT);
+                    getFragmentManager().findFragmentByTag(TAG_SELECT_ACCT_FRAGMENT);
             if (dialogFragment != null) {
                 dialogFragment.setListener(mSelectAcctListener);
             }
@@ -297,7 +308,7 @@
     @Override
     protected void onPause() {
         Log.d(this, "onPause()...");
-        if (mDialpadFragment != null ) {
+        if (mDialpadFragment != null) {
             mDialpadFragment.onDialerKeyUp(null);
         }
 
@@ -438,7 +449,7 @@
     public boolean onKeyUp(int keyCode, KeyEvent event) {
         // push input to the dialer.
         if (mDialpadFragment != null && (mDialpadFragment.isVisible()) &&
-                (mDialpadFragment.onDialerKeyUp(event))){
+                (mDialpadFragment.onDialerKeyUp(event))) {
             return true;
         } else if (keyCode == KeyEvent.KEYCODE_CALL) {
             // Always consume CALL to be sure the PhoneWindow won't do anything with it
@@ -521,8 +532,8 @@
      * Handles changes in device rotation.
      *
      * @param rotation The new device rotation (one of: {@link Surface#ROTATION_0},
-     *      {@link Surface#ROTATION_90}, {@link Surface#ROTATION_180},
-     *      {@link Surface#ROTATION_270}).
+     * {@link Surface#ROTATION_90}, {@link Surface#ROTATION_180},
+     * {@link Surface#ROTATION_270}).
      */
     private void doOrientationChanged(int rotation) {
         Log.d(this, "doOrientationChanged prevOrientation=" + sPreviousRotation +
@@ -738,10 +749,13 @@
         throw new IllegalStateException("Unexpected fragment: " + tag);
     }
 
-    public void showDialpadFragment(boolean show, boolean animate) {
+    /**
+     * @return {@code true} while the visibility of the dialpad has actually changed.
+     */
+    public boolean showDialpadFragment(boolean show, boolean animate) {
         // If the dialpad is already visible, don't animate in. If it's gone, don't animate out.
         if ((show && isDialpadVisible()) || (!show && !isDialpadVisible())) {
-            return;
+            return false;
         }
         // We don't do a FragmentTransaction on the hide case because it will be dealt with when
         // the listener is fired after an animation finishes.
@@ -760,6 +774,7 @@
         if (sensor != null) {
             sensor.onDialpadVisible(show);
         }
+        return true;
     }
 
     public boolean isDialpadVisible() {
@@ -774,7 +789,7 @@
      * Hides or shows the conference manager fragment.
      *
      * @param show {@code true} if the conference manager should be shown, {@code false} if it
-     *                         should be hidden.
+     * should be hidden.
      */
     public void showConferenceFragment(boolean show) {
         showFragment(TAG_CONFERENCE_FRAGMENT, show, true);
@@ -791,7 +806,7 @@
 
     public void showPostCharWaitDialog(String callId, String chars) {
         if (isVisible()) {
-            final PostCharDialogFragment fragment = new PostCharDialogFragment(callId,  chars);
+            final PostCharDialogFragment fragment = new PostCharDialogFragment(callId, chars);
             fragment.show(getFragmentManager(), "postCharWait");
 
             mShowPostCharWaitDialogOnResume = false;
@@ -817,7 +832,7 @@
 
         if (!isFinishing() && !TextUtils.isEmpty(disconnectCause.getDescription())
                 && (disconnectCause.getCode() == DisconnectCause.ERROR ||
-                        disconnectCause.getCode() == DisconnectCause.RESTRICTED)) {
+                disconnectCause.getCode() == DisconnectCause.RESTRICTED)) {
             showErrorDialog(disconnectCause.getDescription());
         }
     }
@@ -846,12 +861,14 @@
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
                         onDialogDismissed();
-                    }})
+                    }
+                })
                 .setOnCancelListener(new OnCancelListener() {
                     @Override
                     public void onCancel(DialogInterface dialog) {
                         onDialogDismissed();
-                    }})
+                    }
+                })
                 .create();
 
         mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
@@ -865,10 +882,10 @@
     }
 
     public void setExcludeFromRecents(boolean exclude) {
-        ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
+        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
         List<ActivityManager.AppTask> tasks = am.getAppTasks();
         int taskId = getTaskId();
-        for (int i=0; i<tasks.size(); i++) {
+        for (int i = 0; i < tasks.size(); i++) {
             ActivityManager.AppTask task = tasks.get(i);
             if (task.getTaskInfo().id == taskId) {
                 try {