add accessibility descriptions/events
Bug: 4979091
added content descriptions to the image buttons
send event for screen transition
Change-Id: I403fe8504cace4aa84a5b1c6ca18f6c10fc9be34
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java
index a361136..9c12ccf 100644
--- a/src/com/android/browser/NavScreen.java
+++ b/src/com/android/browser/NavScreen.java
@@ -111,6 +111,8 @@
private void init() {
LayoutInflater.from(mContext).inflate(R.layout.nav_screen, this);
+ setContentDescription(mContext.getResources().getString(
+ R.string.accessibility_transition_navscreen));
mBookmarks = (ImageButton) findViewById(R.id.bookmarks);
mNewTab = (ImageButton) findViewById(R.id.newtab);
mNewIncognito = (ImageButton) findViewById(R.id.newincognito);
diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java
index 388c262..8173377 100644
--- a/src/com/android/browser/NavigationBarPhone.java
+++ b/src/com/android/browser/NavigationBarPhone.java
@@ -40,6 +40,8 @@
private ImageView mVoiceButton;
private Drawable mStopDrawable;
private Drawable mRefreshDrawable;
+ private String mStopDescription;
+ private String mRefreshDescription;
private View mTabSwitcher;
private View mComboIcon;
private View mTitleContainer;
@@ -78,6 +80,8 @@
Resources res = getContext().getResources();
mStopDrawable = res.getDrawable(R.drawable.ic_stop_holo_dark);
mRefreshDrawable = res.getDrawable(R.drawable.ic_refresh_holo_dark);
+ mStopDescription = res.getString(R.string.accessibility_button_stop);
+ mRefreshDescription = res.getString(R.string.accessibility_button_refresh);
mTextfieldBgDrawable = res.getDrawable(R.drawable.textfield_active_holo_dark);
setUaSwitcher(mComboIcon);
mUrlInput.setContainer(this);
@@ -98,6 +102,7 @@
super.onProgressStarted();
if (mStopButton.getDrawable() != mStopDrawable) {
mStopButton.setImageDrawable(mStopDrawable);
+ mStopButton.setContentDescription(mStopDescription);
if (mStopButton.getVisibility() != View.VISIBLE) {
mComboIcon.setVisibility(View.GONE);
mStopButton.setVisibility(View.VISIBLE);
@@ -109,6 +114,7 @@
public void onProgressStopped() {
super.onProgressStopped();
mStopButton.setImageDrawable(mRefreshDrawable);
+ mStopButton.setContentDescription(mRefreshDescription);
if (!isEditingUrl()) {
mComboIcon.setVisibility(View.VISIBLE);
}
diff --git a/src/com/android/browser/NavigationBarTablet.java b/src/com/android/browser/NavigationBarTablet.java
index 9cb8ff2..e3059ea 100644
--- a/src/com/android/browser/NavigationBarTablet.java
+++ b/src/com/android/browser/NavigationBarTablet.java
@@ -35,6 +35,8 @@
private Drawable mStopDrawable;
private Drawable mReloadDrawable;
+ private String mStopDescription;
+ private String mRefreshDescription;
private View mUrlContainer;
private ImageButton mBackButton;
@@ -71,6 +73,8 @@
Resources resources = context.getResources();
mStopDrawable = resources.getDrawable(R.drawable.ic_stop_holo_dark);
mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_holo_dark);
+ mStopDescription = resources.getString(R.string.accessibility_button_stop);
+ mRefreshDescription = resources.getString(R.string.accessibility_button_refresh);
mFocusDrawable = resources.getDrawable(
R.drawable.textfield_active_holo_dark);
mUnfocusDrawable = resources.getDrawable(
@@ -235,11 +239,13 @@
@Override
public void onProgressStarted() {
mStopButton.setImageDrawable(mStopDrawable);
+ mStopButton.setContentDescription(mStopDescription);
}
@Override
public void onProgressStopped() {
mStopButton.setImageDrawable(mReloadDrawable);
+ mStopButton.setContentDescription(mRefreshDescription);
}
protected void updateSearchMode(boolean userEdited) {
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index 1c9d5a0..853d935 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -17,6 +17,7 @@
package com.android.browser;
import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.ActionMode;
@@ -25,6 +26,8 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
import android.webkit.WebView;
import android.widget.FrameLayout;
@@ -250,6 +253,8 @@
mContentView.setVisibility(View.GONE);
mCustomViewContainer.setVisibility(View.VISIBLE);
mCustomViewContainer.bringToFront();
+ // notify accessibility manager about the screen change
+ mNavScreen.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
void hideNavScreen(boolean animate) {