Workarounds for a couple crashes. (Bug 5612584, Bug 5613438)
Change-Id: I9669d830a10cc98291737f3f1d561c846c408289
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index af5141f..c55853e 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -37,7 +37,6 @@
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.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 @@
* 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 boolean onKey(View v, int keyCode, KeyEvent event) {
+ return FocusHelper.handleAppsCustomizeKeyEvent(v, keyCode, event);
+ }
+
/*
* PagedViewWithDraggableItems implementation
*/
@@ -663,14 +667,16 @@
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 @@
icon.setOnClickListener(this);
icon.setOnLongClickListener(this);
icon.setOnTouchListener(this);
+ icon.setOnKeyListener(this);
int index = i - startIndex;
int x = index % mCellCountX;
@@ -1075,6 +1082,7 @@
widget.setOnClickListener(this);
widget.setOnLongClickListener(this);
widget.setOnTouchListener(this);
+ widget.setOnKeyListener(this);
// Layout each widget
int ix = i % mWidgetCountX;