summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/apps_customize_pane.xml4
-rw-r--r--res/values-land/config.xml5
-rw-r--r--res/values-sw600dp-port/dimens.xml2
-rw-r--r--res/values-sw600dp/config.xml5
-rw-r--r--res/values-sw720dp-port/dimens.xml10
-rw-r--r--res/values-sw720dp/dimens.xml5
-rw-r--r--res/values-vi/strings.xml2
-rw-r--r--res/values/config.xml6
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java117
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java71
-rw-r--r--src/com/android/launcher2/CachedTextView.java182
-rw-r--r--src/com/android/launcher2/Folder.java18
-rw-r--r--src/com/android/launcher2/Launcher.java93
-rw-r--r--src/com/android/launcher2/PagedView.java34
-rw-r--r--src/com/android/launcher2/PagedViewCellLayout.java14
-rw-r--r--src/com/android/launcher2/PagedViewGridLayout.java10
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java23
-rw-r--r--src/com/android/launcher2/PagedViewWidget.java18
-rw-r--r--src/com/android/launcher2/Workspace.java63
19 files changed, 308 insertions, 374 deletions
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index 6ebda0916..efd29a673 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -18,9 +18,11 @@
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:background="#FF000000">
<LinearLayout
+ android:id="@+id/apps_customize_content"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:visibility="gone">
<!-- The layout_width of the tab bar gets overriden to align the content
with the text in the tabs in AppsCustomizeTabHost. -->
<FrameLayout
diff --git a/res/values-land/config.xml b/res/values-land/config.xml
index 121bb0c14..fc20456c3 100644
--- a/res/values-land/config.xml
+++ b/res/values-land/config.xml
@@ -20,4 +20,9 @@
<bool name="config_useDropTargetDownTransition">false</bool>
<!-- Whether or not to fade the side pages -->
<bool name="config_workspaceFadeAdjacentScreens">false</bool>
+
+ <!-- Folder max bounds and max number of items.
+ Note: folder_max_count_x * folder_max_count_y >= folder_max_num_items. -->
+ <integer name="folder_max_count_x">6</integer>
+ <integer name="folder_max_count_y">3</integer>
</resources>
diff --git a/res/values-sw600dp-port/dimens.xml b/res/values-sw600dp-port/dimens.xml
index 84f983534..6753cbfe9 100644
--- a/res/values-sw600dp-port/dimens.xml
+++ b/res/values-sw600dp-port/dimens.xml
@@ -18,7 +18,6 @@
<!-- AppsCustomize -->
<dimen name="apps_customize_cell_width">96dp</dimen>
<dimen name="apps_customize_cell_height">96dp</dimen>
- <dimen name="workspace_page_spacing">64dp</dimen>
<!-- Workspace -->
<!-- the area at the edge of the screen that makes the workspace go left
@@ -31,6 +30,7 @@
<dimen name="workspace_bottom_padding">25dip</dimen>
<dimen name="workspace_width_gap">0dp</dimen>
<dimen name="workspace_height_gap">32dp</dimen>
+ <dimen name="workspace_page_spacing">16dp</dimen>
<dimen name="apps_customize_pageLayoutWidthGap">24dp</dimen>
<dimen name="apps_customize_pageLayoutHeightGap">36dp</dimen>
diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml
index 2a81e12a1..7a0789839 100644
--- a/res/values-sw600dp/config.xml
+++ b/res/values-sw600dp/config.xml
@@ -19,4 +19,9 @@
<!-- When shrinking the workspace, this is the percentage of its original size. -->
<integer name="config_workspaceShrinkPercent">17</integer>
+ <!-- Folder max bounds and max number of items. Note: folder_max_count_x * folder_max_count_y
+ >= folder_max_num_items. When these are set to -1, they are automatically determined. -->
+ <integer name="folder_max_count_x">-1</integer>
+ <integer name="folder_max_count_y">-1</integer>
+ <integer name="folder_max_num_items">-1</integer>
</resources>
diff --git a/res/values-sw720dp-port/dimens.xml b/res/values-sw720dp-port/dimens.xml
index 2e3f8ef6f..52c105d1b 100644
--- a/res/values-sw720dp-port/dimens.xml
+++ b/res/values-sw720dp-port/dimens.xml
@@ -15,10 +15,8 @@
-->
<resources>
- <!-- We can also afford to have a slightly wider portrait layout in
- xlarge -->
- <integer name="apps_customize_widget_cell_count_x">3</integer>
- <integer name="apps_customize_widget_cell_count_y">3</integer>
+<!-- Workspace -->
+ <dimen name="workspace_page_spacing">24dp</dimen>
<!-- AppsCustomize -->
<integer name="apps_customize_maxCellCountX">-1</integer>
@@ -27,4 +25,8 @@
<dimen name="apps_customize_pageLayoutHeightGap">36dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingLeft">24dp</dimen>
<dimen name="apps_customize_pageLayoutPaddingRight">24dp</dimen>
+ <!-- We can also afford to have a slightly wider portrait layout in
+ xlarge -->
+ <integer name="apps_customize_widget_cell_count_x">3</integer>
+ <integer name="apps_customize_widget_cell_count_y">3</integer>
</resources> \ No newline at end of file
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 5c39b01d4..48faf9ab7 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -15,10 +15,9 @@
-->
<resources>
- <dimen name="app_widget_preview_padding_left">0dp</dimen>
- <dimen name="app_widget_preview_padding_top">10dp</dimen>
-
<!-- AppsCustomize -->
<integer name="apps_customize_maxCellCountX">-1</integer>
<integer name="apps_customize_maxCellCountY">-1</integer>
+ <dimen name="app_widget_preview_padding_left">0dp</dimen>
+ <dimen name="app_widget_preview_padding_top">10dp</dimen>
</resources> \ No newline at end of file
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index 5ad3af9f4..164f1e16c 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -32,7 +32,7 @@
<string name="external_drop_widget_error" msgid="127440783198670829">"Không thể thả mục vào Màn hình chính này."</string>
<string name="external_drop_widget_pick_title" msgid="7040647073452295370">"Chọn tiện ích con để tạo"</string>
<string name="rename_folder_label" msgid="5646236631298452787">"Tên thư mục"</string>
- <string name="rename_folder_title" msgid="4544573104191526550">"Đổi tên thư mục"</string>
+ <string name="rename_folder_title" msgid="4544573104191526550">"Đổi tên thư mục"</string>
<string name="rename_action" msgid="6016003384693240896">"OK"</string>
<string name="cancel_action" msgid="3811860427489435048">"Hủy"</string>
<string name="menu_item_add_item" msgid="6233177331075781114">"Thêm vào Màn hình chính"</string>
diff --git a/res/values/config.xml b/res/values/config.xml
index b8040e68f..7ab98707c 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -84,4 +84,10 @@
<!-- When shrinking the workspace, this is the percentage of its original size. -->
<integer name="config_workspaceShrinkPercent">17</integer>
+
+ <!-- Folder max bounds and max number of items. Note: folder_max_count_x * folder_max_count_y
+ >= folder_max_num_items. When these are set to -1, they are automatically determined. -->
+ <integer name="folder_max_count_x">4</integer>
+ <integer name="folder_max_count_y">4</integer>
+ <integer name="folder_max_num_items">16</integer>
</resources>
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index af5141fd4..2cdd16a49 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -37,7 +37,6 @@ import android.graphics.MaskFilter;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Rect;
-import android.graphics.RectF;
import android.graphics.TableMaskFilter;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -45,6 +44,7 @@ import android.os.Process;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -168,7 +168,7 @@ class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTas
* The Apps/Customize page that displays all the applications, widgets, and shortcuts.
*/
public class AppsCustomizePagedView extends PagedViewWithDraggableItems implements
- AllAppsView, View.OnClickListener, DragSource {
+ AllAppsView, View.OnClickListener, View.OnKeyListener, DragSource {
static final String LOG_TAG = "AppsCustomizePagedView";
/**
@@ -227,7 +227,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Previews & outlines
ArrayList<AppsCustomizeAsyncTask> mRunningTasks;
private HolographicOutlineHelper mHolographicOutlineHelper;
- private static final int sPageSleepDelay = 150;
+ private static final int sPageSleepDelay = 200;
public AppsCustomizePagedView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -515,6 +515,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ return FocusHelper.handleAppsCustomizeKeyEvent(v, keyCode, event);
+ }
+
/*
* PagedViewWithDraggableItems implementation
*/
@@ -659,18 +663,33 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
protected void snapToPage(int whichPage, int delta, int duration) {
super.snapToPage(whichPage, delta, duration);
updateCurrentTab(whichPage);
+
+ // Update the thread priorities given the direction lookahead
+ Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
+ while (iter.hasNext()) {
+ AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
+ int pageIndex = task.page + mNumAppsPages;
+ if ((mNextPage > mCurrentPage && pageIndex >= mCurrentPage) ||
+ (mNextPage < mCurrentPage && pageIndex <= mCurrentPage)) {
+ task.setThreadPriority(getThreadPriorityForPage(pageIndex));
+ } else {
+ task.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
+ }
+ }
}
private void updateCurrentTab(int currentPage) {
AppsCustomizeTabHost tabHost = getTabHost();
- String tag = tabHost.getCurrentTabTag();
- if (tag != null) {
- if (currentPage >= mNumAppsPages &&
- !tag.equals(tabHost.getTabTagForContentType(ContentType.Widgets))) {
- tabHost.setCurrentTabFromContent(ContentType.Widgets);
- } else if (currentPage < mNumAppsPages &&
- !tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
- tabHost.setCurrentTabFromContent(ContentType.Applications);
+ if (tabHost != null) {
+ String tag = tabHost.getCurrentTabTag();
+ if (tag != null) {
+ if (currentPage >= mNumAppsPages &&
+ !tag.equals(tabHost.getTabTagForContentType(ContentType.Widgets))) {
+ tabHost.setCurrentTabFromContent(ContentType.Widgets);
+ } else if (currentPage < mNumAppsPages &&
+ !tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
+ tabHost.setCurrentTabFromContent(ContentType.Applications);
+ }
}
}
}
@@ -720,6 +739,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
icon.setOnClickListener(this);
icon.setOnLongClickListener(this);
icon.setOnTouchListener(this);
+ icon.setOnKeyListener(this);
int index = i - startIndex;
int x = index % mCellCountX;
@@ -740,25 +760,45 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
/**
+ * A helper to return the priority for loading of the specified widget page.
+ */
+ private int getWidgetPageLoadPriority(int page) {
+ // If we are snapping to another page, use that index as the target page index
+ int toPage = mCurrentPage;
+ if (mNextPage > -1) {
+ toPage = mNextPage;
+ }
+
+ // We use the distance from the target page as an initial guess of priority, but if there
+ // are no pages of higher priority than the page specified, then bump up the priority of
+ // the specified page.
+ Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
+ int minPageDiff = Integer.MAX_VALUE;
+ while (iter.hasNext()) {
+ AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
+ minPageDiff = Math.abs(task.page + mNumAppsPages - toPage);
+ }
+
+ int rawPageDiff = Math.abs(page - toPage);
+ return rawPageDiff - Math.min(rawPageDiff, minPageDiff);
+ }
+ /**
* Return the appropriate thread priority for loading for a given page (we give the current
* page much higher priority)
*/
private int getThreadPriorityForPage(int page) {
// TODO-APPS_CUSTOMIZE: detect number of cores and set thread priorities accordingly below
- int pageDiff = Math.abs(page - mCurrentPage);
+ int pageDiff = getWidgetPageLoadPriority(page);
if (pageDiff <= 0) {
- // return Process.THREAD_PRIORITY_DEFAULT;
- return Process.THREAD_PRIORITY_MORE_FAVORABLE;
+ return Process.THREAD_PRIORITY_LESS_FAVORABLE;
} else if (pageDiff <= 1) {
- // return Process.THREAD_PRIORITY_BACKGROUND;
- return Process.THREAD_PRIORITY_DEFAULT;
+ return Process.THREAD_PRIORITY_LOWEST;
} else {
- // return Process.THREAD_PRIORITY_LOWEST;
- return Process.THREAD_PRIORITY_DEFAULT;
+ return Process.THREAD_PRIORITY_LOWEST;
}
}
private int getSleepForPage(int page) {
- int pageDiff = Math.abs(page - mCurrentPage) - 1;
+ int pageDiff = getWidgetPageLoadPriority(page);
return Math.max(0, pageDiff * sPageSleepDelay);
}
/**
@@ -766,18 +806,18 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
*/
private void prepareLoadWidgetPreviewsTask(int page, ArrayList<Object> widgets,
int cellWidth, int cellHeight, int cellCountX) {
+
// Prune all tasks that are no longer needed
Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
while (iter.hasNext()) {
AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
- int taskPage = task.page;
- if ((taskPage == page) ||
- taskPage < getAssociatedLowerPageBound(mCurrentPage - mNumAppsPages) ||
- taskPage > getAssociatedUpperPageBound(mCurrentPage - mNumAppsPages)) {
+ int taskPage = task.page + mNumAppsPages;
+ if (taskPage < getAssociatedLowerPageBound(mCurrentPage) ||
+ taskPage > getAssociatedUpperPageBound(mCurrentPage)) {
task.cancel(false);
iter.remove();
} else {
- task.setThreadPriority(getThreadPriorityForPage(taskPage + mNumAppsPages));
+ task.setThreadPriority(getThreadPriorityForPage(taskPage));
}
}
@@ -815,7 +855,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Ensure that the task is appropriately prioritized and runs in parallel
AppsCustomizeAsyncTask t = new AppsCustomizeAsyncTask(page,
AsyncTaskPageData.Type.LoadWidgetPreviewData);
- t.setThreadPriority(getThreadPriorityForPage(page));
+ t.setThreadPriority(getThreadPriorityForPage(page + mNumAppsPages));
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageData);
mRunningTasks.add(t);
}
@@ -1075,6 +1115,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
widget.setOnClickListener(this);
widget.setOnLongClickListener(this);
widget.setOnTouchListener(this);
+ widget.setOnKeyListener(this);
// Layout each widget
int ix = i % mWidgetCountX;
@@ -1118,6 +1159,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
private void loadWidgetPreviewsInBackground(AppsCustomizeAsyncTask task,
AsyncTaskPageData data) {
+ // loadWidgetPreviewsInBackground can be called without a task to load a set of widget
+ // previews synchronously
if (task != null) {
// Ensure that this task starts running at the correct priority
task.syncThreadPriority();
@@ -1163,14 +1206,23 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
widget.applyPreview(new FastBitmapDrawable(preview), i);
}
}
- layout.createHardwareLayer();
+ layout.createHardwareLayer();
invalidate();
+
/* TEMPORARILY DISABLE HOLOGRAPHIC ICONS
if (mFadeInAdjacentScreens) {
prepareGenerateHoloOutlinesTask(data.page, data.items, data.generatedImages);
}
*/
+
+ // Update all thread priorities
+ Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
+ while (iter.hasNext()) {
+ AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
+ int pageIndex = task.page + mNumAppsPages;
+ task.setThreadPriority(getThreadPriorityForPage(pageIndex));
+ }
}
private void onHolographicPageItemsLoaded(AsyncTaskPageData data) {
// Invalidate early to short-circuit children invalidates
@@ -1467,16 +1519,25 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
cancelAllTasks();
}
+
/*
* We load an extra page on each side to prevent flashes from scrolling and loading of the
* widget previews in the background with the AsyncTasks.
*/
+ final static int sLookBehindPageCount = 2;
+ final static int sLookAheadPageCount = 2;
protected int getAssociatedLowerPageBound(int page) {
- return Math.max(0, page - 2);
+ final int count = getChildCount();
+ int windowSize = Math.min(count, sLookBehindPageCount + sLookAheadPageCount + 1);
+ int windowMinIndex = Math.max(Math.min(page - sLookBehindPageCount, count - windowSize), 0);
+ return windowMinIndex;
}
protected int getAssociatedUpperPageBound(int page) {
final int count = getChildCount();
- return Math.min(page + 2, count - 1);
+ int windowSize = Math.min(count, sLookBehindPageCount + sLookAheadPageCount + 1);
+ int windowMaxIndex = Math.min(Math.max(page + sLookAheadPageCount, windowSize - 1),
+ count - 1);
+ return windowMaxIndex;
}
@Override
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 41f8d7e1a..07e662525 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -28,6 +28,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
@@ -49,9 +50,11 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private AppsCustomizePagedView mAppsCustomizePane;
private boolean mSuppressContentCallback = false;
private FrameLayout mAnimationBuffer;
+ private LinearLayout mContent;
private boolean mInTransition;
private boolean mResetAfterTransition;
+ private Animator mLauncherTransition;
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -93,6 +96,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mTabsContainer = tabsContainer;
mAppsCustomizePane = appsCustomizePane;
mAnimationBuffer = (FrameLayout) findViewById(R.id.animation_buffer);
+ mContent = (LinearLayout) findViewById(R.id.apps_customize_content);
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
// Configure the tabs content factory to return the same paged view (that we change the
@@ -167,7 +171,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private void reloadCurrentPage() {
if (!LauncherApplication.isScreenLarge()) {
- mAppsCustomizePane.flashScrollingIndicator();
+ mAppsCustomizePane.flashScrollingIndicator(true);
}
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
mAppsCustomizePane.requestFocus();
@@ -202,6 +206,17 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// Take the visible pages and re-parent them temporarily to mAnimatorBuffer
// and then cross fade to the new pages
+ int[] visiblePageRange = new int[2];
+ mAppsCustomizePane.getVisiblePages(visiblePageRange);
+ if (visiblePageRange[0] == -1 && visiblePageRange[1] == -1) {
+ // If we can't get the visible page ranges, then just skip the animation
+ reloadCurrentPage();
+ return;
+ }
+ ArrayList<View> visiblePages = new ArrayList<View>();
+ for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
+ visiblePages.add(mAppsCustomizePane.getPageAt(i));
+ }
// We want the pages to be rendered in exactly the same way as they were when
// their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer
@@ -209,16 +224,15 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// parameters to be correct for each of the pages
mAnimationBuffer.scrollTo(mAppsCustomizePane.getScrollX(), 0);
- int[] visiblePageRange = new int[2];
- mAppsCustomizePane.getVisiblePages(visiblePageRange);
- ArrayList<View> visiblePages = new ArrayList<View>();
- for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
- visiblePages.add(mAppsCustomizePane.getPageAt(i));
- }
// mAppsCustomizePane renders its children in reverse order, so
// add the pages to mAnimationBuffer in reverse order to match that behavior
for (int i = visiblePages.size() - 1; i >= 0; i--) {
View child = visiblePages.get(i);
+ if (child instanceof PagedViewCellLayout) {
+ ((PagedViewCellLayout) child).resetChildrenOnKeyListeners();
+ } else if (child instanceof PagedViewGridLayout) {
+ ((PagedViewGridLayout) child).resetChildrenOnKeyListeners();
+ }
PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(false);
mAppsCustomizePane.removeView(child);
PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true);
@@ -313,21 +327,49 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
}
}
- /* LauncherTransitionable overrides */
- @Override
- public void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace) {
- mInTransition = true;
+ private void enableAndBuildHardwareLayer() {
// isHardwareAccelerated() checks if we're attached to a window and if that
// window is HW accelerated-- we were sometimes not attached to a window
// and buildLayer was throwing an IllegalStateException
- if (animation != null && isHardwareAccelerated()) {
+ if (isHardwareAccelerated()) {
// Turn on hardware layers for performance
setLayerType(LAYER_TYPE_HARDWARE, null);
- // force building the layer at the beginning of the animation, so you don't get a
- // blip early in the animation
+ // force building the layer, so you don't get a blip early in an animation
+ // when the layer is created layer
buildLayer();
}
+ }
+
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ if (mLauncherTransition != null) {
+ enableAndBuildHardwareLayer();
+ mLauncherTransition.start();
+ mLauncherTransition = null;
+ }
+ }
+
+ /* LauncherTransitionable overrides */
+ @Override
+ public boolean onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace) {
+ mInTransition = true;
+ boolean delayLauncherTransitionUntilLayout = false;
+ mLauncherTransition = null;
+
+ // if the content wasn't visible before, delay the launcher animation until after a cal
+ // to layout -- this prevents a blip
+ if (animation != null) {
+ if (mContent.getVisibility() == GONE) {
+ mLauncherTransition = animation;
+ delayLauncherTransitionUntilLayout = true;
+ }
+ mContent.setVisibility(VISIBLE);
+ if (!delayLauncherTransitionUntilLayout) {
+ enableAndBuildHardwareLayer();
+ }
+ }
+
if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
mAppsCustomizePane.showScrollingIndicator(false);
}
@@ -335,6 +377,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mAppsCustomizePane.reset();
mResetAfterTransition = false;
}
+ return delayLauncherTransitionUntilLayout;
}
@Override
diff --git a/src/com/android/launcher2/CachedTextView.java b/src/com/android/launcher2/CachedTextView.java
deleted file mode 100644
index f9f68a0d4..000000000
--- a/src/com/android/launcher2/CachedTextView.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.PorterDuff.Mode;
-import android.graphics.drawable.Drawable;
-import android.text.Layout;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-/*
- * This class is a bit of a hack, designed to speed up long text labels in Launcher. It caches the
- * text in a TextView to a bitmap and then just draws that Bitmap instead afterward, speeding up
- * rendering. Marquee scrolling is not currently supported.
- *
- */
-public class CachedTextView extends TextView {
- private Bitmap mCache;
- private final Paint mCachePaint = new Paint();
- private final Canvas mCacheCanvas = new Canvas();
-
- private int mPrevAlpha = -1;
- private boolean mIsBuildingCache;
- boolean mIsTextCacheDirty;
- float mTextCacheLeft;
- float mTextCacheTop;
- float mTextCacheScrollX;
- float mRectLeft, mRectTop;
- private float mPaddingH = 0;
- private float mPaddingV = 0;
- private CharSequence mText;
- private boolean mEnabled = true;
-
- public CachedTextView(Context context) {
- super(context);
- }
-
- public CachedTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public CachedTextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- protected int getCacheTopPadding() {
- return 0;
- }
- protected int getCacheLeftPadding() {
- return 0;
- }
- protected int getCacheRightPadding() {
- return 0;
- }
- protected int getCacheBottomPadding() {
- return 0;
- }
-
- public void disableCache() {
- mEnabled = false;
- }
-
- public void setText(CharSequence text, BufferType type) {
- super.setText(text, type);
- mIsTextCacheDirty = true;
- }
-
- private void buildAndUpdateCache() {
- final Layout layout = getLayout();
- final int left = getCompoundPaddingLeft();
- final int top = getExtendedPaddingTop();
- final float prevAlpha = getAlpha();
-
- mTextCacheLeft = layout.getLineLeft(0) - getCacheLeftPadding();
- mTextCacheTop = top + layout.getLineTop(0) - mPaddingV - getCacheTopPadding();
-
- mRectLeft = mScrollX + getLeft();
- mRectTop = 0;
- mTextCacheScrollX = mScrollX;
-
- final float textCacheRight =
- Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) +
- getCacheRightPadding();
- final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV +
- getCacheBottomPadding();
- final float xCharWidth = getPaint().measureText("x");
-
- int width = (int) (textCacheRight - mTextCacheLeft + (2 * xCharWidth));
- int height = (int) (textCacheBottom - mTextCacheTop);
-
- if (width > 0 && height > 0) {
- if (mCache != null) {
- if (mCache.getWidth() != width || mCache.getHeight() != height) {
- mCache.recycle();
- mCache = null;
- }
- }
- if (mCache == null) {
- mCache = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- mCacheCanvas.setBitmap(mCache);
- } else {
- mCacheCanvas.drawColor(0, Mode.CLEAR);
- }
-
- mCacheCanvas.save();
- mCacheCanvas.translate(-mTextCacheLeft, -mTextCacheTop);
-
- mIsBuildingCache = true;
- setAlpha(1.0f);
- draw(mCacheCanvas);
- setAlpha(prevAlpha);
- mIsBuildingCache = false;
- mCacheCanvas.restore();
- mCacheCanvas.setBitmap(null);
-
- // A hack-- we set the text to be one space (we don't make it empty just to avoid any
- // potential issues with text measurement, like line height, etc.) so that the text view
- // doesn't draw it anymore, since it's been cached.
- mText = getText();
- setText(" ");
- }
- }
-
- public CharSequence getText() {
- return (mText == null) ? super.getText() : mText;
- }
-
- public void draw(Canvas canvas) {
- if (mEnabled && mIsTextCacheDirty && !mIsBuildingCache) {
- buildAndUpdateCache();
- mIsTextCacheDirty = false;
- }
- if (mCache != null && !mIsBuildingCache) {
- canvas.drawBitmap(mCache, mTextCacheLeft - mTextCacheScrollX + mScrollX,
- mTextCacheTop, mCachePaint);
- }
- super.draw(canvas);
- }
-
- protected boolean isBuildingCache() {
- return mIsBuildingCache;
- }
-
- @Override
- protected boolean onSetAlpha(int alpha) {
- if (mPrevAlpha != alpha) {
- mPrevAlpha = alpha;
- mCachePaint.setAlpha(alpha);
-
- // We manually update the drawables alpha since the default TextView implementation may
- // not do this if there is a background set (which we may due to the focus bg)
- final Drawable[] dr = getCompoundDrawables();
- for (int i = 0; i < dr.length; ++i) {
- if (dr[i] != null) {
- dr[i].mutate().setAlpha(alpha);
- }
- }
-
- super.onSetAlpha(alpha);
- }
- return true;
- }
-}
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 33b5de17c..a6757d7f1 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -83,6 +83,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private FolderIcon mFolderIcon;
private int mMaxCountX;
private int mMaxCountY;
+ private int mMaxNumItems;
private Rect mNewSize = new Rect();
private Rect mIconRect = new Rect();
private ArrayList<View> mItemsInReadingOrder = new ArrayList<View>();
@@ -121,13 +122,20 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
setAlwaysDrawnWithCacheEnabled(false);
mInflater = LayoutInflater.from(context);
mIconCache = ((LauncherApplication)context.getApplicationContext()).getIconCache();
- mMaxCountX = LauncherModel.getCellCountX();
- mMaxCountY = LauncherModel.getCellCountY();
+
+ Resources res = getResources();
+ mMaxCountX = res.getInteger(R.integer.folder_max_count_x);
+ mMaxCountY = res.getInteger(R.integer.folder_max_count_y);
+ mMaxNumItems = res.getInteger(R.integer.folder_max_num_items);
+ if (mMaxCountX < 0 || mMaxCountY < 0 || mMaxNumItems < 0) {
+ mMaxCountX = LauncherModel.getCellCountX();
+ mMaxCountY = LauncherModel.getCellCountY();
+ mMaxNumItems = mMaxCountX * mMaxCountY;
+ }
mInputMethodManager = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
- Resources res = getResources();
mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration);
if (sDefaultFolderName == null) {
@@ -746,7 +754,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
int oldCountY = countY;
if (countX * countY < count) {
// Current grid is too small, expand it
- if (countX <= countY && countX < mMaxCountX) {
+ if ((countX <= countY || countY == mMaxCountY) && countX < mMaxCountX) {
countX++;
} else if (countY < mMaxCountY) {
countY++;
@@ -764,7 +772,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
public boolean isFull() {
- return getItemCount() >= mMaxCountX * mMaxCountY;
+ return getItemCount() >= mMaxNumItems;
}
private void centerAboutIcon() {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index f91a47198..43510c226 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -78,6 +78,7 @@ import android.view.Surface;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
@@ -161,6 +162,7 @@ public final class Launcher extends Activity
private enum State { WORKSPACE, APPS_CUSTOMIZE, APPS_CUSTOMIZE_SPRING_LOADED };
private State mState = State.WORKSPACE;
private AnimatorSet mStateAnimation;
+ private AnimatorSet mDividerAnimator;
static final int APPWIDGET_HOST_ID = 1024;
private static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300;
@@ -177,8 +179,11 @@ public final class Launcher extends Activity
private LayoutInflater mInflater;
- private DragController mDragController;
private Workspace mWorkspace;
+ private View mQsbDivider;
+ private View mDockDivider;
+ private DragLayer mDragLayer;
+ private DragController mDragController;
private AppWidgetManager mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
@@ -241,7 +246,6 @@ public final class Launcher extends Activity
static final ArrayList<String> sDumpLogs = new ArrayList<String>();
- private DragLayer mDragLayer;
private BubbleTextView mWaitingForResume;
@@ -560,7 +564,24 @@ public final class Launcher extends Activity
// market intent, so refresh the icon
updateAppMarketIcon();
if (!mWorkspaceLoading) {
- mWorkspace.post(mBuildLayersRunnable);
+ final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
+ final Workspace workspace = mWorkspace;
+ // We want to let Launcher draw itself at least once before we force it to build
+ // layers on all the workspace pages, so that transitioning to Launcher from other
+ // apps is nice and speedy. Usually the first call to preDraw doesn't correspond to
+ // a true draw so we wait until the second preDraw call to be safe
+ observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
+ boolean mFirstTime = true;
+ public boolean onPreDraw() {
+ if (mFirstTime) {
+ mFirstTime = false;
+ } else {
+ workspace.post(mBuildLayersRunnable);
+ observer.removeOnPreDrawListener(this);
+ }
+ return true;
+ }
+ });
}
clearTypedText();
}
@@ -726,6 +747,8 @@ public final class Launcher extends Activity
mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
+ mQsbDivider = (ImageView) findViewById(R.id.qsb_divider);
+ mDockDivider = (ImageView) findViewById(R.id.dock_divider);
// Setup the drag layer
mDragLayer.setup(this, dragController);
@@ -2225,10 +2248,6 @@ public final class Launcher extends Activity
alphaAnim.setStartDelay(startDelay);
alphaAnim.start();
- if (toView instanceof LauncherTransitionable) {
- ((LauncherTransitionable) toView).onLauncherTransitionStart(instance, scaleAnim,
- false);
- }
scaleAnim.addListener(new AnimatorListenerAdapter() {
boolean animationCancelled = false;
@@ -2256,7 +2275,7 @@ public final class Launcher extends Activity
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
- mWorkspace.hideDockDivider(true);
+ hideDockDivider();
}
if (!animationCancelled) {
updateWallpaperVisibility(false);
@@ -2272,7 +2291,18 @@ public final class Launcher extends Activity
// toView should appear right at the end of the workspace shrink animation
mStateAnimation = new AnimatorSet();
mStateAnimation.play(scaleAnim).after(startDelay);
- mStateAnimation.start();
+
+ boolean delayAnim = false;
+ if (toView instanceof LauncherTransitionable) {
+ LauncherTransitionable lt = (LauncherTransitionable) toView;
+ delayAnim = lt.onLauncherTransitionStart(instance, mStateAnimation, false);
+ }
+ // if the anim is delayed, the LauncherTransitionable is responsible for starting it
+ if (!delayAnim) {
+ // TODO: q-- what if this anim is cancelled before being started? or started after
+ // being cancelled?
+ mStateAnimation.start();
+ }
} else {
toView.setTranslationX(0.0f);
toView.setTranslationY(0.0f);
@@ -2287,7 +2317,7 @@ public final class Launcher extends Activity
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
- mWorkspace.hideDockDivider(true);
+ hideDockDivider();
}
}
updateWallpaperVisibility(false);
@@ -2299,7 +2329,7 @@ public final class Launcher extends Activity
* This is the opposite of showAppsCustomizeHelper.
* @param animated If true, the transition will be animated.
*/
- private void hideAppsCustomizeHelper(boolean animated) {
+ private void hideAppsCustomizeHelper(boolean animated, final boolean springLoaded) {
if (mStateAnimation != null) {
mStateAnimation.cancel();
mStateAnimation = null;
@@ -2363,6 +2393,7 @@ public final class Launcher extends Activity
((LauncherTransitionable) fromView).onLauncherTransitionStart(instance, null, true);
((LauncherTransitionable) fromView).onLauncherTransitionEnd(instance, null, true);
}
+ mWorkspace.hideScrollingIndicator(false);
}
}
@@ -2373,10 +2404,12 @@ public final class Launcher extends Activity
mWorkspace.changeState(Workspace.State.NORMAL, animated, stagger);
if (mState != State.WORKSPACE) {
mWorkspace.setVisibility(View.VISIBLE);
- hideAppsCustomizeHelper(animated);
+ hideAppsCustomizeHelper(animated, false);
// Show the search bar and hotseat
mSearchDropTargetBar.showSearchBar(animated);
+ // We only need to animate in the dock divider if we're going from spring loaded mode
+ showDockDivider(animated && mState == State.APPS_CUSTOMIZE_SPRING_LOADED);
// Set focus to the AppsCustomize button
if (mAllAppsButton != null) {
@@ -2384,8 +2417,7 @@ public final class Launcher extends Activity
}
}
- mWorkspace.showDockDivider(!animated);
- mWorkspace.flashScrollingIndicator();
+ mWorkspace.flashScrollingIndicator(animated);
// Change the state *after* we've called all the transition code
mState = State.WORKSPACE;
@@ -2422,7 +2454,8 @@ public final class Launcher extends Activity
void enterSpringLoadedDragMode() {
if (mState == State.APPS_CUSTOMIZE) {
mWorkspace.changeState(Workspace.State.SPRING_LOADED);
- hideAppsCustomizeHelper(true);
+ hideAppsCustomizeHelper(true, true);
+ hideDockDivider();
mState = State.APPS_CUSTOMIZE_SPRING_LOADED;
}
}
@@ -2459,6 +2492,33 @@ public final class Launcher extends Activity
// Otherwise, we are not in spring loaded mode, so don't do anything.
}
+ void hideDockDivider() {
+ if (mQsbDivider != null && mDockDivider != null) {
+ mQsbDivider.setVisibility(View.INVISIBLE);
+ mDockDivider.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ void showDockDivider(boolean animated) {
+ if (mQsbDivider != null && mDockDivider != null) {
+ mQsbDivider.setVisibility(View.VISIBLE);
+ mDockDivider.setVisibility(View.VISIBLE);
+ if (mDividerAnimator != null) {
+ mDividerAnimator.cancel();
+ mQsbDivider.setAlpha(1f);
+ mDockDivider.setAlpha(1f);
+ mDividerAnimator = null;
+ }
+ if (animated) {
+ mDividerAnimator = new AnimatorSet();
+ mDividerAnimator.playTogether(ObjectAnimator.ofFloat(mQsbDivider, "alpha", 1f),
+ ObjectAnimator.ofFloat(mDockDivider, "alpha", 1f));
+ mDividerAnimator.setDuration(mSearchDropTargetBar.getTransitionInDuration());
+ mDividerAnimator.start();
+ }
+ }
+ }
+
void lockAllApps() {
// TODO
}
@@ -3249,6 +3309,7 @@ public final class Launcher extends Activity
}
interface LauncherTransitionable {
- void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace);
+ // return true if the callee will take care of start the animation by itself
+ boolean onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace);
void onLauncherTransitionEnd(Launcher l, Animator animation, boolean toWorkspace);
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 14ef53fbb..2f66537ac 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -204,7 +204,7 @@ public abstract class PagedView extends ViewGroup {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.PagedView, defStyle, 0);
- mPageSpacing = a.getDimensionPixelSize(R.styleable.PagedView_pageSpacing, 0);
+ setPageSpacing(a.getDimensionPixelSize(R.styleable.PagedView_pageSpacing, 0));
mPageLayoutPaddingTop = a.getDimensionPixelSize(
R.styleable.PagedView_pageLayoutPaddingTop, 0);
mPageLayoutPaddingBottom = a.getDimensionPixelSize(
@@ -557,6 +557,11 @@ public abstract class PagedView extends ViewGroup {
scrollToNewPageWithoutMovingPages(mCurrentPage);
}
+ public void setPageSpacing(int pageSpacing) {
+ mPageSpacing = pageSpacing;
+ invalidateCachedOffsets();
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (!mIsDataReady) {
@@ -574,7 +579,7 @@ public abstract class PagedView extends ViewGroup {
// Calculate the variable page spacing if necessary
if (mPageSpacing < 0) {
- mPageSpacing = ((right - left) - getChildAt(0).getMeasuredWidth()) / 2;
+ setPageSpacing(((right - left) - getChildAt(0).getMeasuredWidth()) / 2);
}
}
@@ -752,17 +757,18 @@ public abstract class PagedView extends ViewGroup {
getVisiblePages(mTempVisiblePagesRange);
final int leftScreen = mTempVisiblePagesRange[0];
final int rightScreen = mTempVisiblePagesRange[1];
-
- final long drawingTime = getDrawingTime();
- // Clip to the bounds
- canvas.save();
- canvas.clipRect(mScrollX, mScrollY, mScrollX + mRight - mLeft,
- mScrollY + mBottom - mTop);
-
- for (int i = rightScreen; i >= leftScreen; i--) {
- drawChild(canvas, getPageAt(i), drawingTime);
+ if (leftScreen != -1 && rightScreen != -1) {
+ final long drawingTime = getDrawingTime();
+ // Clip to the bounds
+ canvas.save();
+ canvas.clipRect(mScrollX, mScrollY, mScrollX + mRight - mLeft,
+ mScrollY + mBottom - mTop);
+
+ for (int i = rightScreen; i >= leftScreen; i--) {
+ drawChild(canvas, getPageAt(i), drawingTime);
+ }
+ canvas.restore();
}
- canvas.restore();
}
}
@@ -1760,9 +1766,9 @@ public abstract class PagedView extends ViewGroup {
hideScrollingIndicator(false);
}
};
- protected void flashScrollingIndicator() {
+ protected void flashScrollingIndicator(boolean animated) {
removeCallbacks(hideScrollingIndicatorRunnable);
- showScrollingIndicator(false);
+ showScrollingIndicator(!animated);
postDelayed(hideScrollingIndicatorRunnable, sScrollIndicatorFlashDuration);
}
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index 6266ca26f..c29e50d6f 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -131,10 +131,6 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
child.setId(childId);
mChildren.addView(child, index, lp);
- if (child instanceof PagedViewIcon) {
- PagedViewIcon pagedViewIcon = (PagedViewIcon) child;
- pagedViewIcon.disableCache();
- }
return true;
}
return false;
@@ -151,6 +147,16 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
mChildren.removeViewAt(index);
}
+ /**
+ * Clears all the key listeners for the individual icons.
+ */
+ public void resetChildrenOnKeyListeners() {
+ int childCount = mChildren.getChildCount();
+ for (int j = 0; j < childCount; ++j) {
+ mChildren.getChildAt(j).setOnKeyListener(null);
+ }
+ }
+
@Override
public int getPageChildCount() {
return mChildren.getChildCount();
diff --git a/src/com/android/launcher2/PagedViewGridLayout.java b/src/com/android/launcher2/PagedViewGridLayout.java
index 01d75934a..5c32e0934 100644
--- a/src/com/android/launcher2/PagedViewGridLayout.java
+++ b/src/com/android/launcher2/PagedViewGridLayout.java
@@ -46,6 +46,16 @@ public class PagedViewGridLayout extends GridLayout implements Page {
return mCellCountY;
}
+ /**
+ * Clears all the key listeners for the individual widgets.
+ */
+ public void resetChildrenOnKeyListeners() {
+ int childCount = getChildCount();
+ for (int j = 0; j < childCount; ++j) {
+ getChildAt(j).setOnKeyListener(null);
+ }
+ }
+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// PagedView currently has issues with different-sized pages since it calculates the
// offset of each page to scroll to before it updates the actual size of each page
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 3cc7786cc..af10f189c 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -17,21 +17,14 @@
package com.android.launcher2;
import android.animation.ObjectAnimator;
-import android.content.ComponentName;
import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Message;
import android.util.AttributeSet;
-import android.view.KeyEvent;
import android.widget.Checkable;
+import android.widget.TextView;
import com.android.launcher.R;
@@ -40,7 +33,7 @@ import com.android.launcher.R;
* An icon on a PagedView, specifically for items in the launcher's paged view (with compound
* drawables on the top).
*/
-public class PagedViewIcon extends CachedTextView implements Checkable {
+public class PagedViewIcon extends TextView implements Checkable {
private static final String TAG = "PagedViewIcon";
// holographic outline
@@ -155,18 +148,6 @@ public class PagedViewIcon extends CachedTextView implements Checkable {
}
@Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- return FocusHelper.handleAppsCustomizeKeyEvent(this, keyCode, event)
- || super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- return FocusHelper.handleAppsCustomizeKeyEvent(this, keyCode, event)
- || super.onKeyUp(keyCode, event);
- }
-
- @Override
public boolean isChecked() {
return mIsChecked;
}
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index d3541ff2c..9e668fd3c 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -156,12 +156,8 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
if (preview != null) {
image.mAllowRequestLayout = false;
image.setImageDrawable(preview);
+ image.setAlpha(1f);
image.mAllowRequestLayout = true;
- image.setAlpha(0f);
- image.animate()
- .alpha(1f)
- .setDuration(sPreviewFadeInDuration + (index * sPreviewFadeInStaggerDuration))
- .start();
}
}
@@ -183,18 +179,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
}
@Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- return FocusHelper.handleAppsCustomizeKeyEvent(this, keyCode, event)
- || super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- return FocusHelper.handleAppsCustomizeKeyEvent(this, keyCode, event)
- || super.onKeyUp(keyCode, event);
- }
-
- @Override
protected void onDraw(Canvas canvas) {
if (mAlpha > 0) {
super.onDraw(canvas);
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 8ac5248b1..8c5734970 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -107,7 +107,6 @@ public class Workspace extends SmoothPagedView
private float mBackgroundAlpha = 0;
private float mOverScrollMaxBackgroundAlpha = 0.0f;
private int mOverScrollPageIndex = -1;
- private AnimatorSet mDividerAnimator;
private float mWallpaperScrollRatio = 1.0f;
@@ -3493,30 +3492,6 @@ public class Workspace extends SmoothPagedView
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
- void showDockDivider(boolean immediately) {
- final ViewGroup parent = (ViewGroup) getParent();
- final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
- final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
- if (qsbDivider != null && dockDivider != null) {
- qsbDivider.setVisibility(View.VISIBLE);
- dockDivider.setVisibility(View.VISIBLE);
- if (mDividerAnimator != null) {
- mDividerAnimator.cancel();
- mDividerAnimator = null;
- }
- if (immediately) {
- qsbDivider.setAlpha(1f);
- dockDivider.setAlpha(1f);
- } else {
- mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 1f),
- ObjectAnimator.ofFloat(dockDivider, "alpha", 1f));
- mDividerAnimator.setDuration(sScrollIndicatorFadeInDuration);
- mDividerAnimator.start();
- }
- }
- }
-
void setFadeForOverScroll(float fade) {
if (!isScrollingIndicatorEnabled()) return;
@@ -3530,42 +3505,4 @@ public class Workspace extends SmoothPagedView
dockDivider.setAlpha(reducedFade);
scrollIndicator.setAlpha(1 - fade);
}
-
- void hideDockDivider(boolean immediately) {
- final ViewGroup parent = (ViewGroup) getParent();
- final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
- final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
- if (qsbDivider != null && dockDivider != null) {
- if (mDividerAnimator != null) {
- mDividerAnimator.cancel();
- mDividerAnimator = null;
- }
- if (immediately) {
- qsbDivider.setVisibility(View.GONE);
- dockDivider.setVisibility(View.GONE);
- qsbDivider.setAlpha(0f);
- dockDivider.setAlpha(0f);
- } else {
- mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 0f),
- ObjectAnimator.ofFloat(dockDivider, "alpha", 0f));
- mDividerAnimator.addListener(new AnimatorListenerAdapter() {
- private boolean cancelled = false;
- @Override
- public void onAnimationCancel(android.animation.Animator animation) {
- cancelled = true;
- }
- @Override
- public void onAnimationEnd(android.animation.Animator animation) {
- if (!cancelled) {
- qsbDivider.setVisibility(View.GONE);
- dockDivider.setVisibility(View.GONE);
- }
- }
- });
- mDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration);
- mDividerAnimator.start();
- }
- }
- }
}