diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 29 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizeTabHost.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/Folder.java | 16 | ||||
-rw-r--r-- | src/com/android/launcher2/FolderIcon.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher2/HolographicLinearLayout.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher2/InstallShortcutReceiver.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 157 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/UninstallShortcutReceiver.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 46 |
11 files changed, 187 insertions, 91 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 5c0f6b68b..5f81d9c1d 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -310,6 +310,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private boolean mInTransition; private ArrayList<AsyncTaskPageData> mDeferredSyncWidgetPageItems = new ArrayList<AsyncTaskPageData>(); + private ArrayList<Runnable> mDeferredPrepareLoadWidgetPreviewsTasks = + new ArrayList<Runnable>(); // Used for drawing shortcut previews BitmapCache mCachedShortcutPreviewBitmap = new BitmapCache(); @@ -547,13 +549,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // TODO: this isn't ideal, but we actually need to delay here. This call is triggered // by a broadcast receiver, and in order for it to work correctly, we need to know that // the AppWidgetService has already received and processed the same broadcast. Since there - // is no guarantee about ordering of broadcast receipt, we just delay here. Ideally, - // we should have a more precise way of ensuring the AppWidgetService is up to date. + // is no guarantee about ordering of broadcast receipt, we just delay here. This is a + // workaround until we add a callback from AppWidgetService to AppWidgetHost when widget + // packages are added, updated or removed. postDelayed(new Runnable() { public void run() { updatePackages(); } - }, 500); + }, 1500); } public void updatePackages() { @@ -574,6 +577,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (minSpanX <= LauncherModel.getCellCountX() && minSpanY <= LauncherModel.getCellCountY()) { mWidgets.add(widget); + } else { + Log.e(TAG, "Widget " + widget.provider + " can not fit on this device (" + + widget.minWidth + ", " + widget.minHeight + ")"); } } else { Log.e(TAG, "Widget " + widget.provider + " has invalid dimensions (" + @@ -911,12 +917,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen @Override public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) { - Log.d(TAG, "6549598 onLauncherTransitionEnd"); + Log.d(TAG, "6549598 onLauncherTransitionEnd mDeferredSyncWidgetPageItems.size(): " + mDeferredSyncWidgetPageItems.size()); mInTransition = false; for (AsyncTaskPageData d : mDeferredSyncWidgetPageItems) { onSyncWidgetPageItems(d); } mDeferredSyncWidgetPageItems.clear(); + for (Runnable r : mDeferredPrepareLoadWidgetPreviewsTasks) { + r.run(); + } + mDeferredPrepareLoadWidgetPreviewsTasks.clear(); mForceDrawAllChildrenNextFrame = !toWorkspace; } @@ -1000,6 +1010,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } } mDeferredSyncWidgetPageItems.clear(); + mDeferredPrepareLoadWidgetPreviewsTasks.clear(); } public void setContentType(ContentType type) { @@ -1074,7 +1085,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } public void syncAppsPageItems(int page, boolean immediate) { - Log.d(TAG, "6549598 syncAppsPageItems page: " + page); + Log.d(TAG, "6549598 syncAppsPageItems page: " + page + " mNumAppsPages: " + mNumAppsPages); // ensure that we have the right number of items on the pages int numCells = mCellCountX * mCellCountY; int startIndex = page * numCells; @@ -1488,8 +1499,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen loadWidgetPreviewsInBackground(null, data); onSyncWidgetPageItems(data); } else { - prepareLoadWidgetPreviewsTask(page, items, - maxPreviewWidth, maxPreviewHeight, mWidgetCountX); + if (mInTransition) { + mDeferredPrepareLoadWidgetPreviewsTasks.add(this); + } else { + prepareLoadWidgetPreviewsTask(page, items, + maxPreviewWidth, maxPreviewHeight, mWidgetCountX); + } } } }); diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index d3afc3bf0..6bd97a2f2 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -23,6 +23,7 @@ import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.Resources; import android.util.AttributeSet; +import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -392,6 +393,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona // Make sure the current page is loaded (we start loading the side pages after the // transition to prevent slowing down the animation) + Log.d(LOG_TAG, "6549598 onLauncherTransitionPrepare currentPage: " + mAppsCustomizePane.getCurrentPage()); mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true); if (!LauncherApplication.isScreenLarge()) { @@ -434,6 +436,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona mAppsCustomizePane.showAllAppsCling(); // Make sure adjacent pages are loaded (we wait until after the transition to // prevent slowing down the animation) + Log.d(LOG_TAG, "6549598 onLauncherTransitionEnd currentPage: " + mAppsCustomizePane.getCurrentPage()); mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage()); if (!LauncherApplication.isScreenLarge()) { diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index db65a31ee..1163f9ec4 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -100,6 +100,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private boolean mSuppressFolderDeletion = false; private boolean mItemAddedBackToSelfViaIcon = false; FolderEditText mFolderName; + private float mFolderIconPivotX; + private float mFolderIconPivotY; private boolean mIsEditingName = false; private InputMethodManager mInputMethodManager; @@ -839,20 +841,24 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList int folderPivotY = height / 2 + (centeredTop - top); setPivotX(folderPivotX); setPivotY(folderPivotY); - int folderIconPivotX = (int) (mFolderIcon.getMeasuredWidth() * + mFolderIconPivotX = (int) (mFolderIcon.getMeasuredWidth() * (1.0f * folderPivotX / width)); - int folderIconPivotY = (int) (mFolderIcon.getMeasuredHeight() * + mFolderIconPivotY = (int) (mFolderIcon.getMeasuredHeight() * (1.0f * folderPivotY / height)); - mFolderIcon.setPivotX(folderIconPivotX); - mFolderIcon.setPivotY(folderIconPivotY); - lp.width = width; lp.height = height; lp.x = left; lp.y = top; } + float getPivotXForIconAnimation() { + return mFolderIconPivotX; + } + float getPivotYForIconAnimation() { + return mFolderIconPivotY; + } + private void setupContentForNumItems(int count) { setupContentDimensions(count); diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java index d64308406..4919b57f0 100644 --- a/src/com/android/launcher2/FolderIcon.java +++ b/src/com/android/launcher2/FolderIcon.java @@ -321,12 +321,7 @@ public class FolderIcon extends LinearLayout implements FolderListener { // This will animate the first item from it's position as an icon into its // position as the first item in the preview animateFirstItem(animateDrawable, INITIAL_ITEM_ANIMATION_DURATION); - - postDelayed(new Runnable() { - public void run() { - addItem(destInfo); - } - }, INITIAL_ITEM_ANIMATION_DURATION); + addItem(destInfo); } public void onDragExit(Object dragInfo) { diff --git a/src/com/android/launcher2/HolographicLinearLayout.java b/src/com/android/launcher2/HolographicLinearLayout.java index a40c727b5..0f997d5fa 100644 --- a/src/com/android/launcher2/HolographicLinearLayout.java +++ b/src/com/android/launcher2/HolographicLinearLayout.java @@ -68,6 +68,7 @@ public class HolographicLinearLayout extends LinearLayout { void invalidatePressedFocusedStates() { mHolographicHelper.invalidatePressedFocusedStates(mImageView); + invalidate(); } @Override diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java index e05127b27..b454afd7f 100644 --- a/src/com/android/launcher2/InstallShortcutReceiver.java +++ b/src/com/android/launcher2/InstallShortcutReceiver.java @@ -185,7 +185,9 @@ public class InstallShortcutReceiver extends BroadcastReceiver { if (newAppsScreen == screen) { newApps = sharedPrefs.getStringSet(NEW_APPS_LIST_KEY, newApps); } - newApps.add(intent.toUri(0).toString()); + synchronized (newApps) { + newApps.add(intent.toUri(0).toString()); + } final Set<String> savedNewApps = newApps; new Thread("setNewAppsThread") { public void run() { diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 3354d49bd..28dfd6521 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -48,6 +48,9 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -278,6 +281,10 @@ public final class Launcher extends Activity // when we scroll to that page on resume. private int mNewShortcutAnimatePage = -1; private ArrayList<View> mNewShortcutAnimateViews = new ArrayList<View>(); + private ImageView mFolderIconImageView; + private Bitmap mFolderIconBitmap; + private Canvas mFolderIconCanvas; + private Rect mRectForFolderAnimation = new Rect(); private BubbleTextView mWaitingForResume; @@ -374,6 +381,13 @@ public final class Launcher extends Activity IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mCloseSystemDialogsReceiver, filter); + updateGlobalIcons(); + + // On large interfaces, we want the screen to auto-rotate based on the current orientation + unlockScreenOrientation(true); + } + + private void updateGlobalIcons() { boolean searchVisible = false; boolean voiceVisible = false; // If we have a saved version of these external icons, we load them up immediately @@ -396,9 +410,6 @@ public final class Launcher extends Activity updateAppMarketIcon(sAppMarketIcon[coi]); } mSearchDropTargetBar.onSearchPackagesChanged(searchVisible, voiceVisible); - - // On large interfaces, we want the screen to auto-rotate based on the current orientation - unlockScreenOrientation(true); } private void checkForLocaleChange() { @@ -686,27 +697,11 @@ public final class Launcher extends Activity // Consequently, the widgets will be inflated in the orientation of the foreground activity // (framework issue). On resuming, we ensure that any widgets are inflated for the current // orientation. - reinflateWidgetsIfNecessary(); - } - - void reinflateWidgetsIfNecessary() { - for (LauncherAppWidgetInfo info: LauncherModel.getWidgets()) { - LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView; - if (lahv != null && lahv.orientationChangedSincedInflation()) { - AppWidgetProviderInfo pInfo = lahv.getAppWidgetInfo(); - - // Remove the current widget which is inflated with the wrong orientation - getWorkspace().getParentCellLayoutForView(lahv).removeView(lahv); - // Re-inflate the widget using the correct orientation - AppWidgetHostView widget = mAppWidgetHost.createView(this, info.appWidgetId, pInfo); + getWorkspace().reinflateWidgetsIfNecessary(); - // Add the new widget back - widget.setTag(info); - info.hostView = widget; - getWorkspace().addInScreen(widget, info.container, info.screen, - info.cellX, info.cellY, info.spanX, info.spanY); - } - } + // Again, as with the above scenario, it's possible that one or more of the global icons + // were updated in the wrong orientation. + updateGlobalIcons(); } @Override @@ -1238,17 +1233,6 @@ public final class Launcher extends Activity // some communication back with the app. mWorkspace.postDelayed(mBuildLayersRunnable, 500); - // We had to enable the wallpaper visibility when launching apps from all - // apps (so that the transitions would be the same as when launching from - // workspace) so take this time to see if we need to re-disable the - // wallpaper visibility to ensure performance. - mWorkspace.post(new Runnable() { - @Override - public void run() { - disableWallpaperIfInAllApps(); - } - }); - observer.removeOnPreDrawListener(this); return true; } @@ -1892,8 +1876,7 @@ public final class Launcher extends Activity (SearchManager) getSystemService(Context.SEARCH_SERVICE); ComponentName activityName = searchManager.getGlobalSearchActivity(); Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (activityName != null) { intent.setPackage(activityName.getPackageName()); } @@ -1901,8 +1884,7 @@ public final class Launcher extends Activity overridePendingTransition(R.anim.fade_in_fast, R.anim.fade_out_fast); } catch (ActivityNotFoundException e) { Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivitySafely(null, intent, "onClickVoiceButton"); } } @@ -2040,6 +2022,56 @@ public final class Launcher extends Activity } } + /** + * This method draws the FolderIcon to an ImageView and then adds and positions that ImageView + * in the DragLayer in the exact absolute location of the original FolderIcon. + */ + private void copyFolderIconToImage(FolderIcon fi) { + final int width = fi.getMeasuredWidth(); + final int height = fi.getMeasuredHeight(); + + // Lazy load ImageView, Bitmap and Canvas + if (mFolderIconImageView == null) { + mFolderIconImageView = new ImageView(this); + } + if (mFolderIconBitmap == null || mFolderIconBitmap.getWidth() != width || + mFolderIconBitmap.getHeight() != height) { + mFolderIconBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + mFolderIconCanvas = new Canvas(mFolderIconBitmap); + } + + DragLayer.LayoutParams lp; + if (mFolderIconImageView.getLayoutParams() instanceof DragLayer.LayoutParams) { + lp = (DragLayer.LayoutParams) mFolderIconImageView.getLayoutParams(); + } else { + lp = new DragLayer.LayoutParams(width, height); + } + + mDragLayer.getViewRectRelativeToSelf(fi, mRectForFolderAnimation); + lp.customPosition = true; + lp.x = mRectForFolderAnimation.left; + lp.y = mRectForFolderAnimation.top; + lp.width = width; + lp.height = height; + + mFolderIconCanvas.drawColor(0, PorterDuff.Mode.CLEAR); + fi.draw(mFolderIconCanvas); + mFolderIconImageView.setImageBitmap(mFolderIconBitmap); + if (fi.mFolder != null) { + mFolderIconImageView.setPivotX(fi.mFolder.getPivotXForIconAnimation()); + mFolderIconImageView.setPivotY(fi.mFolder.getPivotYForIconAnimation()); + } + // Just in case this image view is still in the drag layer from a previous animation, + // we remove it and re-add it. + if (mDragLayer.indexOfChild(mFolderIconImageView) != -1) { + mDragLayer.removeView(mFolderIconImageView); + } + mDragLayer.addView(mFolderIconImageView, lp); + if (fi.mFolder != null) { + fi.mFolder.bringToFront(); + } + } + private void growAndFadeOutFolderIcon(FolderIcon fi) { if (fi == null) return; PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0); @@ -2053,31 +2085,38 @@ public final class Launcher extends Activity cl.setFolderLeaveBehindCell(lp.cellX, lp.cellY); } - ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(fi, alpha, scaleX, scaleY); + // Push an ImageView copy of the FolderIcon into the DragLayer and hide the original + copyFolderIconToImage(fi); + fi.setVisibility(View.INVISIBLE); + + ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(mFolderIconImageView, alpha, + scaleX, scaleY); oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration)); oa.start(); } - private void shrinkAndFadeInFolderIcon(FolderIcon fi) { + private void shrinkAndFadeInFolderIcon(final FolderIcon fi) { if (fi == null) return; PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); - FolderInfo info = (FolderInfo) fi.getTag(); - CellLayout cl = null; - if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { - cl = (CellLayout) fi.getParent().getParent(); - } + final CellLayout cl = (CellLayout) fi.getParent().getParent(); - final CellLayout layout = cl; - ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(fi, alpha, scaleX, scaleY); + // We remove and re-draw the FolderIcon in-case it has changed + mDragLayer.removeView(mFolderIconImageView); + copyFolderIconToImage(fi); + ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(mFolderIconImageView, alpha, + scaleX, scaleY); oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration)); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - if (layout != null) { - layout.clearFolderLeaveBehind(); + if (cl != null) { + cl.clearFolderLeaveBehind(); + // Remove the ImageView copy of the FolderIcon and make the original visible. + mDragLayer.removeView(mFolderIconImageView); + fi.setVisibility(View.VISIBLE); } } }); @@ -2095,7 +2134,6 @@ public final class Launcher extends Activity Folder folder = folderIcon.mFolder; FolderInfo info = folder.mInfo; - growAndFadeOutFolderIcon(folderIcon); info.opened = true; // Just verify that the folder hasn't already been added to the DragLayer. @@ -2108,6 +2146,7 @@ public final class Launcher extends Activity folder.getParent() + ")."); } folder.animateOpen(); + growAndFadeOutFolderIcon(folderIcon); } public void closeFolder() { @@ -2616,7 +2655,12 @@ public final class Launcher extends Activity updateWallpaperVisibility(true); } else { // When launcher has focus again, disable the wallpaper if we are in AllApps - disableWallpaperIfInAllApps(); + mWorkspace.postDelayed(new Runnable() { + @Override + public void run() { + disableWallpaperIfInAllApps(); + } + }, 500); } } @@ -3157,9 +3201,13 @@ public final class Launcher extends Activity View shortcut = createShortcut(info); workspace.addInScreen(shortcut, item.container, item.screen, item.cellX, item.cellY, 1, 1, false); - if (newApps.contains(uri)) { - newApps.remove(uri); - + boolean animateIconUp = false; + synchronized (newApps) { + if (newApps.contains(uri)) { + animateIconUp = newApps.remove(uri); + } + } + if (animateIconUp) { // Prepare the view to be animated up shortcut.setAlpha(0f); shortcut.setScaleX(0f); @@ -3214,7 +3262,6 @@ public final class Launcher extends Activity item.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo); - item.hostView.setAppWidget(appWidgetId, appWidgetInfo); item.hostView.setTag(item); item.onBindAppWidget(this); diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 1b17ef952..fc1a26d4b 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -377,10 +377,6 @@ public class LauncherModel extends BroadcastReceiver { return items; } - static ArrayList<LauncherAppWidgetInfo> getWidgets() { - return sAppWidgets; - } - /** * Find a folder in the db, creating the FolderInfo if necessary, and adding it to folderList. */ diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index c8202642a..19f6a62a7 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -234,6 +234,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mDirtyPageContent.ensureCapacity(32); mScroller = new Scroller(getContext(), new ScrollInterpolator()); mCurrentPage = 0; + if (this instanceof AppsCustomizePagedView) Log.d(TAG, "6549598 init() mCurrentPage: " + mCurrentPage); mCenterPagesVertically = true; final ViewConfiguration configuration = ViewConfiguration.get(getContext()); @@ -317,7 +318,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc return; } + mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1)); + if (this instanceof AppsCustomizePagedView) Log.d(TAG, "6549598 setCurrentPage mCurrentPage: " + mCurrentPage); updateCurrentPageScroll(); updateScrollingIndicator(); notifyPageSwitchListener(); diff --git a/src/com/android/launcher2/UninstallShortcutReceiver.java b/src/com/android/launcher2/UninstallShortcutReceiver.java index 84b1ad50e..e94a17ffd 100644 --- a/src/com/android/launcher2/UninstallShortcutReceiver.java +++ b/src/com/android/launcher2/UninstallShortcutReceiver.java @@ -139,9 +139,11 @@ public class UninstallShortcutReceiver extends BroadcastReceiver { boolean appRemoved; Set<String> newApps = new HashSet<String>(); newApps = sharedPrefs.getStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY, newApps); - do { - appRemoved = newApps.remove(intent.toUri(0).toString()); - } while (appRemoved); + synchronized (newApps) { + do { + appRemoved = newApps.remove(intent.toUri(0).toString()); + } while (appRemoved); + } if (appRemoved) { final Set<String> savedNewApps = newApps; new Thread("setNewAppsThread-remove") { diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index ba518890e..0192630b6 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -77,7 +77,6 @@ public class Workspace extends SmoothPagedView // Y rotation to apply to the workspace screens private static final float WORKSPACE_OVERSCROLL_ROTATION = 24f; - private static float CAMERA_DISTANCE = 6500; private static final int CHILDREN_OUTLINE_FADE_OUT_DELAY = 0; private static final int CHILDREN_OUTLINE_FADE_OUT_DURATION = 375; @@ -196,6 +195,7 @@ public class Workspace extends SmoothPagedView private boolean mIsStaticWallpaper; private int mWallpaperTravelWidth; private int mSpringLoadedPageSpacing; + private int mCameraDistance; // Variables relating to the creation of user folders by hovering shortcuts over shortcuts private static final int FOLDER_CREATION_TIMEOUT = 0; @@ -321,6 +321,7 @@ public class Workspace extends SmoothPagedView res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mSpringLoadedPageSpacing = res.getDimensionPixelSize(R.dimen.workspace_spring_loaded_page_spacing); + mCameraDistance = res.getInteger(R.integer.config_cameraDistance); // if the value is manually specified, use that instead cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX); @@ -670,6 +671,29 @@ public class Workspace extends SmoothPagedView return super.onInterceptTouchEvent(ev); } + protected void reinflateWidgetsIfNecessary() { + final int clCount = getChildCount(); + for (int i = 0; i < clCount; i++) { + CellLayout cl = (CellLayout) getChildAt(i); + ShortcutAndWidgetContainer swc = cl.getShortcutsAndWidgets(); + final int itemCount = swc.getChildCount(); + for (int j = 0; j < itemCount; j++) { + View v = swc.getChildAt(j); + + if (v.getTag() instanceof LauncherAppWidgetInfo) { + LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag(); + LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView; + if (lahv != null && lahv.orientationChangedSincedInflation()) { + mLauncher.removeAppWidget(info); + // Remove the current widget which is inflated with the wrong orientation + cl.removeView(lahv); + mLauncher.bindAppWidget(info); + } + } + } + } + } + @Override protected void determineScrollingStart(MotionEvent ev) { if (isSmall()) return; @@ -1250,7 +1274,7 @@ public class Workspace extends SmoothPagedView setFadeForOverScroll(Math.abs(scrollProgress)); if (!mOverscrollTransformsSet) { mOverscrollTransformsSet = true; - cl.setCameraDistance(mDensity * CAMERA_DISTANCE); + cl.setCameraDistance(mDensity * mCameraDistance); cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f)); cl.setPivotY(cl.getMeasuredHeight() * 0.5f); cl.setOverscrollTransformsDirty(true); @@ -3659,14 +3683,16 @@ public class Workspace extends SmoothPagedView } // Remove all queued items that match the same package if (newApps != null) { - for (String intentStr : newApps) { - try { - Intent intent = Intent.parseUri(intentStr, 0); - String pn = ItemInfo.getPackageName(intent); - if (packageNames.contains(pn)) { - newApps.remove(intentStr); - } - } catch (URISyntaxException e) {} + synchronized (newApps) { + for (String intentStr : newApps) { + try { + Intent intent = Intent.parseUri(intentStr, 0); + String pn = ItemInfo.getPackageName(intent); + if (packageNames.contains(pn)) { + newApps.remove(intentStr); + } + } catch (URISyntaxException e) {} + } } } } |