summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-xlarge/ic_no_applications.pngbin0 -> 3190 bytes
-rw-r--r--res/layout-xlarge/all_apps_no_items_placeholder.xml (renamed from res/layout-xlarge/customize_paged_view_wallpaper_placeholder.xml)8
-rw-r--r--res/values/strings.xml6
-rw-r--r--src/com/android/launcher2/AllAppsPagedView.java110
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java2
5 files changed, 88 insertions, 38 deletions
diff --git a/res/drawable-xlarge/ic_no_applications.png b/res/drawable-xlarge/ic_no_applications.png
new file mode 100644
index 000000000..a4f695aca
--- /dev/null
+++ b/res/drawable-xlarge/ic_no_applications.png
Binary files differ
diff --git a/res/layout-xlarge/customize_paged_view_wallpaper_placeholder.xml b/res/layout-xlarge/all_apps_no_items_placeholder.xml
index 6112532db..f5ecdec77 100644
--- a/res/layout-xlarge/customize_paged_view_wallpaper_placeholder.xml
+++ b/res/layout-xlarge/all_apps_no_items_placeholder.xml
@@ -17,20 +17,20 @@
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/wallpaper_icon"
+ android:id="@+id/no_items_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingTop="2dip"
android:textColor="#FFFFFFFF"
- android:textSize="14sp"
+ android:textSize="15sp"
android:shadowColor="#FF000000"
android:shadowDx="0.0"
android:shadowDy="1.0"
android:shadowRadius="1.0"
- android:drawableLeft="@drawable/ic_launcher_wallpaper"
- android:drawablePadding="10dip"
+ android:drawableLeft="@drawable/ic_no_applications"
+ android:drawablePadding="0dip"
android:maxLines="2"
android:fadingEdge="horizontal" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4f74b5985..89992827c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -67,6 +67,12 @@
<!-- Tile of the tab for applications that were downloaded from market [CHAR_LIMIT=12] -->
<string name="all_apps_tab_downloaded">Downloaded</string>
+ <!-- All Apps pane -->
+ <!-- Message to show when there are no games [CHAR_LIMIT=25] -->
+ <string name="all_apps_no_games">No games found.</string>
+ <!-- Message to show when there are no downloaded apps [CHAR_LIMIT=25] -->
+ <string name="all_apps_no_downloads">No downloaded apps found.</string>
+
<!-- Customization Drawer -->
<!-- The format string for the dimensions of a widget in the drawer -->
<string name="widget_dims_format" translatable="false">%1$d x %2$d</string>
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index cbb46e2fd..42101eb4c 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -16,13 +16,16 @@
package com.android.launcher2;
-import com.android.launcher.R;
+import java.util.ArrayList;
+import java.util.Collections;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -32,8 +35,7 @@ import android.view.animation.AnimationUtils;
import android.widget.Checkable;
import android.widget.TextView;
-import java.util.ArrayList;
-import java.util.Collections;
+import com.android.launcher.R;
/**
* An implementation of PagedView that populates the pages of the workspace
@@ -341,8 +343,9 @@ public class AllAppsPagedView extends PagedView
@Override
public void syncPages() {
- // ensure that we have the right number of pages
- int numPages = (int) Math.ceil((float) mFilteredApps.size() / (mCellCountX * mCellCountY));
+ // ensure that we have the right number of pages (min of 1, since we have placeholders)
+ int numPages = Math.max(1,
+ (int) Math.ceil((float) mFilteredApps.size() / (mCellCountX * mCellCountY)));
int curNumPages = getChildCount();
// remove any extra pages after the "last" page
int extraPageDiff = curNumPages - numPages;
@@ -364,41 +367,82 @@ public class AllAppsPagedView extends PagedView
@Override
public void syncPageItems(int page) {
- // ensure that we have the right number of items on the pages
+ // Ensure that we have the right number of items on the pages
final int cellsPerPage = mCellCountX * mCellCountY;
final int startIndex = page * cellsPerPage;
final int endIndex = Math.min(startIndex + cellsPerPage, mFilteredApps.size());
PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
- final int curNumPageItems = layout.getChildCount();
- final int numPageItems = endIndex - startIndex;
+ if (!mFilteredApps.isEmpty()) {
+ int curNumPageItems = layout.getChildCount();
+ int numPageItems = endIndex - startIndex;
- // remove any extra items
- int extraPageItemsDiff = curNumPageItems - numPageItems;
- for (int i = 0; i < extraPageItemsDiff; ++i) {
- layout.removeViewAt(numPageItems);
- }
- // add any necessary items
- for (int i = curNumPageItems; i < numPageItems; ++i) {
- TextView text = (TextView) mInflater.inflate(R.layout.all_apps_paged_view_application, layout, false);
- text.setOnClickListener(this);
- text.setOnLongClickListener(this);
-
- layout.addViewToCellLayout(text, -1, i,
- new PagedViewCellLayout.LayoutParams(0, 0, 1, 1));
- }
+ // If we were previously an empty page, then restart anew
+ boolean wasEmptyPage = false;
+ if (curNumPageItems == 1) {
+ View icon = layout.getChildAt(0);
+ if (icon.getTag() == null) {
+ wasEmptyPage = true;
+ }
+ }
+
+ if (wasEmptyPage) {
+ // Remove all the previous items
+ curNumPageItems = 0;
+ layout.removeAllViews();
+ } else {
+ // Remove any extra items
+ int extraPageItemsDiff = curNumPageItems - numPageItems;
+ for (int i = 0; i < extraPageItemsDiff; ++i) {
+ layout.removeViewAt(numPageItems);
+ }
+ }
+
+ // Add any necessary items
+ for (int i = curNumPageItems; i < numPageItems; ++i) {
+ TextView text = (TextView) mInflater.inflate(
+ R.layout.all_apps_paged_view_application, layout, false);
+ text.setOnClickListener(this);
+ text.setOnLongClickListener(this);
+
+ layout.addViewToCellLayout(text, -1, i,
+ new PagedViewCellLayout.LayoutParams(0, 0, 1, 1));
+ }
+
+ // Actually reapply to the existing text views
+ for (int i = startIndex; i < endIndex; ++i) {
+ final int index = i - startIndex;
+ final ApplicationInfo info = mFilteredApps.get(i);
+ PagedViewIcon icon = (PagedViewIcon) layout.getChildAt(index);
+ icon.applyFromApplicationInfo(info, mPageViewIconCache);
+
+ PagedViewCellLayout.LayoutParams params =
+ (PagedViewCellLayout.LayoutParams) icon.getLayoutParams();
+ params.cellX = index % mCellCountX;
+ params.cellY = index / mCellCountX;
+ }
+
+ // Default to left-aligned icons
+ layout.enableCenteredContent(false);
+ } else {
+ // There are no items, so show the user a small message
+ TextView icon = (TextView) mInflater.inflate(
+ R.layout.all_apps_no_items_placeholder, layout, false);
+ switch (mAppFilter) {
+ case ApplicationInfo.GAME_FLAG:
+ icon.setText(mContext.getString(R.string.all_apps_no_games));
+ break;
+ case ApplicationInfo.DOWNLOADED_FLAG:
+ icon.setText(mContext.getString(R.string.all_apps_no_downloads));
+ break;
+ default: break;
+ }
- // actually reapply to the existing text views
- for (int i = startIndex; i < endIndex; ++i) {
- final int index = i - startIndex;
- final ApplicationInfo info = mFilteredApps.get(i);
- PagedViewIcon icon = (PagedViewIcon) layout.getChildAt(index);
- icon.applyFromApplicationInfo(info, mPageViewIconCache);
-
- PagedViewCellLayout.LayoutParams params =
- (PagedViewCellLayout.LayoutParams) icon.getLayoutParams();
- params.cellX = index % mCellCountX;
- params.cellY = index / mCellCountX;
+ // Center-align the message
+ layout.enableCenteredContent(true);
+ layout.removeAllViews();
+ layout.addViewToCellLayout(icon, -1, 0,
+ new PagedViewCellLayout.LayoutParams(0, 0, 2, 1));
}
}
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index ff5ea496b..0f7898b27 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -137,7 +137,7 @@ public class PagedViewIcon extends TextView implements Checkable {
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
- if (mHolographicOutline == null) {
+ if (mIconCache != null && mHolographicOutline == null) {
// update the clipping rect to be used in the holographic pass below
getDrawingRect(mDrawableClipRect);
mDrawableClipRect.bottom = getPaddingTop() + getCompoundPaddingTop();