merge in ics-mr1-release history after reset to ics-mr1
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 1b48b8b..742788b 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -63,7 +63,7 @@
<string name="menu_manage_apps" msgid="2308685199463588895">"Administrer apps"</string>
<string name="menu_wallpaper" msgid="5837429080911269832">"Tapet"</string>
<string name="menu_search" msgid="4826514464423239041">"Søg"</string>
- <string name="menu_notifications" msgid="6424587053194766192">"Meddelelser"</string>
+ <string name="menu_notifications" msgid="6424587053194766192">"Underretninger"</string>
<string name="menu_settings" msgid="3946232973327980394">"Systemindstillinger"</string>
<string name="menu_help" msgid="4901160661634590633">"Hjælp"</string>
<string name="cab_menu_delete_app" msgid="4089398025537640349">"Afinstaller appen"</string>
diff --git a/res/values-sw-sw600dp/strings.xml b/res/values-sw-sw600dp/strings.xml
index d65f8de..20b6c86 100644
--- a/res/values-sw-sw600dp/strings.xml
+++ b/res/values-sw-sw600dp/strings.xml
@@ -19,7 +19,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="wallpaper_dialog_title" msgid="6395005465873616423">"Chagua pazia"</string>
- <string name="wallpaper_chooser_empty" msgid="5909737215399452696">"Hakuna pazia zinazopatikana"</string>
+ <string name="wallpaper_dialog_title" msgid="6395005465873616423">"Chagua mandhari"</string>
+ <string name="wallpaper_chooser_empty" msgid="5909737215399452696">"Hakuna mandhari zinazopatikana"</string>
<string name="wallpaper_cancel" msgid="1110492200533814461">"Ghairi"</string>
</resources>
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
index 053ce2e..df786fb 100644
--- a/res/values-sw/strings.xml
+++ b/res/values-sw/strings.xml
@@ -23,8 +23,8 @@
<string name="uid_name" msgid="3371120195364560632">"Programu Kuu za Android"</string>
<string name="folder_name" msgid="8551881338202938211"></string>
<string name="chooser_wallpaper" msgid="6063168087625352235">"Chagua mandhari kutoka"</string>
- <string name="wallpaper_instructions" msgid="4215640646180727542">"Weka pazia"</string>
- <string name="pick_wallpaper" msgid="5630222540525626723">"Taswira"</string>
+ <string name="wallpaper_instructions" msgid="4215640646180727542">"Weka mandhari"</string>
+ <string name="pick_wallpaper" msgid="5630222540525626723">"Mandhari"</string>
<string name="activity_not_found" msgid="217823393239365967">"Programu haijasakinishwa."</string>
<string name="widgets_tab_label" msgid="9145860100000983599">"Wijeti"</string>
<string name="long_press_widget_to_add" msgid="7395697462851217506">"Gusa & ushikilie ili kuteua wijeti."</string>
@@ -39,7 +39,7 @@
<string name="group_applications" msgid="2103752818818161976">"Prog"</string>
<string name="group_shortcuts" msgid="9133529424900391877">"Njia za mkato"</string>
<string name="group_widgets" msgid="6704978494073105844">"Wijeti"</string>
- <string name="group_wallpapers" msgid="1568191644272224858">"Pazia"</string>
+ <string name="group_wallpapers" msgid="1568191644272224858">"Mandhari"</string>
<string name="out_of_space" msgid="8365249326091984698">"Hakuna nafasi katika skrini hii ya nyumbani."</string>
<string name="invalid_hotseat_item" msgid="6545340627805449250">"Wijeti hii ni kubwa zaidi kwa hotseat."</string>
<string name="shortcut_installed" msgid="7071557296331322355">"Njia ya mkato ya \"<xliff:g id="NAME">%s</xliff:g>\" imeundwa."</string>
@@ -61,7 +61,7 @@
<string name="delete_zone_label_all_apps_system_app" msgid="3683920959591819044">"Sanidua sasisho"</string>
<string name="menu_add" msgid="3065046628354640854">"Ongeza"</string>
<string name="menu_manage_apps" msgid="2308685199463588895">"Dhibiti programu"</string>
- <string name="menu_wallpaper" msgid="5837429080911269832">"Pazia"</string>
+ <string name="menu_wallpaper" msgid="5837429080911269832">"Mandhari"</string>
<string name="menu_search" msgid="4826514464423239041">"Tafuta"</string>
<string name="menu_notifications" msgid="6424587053194766192">"Arifa"</string>
<string name="menu_settings" msgid="3946232973327980394">"Mipangilio ya mfumo"</string>
@@ -88,13 +88,13 @@
<string name="workspace_scroll_format" msgid="7911126267695001437">"Nafasi ya kazi %1$d ya %2$d"</string>
<string name="apps_customize_apps_scroll_format" msgid="5494241912377704885">"Ukurasa wa programu %1$d ya %2$d"</string>
<string name="apps_customize_widgets_scroll_format" msgid="5383009742241717437">"Ukurasa wa wijeti %1$d ya %2$d"</string>
- <string name="workspace_cling_title" msgid="738396473989890567">"Jifanyie ujihisi nyumbani"</string>
- <string name="workspace_cling_move_item" msgid="791013895761065070">"Unaweza kuweka prog zako uzipendazo hapa."</string>
- <string name="workspace_cling_open_all_apps" msgid="2459977609848572588">"Kuangalia prog zako zote, gusa durara."</string>
- <string name="all_apps_cling_title" msgid="2559734712581447107">"Chagua baadhi"</string>
- <string name="all_apps_cling_add_item" msgid="5665035103260318891">"Ili kuongeza programu kwa skrini yako ya Nyumbani, gusa & ishikilie."</string>
- <string name="folder_cling_title" msgid="4308949882377840953">"Panga prog zako na folda"</string>
- <string name="folder_cling_move_item" msgid="270598675060435169">"Kuhamisha prog, gusa na; uishikilie."</string>
+ <string name="workspace_cling_title" msgid="738396473989890567">"Jisikie huru"</string>
+ <string name="workspace_cling_move_item" msgid="791013895761065070">"Unaweza kuweka programu unazozipenda zaidi hapa."</string>
+ <string name="workspace_cling_open_all_apps" msgid="2459977609848572588">"Kutazama programu zako zote, gusa duara."</string>
+ <string name="all_apps_cling_title" msgid="2559734712581447107">"Chagua programu kadhaa"</string>
+ <string name="all_apps_cling_add_item" msgid="5665035103260318891">"Ili kuongeza programu kwa skrini yako ya Nyumbani, iguse na uishikilie."</string>
+ <string name="folder_cling_title" msgid="4308949882377840953">"Panga programu zako na folda"</string>
+ <string name="folder_cling_move_item" msgid="270598675060435169">"Kuhamisha programu, gusa na; uishikilie."</string>
<string name="folder_cling_create_folder" msgid="8352867485656129478">"Kuunda folda mpya katika skrini yako ya nyumbani, rundika programu moja juu ya nyingine."</string>
<string name="cling_dismiss" msgid="2780907108735868381">"Sawa"</string>
<string name="folder_opened" msgid="4129072635480822768">"Folda imefunguliwa,%1$d na %2$d"</string>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index 164f1e1..73896b4 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -43,7 +43,7 @@
<string name="out_of_space" msgid="8365249326091984698">"Không còn khoảng trống trên Màn hình chính này."</string>
<string name="invalid_hotseat_item" msgid="6545340627805449250">"Tiện ích này quá lớn cho điểm giới hạn."</string>
<string name="shortcut_installed" msgid="7071557296331322355">"Lối tắt \"<xliff:g id="NAME">%s</xliff:g>\" đã được tạo."</string>
- <string name="shortcut_uninstalled" msgid="2129499669449749995">"Lối tắt \"<xliff:g id="NAME">%s</xliff:g>\" đã bị xoá."</string>
+ <string name="shortcut_uninstalled" msgid="2129499669449749995">"Lối tắt \"<xliff:g id="NAME">%s</xliff:g>\" đã bị xóa."</string>
<string name="shortcut_duplicate" msgid="4757756326465060694">"Lối tắt \"<xliff:g id="NAME">%s</xliff:g>\" đã tồn tại."</string>
<string name="title_select_shortcut" msgid="2858897527672831763">"Chọn lối tắt"</string>
<string name="title_select_application" msgid="1793455815754848652">"Chọn ứng dụng"</string>
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 0189d6c..b732eec 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -393,15 +393,17 @@
mWidgetSpacingLayout.measure(widthSpec, heightSpec);
mContentWidth = mWidgetSpacingLayout.getContentWidth();
+ AppsCustomizeTabHost host = (AppsCustomizeTabHost) getTabHost();
+ final boolean hostIsTransitioning = host.isTransitioning();
+
// Restore the page
int page = getPageForComponent(mSaveInstanceStateItemIndex);
- invalidatePageData(Math.max(0, page));
+ invalidatePageData(Math.max(0, page), hostIsTransitioning);
// Show All Apps cling if we are finished transitioning, otherwise, we will try again when
// the transition completes in AppsCustomizeTabHost (otherwise the wrong offsets will be
// returned while animating)
- AppsCustomizeTabHost host = (AppsCustomizeTabHost) getTabHost();
- if (!host.isTransitioning()) {
+ if (!hostIsTransitioning) {
post(new Runnable() {
@Override
public void run() {
@@ -558,7 +560,8 @@
PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
// Compose the drag image
- Bitmap b;
+ Bitmap preview;
+ Bitmap outline;
if (createItemInfo instanceof PendingAddWidgetInfo) {
PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) createItemInfo;
int[] spanXY = mLauncher.getSpanForWidget(createWidgetInfo, null);
@@ -567,20 +570,17 @@
int[] maxSize = mLauncher.getWorkspace().estimateItemSize(spanXY[0], spanXY[1],
createWidgetInfo, true);
- b = getWidgetPreview(createWidgetInfo.componentName, createWidgetInfo.previewImage,
+ preview = getWidgetPreview(createWidgetInfo.componentName, createWidgetInfo.previewImage,
createWidgetInfo.icon, spanXY[0], spanXY[1], maxSize[0], maxSize[1]);
} else {
// Workaround for the fact that we don't keep the original ResolveInfo associated with
// the shortcut around. To get the icon, we just render the preview image (which has
// the shortcut icon) to a new drag bitmap that clips the non-icon space.
- b = Bitmap.createBitmap(mWidgetPreviewIconPaddedDimension,
+ preview = Bitmap.createBitmap(mWidgetPreviewIconPaddedDimension,
mWidgetPreviewIconPaddedDimension, Bitmap.Config.ARGB_8888);
- Drawable preview = image.getDrawable();
- mCanvas.setBitmap(b);
- mCanvas.save();
- preview.draw(mCanvas);
- mCanvas.restore();
- mCanvas.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY);
+ Drawable d = image.getDrawable();
+ mCanvas.setBitmap(preview);
+ d.draw(mCanvas);
mCanvas.setBitmap(null);
createItemInfo.spanX = createItemInfo.spanY = 1;
}
@@ -595,12 +595,21 @@
}
}
+ // Save the preview for the outline generation, then dim the preview
+ outline = Bitmap.createScaledBitmap(preview, preview.getWidth(), preview.getHeight(),
+ false);
+ mCanvas.setBitmap(preview);
+ mCanvas.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY);
+ mCanvas.setBitmap(null);
+
// Start the drag
+ alphaClipPaint = null;
mLauncher.lockScreenOrientationOnLargeUI();
- mLauncher.getWorkspace().onDragStartedWithItem(createItemInfo, b, alphaClipPaint);
- mDragController.startDrag(image, b, this, createItemInfo,
+ mLauncher.getWorkspace().onDragStartedWithItem(createItemInfo, outline, alphaClipPaint);
+ mDragController.startDrag(image, preview, this, createItemInfo,
DragController.DRAG_ACTION_COPY, null);
- b.recycle();
+ outline.recycle();
+ preview.recycle();
}
@Override
protected boolean beginDragging(View v) {
@@ -662,6 +671,18 @@
cancelAllTasks();
}
+ public void clearAllWidgetPages() {
+ cancelAllTasks();
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ View v = getPageAt(i);
+ if (v instanceof PagedViewGridLayout) {
+ ((PagedViewGridLayout) v).removeAllViewsOnPage();
+ mDirtyPageContent.set(i, true);
+ }
+ }
+ }
+
private void cancelAllTasks() {
// Clean up all the async tasks
Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 778d6bc..2963240 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -366,6 +366,11 @@
}
mContent.setVisibility(VISIBLE);
+ if (!toWorkspace) {
+ // Make sure the current page is loaded (we start loading the side pages after the
+ // transition to prevent slowing down the animation)
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
+ }
if (animated && !delayLauncherTransitionUntilLayout) {
enableAndBuildHardwareLayer();
}
@@ -391,6 +396,9 @@
// Dismiss the workspace cling and show the all apps cling (if not already shown)
l.dismissWorkspaceCling(null);
mAppsCustomizePane.showAllAppsCling();
+ // Make sure adjacent pages are loaded (we wait until after the transition to
+ // prevent slowing down the animation)
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
if (!LauncherApplication.isScreenLarge()) {
mAppsCustomizePane.hideScrollingIndicator(false);
@@ -398,6 +406,23 @@
}
}
+ public void onResume() {
+ if (getVisibility() == VISIBLE) {
+ mContent.setVisibility(VISIBLE);
+ // We unload the widget previews when the UI is hidden, so need to reload pages
+ // Load the current page synchronously, and the neighboring pages asynchronously
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
+ }
+ }
+
+ public void onTrimMemory() {
+ mContent.setVisibility(GONE);
+ // Clear the widget pages of all their subviews - this will trigger the widget previews
+ // to delete their bitmaps
+ mAppsCustomizePane.clearAllWidgetPages();
+ }
+
boolean isTransitioning() {
return mInTransition;
}
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index a6757d7..fdde4d5 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -156,6 +156,7 @@
super.onFinishInflate();
mContent = (CellLayout) findViewById(R.id.folder_content);
mContent.setGridSize(0, 0);
+ mContent.getChildrenLayout().setMotionEventSplittingEnabled(false);
mFolderName = (FolderEditText) findViewById(R.id.folder_name);
mFolderName.setFolder(this);
mFolderName.setOnFocusChangeListener(this);
diff --git a/src/com/android/launcher2/HolographicImageView.java b/src/com/android/launcher2/HolographicImageView.java
index 1d34cd6..9e551e0 100644
--- a/src/com/android/launcher2/HolographicImageView.java
+++ b/src/com/android/launcher2/HolographicImageView.java
@@ -39,6 +39,10 @@
mHolographicHelper = new HolographicViewHelper(context);
}
+ void invalidatePressedFocusedStates() {
+ mHolographicHelper.invalidatePressedFocusedStates(this);
+ }
+
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
diff --git a/src/com/android/launcher2/HolographicLinearLayout.java b/src/com/android/launcher2/HolographicLinearLayout.java
index c6a8d6a..a40c727 100644
--- a/src/com/android/launcher2/HolographicLinearLayout.java
+++ b/src/com/android/launcher2/HolographicLinearLayout.java
@@ -66,6 +66,10 @@
}
}
+ void invalidatePressedFocusedStates() {
+ mHolographicHelper.invalidatePressedFocusedStates(mImageView);
+ }
+
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
diff --git a/src/com/android/launcher2/HolographicViewHelper.java b/src/com/android/launcher2/HolographicViewHelper.java
index 11e81b4..fd49908 100644
--- a/src/com/android/launcher2/HolographicViewHelper.java
+++ b/src/com/android/launcher2/HolographicViewHelper.java
@@ -42,7 +42,7 @@
void generatePressedFocusedStates(ImageView v) {
if (!mStatesUpdated && v != null) {
mStatesUpdated = true;
- Bitmap outline = createGlowingOutline(v, mTempCanvas);
+ Bitmap outline = createPressImage(v, mTempCanvas);
FastBitmapDrawable d = new FastBitmapDrawable(outline);
StateListDrawable states = new StateListDrawable();
@@ -54,10 +54,20 @@
}
/**
- * Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location.
+ * Invalidates the pressed/focused states.
+ */
+ void invalidatePressedFocusedStates(ImageView v) {
+ mStatesUpdated = false;
+ if (v != null) {
+ v.invalidate();
+ }
+ }
+
+ /**
+ * Creates a new press state image which is the old image with a blue overlay.
* Responsibility for the bitmap is transferred to the caller.
*/
- private Bitmap createGlowingOutline(ImageView v, Canvas canvas) {
+ private Bitmap createPressImage(ImageView v, Canvas canvas) {
final int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
final Bitmap b = Bitmap.createBitmap(
v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888);
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java
index 9d7054c..ed8f299 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/android/launcher2/InstallShortcutReceiver.java
@@ -65,11 +65,15 @@
boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);
if (duplicate || !LauncherModel.shortcutExists(context, name, intent)) {
LauncherApplication app = (LauncherApplication) context.getApplicationContext();
- app.getModel().addShortcut(context, data,
+ ShortcutInfo info = app.getModel().addShortcut(context, data,
LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, mCoordinates[0],
mCoordinates[1], true);
- Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
- Toast.LENGTH_SHORT).show();
+ if (info != null) {
+ Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
+ Toast.LENGTH_SHORT).show();
+ } else {
+ return false;
+ }
} else {
Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name),
Toast.LENGTH_SHORT).show();
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 6ea14db..33ead5c 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -36,6 +36,7 @@
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipDescription;
+import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -563,6 +564,7 @@
// When we resume Launcher, a different Activity might be responsible for the app
// market intent, so refresh the icon
updateAppMarketIcon();
+ mAppsCustomizeTabHost.onResume();
if (!mWorkspaceLoading) {
final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
final Workspace workspace = mWorkspace;
@@ -873,6 +875,9 @@
boolean foundCellSpan = false;
ShortcutInfo info = mModel.infoFromShortcutIntent(this, data, null);
+ if (info == null) {
+ return;
+ }
final View view = createShortcut(info);
// First we check if we already know the exact location where we want to add this item.
@@ -1709,6 +1714,8 @@
* @param v The view that was clicked.
*/
public void onClickSearchButton(View v) {
+ v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+
onSearchRequested();
}
@@ -1718,10 +1725,8 @@
* @param v The view that was clicked.
*/
public void onClickVoiceButton(View v) {
- startVoiceSearch();
- }
+ v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
- private void startVoiceSearch() {
Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(intent);
@@ -2397,6 +2402,14 @@
}
}
+ @Override
+ public void onTrimMemory(int level) {
+ super.onTrimMemory(level);
+ if (level == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
+ mAppsCustomizeTabHost.onTrimMemory();
+ }
+ }
+
void showWorkspace(boolean animated) {
Resources res = getResources();
int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
@@ -2661,6 +2674,16 @@
button.setImageDrawable(d.newDrawable(getResources()));
}
+ private void invalidatePressedFocusedStates(View container, View button) {
+ if (container instanceof HolographicLinearLayout) {
+ HolographicLinearLayout layout = (HolographicLinearLayout) container;
+ layout.invalidatePressedFocusedStates();
+ } else if (button instanceof HolographicImageView) {
+ HolographicImageView view = (HolographicImageView) button;
+ view.invalidatePressedFocusedStates();
+ }
+ }
+
private boolean updateGlobalSearchIcon() {
final View searchButtonContainer = findViewById(R.id.search_button_container);
final ImageView searchButton = (ImageView) findViewById(R.id.search_button);
@@ -2678,6 +2701,7 @@
if (searchDivider != null) searchDivider.setVisibility(View.VISIBLE);
if (searchButtonContainer != null) searchButtonContainer.setVisibility(View.VISIBLE);
searchButton.setVisibility(View.VISIBLE);
+ invalidatePressedFocusedStates(searchButtonContainer, searchButton);
return true;
} else {
// We disable both search and voice search when there is no global search provider
@@ -2691,7 +2715,10 @@
}
private void updateGlobalSearchIcon(Drawable.ConstantState d) {
+ final View searchButtonContainer = findViewById(R.id.search_button_container);
+ final View searchButton = (ImageView) findViewById(R.id.search_button);
updateButtonWithDrawable(R.id.search_button, d);
+ invalidatePressedFocusedStates(searchButtonContainer, searchButton);
}
private boolean updateVoiceSearchIcon(boolean searchVisible) {
@@ -2709,6 +2736,7 @@
if (searchDivider != null) searchDivider.setVisibility(View.VISIBLE);
if (voiceButtonContainer != null) voiceButtonContainer.setVisibility(View.VISIBLE);
voiceButton.setVisibility(View.VISIBLE);
+ invalidatePressedFocusedStates(voiceButtonContainer, voiceButton);
return true;
} else {
if (searchDivider != null) searchDivider.setVisibility(View.GONE);
@@ -2719,7 +2747,10 @@
}
private void updateVoiceSearchIcon(Drawable.ConstantState d) {
+ final View voiceButtonContainer = findViewById(R.id.voice_button_container);
+ final View voiceButton = findViewById(R.id.voice_button);
updateButtonWithDrawable(R.id.voice_button, d);
+ invalidatePressedFocusedStates(voiceButtonContainer, voiceButton);
}
/**
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 1755903..50a36a5 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1772,6 +1772,9 @@
ShortcutInfo addShortcut(Context context, Intent data, long container, int screen,
int cellX, int cellY, boolean notify) {
final ShortcutInfo info = infoFromShortcutIntent(context, data, null);
+ if (info == null) {
+ return null;
+ }
addItemToDatabase(context, info, container, screen, cellX, cellY, notify);
return info;
@@ -1835,6 +1838,12 @@
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
+ if (intent == null) {
+ // If the intent is null, we can't construct a valid ShortcutInfo, so we return null
+ Log.e(TAG, "Can't construct ShorcutInfo with null intent");
+ return null;
+ }
+
Bitmap icon = null;
boolean customIcon = false;
ShortcutIconResource iconResource = null;
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 2f66537..3f5652e 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -61,8 +61,6 @@
// the min drag distance for a fling to register, to prevent random page shifts
private static final int MIN_LENGTH_FOR_FLING = 25;
- // The min drag distance to trigger a page shift (regardless of velocity)
- private static final int MIN_LENGTH_FOR_MOVE = 200;
private static final int PAGE_SNAP_ANIMATION_DURATION = 550;
protected static final float NANOTIME_DIV = 1000000000.0f;
@@ -72,6 +70,8 @@
private static final int MINIMUM_SNAP_VELOCITY = 2200;
private static final int MIN_FLING_VELOCITY = 250;
private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
+ // The page is moved more than halfway, automatically move to the next page on touch up.
+ private static final float SIGNIFICANT_MOVE_THRESHOLD = 0.4f;
// the velocity at which a fling gesture will cause us to snap to the next page
protected int mSnapVelocity = 500;
@@ -143,7 +143,7 @@
private PageSwitchListener mPageSwitchListener;
- private ArrayList<Boolean> mDirtyPageContent;
+ protected ArrayList<Boolean> mDirtyPageContent;
// choice modes
protected static final int CHOICE_MODE_NONE = 0;
@@ -1205,24 +1205,25 @@
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
int velocityX = (int) velocityTracker.getXVelocity(activePointerId);
final int deltaX = (int) (x - mDownMotionX);
- boolean isSignificantMove = Math.abs(deltaX) > MIN_LENGTH_FOR_MOVE;
+ final int pageWidth = getScaledMeasuredWidth(getPageAt(mCurrentPage));
+ boolean isSignificantMove = Math.abs(deltaX) > pageWidth *
+ SIGNIFICANT_MOVE_THRESHOLD;
final int snapVelocity = mSnapVelocity;
mTotalMotionX += Math.abs(mLastMotionX + mLastMotionXRemainder - x);
+ boolean isFling = mTotalMotionX > MIN_LENGTH_FOR_FLING &&
+ Math.abs(velocityX) > snapVelocity;
+
// In the case that the page is moved far to one direction and then is flung
// in the opposite direction, we use a threshold to determine whether we should
// just return to the starting page, or if we should skip one further.
boolean returnToOriginalPage = false;
- final int pageWidth = getScaledMeasuredWidth(getPageAt(mCurrentPage));
if (Math.abs(deltaX) > pageWidth * RETURN_TO_ORIGINAL_PAGE_THRESHOLD &&
- Math.signum(velocityX) != Math.signum(deltaX)) {
+ Math.signum(velocityX) != Math.signum(deltaX) && isFling) {
returnToOriginalPage = true;
}
- boolean isFling = mTotalMotionX > MIN_LENGTH_FOR_FLING &&
- Math.abs(velocityX) > snapVelocity;
-
int finalPage;
// We give flings precedence over large moves, which is why we short-circuit our
// test for a large move if a fling has been registered. That is, a large
diff --git a/src/com/android/launcher2/PagedViewGridLayout.java b/src/com/android/launcher2/PagedViewGridLayout.java
index 5c32e09..b1b6215 100644
--- a/src/com/android/launcher2/PagedViewGridLayout.java
+++ b/src/com/android/launcher2/PagedViewGridLayout.java
@@ -68,6 +68,12 @@
heightMeasureSpec);
}
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ mOnLayoutListener = null;
+ }
+
public void setOnLayoutListener(Runnable r) {
mOnLayoutListener = r;
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 79e9942..d4e8ad4 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -57,6 +57,7 @@
import android.view.DragEvent;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
@@ -1280,21 +1281,34 @@
return (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground);
}
- @Override
- protected void dispatchDraw(Canvas canvas) {
+ public void scrollTo (int x, int y) {
+ super.scrollTo(x, y);
+ syncChildrenLayersEnabledOnVisiblePages();
+ }
+
+ // This method just applies the value mChildrenLayersEnabled to all the pages that
+ // will be rendered on the next frame.
+ // We do this because calling setChildrenLayersEnabled on a view that's not
+ // visible/rendered causes slowdowns on some graphics cards
+ private void syncChildrenLayersEnabledOnVisiblePages() {
if (mChildrenLayersEnabled) {
getVisiblePages(mTempVisiblePagesRange);
final int leftScreen = mTempVisiblePagesRange[0];
final int rightScreen = mTempVisiblePagesRange[1];
if (leftScreen != -1 && rightScreen != -1) {
- // calling setChildrenLayersEnabled on a view that's not visible/rendered
- // causes slowdowns on some graphics cards, so we set it here to be sure
- // it's only called when it's safe (ie when the view will be rendered)
for (int i = leftScreen; i <= rightScreen; i++) {
- ((ViewGroup)getPageAt(i)).setChildrenLayersEnabled(true);
+ ViewGroup page = (ViewGroup) getPageAt(i);
+ if (page.getVisibility() == VISIBLE &&
+ page.getAlpha() > ViewConfiguration.ALPHA_THRESHOLD) {
+ ((ViewGroup)getPageAt(i)).setChildrenLayersEnabled(true);
+ }
}
}
}
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mInScrollArea && !LauncherApplication.isScreenLarge()) {
@@ -1723,6 +1737,7 @@
b * mNewBackgroundAlphaMultipliers[i]);
cl.setFastAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]);
}
+ syncChildrenLayersEnabledOnVisiblePages();
}
});
@@ -1760,6 +1775,7 @@
// Fade the background gradient away
animateBackgroundGradient(0f, true);
}
+ syncChildrenLayersEnabledOnVisiblePages();
}
/**
@@ -1875,9 +1891,7 @@
// center the image
dst.offset((w - scaledWidth) / 2, (h - scaledHeight) / 2);
- Paint p = new Paint();
- p.setFilterBitmap(true);
- canvas.drawBitmap(orig, src, dst, p);
+ canvas.drawBitmap(orig, src, dst, null);
mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor,
alphaClipPaint);
canvas.setBitmap(null);
@@ -2038,9 +2052,18 @@
return true;
}
-
// Don't accept the drop if there's no room for the item
if (!mDragTargetLayout.findCellForSpanIgnoring(null, spanX, spanY, ignoreView)) {
+ // Don't show the message if we are dropping on the AllApps button and the hotseat
+ // is full
+ if (mTargetCell != null && mLauncher.isHotseatLayout(mDragTargetLayout)) {
+ Hotseat hotseat = mLauncher.getHotseat();
+ if (Hotseat.isAllAppsButtonRank(
+ hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) {
+ return false;
+ }
+ }
+
mLauncher.showOutOfSpaceMessage();
return false;
}
@@ -2347,6 +2370,7 @@
mDragTargetLayout.onDragExit();
}
mLastDragOverView = null;
+ mSpringLoadedDragController.cancel();
if (!mIsPageMoving) {
hideOutlines();
@@ -2455,7 +2479,9 @@
if (isShortcut) {
final Intent intent = data.getItemAt(index).getIntent();
Object info = model.infoFromShortcutIntent(mContext, intent, data.getIcon());
- onDropExternal(new int[] { x, y }, info, layout, false);
+ if (info != null) {
+ onDropExternal(new int[] { x, y }, info, layout, false);
+ }
} else {
if (widgets.size() == 1) {
// If there is only one item, then go ahead and add and configure
@@ -2620,7 +2646,7 @@
return cl;
}
- if (!exact && overlaps(cl, dragView, (int) originX, (int) originY, mTempInverseMatrix)) {
+ if (!exact) {
// Get the center of the cell layout in screen coordinates
final float[] cellLayoutCenter = mTempCellLayoutCenterCoordinates;
cellLayoutCenter[0] = cl.getWidth()/2;
@@ -2706,7 +2732,7 @@
}
}
if (layout == null) {
- layout = findMatchingPageForDragOver(d.dragView, d.x, d.y, true);
+ layout = findMatchingPageForDragOver(d.dragView, d.x, d.y, false);
}
if (layout != mDragTargetLayout) {
// Cancel all intermediate folder states