* commit 'de7e97adfb9eb5806511480743a59770819195fc': Workarounds for a couple crashes. (Bug 5612584, Bug 5613438)
This commit is contained in:
@@ -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";
|
||||
|
||||
/**
|
||||
@@ -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
|
||||
*/
|
||||
@@ -663,14 +667,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
|
||||
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 +726,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;
|
||||
@@ -1075,6 +1082,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;
|
||||
|
||||
@@ -202,6 +202,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 +220,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);
|
||||
|
||||
@@ -752,17 +752,18 @@ public abstract class PagedView extends ViewGroup {
|
||||
getVisiblePages(mTempVisiblePagesRange);
|
||||
final int leftScreen = mTempVisiblePagesRange[0];
|
||||
final int rightScreen = mTempVisiblePagesRange[1];
|
||||
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);
|
||||
|
||||
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);
|
||||
for (int i = rightScreen; i >= leftScreen; i--) {
|
||||
drawChild(canvas, getPageAt(i), drawingTime);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -154,18 +154,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;
|
||||
|
||||
@@ -182,18 +182,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
|
||||
return super.onTouchEvent(event) || true;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
Reference in New Issue
Block a user