Merge "Making all provider calls using content resolver." into ub-launcher3-master
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
index 4be6f17..3554ca7 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
@@ -108,6 +108,7 @@
new View.OnClickListener() {
@Override
public void onClick(View v) {
+ actionBar.hide();
// Never fade on finish because we return to the app that started us (e.g.
// Photos), not the home screen.
cropImageAndSetWallpaper(imageUri, null, false /* shouldFadeOutOnFinish */);
diff --git a/res/values-fr-rCA/strings.xml b/res/values-fr-rCA/strings.xml
index 1c957e7..ca6eccc 100644
--- a/res/values-fr-rCA/strings.xml
+++ b/res/values-fr-rCA/strings.xml
@@ -46,7 +46,7 @@
<string name="permdesc_read_settings" msgid="5833423719057558387">"Permet à l\'application de lire les paramètres et les raccourcis de l\'écran d\'accueil."</string>
<string name="permlab_write_settings" msgid="3574213698004620587">"enregistrer les paramètres de la page d\'accueil et des raccourcis"</string>
<string name="permdesc_write_settings" msgid="5440712911516509985">"Permet à l\'application de modifier les paramètres et les raccourcis de l\'écran d\'accueil."</string>
- <string name="msg_no_phone_permission" msgid="9208659281529857371">"<xliff:g id="APP_NAME">%1$s</xliff:g> n\'est pas autorisée à faire des appels téléphoniques"</string>
+ <string name="msg_no_phone_permission" msgid="9208659281529857371">"L\'application <xliff:g id="APP_NAME">%1$s</xliff:g> n\'est pas autorisée à faire des appels téléphoniques"</string>
<string name="gadget_error_text" msgid="6081085226050792095">"Problème lors du chargement du widget"</string>
<string name="gadget_setup_text" msgid="8274003207686040488">"Configuration"</string>
<string name="uninstall_system_app_text" msgid="4172046090762920660">"Impossible de désinstaller cette application, car il s\'agit d\'une application système."</string>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index bfad879..b76991b 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -46,7 +46,7 @@
<string name="permdesc_read_settings" msgid="5833423719057558387">"允许应用读取主屏幕中的设置和快捷方式。"</string>
<string name="permlab_write_settings" msgid="3574213698004620587">"写入主屏幕设置和快捷方式"</string>
<string name="permdesc_write_settings" msgid="5440712911516509985">"允许应用更改主屏幕中的设置和快捷方式。"</string>
- <string name="msg_no_phone_permission" msgid="9208659281529857371">"不允许使用<xliff:g id="APP_NAME">%1$s</xliff:g>拨打电话"</string>
+ <string name="msg_no_phone_permission" msgid="9208659281529857371">"不允许使用“<xliff:g id="APP_NAME">%1$s</xliff:g>”拨打电话"</string>
<string name="gadget_error_text" msgid="6081085226050792095">"加载小部件时出现问题"</string>
<string name="gadget_setup_text" msgid="8274003207686040488">"设置"</string>
<string name="uninstall_system_app_text" msgid="4172046090762920660">"这是系统应用,无法卸载。"</string>
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 10db459..a3b92dc 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -252,6 +252,9 @@
FastBitmapDrawable d = (FastBitmapDrawable) mIcon;
if (isPressed() || mStayPressed) {
d.animateState(FastBitmapDrawable.State.PRESSED);
+ } else if (getTag() instanceof ShortcutInfo
+ && ((ShortcutInfo) getTag()).isDisabled != 0) {
+ d.animateState(FastBitmapDrawable.State.DISABLED);
} else {
d.animateState(FastBitmapDrawable.State.NORMAL);
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 4ee8a51..feb5f92 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -104,7 +104,6 @@
private int searchBarSpaceWidthPx;
private int searchBarSpaceHeightNormalPx, searchBarSpaceHeightTallPx;
private int searchBarSpaceHeightPx; // One of the above.
- private int searchBarHeight = LauncherCallbacks.SEARCH_BAR_HEIGHT_NORMAL;
public DeviceProfile(Context context, InvariantDeviceProfile inv,
Point minSize, Point maxSize,
@@ -408,13 +407,8 @@
return visibleChildren;
}
- public void layout(Launcher launcher) {
- FrameLayout.LayoutParams lp;
- boolean hasVerticalBarLayout = isVerticalBarLayout();
- final boolean isLayoutRtl = Utilities.isRtl(launcher.getResources());
-
- // Layout the search bar space
- searchBarHeight = launcher.getSearchBarHeight();
+ // TODO(twickham): b/25154513
+ public void setSearchBarHeight(int searchBarHeight) {
if (searchBarHeight == LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL) {
hotseatBarHeightPx = hotseatBarHeightShortPx;
searchBarSpaceHeightPx = searchBarSpaceHeightTallPx;
@@ -422,6 +416,14 @@
hotseatBarHeightPx = hotseatBarHeightNormalPx;
searchBarSpaceHeightPx = searchBarSpaceHeightNormalPx;
}
+ }
+
+ public void layout(Launcher launcher) {
+ FrameLayout.LayoutParams lp;
+ boolean hasVerticalBarLayout = isVerticalBarLayout();
+ final boolean isLayoutRtl = Utilities.isRtl(launcher.getResources());
+
+ // Layout the search bar space
View searchBar = launcher.getSearchDropTargetBar();
lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, searchBar, Gravity.TOP);
searchBar.setLayoutParams(lp);
@@ -542,7 +544,7 @@
// Vertical drop target bar space -- The drop target bar is fixed in the layout to be on
// the left of the screen regardless of RTL
lp.gravity = Gravity.LEFT;
- lp.width = searchBarSpaceHeightPx;
+ lp.width = searchBarSpaceHeightNormalPx;
LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar);
targets.setOrientation(LinearLayout.VERTICAL);
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index da32e7e..310b636 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -432,7 +432,7 @@
/**
* Creates a new UserFolder, inflated from R.layout.user_folder.
*
- * @param context The application's context.
+ * @param launcher The main activity.
*
* @return A new UserFolder.
*/
@@ -649,9 +649,8 @@
oa.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- onCloseComplete();
setLayerType(LAYER_TYPE_NONE, null);
- mState = STATE_SMALL;
+ close();
}
@Override
public void onAnimationStart(Animator animation) {
@@ -665,6 +664,32 @@
oa.start();
}
+ public void close() {
+ // TODO: Clear all active animations.
+ DragLayer parent = (DragLayer) getParent();
+ if (parent != null) {
+ parent.removeView(this);
+ }
+ mDragController.removeDropTarget(this);
+ clearFocus();
+ mFolderIcon.requestFocus();
+
+ if (mRearrangeOnClose) {
+ rearrangeChildren();
+ mRearrangeOnClose = false;
+ }
+ if (getItemCount() <= 1) {
+ if (!mDragInProgress && !mSuppressFolderDeletion) {
+ replaceFolderWithFinalItem();
+ } else if (mDragInProgress) {
+ mDeleteFolderOnDropCompleted = true;
+ }
+ }
+ mSuppressFolderDeletion = false;
+ clearDragInfo();
+ mState = STATE_SMALL;
+ }
+
public boolean acceptDrop(DragObject d) {
final ItemInfo item = d.dragInfo;
final int itemType = item.itemType;
@@ -1102,30 +1127,6 @@
return mContent.getItemCount();
}
- @Thunk void onCloseComplete() {
- DragLayer parent = (DragLayer) getParent();
- if (parent != null) {
- parent.removeView(this);
- }
- mDragController.removeDropTarget((DropTarget) this);
- clearFocus();
- mFolderIcon.requestFocus();
-
- if (mRearrangeOnClose) {
- rearrangeChildren();
- mRearrangeOnClose = false;
- }
- if (getItemCount() <= 1) {
- if (!mDragInProgress && !mSuppressFolderDeletion) {
- replaceFolderWithFinalItem();
- } else if (mDragInProgress) {
- mDeleteFolderOnDropCompleted = true;
- }
- }
- mSuppressFolderDeletion = false;
- clearDragInfo();
- }
-
@Thunk void replaceFolderWithFinalItem() {
// Add the last remaining child to the workspace in place of the folder
Runnable onCompleteRunnable = new Runnable() {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3897d9e..19bdea0 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -441,6 +441,8 @@
setContentView(R.layout.launcher);
+ app.getInvariantDeviceProfile().landscapeProfile.setSearchBarHeight(getSearchBarHeight());
+ app.getInvariantDeviceProfile().portraitProfile.setSearchBarHeight(getSearchBarHeight());
setupViews();
mDeviceProfile.layout(this);
@@ -1878,7 +1880,7 @@
// In all these cases, only animate if we're already on home
mWorkspace.exitWidgetResizeMode();
- closeFolder();
+ closeFolder(alreadyOnHome);
exitSpringLoadedDragMode();
// If we are already on home, then just animate back to the workspace,
@@ -1891,7 +1893,7 @@
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
- InputMethodManager imm = (InputMethodManager)getSystemService(
+ InputMethodManager imm = (InputMethodManager) getSystemService(
INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
@@ -1930,7 +1932,9 @@
mWorkspace.post(new Runnable() {
@Override
public void run() {
- mWorkspace.moveToDefaultScreen(true);
+ if (mWorkspace != null) {
+ mWorkspace.moveToDefaultScreen(true);
+ }
}
});
}
@@ -1960,7 +1964,7 @@
outState.putInt(RUNTIME_STATE, mState.ordinal());
// We close any open folder since it will not be re-opened, and we need to make sure
// this state is reflected.
- closeFolder();
+ closeFolder(false);
if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 &&
mWaitingForResult) {
@@ -2750,7 +2754,7 @@
if (openFolder != null) {
folderScreen = mWorkspace.getPageForView(openFolder);
// .. and close it
- closeFolder(openFolder);
+ closeFolder(openFolder, true);
if (folderScreen != mWorkspace.getCurrentPage()) {
// Close any folder open on the current screen
closeFolder();
@@ -3086,7 +3090,7 @@
oa.start();
}
- private void shrinkAndFadeInFolderIcon(final FolderIcon fi) {
+ private void shrinkAndFadeInFolderIcon(final FolderIcon fi, boolean animate) {
if (fi == null) return;
final CellLayout cl = (CellLayout) fi.getParent().getParent();
@@ -3107,6 +3111,9 @@
}
});
oa.start();
+ if (!animate) {
+ oa.end();
+ }
}
/**
@@ -3150,30 +3157,38 @@
}
public void closeFolder() {
+ closeFolder(true);
+ }
+
+ public void closeFolder(boolean animate) {
Folder folder = mWorkspace != null ? mWorkspace.getOpenFolder() : null;
if (folder != null) {
if (folder.isEditingName()) {
folder.dismissEditingName();
}
- closeFolder(folder);
+ closeFolder(folder, animate);
}
}
- public void closeFolder(Folder folder) {
+ public void closeFolder(Folder folder, boolean animate) {
folder.getInfo().opened = false;
ViewGroup parent = (ViewGroup) folder.getParent().getParent();
if (parent != null) {
FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo);
- shrinkAndFadeInFolderIcon(fi);
+ shrinkAndFadeInFolderIcon(fi, animate);
if (fi != null) {
((CellLayout.LayoutParams) fi.getLayoutParams()).canReorder = true;
}
}
- folder.animateClosed();
+ if (animate) {
+ folder.animateClosed();
+ } else {
+ folder.close();
+ }
- // Notify the accessibility manager that this folder "window" has disappeard and no
- // longer occludeds the workspace items
+ // Notify the accessibility manager that this folder "window" has disappeared and no
+ // longer occludes the workspace items
getDragLayer().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
@@ -3590,6 +3605,10 @@
opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight);
opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth);
opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth);
+ if (LOGD) {
+ Log.d(TAG, "QSB widget options: maxHeight=" + maxHeight + " minHeight=" + minHeight
+ + " maxWidth=" + maxWidth + " minWidth=" + minWidth);
+ }
if (mLauncherCallbacks != null) {
opts.putAll(mLauncherCallbacks.getAdditionalSearchWidgetOptions());
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index 603b072..10c1053 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -428,8 +428,9 @@
float iconScale = Math.min((float) smallestSide / (appIconSize + 2 * minOffset), scale);
try {
- Drawable icon = mutateOnMainThread(mManager.loadIcon(info, mIconCache));
+ Drawable icon = mManager.loadIcon(info, mIconCache);
if (icon != null) {
+ icon = mutateOnMainThread(icon);
int hoffset = (int) ((tileW - appIconSize * iconScale) / 2) + x;
int yoffset = (int) ((tileH - appIconSize * iconScale) / 2);
icon.setBounds(hoffset, yoffset,
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index f5db6c0..03731d1 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -172,7 +172,7 @@
return true;
} else if (action == MOVE_TO_WORKSPACE) {
Folder folder = mLauncher.getWorkspace().getOpenFolder();
- mLauncher.closeFolder(folder);
+ mLauncher.closeFolder(folder, true);
ShortcutInfo info = (ShortcutInfo) item;
folder.getInfo().remove(info);
diff --git a/src/com/android/launcher3/util/FocusLogic.java b/src/com/android/launcher3/util/FocusLogic.java
index 1c6efbc..7f0da77 100644
--- a/src/com/android/launcher3/util/FocusLogic.java
+++ b/src/com/android/launcher3/util/FocusLogic.java
@@ -48,7 +48,7 @@
private static final String TAG = "FocusLogic";
private static final boolean DEBUG = false;
- // Item and page index related constant used by {@link #handleKeyEvent}.
+ /** Item and page index related constant used by {@link #handleKeyEvent}. */
public static final int NOOP = -1;
public static final int PREVIOUS_PAGE_RIGHT_COLUMN = -2;
@@ -91,7 +91,7 @@
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, -1 /*increment*/);
- if (isRtl && newIndex == NOOP && pageIndex > 0) {
+ if (!isRtl && newIndex == NOOP && pageIndex > 0) {
newIndex = PREVIOUS_PAGE_RIGHT_COLUMN;
} else if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
newIndex = NEXT_PAGE_RIGHT_COLUMN;
@@ -99,7 +99,7 @@
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, 1 /*increment*/);
- if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
+ if (!isRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
newIndex = NEXT_PAGE_LEFT_COLUMN;
} else if (isRtl && newIndex == NOOP && pageIndex > 0) {
newIndex = PREVIOUS_PAGE_LEFT_COLUMN;
@@ -165,8 +165,12 @@
// Iterate thru the children.
for (int i = 0; i < parent.getChildCount(); i++ ) {
- int cx = ((CellLayout.LayoutParams) parent.getChildAt(i).getLayoutParams()).cellX;
- int cy = ((CellLayout.LayoutParams) parent.getChildAt(i).getLayoutParams()).cellY;
+ View cell = parent.getChildAt(i);
+ if (!cell.isFocusable()) {
+ continue;
+ }
+ int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX;
+ int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY;
matrix[invert ? (m - cx - 1) : cx][cy] = i;
}
if (DEBUG) {
@@ -199,8 +203,12 @@
// Iterate thru the children of the top parent.
for (int i = 0; i < iconParent.getChildCount(); i++) {
- int cx = ((CellLayout.LayoutParams) iconParent.getChildAt(i).getLayoutParams()).cellX;
- int cy = ((CellLayout.LayoutParams) iconParent.getChildAt(i).getLayoutParams()).cellY;
+ View cell = iconParent.getChildAt(i);
+ if (!cell.isFocusable()) {
+ continue;
+ }
+ int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX;
+ int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY;
matrix[cx][cy] = i;
}
@@ -253,8 +261,12 @@
// Iterate thru the children of the top parent.
for (int i = 0; i < iconParent.getChildCount(); i++) {
- int cx = ((CellLayout.LayoutParams) iconParent.getChildAt(i).getLayoutParams()).cellX;
- int cy = ((CellLayout.LayoutParams) iconParent.getChildAt(i).getLayoutParams()).cellY;
+ View cell = iconParent.getChildAt(i);
+ if (!cell.isFocusable()) {
+ continue;
+ }
+ int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX;
+ int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY;
if (pivotX < 0) {
matrix[cx - pivotX][cy] = i;
} else {