summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java79
-rw-r--r--src/com/android/launcher2/InstallShortcutReceiver.java10
-rw-r--r--src/com/android/launcher2/Launcher.java13
-rw-r--r--src/com/android/launcher2/UninstallShortcutReceiver.java16
-rw-r--r--src/com/android/launcher2/Workspace.java5
5 files changed, 54 insertions, 69 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 61329adaf..a24bfdaf2 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -434,16 +434,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
- /**
- * This differs from isDataReady as this is the test done if isDataReady is not set.
- */
- private boolean testDataReady() {
- // We only do this test once, and we default to the Applications page, so we only really
- // have to wait for there to be apps.
- // TODO: What if one of them is validly empty
- return !mApps.isEmpty() && !mWidgets.isEmpty();
- }
-
/** Restores the page for an item at the specified index */
void restorePageForIndex(int index) {
if (index < 0) return;
@@ -515,7 +505,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
void showAllAppsCling() {
- if (!mHasShownAllAppsCling && isDataReady() && testDataReady()) {
+ if (!mHasShownAllAppsCling && isDataReady()) {
mHasShownAllAppsCling = true;
// Calculate the position for the cling punch through
int[] offset = new int[2];
@@ -534,7 +524,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (!isDataReady()) {
- if (testDataReady()) {
+ if (!mApps.isEmpty() && !mWidgets.isEmpty()) {
setDataIsReady();
setMeasuredDimension(width, height);
onDataReady(width, height);
@@ -561,7 +551,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void updatePackages() {
// Get the list of widgets and shortcuts
- boolean wasEmpty = mWidgets.isEmpty();
mWidgets.clear();
List<AppWidgetProviderInfo> widgets =
AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
@@ -589,17 +578,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mWidgets.addAll(shortcuts);
Collections.sort(mWidgets,
new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
- Log.d(TAG, "6549598 updatePackages mWidgets.size(): " + mWidgets.size() + " wasEmpty: " + wasEmpty);
+ Log.d(TAG, "6549598 updatePackages mWidgets.size(): " + mWidgets.size());
updatePageCounts();
-
- if (wasEmpty) {
- // The next layout pass will trigger data-ready if both widgets and apps are set, so request
- // a layout to do this test and invalidate the page data when ready.
- if (testDataReady()) requestLayout();
- } else {
- cancelAllTasks();
- invalidatePageData();
- }
+ invalidateOnDataChange();
}
@Override
@@ -660,7 +641,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
private void preloadWidget(final PendingAddWidgetInfo info) {
- Log.d(TAG, "6557954 Preload widget: " + info.info);
final AppWidgetProviderInfo pInfo = info.info;
if (pInfo.configure != null) {
return;
@@ -670,7 +650,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mBindWidgetRunnable = new Runnable() {
@Override
public void run() {
- Log.d(TAG, " 6557954 Preload, bind widget: " + info.info);
mWidgetLoadingId = mLauncher.getAppWidgetHost().allocateAppWidgetId();
if (AppWidgetManager.getInstance(mLauncher)
.bindAppWidgetIdIfAllowed(mWidgetLoadingId, info.componentName)) {
@@ -686,7 +665,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
AppWidgetHostView hostView = mLauncher.
getAppWidgetHost().createView(getContext(), mWidgetLoadingId, pInfo);
info.boundWidget = hostView;
- Log.d(TAG, " 6557954 Preload, inflate widget: " + info.info);
mWidgetCleanupState = WIDGET_INFLATED;
hostView.setVisibility(INVISIBLE);
int[] unScaledSize = mLauncher.getWorkspace().estimateItemSize(info.spanX,
@@ -711,49 +689,37 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// the widget. This will need to be cleaned up if it turns out no long press occurs.
if (mCreateWidgetInfo != null) {
// Just in case the cleanup process wasn't properly executed. This shouldn't happen.
- Log.d(TAG, "**** 6557954 Previous shortpress not cleaned up, cleaning up now: " + mCreateWidgetInfo.info);
cleanupWidgetPreloading(false);
}
mCreateWidgetInfo = new PendingAddWidgetInfo((PendingAddWidgetInfo) v.getTag());
- Log.d(TAG, "6557954 Short press triggered for view: " + v + ", widget info: " + mCreateWidgetInfo.info);
preloadWidget(mCreateWidgetInfo);
}
private void cleanupWidgetPreloading(boolean widgetWasAdded) {
- Log.d(TAG, "6557954 Cleaning up widget, was added: " + widgetWasAdded);
- if (mCreateWidgetInfo != null) {
- Log.d(TAG, " 6557954 Cleaning up widget, widget info: " + mCreateWidgetInfo.info);
- }
-
if (!widgetWasAdded) {
// If the widget was not added, we may need to do further cleanup.
PendingAddWidgetInfo info = mCreateWidgetInfo;
mCreateWidgetInfo = null;
if (mWidgetCleanupState == WIDGET_PRELOAD_PENDING) {
- Log.d(TAG, " 6557954 Cleaning up widget, remove preload callbacks");
// We never did any preloading, so just remove pending callbacks to do so
removeCallbacks(mBindWidgetRunnable);
removeCallbacks(mInflateWidgetRunnable);
} else if (mWidgetCleanupState == WIDGET_BOUND) {
// Delete the widget id which was allocated
if (mWidgetLoadingId != -1) {
- Log.d(TAG, " 6557954 Cleaning up widget, delete widget id");
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
}
// We never got around to inflating the widget, so remove the callback to do so.
- Log.d(TAG, " 6557954 Cleaning up widget, remove callbacks");
removeCallbacks(mInflateWidgetRunnable);
} else if (mWidgetCleanupState == WIDGET_INFLATED) {
// Delete the widget id which was allocated
if (mWidgetLoadingId != -1) {
- Log.d(TAG, " 6557954 Cleaning up widget, delete widget id");
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
}
// The widget was inflated and added to the DragLayer -- remove it.
- Log.d(TAG, " 6557954 Cleaning up widget, remove inflated widget from draglayer");
AppWidgetHostView widget = info.boundWidget;
mLauncher.getDragLayer().removeView(widget);
}
@@ -766,9 +732,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
@Override
public void cleanUpShortPress(View v) {
- Log.d(TAG, "6557954 Cleanup shortpress");
if (!mDraggingWidget) {
- Log.d(TAG, " 6557954 Cleanup shortpress, cleanup cleanup preloading");
cleanupWidgetPreloading(false);
}
}
@@ -779,15 +743,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
ImageView image = (ImageView) v.findViewById(R.id.widget_preview);
PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
- if (createItemInfo instanceof PendingAddWidgetInfo) {
- PendingAddWidgetInfo createWidgetInfo = mCreateWidgetInfo;
- Log.d(TAG, "6557954 Begin dragging widget, view: " + v + ", widget info: " + createWidgetInfo.info);
- }
-
// If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and
// we abort the drag.
if (image.getDrawable() == null) {
- Log.d(TAG, " 6557954 Begin dragging widget, abort, no drawable set");
mDraggingWidget = false;
return false;
}
@@ -1763,16 +1721,31 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public boolean isAnimating() {
return false;
}
+
+ /**
+ * We should call thise method whenever the core data changes (mApps, mWidgets) so that we can
+ * appropriately determine when to invalidate the PagedView page data. In cases where the data
+ * has yet to be set, we can requestLayout() and wait for onDataReady() to be called in the
+ * next onMeasure() pass, which will trigger an invalidatePageData() itself.
+ */
+ private void invalidateOnDataChange() {
+ if (!isDataReady()) {
+ // The next layout pass will trigger data-ready if both widgets and apps are set, so
+ // request a layout to trigger the page data when ready.
+ requestLayout();
+ } else {
+ cancelAllTasks();
+ invalidatePageData();
+ }
+ }
+
@Override
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
Log.d(TAG, "6549598 setApps mApps.size(): " + mApps.size());
updatePageCounts();
-
- // The next layout pass will trigger data-ready if both widgets and apps are set, so
- // request a layout to do this test and invalidate the page data when ready.
- if (testDataReady()) requestLayout();
+ invalidateOnDataChange();
}
private void addAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
// We add it in place, in alphabetical order
@@ -1790,7 +1763,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
addAppsWithoutInvalidate(list);
Log.d(TAG, "6549598 addApps mApps.size(): " + mApps.size() + " list.size(): " + list.size());
updatePageCounts();
- invalidatePageData();
+ invalidateOnDataChange();
Log.d(TAG, "6549598 addApps mNumAppsPages: " + mNumAppsPages);
}
private int findAppByComponent(List<ApplicationInfo> list, ApplicationInfo item) {
@@ -1820,7 +1793,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
removeAppsWithoutInvalidate(list);
Log.d(TAG, "6549598 removeApps mApps.size(): " + mApps.size() + " list.size(): " + list.size());
updatePageCounts();
- invalidatePageData();
+ invalidateOnDataChange();
Log.d(TAG, "6549598 removeApps mNumAppsPages: " + mNumAppsPages);
}
@Override
@@ -1832,7 +1805,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
addAppsWithoutInvalidate(list);
Log.d(TAG, "6549598 updateApps mApps.size(): " + mApps.size() + " list.size(): " + list.size());
updatePageCounts();
- invalidatePageData();
+ invalidateOnDataChange();
Log.d(TAG, "6549598 updateApps mNumAppsPages: " + mNumAppsPages);
}
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java
index b454afd7f..54ba7de18 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/android/launcher2/InstallShortcutReceiver.java
@@ -191,10 +191,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
final Set<String> savedNewApps = newApps;
new Thread("setNewAppsThread") {
public void run() {
- sharedPrefs.edit()
- .putInt(NEW_APPS_PAGE_KEY, screen)
- .putStringSet(NEW_APPS_LIST_KEY, savedNewApps)
- .commit();
+ synchronized (savedNewApps) {
+ sharedPrefs.edit()
+ .putInt(NEW_APPS_PAGE_KEY, screen)
+ .putStringSet(NEW_APPS_LIST_KEY, savedNewApps)
+ .commit();
+ }
}
}.start();
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 543248449..fc522aa8d 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2923,9 +2923,9 @@ public final class Launcher extends Activity
}
- private void updateTextButtonWithDrawable(int buttonId, Drawable.ConstantState d) {
+ private void updateTextButtonWithDrawable(int buttonId, Drawable d) {
TextView button = (TextView) findViewById(buttonId);
- button.setCompoundDrawables(d.newDrawable(getResources()), null, null, null);
+ button.setCompoundDrawables(d, null, null, null);
}
private void updateButtonWithDrawable(int buttonId, Drawable.ConstantState d) {
@@ -3077,7 +3077,14 @@ public final class Launcher extends Activity
}
private void updateAppMarketIcon(Drawable.ConstantState d) {
- updateTextButtonWithDrawable(R.id.market_button, d);
+ // Ensure that the new drawable we are creating has the approprate toolbar icon bounds
+ Resources r = getResources();
+ Drawable marketIconDrawable = d.newDrawable(r);
+ int w = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_width);
+ int h = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_height);
+ marketIconDrawable.setBounds(0, 0, w, h);
+
+ updateTextButtonWithDrawable(R.id.market_button, marketIconDrawable);
}
@Override
diff --git a/src/com/android/launcher2/UninstallShortcutReceiver.java b/src/com/android/launcher2/UninstallShortcutReceiver.java
index e94a17ffd..02590c9f6 100644
--- a/src/com/android/launcher2/UninstallShortcutReceiver.java
+++ b/src/com/android/launcher2/UninstallShortcutReceiver.java
@@ -148,14 +148,16 @@ public class UninstallShortcutReceiver extends BroadcastReceiver {
final Set<String> savedNewApps = newApps;
new Thread("setNewAppsThread-remove") {
public void run() {
- SharedPreferences.Editor editor = sharedPrefs.edit();
- editor.putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY,
- savedNewApps);
- if (savedNewApps.isEmpty()) {
- // Reset the page index if there are no more items
- editor.putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1);
+ synchronized (savedNewApps) {
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY,
+ savedNewApps);
+ if (savedNewApps.isEmpty()) {
+ // Reset the page index if there are no more items
+ editor.putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1);
+ }
+ editor.commit();
}
- editor.commit();
}
}.start();
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 11eb3c15b..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);
@@ -1273,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);