Index: chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerView.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerView.java b/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerView.java |
index 9345693824256146903a5939f53024940756e817..393c11877940a24c0aedc62560aa67598d5c9658 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerView.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerView.java |
@@ -17,6 +17,7 @@ import android.content.res.Configuration; |
import android.content.res.Resources; |
import android.graphics.Rect; |
import android.os.Looper; |
+import android.text.TextUtils; |
import android.util.AttributeSet; |
import android.util.Log; |
import android.view.LayoutInflater; |
@@ -36,6 +37,8 @@ import org.chromium.ui.base.LocalizationUtils; |
import org.chromium.ui.base.WindowAndroid; |
import org.chromium.ui.base.WindowAndroid.IntentCallback; |
+import java.util.Locale; |
+ |
/** |
* Lays out a banner for showing info about an app on the Play Store. |
* The banner mimics the appearance of a Google Now card using a background Drawable with a shadow. |
@@ -242,6 +245,7 @@ public class AppBannerView extends SwipableOverlayView |
mTitleView.setText(mAppData.title()); |
mIconView.setImageDrawable(mAppData.icon()); |
mRatingView.initialize(mAppData.rating()); |
+ setAccessibilityInformation(); |
// Determine how much the user can drag sideways before their touch is considered a scroll. |
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); |
@@ -250,6 +254,17 @@ public class AppBannerView extends SwipableOverlayView |
updateButtonAppearance(); |
} |
+ /** |
+ * Creates a succinct description about the app being advertised. |
+ */ |
+ private void setAccessibilityInformation() { |
+ String ratingString = String.format(Locale.getDefault(), "%.1f", mAppData.rating(), 1); |
+ String appTitle = mAppData.title(); |
+ String bannerTemplate = getContext().getString(R.string.app_banner_view_accessibility); |
David Trainor- moved to gerrit
2014/04/02 19:48:54
I think you can put arguments inline in the getStr
gone
2014/04/02 22:18:26
Redid this a bit.
|
+ CharSequence bannerText = TextUtils.expandTemplate(bannerTemplate, appTitle, ratingString); |
+ setContentDescription(bannerText); |
+ } |
+ |
@Override |
public void onClick(View view) { |
if (mObserver == null) return; |
@@ -420,6 +435,7 @@ public class AppBannerView extends SwipableOverlayView |
Resources res = getResources(); |
int fgColor; |
String text; |
+ String accessibilityText = null; |
newt (away)
2014/04/02 18:48:40
why create this variable, if it's only set in one
gone
2014/04/02 22:18:26
Because Rome was built like pancakes.
newt (away)
2014/04/02 22:51:20
Rome is the messiest city. The Egyptians invented
gone
2014/04/02 23:13:12
Perhaps, but Romans did build aqueducts, which mad
|
if (mInstallState == INSTALL_STATE_INSTALLED) { |
ApiCompatibilityUtils.setBackgroundForView(mInstallButtonView, |
res.getDrawable(R.drawable.app_banner_button_open)); |
@@ -431,11 +447,17 @@ public class AppBannerView extends SwipableOverlayView |
fgColor = res.getColor(R.color.app_banner_install_button_fg); |
if (mInstallState == INSTALL_STATE_NOT_INSTALLED) { |
text = mAppData.installButtonText(); |
+ accessibilityText = |
+ getContext().getString(R.string.app_banner_install_accessibility, text); |
} else { |
text = res.getString(R.string.app_banner_installing); |
} |
} |
+ if (accessibilityText != null) { |
+ mInstallButtonView.setContentDescription(accessibilityText); |
+ } |
+ |
mInstallButtonView.setTextColor(fgColor); |
mInstallButtonView.setText(text); |
mInstallButtonView.setEnabled(mInstallState != INSTALL_STATE_INSTALLING); |