Merge "Ensuring that the widget drag outline is padded by the default widget padding. (Bug 10881814)" into jb-ub-now-indigo-rose
diff --git a/Android.mk b/Android.mk
index e22d53c..3b1a244 100644
--- a/Android.mk
+++ b/Android.mk
@@ -32,7 +32,7 @@
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
-LOCAL_SDK_VERSION := 17
+LOCAL_SDK_VERSION := 19
LOCAL_PACKAGE_NAME := Launcher3
#LOCAL_CERTIFICATE := shared
diff --git a/res/values/strings.xml b/res/values/strings.xml
index dfccd98..9f4f20b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -38,6 +38,9 @@
<item quantity="one">%1$d selected</item>
<item quantity="other">%1$d selected</item>
</plurals>
+ <!-- Accessibility string used as a label for a particular wallpaper in the Wallpaper Picker list.
+ e.g. "Wallpaper 3 of 10" -->
+ <string name="wallpaper_accessibility_name">Wallpaper %1$d of %2$d</string>
<!-- Label on button to delete wallpaper(s) -->
<string name="wallpaper_delete">Delete</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9f2a105..42704df 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -22,6 +22,7 @@
<item name="android:actionBarStyle">@style/WallpaperCropperActionBar</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBarOverlay">true</item>
+ <item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="WallpaperCropperActionBar" parent="android:style/Widget.Holo.ActionBar">
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7aceb41..201e583 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -270,6 +270,7 @@
private IconCache mIconCache;
private boolean mUserPresent = true;
private boolean mVisible = false;
+ private boolean mHasFocus = false;
private boolean mAttached = false;
private static final boolean DISABLE_CLINGS = false;
private static final boolean DISABLE_CUSTOM_CLINGS = true;
@@ -1009,25 +1010,11 @@
}
// We can't hide the IME if it was forced open. So don't bother
- /*
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
-
- if (hasFocus) {
- final InputMethodManager inputManager = (InputMethodManager)
- getSystemService(Context.INPUT_METHOD_SERVICE);
- WindowManager.LayoutParams lp = getWindow().getAttributes();
- inputManager.hideSoftInputFromWindow(lp.token, 0, new android.os.ResultReceiver(new
- android.os.Handler()) {
- protected void onReceiveResult(int resultCode, Bundle resultData) {
- Log.d(TAG, "ResultReceiver got resultCode=" + resultCode);
- }
- });
- Log.d(TAG, "called hideSoftInputFromWindow from onWindowFocusChanged");
- }
+ mHasFocus = hasFocus;
}
- */
private boolean acceptFilter() {
final InputMethodManager inputManager = (InputMethodManager)
@@ -1485,7 +1472,7 @@
// Reset AllApps to its initial state only if we are not in the middle of
// processing a multi-step drop
if (mAppsCustomizeTabHost != null && mPendingAddInfo.container == ItemInfo.NO_ID) {
- showWorkspaceAndExitOverviewMode(false);
+ showWorkspace(false);
}
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
mUserPresent = true;
@@ -1669,9 +1656,9 @@
// also will cancel mWaitingForResult.
closeSystemDialogs();
- final boolean alreadyOnHome =
- ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
- != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
+ final boolean alreadyOnHome = mHasFocus && ((intent.getFlags() &
+ Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
+ != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
if (mWorkspace == null) {
// Can be cases where mWorkspace is null, this prevents a NPE
@@ -1691,7 +1678,7 @@
// If we are already on home, then just animate back to the workspace,
// otherwise, just wait until onResume to set the state back to Workspace
if (alreadyOnHome) {
- showWorkspaceAndExitOverviewMode(true);
+ showWorkspace(true);
} else {
mOnResumeState = State.WORKSPACE;
}
@@ -1708,21 +1695,12 @@
mAppsCustomizeTabHost.reset();
}
}
+
if (DEBUG_RESUME_TIME) {
Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
}
}
- protected void showWorkspaceAndExitOverviewMode(boolean animate) {
- showWorkspace(animate);
- if (mWorkspace.isInOverviewMode()) {
- mWorkspace.exitOverviewMode(animate);
- }
- }
- protected void showWorkspaceAndExitOverviewMode() {
- showWorkspaceAndExitOverviewMode(false);
- }
-
@Override
public void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
@@ -2079,7 +2057,6 @@
}
protected void startWallpaper() {
- showWorkspace(true);
final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);
pickWallpaper.setComponent(getWallpaperPickerComponent());
startActivityForResult(pickWallpaper, REQUEST_PICK_WALLPAPER);
@@ -2125,7 +2102,12 @@
@Override
public void onBackPressed() {
if (isAllAppsVisible()) {
- showWorkspace(true);
+ if (mAppsCustomizeContent.getContentType() ==
+ AppsCustomizePagedView.ContentType.Applications) {
+ showWorkspace(true);
+ } else {
+ showOverviewMode(true);
+ }
} else if (mWorkspace.isInOverviewMode()) {
mWorkspace.exitOverviewMode(true);
} else if (mWorkspace.getOpenFolder() != null) {
@@ -2943,7 +2925,7 @@
* This is the opposite of showAppsCustomizeHelper.
* @param animated If true, the transition will be animated.
*/
- private void hideAppsCustomizeHelper(State toState, final boolean animated,
+ private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated,
final boolean springLoaded, final Runnable onCompleteRunnable) {
if (mStateAnimation != null) {
@@ -2961,13 +2943,14 @@
final View fromView = mAppsCustomizeTabHost;
final View toView = mWorkspace;
Animator workspaceAnim = null;
- if (toState == State.WORKSPACE) {
+ if (toState == Workspace.State.NORMAL) {
int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
workspaceAnim = mWorkspace.getChangeStateAnimation(
- Workspace.State.NORMAL, animated, stagger, -1);
- } else if (toState == State.APPS_CUSTOMIZE_SPRING_LOADED) {
+ toState, animated, stagger, -1);
+ } else if (toState == Workspace.State.SPRING_LOADED ||
+ toState == Workspace.State.OVERVIEW) {
workspaceAnim = mWorkspace.getChangeStateAnimation(
- Workspace.State.SPRING_LOADED, animated);
+ toState, animated);
}
setPivotsForZoom(fromView, scaleFactor);
@@ -3039,15 +3022,22 @@
}
}
- void showWorkspace(boolean animated) {
+ protected void showWorkspace(boolean animated) {
showWorkspace(animated, null);
}
+ protected void showWorkspace() {
+ showWorkspace(true);
+ }
+
void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
+ if (mWorkspace.isInOverviewMode()) {
+ mWorkspace.exitOverviewMode(animated);
+ }
if (mState != State.WORKSPACE) {
boolean wasInSpringLoadedMode = (mState != State.WORKSPACE);
mWorkspace.setVisibility(View.VISIBLE);
- hideAppsCustomizeHelper(State.WORKSPACE, animated, false, onCompleteRunnable);
+ hideAppsCustomizeHelper(Workspace.State.NORMAL, animated, false, onCompleteRunnable);
// Show the search bar (only animate if we were showing the drop target bar in spring
// loaded mode)
@@ -3075,6 +3065,13 @@
onWorkspaceShown(animated);
}
+ void showOverviewMode(boolean animated) {
+ mWorkspace.setVisibility(View.VISIBLE);
+ hideAppsCustomizeHelper(Workspace.State.OVERVIEW, animated, false, null);
+ mState = State.WORKSPACE;
+ onWorkspaceShown(animated);
+ }
+
public void onWorkspaceShown(boolean animated) {
}
@@ -3100,7 +3097,7 @@
void enterSpringLoadedDragMode() {
if (isAllAppsVisible()) {
- hideAppsCustomizeHelper(State.APPS_CUSTOMIZE_SPRING_LOADED, true, true, null);
+ hideAppsCustomizeHelper(Workspace.State.SPRING_LOADED, true, true, null);
mState = State.APPS_CUSTOMIZE_SPRING_LOADED;
}
}
diff --git a/src/com/android/launcher3/LiveWallpaperListAdapter.java b/src/com/android/launcher3/LiveWallpaperListAdapter.java
index 4b59794..54e0af7 100644
--- a/src/com/android/launcher3/LiveWallpaperListAdapter.java
+++ b/src/com/android/launcher3/LiveWallpaperListAdapter.java
@@ -93,6 +93,7 @@
WallpaperPickerActivity.setWallpaperItemPaddingToZero((FrameLayout) view);
LiveWallpaperTile wallpaperInfo = mWallpapers.get(position);
+ wallpaperInfo.setView(view);
ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image);
ImageView icon = (ImageView) view.findViewById(R.id.wallpaper_icon);
if (wallpaperInfo.mThumbnail != null) {
@@ -174,46 +175,10 @@
Intent launchIntent = new Intent(WallpaperService.SERVICE_INTERFACE);
launchIntent.setClassName(info.getPackageName(), info.getServiceName());
LiveWallpaperTile wallpaper = new LiveWallpaperTile(thumb, info, launchIntent);
-
- // TODO: generate a default thumb
- /*
- final Resources res = mContext.getResources();
- Canvas canvas = new Canvas();
- Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
- paint.setTextAlign(Paint.Align.CENTER);
- BitmapDrawable galleryIcon = (BitmapDrawable) res.getDrawable(
- R.drawable.livewallpaper_placeholder);
- if (thumb == null) {
- int thumbWidth = res.getDimensionPixelSize(
- R.dimen.live_wallpaper_thumbnail_width);
- int thumbHeight = res.getDimensionPixelSize(
- R.dimen.live_wallpaper_thumbnail_height);
-
- Bitmap thumbnail = Bitmap.createBitmap(thumbWidth, thumbHeight,
- Bitmap.Config.ARGB_8888);
-
- paint.setColor(res.getColor(R.color.live_wallpaper_thumbnail_background));
- canvas.setBitmap(thumbnail);
- canvas.drawPaint(paint);
-
- galleryIcon.setBounds(0, 0, thumbWidth, thumbHeight);
- galleryIcon.setGravity(Gravity.CENTER);
- galleryIcon.draw(canvas);
-
- String title = info.loadLabel(packageManager).toString();
-
- paint.setColor(res.getColor(R.color.live_wallpaper_thumbnail_text_color));
- paint.setTextSize(
- res.getDimensionPixelSize(R.dimen.live_wallpaper_thumbnail_text_size));
-
- canvas.drawText(title, (int) (thumbWidth * 0.5),
- thumbHeight - res.getDimensionPixelSize(
- R.dimen.live_wallpaper_thumbnail_text_offset), paint);
-
- thumb = new BitmapDrawable(res, thumbnail);
- }*/
publishProgress(wallpaper);
}
+ // Send a null object to show loading is finished
+ publishProgress((LiveWallpaperTile) null);
return null;
}
@@ -221,6 +186,10 @@
@Override
protected void onProgressUpdate(LiveWallpaperTile...infos) {
for (LiveWallpaperTile info : infos) {
+ if (info == null) {
+ LiveWallpaperListAdapter.this.notifyDataSetChanged();
+ break;
+ }
info.mThumbnail.setDither(true);
if (mWallpaperPosition < mWallpapers.size()) {
mWallpapers.set(mWallpaperPosition, info);
@@ -228,9 +197,6 @@
mWallpapers.add(info);
}
mWallpaperPosition++;
- if (mWallpaperPosition == getCount()) {
- LiveWallpaperListAdapter.this.notifyDataSetChanged();
- }
}
}
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 003b2db..b209436 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -668,11 +668,10 @@
if (am.isEnabled()) {
AccessibilityEvent ev =
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
- ev.getText().add("");
ev.setItemCount(getChildCount());
ev.setFromIndex(mCurrentPage);
- int action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
+ final int action;
if (getNextPage() >= mCurrentPage) {
action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
} else {
@@ -2754,6 +2753,14 @@
}
@Override
+ public void sendAccessibilityEvent(int eventType) {
+ // Don't let the view send real scroll events.
+ if (eventType != AccessibilityEvent.TYPE_VIEW_SCROLLED) {
+ super.sendAccessibilityEvent(eventType);
+ }
+ }
+
+ @Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
event.setScrollable(true);
diff --git a/src/com/android/launcher3/SavedWallpaperImages.java b/src/com/android/launcher3/SavedWallpaperImages.java
index 531672a..ee4888d 100644
--- a/src/com/android/launcher3/SavedWallpaperImages.java
+++ b/src/com/android/launcher3/SavedWallpaperImages.java
@@ -79,6 +79,10 @@
public boolean isSelectable() {
return true;
}
+ @Override
+ public boolean isNamelessWallpaper() {
+ return true;
+ }
}
public SavedWallpaperImages(Activity context) {
diff --git a/src/com/android/launcher3/WallpaperCropActivity.java b/src/com/android/launcher3/WallpaperCropActivity.java
index 78c8964..fe09a55 100644
--- a/src/com/android/launcher3/WallpaperCropActivity.java
+++ b/src/com/android/launcher3/WallpaperCropActivity.java
@@ -102,8 +102,6 @@
cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
}
});
- TranslucentDecor transparentDecor = new TranslucentDecor(findViewById(R.id.wallpaper_root));
- transparentDecor.requestTranslucentDecor(true);
}
public boolean enableRotation() {
diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java
index 82c9977..9d3164b 100644
--- a/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -92,10 +92,20 @@
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 boolean isSelectable() {
return true;
}
+ @Override
+ public boolean isNamelessWallpaper() {
+ return true;
+ }
}
public static class ResourceWallpaperInfo extends WallpaperTileInfo {
@@ -171,6 +185,10 @@
public boolean isSelectable() {
return true;
}
+ @Override
+ public boolean isNamelessWallpaper() {
+ return true;
+ }
}
public void setWallpaperStripYOffset(float offset) {
@@ -181,8 +199,6 @@
protected void init() {
setContentView(R.layout.wallpaper_picker);
final WallpaperRootView root = (WallpaperRootView) findViewById(R.id.wallpaper_root);
- TranslucentDecor transparentDecor = new TranslucentDecor(root);
- transparentDecor.requestTranslucentDecor(true);
mCropView = (CropView) findViewById(R.id.cropView);
mWallpaperStrip = findViewById(R.id.wallpaper_strip);
@@ -282,6 +298,7 @@
liveWallpapersView.removeAllViews();
populateWallpapersFromAdapter(liveWallpapersView, a, false, false);
initializeScrollForRtl();
+ updateTileIndices();
}
});
@@ -294,16 +311,16 @@
// 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 +328,12 @@
}
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 +417,7 @@
for (View v : viewsToRemove) {
mWallpapersView.removeView(v);
}
+ updateTileIndices();
mode.finish(); // Action picked, so close the CAB
return true;
} else {
@@ -479,7 +501,9 @@
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 +514,48 @@
}
}
+ 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 +611,11 @@
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);
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index d7d17ed..a23d7d0 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2075,7 +2075,7 @@
R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, true);
} else {
// Fade the background gradient away
- animateBackgroundGradient(0f, true);
+ animateBackgroundGradient(0f, animated);
}
return anim;
}