summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/preview_bg.9.png (renamed from res/drawable-hdpi/preview_popup.9.png)bin4108 -> 4304 bytes
-rw-r--r--res/drawable-hdpi/preview_bg_focus.9.pngbin0 -> 4515 bytes
-rw-r--r--res/drawable-hdpi/preview_bg_press.9.pngbin0 -> 4509 bytes
-rw-r--r--res/drawable/preview_background.xml22
-rw-r--r--src/com/android/launcher2/Launcher.java82
5 files changed, 66 insertions, 38 deletions
diff --git a/res/drawable-hdpi/preview_popup.9.png b/res/drawable-hdpi/preview_bg.9.png
index c2dd07cf6..5647144af 100644
--- a/res/drawable-hdpi/preview_popup.9.png
+++ b/res/drawable-hdpi/preview_bg.9.png
Binary files differ
diff --git a/res/drawable-hdpi/preview_bg_focus.9.png b/res/drawable-hdpi/preview_bg_focus.9.png
new file mode 100644
index 000000000..31200fdcd
--- /dev/null
+++ b/res/drawable-hdpi/preview_bg_focus.9.png
Binary files differ
diff --git a/res/drawable-hdpi/preview_bg_press.9.png b/res/drawable-hdpi/preview_bg_press.9.png
new file mode 100644
index 000000000..9cb12669e
--- /dev/null
+++ b/res/drawable-hdpi/preview_bg_press.9.png
Binary files differ
diff --git a/res/drawable/preview_background.xml b/res/drawable/preview_background.xml
new file mode 100644
index 000000000..0054aa03e
--- /dev/null
+++ b/res/drawable/preview_background.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true" android:drawable="@drawable/preview_bg_press" />
+ <item android:state_focused="true" android:state_window_focused="true" android:drawable="@drawable/preview_bg_focus" />
+ <item android:state_focused="true" android:state_window_focused="false" android:drawable="@drawable/preview_bg" />
+ <item android:drawable="@drawable/preview_bg" />
+</selector>
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 2242e6f25..4ce73f684 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -885,8 +885,6 @@ public final class Launcher extends Activity
super.onSaveInstanceState(outState);
}
- final boolean isConfigurationChange = getChangingConfigurations() != 0;
-
// TODO should not do this if the drawer is currently closing.
if (isAllAppsVisible()) {
outState.putBoolean(RUNTIME_STATE_ALL_APPS_FOLDER, true);
@@ -1511,23 +1509,26 @@ public final class Launcher extends Activity
}
@SuppressWarnings({"unchecked"})
- private void dismissPreview(View v) {
- PopupWindow window = (PopupWindow) v.getTag();
+ private void dismissPreview(final View v) {
+ final PopupWindow window = (PopupWindow) v.getTag();
if (window != null) {
- window.setOnDismissListener(null);
- window.dismiss();
-
- ViewGroup group = (ViewGroup) v.getTag(R.id.workspace);
- int count = group.getChildCount();
- for (int i = 0; i < count; i++) {
- ((ImageView) group.getChildAt(i)).setImageDrawable(null);
- }
+ window.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ public void onDismiss() {
+ ViewGroup group = (ViewGroup) v.getTag(R.id.workspace);
+ int count = group.getChildCount();
+ for (int i = 0; i < count; i++) {
+ ((ImageView) group.getChildAt(i)).setImageDrawable(null);
+ }
- ArrayList<Bitmap> bitmaps = (ArrayList<Bitmap>) v.getTag(R.id.icon);
- for (Bitmap bitmap : bitmaps) bitmap.recycle();
+ ArrayList<Bitmap> bitmaps = (ArrayList<Bitmap>) v.getTag(R.id.icon);
+ for (Bitmap bitmap : bitmaps) bitmap.recycle();
- v.setTag(R.id.workspace, null);
- v.setTag(R.id.icon, null);
+ v.setTag(R.id.workspace, null);
+ v.setTag(R.id.icon, null);
+ window.setOnDismissListener(null);
+ }
+ });
+ window.dismiss();
}
v.setTag(null);
}
@@ -1536,36 +1537,26 @@ public final class Launcher extends Activity
int current = mWorkspace.getCurrentScreen();
if (current <= 0) return;
- showPreviews(anchor, 0, current);
+ showPreviews(anchor, 0, mWorkspace.getChildCount());
}
private void showNextPreview(View anchor) {
int current = mWorkspace.getCurrentScreen();
if (current >= mWorkspace.getChildCount() - 1) return;
- showPreviews(anchor, current + 1, mWorkspace.getChildCount());
- }
-
- @Override
- public void onWindowFocusChanged(boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
-
- if (!hasFocus) {
- dismissPreview(mPreviousView);
- dismissPreview(mNextView);
- }
+ showPreviews(anchor, 0, mWorkspace.getChildCount());
}
private void showPreviews(final View anchor, int start, int end) {
- Drawable d = getResources().getDrawable(R.drawable.preview_popup);
+ Resources resources = getResources();
Workspace workspace = mWorkspace;
CellLayout cell = ((CellLayout) workspace.getChildAt(start));
-
- float max = workspace.getChildCount() - 1;
+
+ float max = workspace.getChildCount();
Rect r = new Rect();
- d.getPadding(r);
+ resources.getDrawable(R.drawable.preview_background).getPadding(r);
int extraW = (int) ((r.left + r.right) * max);
int extraH = r.top + r.bottom;
@@ -1603,14 +1594,18 @@ public final class Launcher extends Activity
c.translate(-cell.getLeftPadding(), -cell.getTopPadding());
cell.dispatchDraw(c);
- image.setBackgroundDrawable(d);
+ image.setBackgroundDrawable(resources.getDrawable(R.drawable.preview_background));
image.setImageBitmap(bitmap);
image.setTag(i);
image.setOnClickListener(handler);
- bitmaps.add(bitmap);
+ image.setOnFocusChangeListener(handler);
+ image.setFocusable(true);
+ if (i == mWorkspace.getCurrentScreen()) image.requestFocus();
preview.addView(image,
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+
+ bitmaps.add(bitmap);
}
PopupWindow p = new PopupWindow(this);
@@ -1619,8 +1614,9 @@ public final class Launcher extends Activity
p.setHeight((int) (sHeight + extraH));
p.setAnimationStyle(R.style.AnimationPreview);
p.setOutsideTouchable(true);
+ p.setFocusable(true);
p.setBackgroundDrawable(new ColorDrawable(0));
- p.showAsDropDown(anchor, 0, 0);
+ p.showAsDropDown(anchor, 0, 0);
p.setOnDismissListener(new PopupWindow.OnDismissListener() {
public void onDismiss() {
@@ -1633,7 +1629,7 @@ public final class Launcher extends Activity
anchor.setTag(R.id.icon, bitmaps);
}
- class PreviewTouchHandler implements View.OnClickListener {
+ class PreviewTouchHandler implements View.OnClickListener, Runnable, View.OnFocusChangeListener {
private final View mAnchor;
public PreviewTouchHandler(View anchor) {
@@ -1642,7 +1638,17 @@ public final class Launcher extends Activity
public void onClick(View v) {
mWorkspace.snapToScreen((Integer) v.getTag());
- dismissPreview(mAnchor);
+ v.post(this);
+ }
+
+ public void run() {
+ dismissPreview(mAnchor);
+ }
+
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus) {
+ mWorkspace.snapToScreen((Integer) v.getTag());
+ }
}
}