summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-08-21 17:57:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-21 17:57:33 +0000
commitb2881330348b8dd00c2fea630963b2211ac1eade (patch)
tree17c710b3f4509ef7a922283e4853655e42f6cdc7 /InCallUI
parent8d48032acd64d4c09b7fe5f61c789f4e5ffaec45 (diff)
parent3fb6af5fe7b4b287fe381f53a7d3c5225fb75c44 (diff)
Merge "Add accessibility announcements for call state changes" into lmp-dev
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/res/values/strings.xml24
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonFragment.java58
2 files changed, 76 insertions, 6 deletions
diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml
index 964286aa0..fc2ee20c8 100644
--- a/InCallUI/res/values/strings.xml
+++ b/InCallUI/res/values/strings.xml
@@ -486,12 +486,30 @@
-->
<string name="description_delete_button">backspace</string>
- <!-- Content description of the speakerphone enabled notification icon for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
- <string name="accessibility_speakerphone_enabled">Speakerphone enabled.</string>
+ <!-- String used by AccessibilityService to announce that the speakerphone has been selected for audio output [CHAR LIMIT=NONE]-->
+ <string name="accessibility_speakerphone_selected">Speakerphone selected</string>
- <!-- Content description of the call muted notification icon for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
+ <!-- String used by AccessibilityService to announce that the phone's earpiece has been selected for audio output [CHAR LIMIT=NONE]-->
+ <string name="accessibility_earpiece_selected">Earpiece selected</string>
+
+ <!-- String used by AccessibilityService to announce that the wired headset has been selected for audio output [CHAR LIMIT=NONE]-->
+ <string name="accessibility_wired_headset_selected">Wired headset selected</string>
+
+ <!-- String used by AccessibilityService to announce that the bluetooth headset has been selected for audio output [CHAR LIMIT=NONE]-->
+ <string name="accessibility_bluetooth_headset_selected">Bluetooth headset selected</string>
+
+ <!-- String used by AccessibilityService to announce that the call has been muted [CHAR LIMIT=NONE]-->
<string name="accessibility_call_muted">Call muted.</string>
+ <!-- String used by AccessibilityService to announce that the call has been unmuted [CHAR LIMIT=NONE]-->
+ <string name="accessibility_call_unmuted">Call unmuted.</string>
+
+ <!-- String used by AccessibilityService to announce that the call has been put on hold [CHAR LIMIT=NONE]-->
+ <string name="accessibility_call_put_on_hold">Call put on hold.</string>
+
+ <!-- String used by AccessibilityService to announce that the call has been removed from hold [CHAR LIMIT=NONE]-->
+ <string name="accessibility_call_removed_from_hold">Call removed from hold.</string>
+
<!-- Description of the answer target in the Slide unlock screen of Phone. [CHAR LIMIT=NONE] -->
<string name="description_target_answer">Answer</string>
<!-- Description of the send_sms target in the Slide unlock screen of Phone. [CHAR LIMIT=NONE] -->
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index 9b141dac1..09a3bc292 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -16,9 +16,9 @@
package com.android.incallui;
+import android.content.Context;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
-
import android.telecomm.AudioState;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
@@ -26,6 +26,8 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.PopupMenu;
@@ -60,6 +62,8 @@ public class CallButtonFragment
private View mManageConferenceButton;
private View mGenericMergeButton;
+ private int mPrevAudioMode = 0;
+
// Constants for Drawable.setAlpha()
private static final int HIDDEN = 0;
private static final int VISIBLE = 255;
@@ -224,7 +228,11 @@ public class CallButtonFragment
@Override
public void setMute(boolean value) {
- mMuteButton.setSelected(value);
+ if (mMuteButton.isSelected() != value) {
+ mMuteButton.setSelected(value);
+ maybeSendAccessibilityEvent(mMuteButton, value ? R.string.accessibility_call_muted
+ : R.string.accessibility_call_unmuted);
+ }
}
@Override
@@ -249,7 +257,12 @@ public class CallButtonFragment
@Override
public void setHold(boolean value) {
- mHoldButton.setSelected(value);
+ if (mHoldButton.isSelected() != value) {
+ mHoldButton.setSelected(value);
+ maybeSendAccessibilityEvent(mHoldButton,
+ value ? R.string.accessibility_call_put_on_hold :
+ R.string.accessibility_call_removed_from_hold);
+ }
}
@Override
@@ -372,6 +385,30 @@ public class CallButtonFragment
public void setAudio(int mode) {
updateAudioButtons(getPresenter().getSupportedAudio());
refreshAudioModePopup();
+
+ if (mPrevAudioMode != mode) {
+ if (mPrevAudioMode != 0) {
+ int stringId = 0;
+ switch (mode) {
+ case AudioState.ROUTE_EARPIECE:
+ stringId = R.string.accessibility_earpiece_selected;
+ break;
+ case AudioState.ROUTE_BLUETOOTH:
+ stringId = R.string.accessibility_bluetooth_headset_selected;
+ break;
+ case AudioState.ROUTE_WIRED_HEADSET:
+ stringId = R.string.accessibility_wired_headset_selected;
+ break;
+ case AudioState.ROUTE_SPEAKER:
+ stringId = R.string.accessibility_speakerphone_selected;
+ break;
+ }
+ if (stringId != 0) {
+ maybeSendAccessibilityEvent(mAudioButton, stringId);
+ }
+ }
+ mPrevAudioMode = mode;
+ }
}
@Override
@@ -651,4 +688,19 @@ public class CallButtonFragment
public void hideExtraRow() {
mExtraRowButton.setVisibility(View.GONE);
}
+
+ private void maybeSendAccessibilityEvent(View view, int stringId) {
+ final Context context = getActivity();
+ AccessibilityManager manager =
+ (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
+ if (manager != null && manager.isEnabled()) {
+ AccessibilityEvent e = AccessibilityEvent.obtain();
+ e.setSource(view);
+ e.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
+ e.setClassName(getClass().getName());
+ e.setPackageName(context.getPackageName());
+ e.getText().add(context.getResources().getString(stringId));
+ manager.sendAccessibilityEvent(e);
+ }
+ }
}