From 90576b5f095371e1ba4fedcb775f43715adf9634 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 27 Sep 2011 17:45:27 -0700 Subject: Fixing some small issues. - Adding All Apps pressed state (5375824) - Ensuring the drop targets are single line (5375563) - Adding some checks in kb focus logic to appease some frantic monkeys (4508638) - Removing some unused assets Change-Id: I46702ee25c638849c716f0d8428f68c2b06c1c2e --- res/drawable-hdpi/ic_allapps_pressed.png | Bin 0 -> 9242 bytes res/drawable-hdpi/ic_launcher_appwidget.png | Bin 6399 -> 0 bytes .../pressed_application_background.9.png | Bin 1348 -> 0 bytes res/drawable-hdpi/preview_bg.9.png | Bin 1584 -> 0 bytes res/drawable-hdpi/preview_bg_focus.9.png | Bin 1781 -> 0 bytes res/drawable-hdpi/preview_bg_press.9.png | Bin 1778 -> 0 bytes res/drawable-mdpi/apps_hotseat_button.png | Bin 1736 -> 0 bytes res/drawable-mdpi/ic_allapps_pressed.png | Bin 0 -> 6467 bytes res/drawable-mdpi/ic_launcher_appwidget.png | Bin 4224 -> 0 bytes .../pressed_application_background.9.png | Bin 899 -> 0 bytes res/drawable-mdpi/preview_bg.9.png | Bin 1042 -> 0 bytes res/drawable-mdpi/preview_bg_focus.9.png | Bin 1207 -> 0 bytes res/drawable-mdpi/preview_bg_press.9.png | Bin 1188 -> 0 bytes res/drawable-xhdpi/apps_hotseat_button.png | Bin 11217 -> 0 bytes res/drawable-xhdpi/ic_allapps_pressed.png | Bin 0 -> 12548 bytes res/drawable-xhdpi/ic_launcher_appwidget.png | Bin 11507 -> 0 bytes .../pressed_application_background.9.png | Bin 2811 -> 0 bytes res/drawable-xhdpi/preview_bg.9.png | Bin 2989 -> 0 bytes res/drawable-xhdpi/preview_bg_focus.9.png | Bin 3650 -> 0 bytes res/drawable-xhdpi/preview_bg_press.9.png | Bin 3640 -> 0 bytes res/drawable/all_apps_button_icon.xml | 21 ++++++++++ res/drawable/preview_background.xml | 22 ---------- res/values/styles.xml | 2 + src/com/android/launcher2/FocusHelper.java | 45 ++++++++++++++------- src/com/android/launcher2/Hotseat.java | 2 +- src/com/android/launcher2/PagedView.java | 12 ------ 26 files changed, 54 insertions(+), 50 deletions(-) create mode 100644 res/drawable-hdpi/ic_allapps_pressed.png delete mode 100644 res/drawable-hdpi/ic_launcher_appwidget.png delete mode 100644 res/drawable-hdpi/pressed_application_background.9.png delete mode 100644 res/drawable-hdpi/preview_bg.9.png delete mode 100644 res/drawable-hdpi/preview_bg_focus.9.png delete mode 100644 res/drawable-hdpi/preview_bg_press.9.png delete mode 100644 res/drawable-mdpi/apps_hotseat_button.png create mode 100644 res/drawable-mdpi/ic_allapps_pressed.png delete mode 100644 res/drawable-mdpi/ic_launcher_appwidget.png delete mode 100644 res/drawable-mdpi/pressed_application_background.9.png delete mode 100644 res/drawable-mdpi/preview_bg.9.png delete mode 100644 res/drawable-mdpi/preview_bg_focus.9.png delete mode 100644 res/drawable-mdpi/preview_bg_press.9.png delete mode 100644 res/drawable-xhdpi/apps_hotseat_button.png create mode 100644 res/drawable-xhdpi/ic_allapps_pressed.png delete mode 100644 res/drawable-xhdpi/ic_launcher_appwidget.png delete mode 100644 res/drawable-xhdpi/pressed_application_background.9.png delete mode 100644 res/drawable-xhdpi/preview_bg.9.png delete mode 100644 res/drawable-xhdpi/preview_bg_focus.9.png delete mode 100644 res/drawable-xhdpi/preview_bg_press.9.png create mode 100644 res/drawable/all_apps_button_icon.xml delete mode 100644 res/drawable/preview_background.xml diff --git a/res/drawable-hdpi/ic_allapps_pressed.png b/res/drawable-hdpi/ic_allapps_pressed.png new file mode 100644 index 000000000..6d87bbb23 Binary files /dev/null and b/res/drawable-hdpi/ic_allapps_pressed.png differ diff --git a/res/drawable-hdpi/ic_launcher_appwidget.png b/res/drawable-hdpi/ic_launcher_appwidget.png deleted file mode 100644 index 13513e03c..000000000 Binary files a/res/drawable-hdpi/ic_launcher_appwidget.png and /dev/null differ diff --git a/res/drawable-hdpi/pressed_application_background.9.png b/res/drawable-hdpi/pressed_application_background.9.png deleted file mode 100644 index 3a59f255f..000000000 Binary files a/res/drawable-hdpi/pressed_application_background.9.png and /dev/null differ diff --git a/res/drawable-hdpi/preview_bg.9.png b/res/drawable-hdpi/preview_bg.9.png deleted file mode 100644 index 5fa2ed82c..000000000 Binary files a/res/drawable-hdpi/preview_bg.9.png and /dev/null differ diff --git a/res/drawable-hdpi/preview_bg_focus.9.png b/res/drawable-hdpi/preview_bg_focus.9.png deleted file mode 100644 index bbf67f7a2..000000000 Binary files a/res/drawable-hdpi/preview_bg_focus.9.png and /dev/null differ diff --git a/res/drawable-hdpi/preview_bg_press.9.png b/res/drawable-hdpi/preview_bg_press.9.png deleted file mode 100644 index 6d0b02298..000000000 Binary files a/res/drawable-hdpi/preview_bg_press.9.png and /dev/null differ diff --git a/res/drawable-mdpi/apps_hotseat_button.png b/res/drawable-mdpi/apps_hotseat_button.png deleted file mode 100644 index 62f119d67..000000000 Binary files a/res/drawable-mdpi/apps_hotseat_button.png and /dev/null differ diff --git a/res/drawable-mdpi/ic_allapps_pressed.png b/res/drawable-mdpi/ic_allapps_pressed.png new file mode 100644 index 000000000..5c2076f24 Binary files /dev/null and b/res/drawable-mdpi/ic_allapps_pressed.png differ diff --git a/res/drawable-mdpi/ic_launcher_appwidget.png b/res/drawable-mdpi/ic_launcher_appwidget.png deleted file mode 100644 index 72dbfdf6b..000000000 Binary files a/res/drawable-mdpi/ic_launcher_appwidget.png and /dev/null differ diff --git a/res/drawable-mdpi/pressed_application_background.9.png b/res/drawable-mdpi/pressed_application_background.9.png deleted file mode 100644 index 7d5da3da2..000000000 Binary files a/res/drawable-mdpi/pressed_application_background.9.png and /dev/null differ diff --git a/res/drawable-mdpi/preview_bg.9.png b/res/drawable-mdpi/preview_bg.9.png deleted file mode 100644 index d96e88543..000000000 Binary files a/res/drawable-mdpi/preview_bg.9.png and /dev/null differ diff --git a/res/drawable-mdpi/preview_bg_focus.9.png b/res/drawable-mdpi/preview_bg_focus.9.png deleted file mode 100644 index 19e82a773..000000000 Binary files a/res/drawable-mdpi/preview_bg_focus.9.png and /dev/null differ diff --git a/res/drawable-mdpi/preview_bg_press.9.png b/res/drawable-mdpi/preview_bg_press.9.png deleted file mode 100644 index f9380903b..000000000 Binary files a/res/drawable-mdpi/preview_bg_press.9.png and /dev/null differ diff --git a/res/drawable-xhdpi/apps_hotseat_button.png b/res/drawable-xhdpi/apps_hotseat_button.png deleted file mode 100644 index 932dac7c9..000000000 Binary files a/res/drawable-xhdpi/apps_hotseat_button.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_allapps_pressed.png b/res/drawable-xhdpi/ic_allapps_pressed.png new file mode 100644 index 000000000..72ff3b974 Binary files /dev/null and b/res/drawable-xhdpi/ic_allapps_pressed.png differ diff --git a/res/drawable-xhdpi/ic_launcher_appwidget.png b/res/drawable-xhdpi/ic_launcher_appwidget.png deleted file mode 100644 index 997504abe..000000000 Binary files a/res/drawable-xhdpi/ic_launcher_appwidget.png and /dev/null differ diff --git a/res/drawable-xhdpi/pressed_application_background.9.png b/res/drawable-xhdpi/pressed_application_background.9.png deleted file mode 100644 index 05e240a9e..000000000 Binary files a/res/drawable-xhdpi/pressed_application_background.9.png and /dev/null differ diff --git a/res/drawable-xhdpi/preview_bg.9.png b/res/drawable-xhdpi/preview_bg.9.png deleted file mode 100644 index 11cbcb5a2..000000000 Binary files a/res/drawable-xhdpi/preview_bg.9.png and /dev/null differ diff --git a/res/drawable-xhdpi/preview_bg_focus.9.png b/res/drawable-xhdpi/preview_bg_focus.9.png deleted file mode 100644 index 698c465e3..000000000 Binary files a/res/drawable-xhdpi/preview_bg_focus.9.png and /dev/null differ diff --git a/res/drawable-xhdpi/preview_bg_press.9.png b/res/drawable-xhdpi/preview_bg_press.9.png deleted file mode 100644 index 78e751099..000000000 Binary files a/res/drawable-xhdpi/preview_bg_press.9.png and /dev/null differ diff --git a/res/drawable/all_apps_button_icon.xml b/res/drawable/all_apps_button_icon.xml new file mode 100644 index 000000000..7c69cad3a --- /dev/null +++ b/res/drawable/all_apps_button_icon.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/res/drawable/preview_background.xml b/res/drawable/preview_background.xml deleted file mode 100644 index 0054aa03e..000000000 --- a/res/drawable/preview_background.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - diff --git a/res/values/styles.xml b/res/values/styles.xml index 19a05a0a1..de438bec2 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -146,6 +146,8 @@ 25dp #FFFFFFFF 16sp + true + end #FF000000 0.0 1.0 diff --git a/src/com/android/launcher2/FocusHelper.java b/src/com/android/launcher2/FocusHelper.java index f97492bd6..f03073998 100644 --- a/src/com/android/launcher2/FocusHelper.java +++ b/src/com/android/launcher2/FocusHelper.java @@ -278,30 +278,36 @@ public class FocusHelper { final ViewGroup container = (ViewGroup) parentLayout.getParent(); final TabHost tabHost = findTabHostParent(container); final TabWidget tabs = (TabWidget) tabHost.findViewById(com.android.internal.R.id.tabs); - final int widgetIndex = parent.indexOfChild(v); + final int iconIndex = parent.indexOfChild(v); final int widgetCount = parent.getChildCount(); final int pageIndex = container.indexOfChild(parentLayout); final int pageCount = container.getChildCount(); final int cellCountX = parentLayout.getCellCountX(); final int cellCountY = parentLayout.getCellCountY(); - final int x = widgetIndex % cellCountX; - final int y = widgetIndex / cellCountX; + final int x = iconIndex % cellCountX; + final int y = iconIndex / cellCountX; final int action = e.getAction(); final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP); PagedViewCellLayoutChildren newParent = null; + // Side pages do not always load synchronously, so check before focusing child siblings + // willy-nilly + View child = null; boolean wasHandled = false; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (handleKeyEvent) { // Select the previous icon or the last icon on the previous page - if (widgetIndex > 0) { - parent.getChildAt(widgetIndex - 1).requestFocus(); + if (iconIndex > 0) { + parent.getChildAt(iconIndex - 1).requestFocus(); } else { if (pageIndex > 0) { newParent = getPagedViewCellLayoutChildrenForIndex(container, pageIndex - 1); - newParent.getChildAt(newParent.getChildCount() - 1).requestFocus(); + if (newParent != null) { + child = newParent.getChildAt(newParent.getChildCount() - 1); + if (child != null) child.requestFocus(); + } } } } @@ -310,13 +316,16 @@ public class FocusHelper { case KeyEvent.KEYCODE_DPAD_RIGHT: if (handleKeyEvent) { // Select the next icon or the first icon on the next page - if (widgetIndex < (widgetCount - 1)) { - parent.getChildAt(widgetIndex + 1).requestFocus(); + if (iconIndex < (widgetCount - 1)) { + parent.getChildAt(iconIndex + 1).requestFocus(); } else { if (pageIndex < (pageCount - 1)) { newParent = getPagedViewCellLayoutChildrenForIndex(container, pageIndex + 1); - newParent.getChildAt(0).requestFocus(); + if (newParent != null) { + child = newParent.getChildAt(0); + if (child != null) child.requestFocus(); + } } } } @@ -326,8 +335,8 @@ public class FocusHelper { if (handleKeyEvent) { // Select the closest icon in the previous row, otherwise select the tab bar if (y > 0) { - int newWidgetIndex = ((y - 1) * cellCountX) + x; - parent.getChildAt(newWidgetIndex).requestFocus(); + int newiconIndex = ((y - 1) * cellCountX) + x; + parent.getChildAt(newiconIndex).requestFocus(); } else { tabs.requestFocus(); } @@ -338,8 +347,8 @@ public class FocusHelper { if (handleKeyEvent) { // Select the closest icon in the previous row, otherwise do nothing if (y < (cellCountY - 1)) { - int newWidgetIndex = Math.min(widgetCount - 1, ((y + 1) * cellCountX) + x); - parent.getChildAt(newWidgetIndex).requestFocus(); + int newiconIndex = Math.min(widgetCount - 1, ((y + 1) * cellCountX) + x); + parent.getChildAt(newiconIndex).requestFocus(); } } wasHandled = true; @@ -360,7 +369,10 @@ public class FocusHelper { if (pageIndex > 0) { newParent = getPagedViewCellLayoutChildrenForIndex(container, pageIndex - 1); - newParent.getChildAt(0).requestFocus(); + if (newParent != null) { + child = newParent.getChildAt(0); + if (child != null) child.requestFocus(); + } } else { parent.getChildAt(0).requestFocus(); } @@ -374,7 +386,10 @@ public class FocusHelper { if (pageIndex < (pageCount - 1)) { newParent = getPagedViewCellLayoutChildrenForIndex(container, pageIndex + 1); - newParent.getChildAt(0).requestFocus(); + if (newParent != null) { + child = newParent.getChildAt(0); + if (child != null) child.requestFocus(); + } } else { parent.getChildAt(widgetCount - 1).requestFocus(); } diff --git a/src/com/android/launcher2/Hotseat.java b/src/com/android/launcher2/Hotseat.java index f6ce05904..b9be6dca9 100644 --- a/src/com/android/launcher2/Hotseat.java +++ b/src/com/android/launcher2/Hotseat.java @@ -100,7 +100,7 @@ public class Hotseat extends FrameLayout { BubbleTextView allAppsButton = (BubbleTextView) inflater.inflate(R.layout.application, mContent, false); allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null, - context.getResources().getDrawable(R.drawable.ic_allapps), null, null); + context.getResources().getDrawable(R.drawable.all_apps_button_icon), null, null); // allAppsButton.setText(context.getString(R.string.all_apps_button_label)); allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label)); allAppsButton.setOnClickListener(new View.OnClickListener() { diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index d7e9e06e0..8bc38c258 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -1664,18 +1664,6 @@ public abstract class PagedView extends ViewGroup { */ public abstract void syncPageItems(int page, boolean immediate); - protected void postInvalidatePageData(final boolean clearViews) { - post(new Runnable() { - // post the call to avoid a call to requestLayout from a layout pass - public void run() { - if (clearViews) { - removeAllViews(); - } - invalidatePageData(); - } - }); - } - protected void invalidatePageData() { invalidatePageData(-1, false); } -- cgit v1.2.3