diff options
author | Andrew Lee <anwlee@google.com> | 2015-01-08 19:07:51 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-08 19:07:51 +0000 |
commit | 525d9a3abcf98beebc94609a868e224d82215d32 (patch) | |
tree | a0543261e0992035e499e2b8772435d58b3b14bf | |
parent | 79f89492d79d1dd4a02057b7590ec837da84fdb1 (diff) | |
parent | f7219658e122e8134ec6c284d585b490700121b0 (diff) |
am 9268114e: am 5718958a: am 2759ccba: Read enabled/disabled state for InCall buttons.
* commit '9268114ef4367d6ccc12fca7ef0feaaa64d19311':
Read enabled/disabled state for InCall buttons.
-rw-r--r-- | InCallUI/res/layout/call_button_fragment.xml | 13 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallButtonFragment.java | 37 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallToggleButton.java | 54 |
3 files changed, 77 insertions, 27 deletions
diff --git a/InCallUI/res/layout/call_button_fragment.xml b/InCallUI/res/layout/call_button_fragment.xml index 56d65b07f..2ca640368 100644 --- a/InCallUI/res/layout/call_button_fragment.xml +++ b/InCallUI/res/layout/call_button_fragment.xml @@ -47,7 +47,8 @@ android:layout_height="wrap_content" android:paddingStart="@dimen/button_cluster_horizontal_padding" android:paddingEnd="@dimen/button_cluster_horizontal_padding" - android:gravity="bottom|center_horizontal"> + android:gravity="bottom|center_horizontal" + android:baselineAligned="false"> <!-- This row only ever shows either 4 or 5 buttons. This may depend on whether the device supports "Hold" (i.e. 4 buttons on CDMA devices, 5 buttons on GSM devices.) or whether @@ -81,7 +82,7 @@ <!-- MIDDLE LEFT SLOT ================================================================== --> <!-- "Mute" --> - <ImageButton android:id="@+id/muteButton" + <com.android.incallui.CallToggleButton android:id="@+id/muteButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_mute" android:contentDescription="@string/onscreenMuteText" /> @@ -89,7 +90,7 @@ <!-- CENTER SLOT ======================================================================= --> <!-- "Dialpad" --> - <ImageButton android:id="@+id/dialpadButton" + <com.android.incallui.CallToggleButton android:id="@+id/dialpadButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_dialpad" android:contentDescription="@string/onscreenShowDialpadText" /> @@ -100,7 +101,7 @@ other of these must always be set to GONE. --> <!-- "Hold" --> - <ImageButton android:id="@+id/holdButton" + <com.android.incallui.CallToggleButton android:id="@+id/holdButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_hold" android:contentDescription="@string/onscreenHoldText" /> @@ -120,7 +121,7 @@ android:visibility="gone" /> <!-- "Switch camera" for video calls. --> - <ImageButton android:id="@+id/switchCameraButton" + <com.android.incallui.CallToggleButton android:id="@+id/switchCameraButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_video_switch" android:contentDescription="@string/onscreenSwitchCameraText" @@ -148,7 +149,7 @@ android:visibility="gone" /> <!-- "Switch camera" for video calls. --> - <ImageButton android:id="@+id/pauseVideoButton" + <com.android.incallui.CallToggleButton android:id="@+id/pauseVideoButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_video_off" android:contentDescription="@string/onscreenPauseVideoText" diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 5c67862fc..bb23a8816 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -50,18 +50,18 @@ import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; public class CallButtonFragment extends BaseFragment<CallButtonPresenter, CallButtonPresenter.CallButtonUi> implements CallButtonPresenter.CallButtonUi, OnMenuItemClickListener, OnDismissListener, - View.OnClickListener, CompoundButton.OnCheckedChangeListener { + View.OnClickListener { private ImageButton mAudioButton; private ImageButton mChangeToVoiceButton; - private ImageButton mMuteButton; - private ImageButton mShowDialpadButton; - private ImageButton mHoldButton; + private CompoundButton mMuteButton; + private CompoundButton mShowDialpadButton; + private CompoundButton mHoldButton; private ImageButton mSwapButton; private ImageButton mChangeToVideoButton; - private ImageButton mSwitchCameraButton; + private CompoundButton mSwitchCameraButton; private ImageButton mAddCallButton; private ImageButton mMergeButton; - private ImageButton mPauseVideoButton; + private CompoundButton mPauseVideoButton; private ImageButton mOverflowButton; private PopupMenu mAudioModePopup; @@ -102,23 +102,23 @@ public class CallButtonFragment mAudioButton.setOnClickListener(this); mChangeToVoiceButton = (ImageButton) parent.findViewById(R.id.changeToVoiceButton); mChangeToVoiceButton. setOnClickListener(this); - mMuteButton = (ImageButton) parent.findViewById(R.id.muteButton); + mMuteButton = (CompoundButton) parent.findViewById(R.id.muteButton); mMuteButton.setOnClickListener(this); - mShowDialpadButton = (ImageButton) parent.findViewById(R.id.dialpadButton); + mShowDialpadButton = (CompoundButton) parent.findViewById(R.id.dialpadButton); mShowDialpadButton.setOnClickListener(this); - mHoldButton = (ImageButton) parent.findViewById(R.id.holdButton); + mHoldButton = (CompoundButton) parent.findViewById(R.id.holdButton); mHoldButton.setOnClickListener(this); mSwapButton = (ImageButton) parent.findViewById(R.id.swapButton); mSwapButton.setOnClickListener(this); mChangeToVideoButton = (ImageButton) parent.findViewById(R.id.changeToVideoButton); mChangeToVideoButton.setOnClickListener(this); - mSwitchCameraButton = (ImageButton) parent.findViewById(R.id.switchCameraButton); + mSwitchCameraButton = (CompoundButton) parent.findViewById(R.id.switchCameraButton); mSwitchCameraButton.setOnClickListener(this); mAddCallButton = (ImageButton) parent.findViewById(R.id.addButton); mAddCallButton.setOnClickListener(this); mMergeButton = (ImageButton) parent.findViewById(R.id.mergeButton); mMergeButton.setOnClickListener(this); - mPauseVideoButton = (ImageButton) parent.findViewById(R.id.pauseVideoButton); + mPauseVideoButton = (CompoundButton) parent.findViewById(R.id.pauseVideoButton); mPauseVideoButton.setOnClickListener(this); mOverflowButton = (ImageButton) parent.findViewById(R.id.overflowButton); mOverflowButton.setOnClickListener(this); @@ -145,10 +145,6 @@ public class CallButtonFragment } @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - } - - @Override public void onClick(View view) { int id = view.getId(); Log.d(this, "onClick(View " + view + ", id " + id + ")..."); @@ -165,8 +161,7 @@ public class CallButtonFragment getPresenter().changeToVoiceClicked(); break; case R.id.muteButton: { - final ImageButton button = (ImageButton) view; - getPresenter().muteClicked(!button.isSelected()); + getPresenter().muteClicked(!mMuteButton.isSelected()); break; } case R.id.mergeButton: @@ -174,8 +169,7 @@ public class CallButtonFragment mMergeButton.setEnabled(false); break; case R.id.holdButton: { - final ImageButton button = (ImageButton) view; - getPresenter().holdClicked(!button.isSelected()); + getPresenter().holdClicked(!mHoldButton.isSelected()); break; } case R.id.swapButton: @@ -219,7 +213,7 @@ public class CallButtonFragment } Resources res = getActivity().getResources(); - ImageButton[] compoundButtons = { + View[] compoundButtons = { mAudioButton, mMuteButton, mShowDialpadButton, @@ -228,7 +222,7 @@ public class CallButtonFragment mPauseVideoButton }; - for (ImageButton button : compoundButtons) { + for (View button : compoundButtons) { final LayerDrawable layers = (LayerDrawable) button.getBackground(); final RippleDrawable btnCompoundDrawable = compoundBackgroundDrawable(themeColors); layers.setDrawableByLayerId(R.id.compoundBackgroundItem, btnCompoundDrawable); @@ -770,6 +764,7 @@ public class CallButtonFragment mShowDialpadButton.setSelected(value); if (getActivity() != null && getActivity() instanceof InCallActivity) { ((InCallActivity) getActivity()).displayDialpad(value, animate); + maybeSendAccessibilityEvent(mShowDialpadButton, R.string.onscreenShowDialpadText); } } diff --git a/InCallUI/src/com/android/incallui/CallToggleButton.java b/InCallUI/src/com/android/incallui/CallToggleButton.java new file mode 100644 index 000000000..72c1d593f --- /dev/null +++ b/InCallUI/src/com/android/incallui/CallToggleButton.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.incallui; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.accessibility.AccessibilityEvent; +import android.widget.ToggleButton; + +public class CallToggleButton extends ToggleButton { + private static final String EMPTY_STRING = ""; + + public CallToggleButton(Context context) { + this(context, null); + } + + public CallToggleButton(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CallToggleButton(Context context, AttributeSet attrs, int defStyleAttr) { + this(context, attrs, defStyleAttr, 0); + } + + public CallToggleButton(Context context, AttributeSet attrs, int defStyleAttr, + int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + /** + * Ignore the content description so it is not read by Talkback. When clicked, we expect + * {@link CallButtonFragment#maybeSendAccessibilityEvent} to dispatch an accessibility event + * with the text for Talkback to read. + */ + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + super.onInitializeAccessibilityEvent(event); + event.setContentDescription(EMPTY_STRING); + } +} |