summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/WallpaperPickerActivity.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2013-10-04 12:26:48 -0700
committerMichael Jurka <mikejurka@google.com>2013-10-07 15:39:42 -0700
commit6b783a06d2f4c169b0b6988740297e93393ec430 (patch)
treeb50dbf04dae0cde5b5f45b0a79f6fa101ea924b7 /src/com/android/launcher3/WallpaperPickerActivity.java
parentcffa7175f8328cfbf6bc9ed1507f1900fe4bc85c (diff)
downloadandroid_packages_apps_Trebuchet-6b783a06d2f4c169b0b6988740297e93393ec430.tar.gz
android_packages_apps_Trebuchet-6b783a06d2f4c169b0b6988740297e93393ec430.tar.bz2
android_packages_apps_Trebuchet-6b783a06d2f4c169b0b6988740297e93393ec430.zip
Add content description for wallpaper thumbs
Bug: 11012903
Diffstat (limited to 'src/com/android/launcher3/WallpaperPickerActivity.java')
-rw-r--r--src/com/android/launcher3/WallpaperPickerActivity.java84
1 files changed, 77 insertions, 7 deletions
diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java
index 82c9977c7..26d858bf3 100644
--- a/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -92,10 +92,20 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
private WallpaperInfo mLiveWallpaperInfoOnPickerLaunch;
public static abstract class WallpaperTileInfo {
+ protected View mView;
+ public void setView(View v) {
+ mView = v;
+ }
public void onClick(WallpaperPickerActivity a) {}
public void onSave(WallpaperPickerActivity a) {}
public void onDelete(WallpaperPickerActivity a) {}
public boolean isSelectable() { return false; }
+ public boolean isNamelessWallpaper() { return false; }
+ public void onIndexUpdated(CharSequence label) {
+ if (isNamelessWallpaper()) {
+ mView.setContentDescription(label);
+ }
+ }
}
public static class PickImageInfo extends WallpaperTileInfo {
@@ -136,6 +146,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
public boolean isSelectable() {
return true;
}
+ @Override
+ public boolean isNamelessWallpaper() {
+ return true;
+ }
}
public static class ResourceWallpaperInfo extends WallpaperTileInfo {
@@ -171,6 +185,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
public boolean isSelectable() {
return true;
}
+ @Override
+ public boolean isNamelessWallpaper() {
+ return true;
+ }
}
public void setWallpaperStripYOffset(float offset) {
@@ -282,6 +300,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
liveWallpapersView.removeAllViews();
populateWallpapersFromAdapter(liveWallpapersView, a, false, false);
initializeScrollForRtl();
+ updateTileIndices();
}
});
@@ -294,16 +313,16 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
// Add a tile for the Gallery
LinearLayout masterWallpaperList = (LinearLayout) findViewById(R.id.master_wallpaper_list);
- FrameLayout galleryThumbnail = (FrameLayout) getLayoutInflater().
+ FrameLayout pickImageTile = (FrameLayout) getLayoutInflater().
inflate(R.layout.wallpaper_picker_image_picker_item, masterWallpaperList, false);
- setWallpaperItemPaddingToZero(galleryThumbnail);
- masterWallpaperList.addView(galleryThumbnail, 0);
+ setWallpaperItemPaddingToZero(pickImageTile);
+ masterWallpaperList.addView(pickImageTile, 0);
// Make its background the last photo taken on external storage
Bitmap lastPhoto = getThumbnailOfLastPhoto();
if (lastPhoto != null) {
ImageView galleryThumbnailBg =
- (ImageView) galleryThumbnail.findViewById(R.id.wallpaper_image);
+ (ImageView) pickImageTile.findViewById(R.id.wallpaper_image);
galleryThumbnailBg.setImageBitmap(getThumbnailOfLastPhoto());
int colorOverlay = getResources().getColor(R.color.wallpaper_picker_translucent_gray);
galleryThumbnailBg.setColorFilter(colorOverlay, PorterDuff.Mode.SRC_ATOP);
@@ -311,8 +330,12 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
PickImageInfo pickImageInfo = new PickImageInfo();
- galleryThumbnail.setTag(pickImageInfo);
- galleryThumbnail.setOnClickListener(mThumbnailOnClickListener);
+ pickImageTile.setTag(pickImageInfo);
+ pickImageInfo.setView(pickImageTile);
+ pickImageTile.setOnClickListener(mThumbnailOnClickListener);
+ pickImageInfo.setView(pickImageTile);
+
+ updateTileIndices();
// Update the scroll for RTL
initializeScrollForRtl();
@@ -396,6 +419,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
for (View v : viewsToRemove) {
mWallpapersView.removeView(v);
}
+ updateTileIndices();
mode.finish(); // Action picked, so close the CAB
return true;
} else {
@@ -479,7 +503,9 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
for (int i = 0; i < adapter.getCount(); i++) {
FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
parent.addView(thumbnail, i);
- thumbnail.setTag(adapter.getItem(i));
+ WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
+ thumbnail.setTag(info);
+ info.setView(thumbnail);
if (addLongPressHandler) {
addLongPressHandler(thumbnail);
}
@@ -490,6 +516,48 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
}
+ private void updateTileIndices() {
+ LinearLayout masterWallpaperList = (LinearLayout) findViewById(R.id.master_wallpaper_list);
+ final int childCount = masterWallpaperList.getChildCount();
+ ArrayList<WallpaperTileInfo> tiles = new ArrayList<WallpaperTileInfo>();
+ final Resources res = getResources();
+
+ // Do two passes; the first pass gets the total number of tiles
+ int numTiles = 0;
+ for (int passNum = 0; passNum < 2; passNum++) {
+ int tileIndex = 0;
+ for (int i = 0; i < childCount; i++) {
+ View child = masterWallpaperList.getChildAt(i);
+ LinearLayout subList;
+
+ int subListStart;
+ int subListEnd;
+ if (child.getTag() instanceof WallpaperTileInfo) {
+ subList = masterWallpaperList;
+ subListStart = i;
+ subListEnd = i + 1;
+ } else { // if (child instanceof LinearLayout) {
+ subList = (LinearLayout) child;
+ subListStart = 0;
+ subListEnd = subList.getChildCount();
+ }
+
+ for (int j = subListStart; j < subListEnd; j++) {
+ WallpaperTileInfo info = (WallpaperTileInfo) subList.getChildAt(j).getTag();
+ if (info.isNamelessWallpaper()) {
+ if (passNum == 0) {
+ numTiles++;
+ } else {
+ CharSequence label = res.getString(
+ R.string.wallpaper_accessibility_name, ++tileIndex, numTiles);
+ info.onIndexUpdated(label);
+ }
+ }
+ }
+ }
+ }
+ }
+
private static Point getDefaultThumbnailSize(Resources res) {
return new Point(res.getDimensionPixelSize(R.dimen.wallpaperThumbnailWidth),
res.getDimensionPixelSize(R.dimen.wallpaperThumbnailHeight));
@@ -545,9 +613,11 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
Log.e(TAG, "Error loading thumbnail for uri=" + uri);
}
mWallpapersView.addView(pickedImageThumbnail, 0);
+ updateTileIndices();
UriWallpaperInfo info = new UriWallpaperInfo(uri);
pickedImageThumbnail.setTag(info);
+ info.setView(pickedImageThumbnail);
pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
mThumbnailOnClickListener.onClick(pickedImageThumbnail);
}