From 62f9ccb88e5a4569e5d95d49998027549b9ad489 Mon Sep 17 00:00:00 2001 From: Richard MacGregor Date: Mon, 18 Apr 2016 10:22:16 -0700 Subject: Revert and modify "Change in InCallAPI handover button UI" This reverts commit f8f80324806a7ea70916255f0adce5770474691e. And then modifies the icons to reflect design choices. Ticket CD-532 Change-Id: I36c56911c532b3023ee1ddb60c5aac9e5322fed0 (cherry picked from commit b436d85994959c3a7ab66bbfee2c4dd4d9b9db11) --- src/com/android/incallui/CallButtonFragment.java | 60 +++++++++++++++++++++- src/com/android/incallui/CallButtonPresenter.java | 4 ++ .../incallui/incallapi/InCallPluginInfo.java | 42 +++++++++------ .../incallapi/InCallPluginInfoAsyncTask.java | 4 +- 4 files changed, 92 insertions(+), 18 deletions(-) diff --git a/src/com/android/incallui/CallButtonFragment.java b/src/com/android/incallui/CallButtonFragment.java index c32d7fd5..986dd70e 100644 --- a/src/com/android/incallui/CallButtonFragment.java +++ b/src/com/android/incallui/CallButtonFragment.java @@ -465,6 +465,64 @@ public class CallButtonFragment mSwitchCameraButton.setSelected(isBackFacingCamera); } + // The icons used for the call button fragment are constructed using layerdrawables, + // where the second layer is a item containing a bitmap with it's gravity set to "center". + // This method gets the insets set on the layerdrawable layer when the bitmap is centered, + // and applies it to the vector drawable that we are replacing it with. + public void modifyChangeToVideoButton() { + boolean canVideoCall = getPresenter().canVideoCall(); + List contactInCallPlugins = + getPresenter().getContactInCallPluginInfoList(); + int listSize = (contactInCallPlugins != null) ? contactInCallPlugins.size() : 0; + if (!canVideoCall && listSize == 1) { + InCallPluginInfo info = contactInCallPlugins.get(0); + if (info != null && info.getPluginVideoIcon() != null) { + LayerDrawable layerDrawable = + (LayerDrawable) getResources().getDrawable(R.drawable.btn_change_to_video) + .mutate(); + + int buttonWidth = mChangeToVideoButton.getWidth(); + int buttonHeight = mChangeToVideoButton.getWidth(); + if (buttonWidth == 0 || buttonHeight == 0) { + buttonWidth = + getResources().getDimensionPixelSize(R.dimen.in_call_button_dimension); + buttonHeight = + getResources().getDimensionPixelSize(R.dimen.in_call_button_dimension); + } + int xInset = buttonWidth - layerDrawable.getIntrinsicWidth(); + if (xInset > 0) { + xInset = xInset / 2; + } else { + xInset = 0; + } + int yInset = buttonHeight - layerDrawable.getIntrinsicHeight(); + if (yInset > 0) { + yInset = yInset / 2; + } else { + yInset = 0; + } + + if (DEBUG) { + Log.i(TAG, "mChangeToVideoButton: [w h] [" + mChangeToVideoButton.getWidth() + + " " + mChangeToVideoButton.getHeight() + "]\n" + + "adjusted button: [w h] [" + buttonWidth + " " + buttonHeight + "]\n" + + "layerDrawable: [w h] [" + layerDrawable.getIntrinsicWidth() + " " + + layerDrawable.getIntrinsicHeight() + "]\n" + + "xInset = " + xInset + ", xInset = " + yInset); + } + + Drawable icon = info.getPluginVideoIcon(); + icon.setTintList(getResources().getColorStateList(R.color.selectable_icon_tint)); + icon.setAutoMirrored(false); + + // layer 0 is background, layer 1 is the icon to use. + layerDrawable.setLayerInset(1, xInset, yInset, xInset, yInset); + layerDrawable.setDrawableByLayerId(R.id.foregroundItem, icon); + mChangeToVideoButton.setBackground(layerDrawable); + } + } + } + @Override public void setVideoPaused(boolean isPaused) { mPauseVideoButton.setSelected(isPaused); @@ -585,7 +643,7 @@ public class CallButtonFragment int i = 0; for (InCallPluginInfo info : contactInCallPlugins) { items.add(info.getPluginTitle()); - icons.add(info.getPluginColorIcon()); + icons.add(info.getPluginBrandIcon()); itemToCallType.add(i++); } } diff --git a/src/com/android/incallui/CallButtonPresenter.java b/src/com/android/incallui/CallButtonPresenter.java index c0f51114..cb7b6a03 100644 --- a/src/com/android/incallui/CallButtonPresenter.java +++ b/src/com/android/incallui/CallButtonPresenter.java @@ -628,6 +628,9 @@ public class CallButtonPresenter extends Presenter