diff options
author | Richard MacGregor <rmacgregor@cyngn.com> | 2016-04-18 10:22:16 -0700 |
---|---|---|
committer | Richard MacGregor <rmacgregor@cyngn.com> | 2016-04-21 10:54:15 -0700 |
commit | 62f9ccb88e5a4569e5d95d49998027549b9ad489 (patch) | |
tree | 48f593b8af139e71adc5903f205a42a527d56a79 | |
parent | f9bae94cfa2ee0c0c277a904a3580d99bf26812f (diff) | |
download | android_packages_apps_InCallUI-62f9ccb88e5a4569e5d95d49998027549b9ad489.tar.gz android_packages_apps_InCallUI-62f9ccb88e5a4569e5d95d49998027549b9ad489.tar.bz2 android_packages_apps_InCallUI-62f9ccb88e5a4569e5d95d49998027549b9ad489.zip |
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)
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<InCallPluginInfo> 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<CallButtonPresenter.CallButto ui.showButton(BUTTON_MUTE, showMute); ui.showButton(BUTTON_ADD_CALL, showAddCall); ui.showButton(BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo); + if (showUpgradeToVideo) { + ui.modifyChangeToVideoButton(); + } ui.showButton(BUTTON_SWITCH_CAMERA, isVideo); ui.showButton(BUTTON_PAUSE_VIDEO, isVideo && !useExt); ui.showButton(BUTTON_DIALPAD, !isVideo || useExt); @@ -706,6 +709,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto void requestCallRecordingPermission(String[] permissions); void displayDialpad(boolean on, boolean animate); boolean isDialpadVisible(); + void modifyChangeToVideoButton(); void displayVideoCallOptions(); void showInviteSnackbar(PendingIntent inviteIntent, String inviteText); diff --git a/src/com/android/incallui/incallapi/InCallPluginInfo.java b/src/com/android/incallui/incallapi/InCallPluginInfo.java index e6b809af..5d8c8025 100644 --- a/src/com/android/incallui/incallapi/InCallPluginInfo.java +++ b/src/com/android/incallui/incallapi/InCallPluginInfo.java @@ -25,8 +25,14 @@ public class InCallPluginInfo { private String mPluginTitle; private String mUserId; private String mMimeType; - private Drawable mPluginColorIcon; - private Drawable mPluginSingleColorIcon; + /* Plugin's simple brand icon (24dp x 24dp) + Expected format: Vector Drawable (.xml) + 2 colors allowed. */ + private Drawable mPluginBrandIcon; + /* Plugin's video call action icon (24dp x 24dp) + Expected format: Vector Drawable (.xml) + 1 color allowed. */ + private Drawable mPluginVideoIcon; private PendingIntent mInviteIntent; private InCallPluginInfo() { @@ -48,12 +54,18 @@ public class InCallPluginInfo { return mMimeType; } - public Drawable getPluginColorIcon() { - return mPluginColorIcon; + /* Plugin's simple brand icon (24dp x 24dp) + Expected format: Vector Drawable (.xml) + 2 colors allowed. */ + public Drawable getPluginBrandIcon() { + return mPluginBrandIcon; } - public Drawable getPluginSingleColorIcon() { - return mPluginSingleColorIcon; + /* Plugin's video call action icon (24dp x 24dp) + Expected format: Vector Drawable (.xml) + 1 color allowed. */ + public Drawable getPluginVideoIcon() { + return mPluginVideoIcon; } public PendingIntent getPluginInviteIntent() { @@ -65,8 +77,8 @@ public class InCallPluginInfo { private String mPluginTitle; private String mUserId; private String mMimeType; - private Drawable mPluginColorIcon; - private Drawable mPluginSingleColorIcon; + private Drawable mPluginBrandIcon; + private Drawable mPluginVideoIcon; private PendingIntent mInviteIntent; public Builder() { @@ -92,13 +104,13 @@ public class InCallPluginInfo { return this; } - public Builder setPluginColorIcon(Drawable pluginColorIcon) { - this.mPluginColorIcon = pluginColorIcon; + public Builder setPluginBrandIcon(Drawable pluginBrandIcon) { + this.mPluginBrandIcon = pluginBrandIcon; return this; } - public Builder setPluginSingleColorIcon(Drawable pluginSingleColorIcon) { - this.mPluginSingleColorIcon = pluginSingleColorIcon; + public Builder setPluginVideoIcon(Drawable pluginVideoIcon) { + this.mPluginVideoIcon = pluginVideoIcon; return this; } @@ -110,7 +122,7 @@ public class InCallPluginInfo { // TODO: Check if we want to require an invite intent or not public InCallPluginInfo build() throws IllegalStateException{ if (mPluginComponent == null || mPluginTitle == null || mMimeType == null - || mPluginColorIcon == null || mPluginSingleColorIcon == null) { + || mPluginBrandIcon == null || mPluginVideoIcon == null) { throw new IllegalStateException(); } InCallPluginInfo info = new InCallPluginInfo(); @@ -118,8 +130,8 @@ public class InCallPluginInfo { info.mPluginTitle = mPluginTitle; info.mUserId = mUserId; info.mMimeType = mMimeType; - info.mPluginColorIcon = mPluginColorIcon; - info.mPluginSingleColorIcon = mPluginSingleColorIcon; + info.mPluginBrandIcon = mPluginBrandIcon; + info.mPluginVideoIcon = mPluginVideoIcon; info.mInviteIntent = mInviteIntent; return info; } diff --git a/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java b/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java index 998e258c..17a9ec40 100644 --- a/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java +++ b/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java @@ -174,8 +174,8 @@ public class InCallPluginInfoAsyncTask extends AsyncTask<Void, Void, List<InCall InCallPluginInfo.Builder infoBuilder = inCallPluginInfoBuilderList.get(index); infoBuilder.setPluginComponent(callMethod.mComponent) .setPluginTitle(callMethod.mName) - .setPluginColorIcon(callMethod.mBrandIcon) - .setPluginSingleColorIcon(callMethod.mSingleColorBrandIcon); + .setPluginBrandIcon(callMethod.mBrandIcon) + .setPluginVideoIcon(callMethod.mVideoIcon); try { inCallPluginList.add(infoBuilder.build()); |