small fixes to Launcher
- more robust unshrink animation
- catching a resource not found exception when
making widget preview
- added more missing copyright headers
- hiding customization drawer when long press on widget
- long-pressing on widget is temporarily always
springloaded to zoom in to workspace screen
Change-Id: I6c92877357e907d89840fecc4662f0700b96255b
diff --git a/src/com/android/launcher2/IntentListAdapter.java b/src/com/android/launcher2/IntentListAdapter.java
index 7ebffd4..f844738 100644
--- a/src/com/android/launcher2/IntentListAdapter.java
+++ b/src/com/android/launcher2/IntentListAdapter.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.launcher2;
import com.android.launcher.R;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 8557241..5a508ab 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1040,7 +1040,6 @@
}
closeAllApps(alreadyOnHome && allAppsVisible);
hideCustomizationDrawer();
- mWorkspace.unshrink();
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
@@ -1512,7 +1511,6 @@
closeAllApps(true);
} else if (isCustomizationDrawerVisible()) {
hideCustomizationDrawer();
- mWorkspace.unshrink();
} else {
closeFolder();
}
@@ -1590,7 +1588,6 @@
// this is an intercepted event being forwarded from mWorkspace;
// clicking anywhere on the workspace causes the drawer to slide down
hideCustomizationDrawer();
- mWorkspace.unshrink();
return false;
}
@@ -2062,7 +2059,8 @@
}
void showAllApps(boolean animated) {
- hideCustomizationDrawer();
+ boolean unshrinkWorkspace = false;
+ hideCustomizationDrawer(unshrinkWorkspace);
if (LauncherApplication.isScreenXLarge()) {
mWorkspace.shrinkToBottom(animated);
@@ -2213,7 +2211,11 @@
AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_up));
}
- private void hideCustomizationDrawer() {
+ void hideCustomizationDrawer() {
+ hideCustomizationDrawer(true);
+ }
+
+ void hideCustomizationDrawer(boolean unshrinkWorkspace) {
if (isCustomizationDrawerVisible()) {
Animation slideDownAnimation = AnimationUtils.loadAnimation(
this, R.anim.home_customization_drawer_slide_down);
@@ -2225,6 +2227,9 @@
public void onAnimationStart(Animation animation) {}
});
mHomeCustomizationDrawer.startAnimation(slideDownAnimation);
+ if (unshrinkWorkspace) {
+ mWorkspace.unshrink();
+ }
}
}
diff --git a/src/com/android/launcher2/WidgetChooser.java b/src/com/android/launcher2/WidgetChooser.java
index ea6888e..2218e6dc 100644
--- a/src/com/android/launcher2/WidgetChooser.java
+++ b/src/com/android/launcher2/WidgetChooser.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.launcher2;
import android.appwidget.AppWidgetProviderInfo;
@@ -38,6 +54,7 @@
dragInfo.minHeight = info.minHeight;
mDragController.startDrag(bmp, screenX, screenY,
0, 0, w, h, this, dragInfo, DragController.DRAG_ACTION_COPY);
+ mLauncher.hideCustomizationDrawer();
return true;
}
diff --git a/src/com/android/launcher2/WidgetListAdapter.java b/src/com/android/launcher2/WidgetListAdapter.java
index 7ec0112..61e7c89 100644
--- a/src/com/android/launcher2/WidgetListAdapter.java
+++ b/src/com/android/launcher2/WidgetListAdapter.java
@@ -109,14 +109,18 @@
background.draw(mCanvas);
// Draw the icon vertically centered, flush left
- Drawable icon = packageManager.getDrawable(packageName, info.icon, null);
- background.getPadding(mTempRect);
+ try {
+ Drawable icon = packageManager.getDrawable(packageName, info.icon, null);
+ background.getPadding(mTempRect);
- final int left = mTempRect.left;
- final int top = (height - icon.getIntrinsicHeight()) / 2;
- icon.setBounds(
- left, top, left + icon.getIntrinsicWidth(), top + icon.getIntrinsicHeight());
- icon.draw(mCanvas);
+ final int left = mTempRect.left;
+ final int top = (height - icon.getIntrinsicHeight()) / 2;
+ icon.setBounds(
+ left, top, left + icon.getIntrinsicWidth(), top + icon.getIntrinsicHeight());
+ icon.draw(mCanvas);
+ } catch (Resources.NotFoundException e) {
+ // if we can't find the icon, then just don't draw it
+ }
drawable = new BitmapDrawable(resources, bitmap);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 2bb1b7f..2021580 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1171,7 +1171,6 @@
public void unshrink() {
if (mIsSmall) {
- final int screenWidth = getWidth();
Sequencer s = new Sequencer();
final int screenCount = getChildCount();
for (int i = 0; i < screenCount; i++) {
@@ -1179,8 +1178,8 @@
final int duration =
getResources().getInteger(R.integer.config_workspaceUnshrinkTime);
s.playTogether(
- new PropertyAnimator(duration, cl, "x", (float) screenWidth * i),
- new PropertyAnimator(duration, cl, "y", 0.0f),
+ new PropertyAnimator(duration, cl, "translationX", 0.0f),
+ new PropertyAnimator(duration, cl, "translationY", 0.0f),
new PropertyAnimator(duration, cl, "scaleX", 1.0f),
new PropertyAnimator(duration, cl, "scaleY", cl.getScaleY(), 1.0f),
new PropertyAnimator(duration, cl, "dimmedBitmapAlpha", 0.0f));