diff options
Diffstat (limited to 'src/com/android/launcher3')
40 files changed, 203 insertions, 935 deletions
diff --git a/src/com/android/launcher3/AddAdapter.java b/src/com/android/launcher3/AddAdapter.java index ad15e75c6..5308a3de4 100644 --- a/src/com/android/launcher3/AddAdapter.java +++ b/src/com/android/launcher3/AddAdapter.java @@ -27,8 +27,6 @@ import android.widget.TextView; import java.util.ArrayList; -import com.android.launcher3.R; - /** * Adapter showing the types of items that can be added to a {@link Workspace}. */ diff --git a/src/com/android/launcher3/AllAppsList.java b/src/com/android/launcher3/AllAppsList.java index d955e4eae..b641eb5b3 100644 --- a/src/com/android/launcher3/AllAppsList.java +++ b/src/com/android/launcher3/AllAppsList.java @@ -16,9 +16,6 @@ package com.android.launcher3; -import java.util.ArrayList; -import java.util.List; - import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -26,6 +23,9 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import java.util.ArrayList; +import java.util.List; + /** * Stores the list of all applications for the all apps view. diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java index 53f81bb1c..d5a776901 100644 --- a/src/com/android/launcher3/AppInfo.java +++ b/src/com/android/launcher3/AppInfo.java @@ -18,9 +18,9 @@ package com.android.launcher3; import android.content.ComponentName; import android.content.Intent; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.pm.PackageInfo; import android.content.pm.ResolveInfo; import android.graphics.Bitmap; import android.util.Log; diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index fcb04ea08..f57f4d036 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -13,8 +13,6 @@ import android.view.Gravity; import android.widget.FrameLayout; import android.widget.ImageView; -import com.android.launcher3.R; - public class AppWidgetResizeFrame extends FrameLayout { private LauncherAppWidgetHostView mWidgetView; private CellLayout mCellLayout; diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 30016e5b3..ee42904dd 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Rect; import android.graphics.Region; import android.graphics.Region.Op; diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index d51ae46e8..019f86c21 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -25,8 +25,6 @@ import android.util.AttributeSet; import android.view.View; import android.widget.TextView; -import com.android.launcher3.R; - /** * Implements a DropTarget. diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 75f6a196c..2436a51a3 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -35,7 +35,6 @@ import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.NinePatchDrawable; import android.os.Parcelable; import android.util.AttributeSet; import android.util.Log; @@ -48,7 +47,6 @@ import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; import android.view.animation.LayoutAnimationController; -import com.android.launcher3.R; import com.android.launcher3.FolderIcon.FolderRingAnimator; import java.util.ArrayList; @@ -100,6 +98,7 @@ public class CellLayout extends ViewGroup { private int mForegroundAlpha = 0; private float mBackgroundAlpha; private float mBackgroundAlphaMultiplier = 1.0f; + private boolean mDrawBackground = true; private Drawable mNormalBackground; private Drawable mActiveGlowBackground; @@ -200,7 +199,7 @@ public class CellLayout extends ViewGroup { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0); mCellWidth = mCellHeight = -1; - mFixedCellHeight = mFixedCellHeight = -1; + mFixedCellWidth = mFixedCellHeight = -1; mWidthGap = mOriginalWidthGap = 0; mHeightGap = mOriginalHeightGap = 0; mMaxGap = Integer.MAX_VALUE; @@ -388,6 +387,10 @@ public class CellLayout extends ViewGroup { mUseActiveGlowBackground = use; } + void disableBackground() { + mDrawBackground = false; + } + boolean getIsDragOverlapping() { return mIsDragOverlapping; } @@ -416,7 +419,7 @@ public class CellLayout extends ViewGroup { // When we're small, we are either drawn normally or in the "accepts drops" state (during // a drag). However, we also drag the mini hover background *over* one of those two // backgrounds - if (mBackgroundAlpha > 0.0f) { + if (mDrawBackground && mBackgroundAlpha > 0.0f) { Drawable bg; if (mUseActiveGlowBackground) { diff --git a/src/com/android/launcher3/CheckableFrameLayout.java b/src/com/android/launcher3/CheckableFrameLayout.java deleted file mode 100644 index 5b7d82425..000000000 --- a/src/com/android/launcher3/CheckableFrameLayout.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2013 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.launcher3; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.Checkable; -import android.widget.FrameLayout; - -public class CheckableFrameLayout extends FrameLayout implements Checkable { - private static final int[] CHECKED_STATE_SET = { android.R.attr.state_checked }; - boolean mChecked; - - public CheckableFrameLayout(Context context) { - super(context); - } - - public CheckableFrameLayout(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public CheckableFrameLayout(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public boolean isChecked() { - return mChecked; - } - - public void setChecked(boolean checked) { - if (checked != mChecked) { - mChecked = checked; - refreshDrawableState(); - } - } - - public void toggle() { - setChecked(!mChecked); - } - - @Override - protected int[] onCreateDrawableState(int extraSpace) { - final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); - if (isChecked()) { - mergeDrawableStates(drawableState, CHECKED_STATE_SET); - } - return drawableState; - } -} diff --git a/src/com/android/launcher3/Cling.java b/src/com/android/launcher3/Cling.java index 9974acde6..3af427139 100644 --- a/src/com/android/launcher3/Cling.java +++ b/src/com/android/launcher3/Cling.java @@ -18,9 +18,8 @@ package com.android.launcher3; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; -import android.app.ActivityOptions; -import android.content.Context; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.content.res.TypedArray; diff --git a/src/com/android/launcher3/DeferredHandler.java b/src/com/android/launcher3/DeferredHandler.java index 92ecf9643..a2d121d63 100644 --- a/src/com/android/launcher3/DeferredHandler.java +++ b/src/com/android/launcher3/DeferredHandler.java @@ -21,6 +21,7 @@ import android.os.Looper; import android.os.Message; import android.os.MessageQueue; import android.util.Pair; + import java.util.LinkedList; import java.util.ListIterator; diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java index a8ac0746c..c76425a5e 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -266,19 +266,8 @@ public class DeleteDropTarget extends ButtonDropTarget { private boolean isUninstallFromWorkspace(DragObject d) { if (AppsCustomizePagedView.DISABLE_ALL_APPS && isWorkspaceOrFolderApplication(d)) { ShortcutInfo shortcut = (ShortcutInfo) d.dragInfo; - if (shortcut.intent != null && shortcut.intent.getComponent() != null) { - Set<String> categories = shortcut.intent.getCategories(); - boolean includesLauncherCategory = false; - if (categories != null) { - for (String category : categories) { - if (category.equals(Intent.CATEGORY_LAUNCHER)) { - includesLauncherCategory = true; - break; - } - } - } - return includesLauncherCategory; - } + // Only allow manifest shortcuts to initiate an un-install. + return !InstallShortcutReceiver.isValidShortcutLaunchIntent(shortcut.intent); } return false; } diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 511b7182f..67b0933c9 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -119,6 +119,8 @@ public class DeviceProfile { int searchBarHeightPx; int pageIndicatorHeightPx; + float dragViewScale; + private ArrayList<DeviceProfileCallbacks> mCallbacks = new ArrayList<DeviceProfileCallbacks>(); DeviceProfile(String n, float w, float h, float r, float c, @@ -282,11 +284,12 @@ public class DeviceProfile { // Check to see if the icons fit in the new available height. If not, then we need to // shrink the icon size. - Rect workspacePadding = getWorkspacePadding(); float scale = 1f; int drawablePadding = iconDrawablePaddingOriginalPx; updateIconSize(1f, drawablePadding, resources, dm); float usedHeight = (cellHeightPx * numRows); + + Rect workspacePadding = getWorkspacePadding(); int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom); if (usedHeight > maxHeight) { scale = maxHeight / usedHeight; @@ -319,6 +322,8 @@ public class DeviceProfile { FontMetrics fm = textPaint.getFontMetrics(); cellWidthPx = iconSizePx; cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top); + final float scaleDps = resources.getDimensionPixelSize(R.dimen.dragViewScale); + dragViewScale = (iconSizePx + scaleDps) / iconSizePx; // Hotseat hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx; @@ -491,17 +496,21 @@ public class DeviceProfile { if (isTablet()) { // Pad the left and right of the workspace to ensure consistent spacing // between all icons + float gapScale = 1f + (dragViewScale - 1f) / 2f; int width = (orientation == CellLayout.LANDSCAPE) ? Math.max(widthPx, heightPx) : Math.min(widthPx, heightPx); - // XXX: If the icon size changes across orientations, we will have to take - // that into account here too. - int gap = (int) ((width - 2 * edgeMarginPx - - (numColumns * cellWidthPx)) / (2 * (numColumns + 1))); - padding.set(edgeMarginPx + gap, - searchBarBounds.bottom, - edgeMarginPx + gap, - hotseatBarHeightPx + pageIndicatorHeightPx); + int height = (orientation != CellLayout.LANDSCAPE) + ? Math.max(widthPx, heightPx) + : Math.min(widthPx, heightPx); + int paddingTop = searchBarBounds.bottom; + int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx; + int availableWidth = Math.max(0, width - (int) ((numColumns * cellWidthPx) + + (numColumns * gapScale * cellWidthPx))); + int availableHeight = Math.max(0, height - paddingTop - paddingBottom + - (int) (2 * numRows * cellHeightPx)); + padding.set(availableWidth / 2, paddingTop + availableHeight / 2, + availableWidth / 2, paddingBottom + availableHeight / 2); } else { // Pad the top and bottom of the workspace with search/hotseat bar sizes padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left, @@ -514,8 +523,8 @@ public class DeviceProfile { } int getWorkspacePageSpacing(int orientation) { - if (orientation == CellLayout.LANDSCAPE && - transposeLayoutWithOrientation) { + if ((orientation == CellLayout.LANDSCAPE && + transposeLayoutWithOrientation) || isLargeTablet()) { // In landscape mode the page spacing is set to the default. return defaultPageSpacingPx; } else { @@ -645,19 +654,12 @@ public class DeviceProfile { lp.height = LayoutParams.MATCH_PARENT; hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx); } else if (isTablet()) { - // Pad the hotseat with the grid gap calculated above - int gridGap = (int) ((widthPx - 2 * edgeMarginPx - - (numColumns * cellWidthPx)) / (2 * (numColumns + 1))); - int gridWidth = (int) ((numColumns * cellWidthPx) + - ((numColumns - 1) * gridGap)); - int hotseatGap = (int) Math.max(0, - (gridWidth - (numHotseatIcons * hotseatCellWidthPx)) - / (numHotseatIcons - 1)); + // Pad the hotseat with the workspace padding calculated above lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; lp.height = hotseatBarHeightPx; - hotseat.setPadding(2 * edgeMarginPx + gridGap + hotseatGap, 0, - 2 * edgeMarginPx + gridGap + hotseatGap, + hotseat.setPadding(edgeMarginPx + padding.left, 0, + edgeMarginPx + padding.right, 2 * edgeMarginPx); } else { // For phones, layout the hotseat without any bottom margin diff --git a/src/com/android/launcher3/DragController.java b/src/com/android/launcher3/DragController.java index 1bfaa233b..4c3ea2a0a 100644 --- a/src/com/android/launcher3/DragController.java +++ b/src/com/android/launcher3/DragController.java @@ -28,7 +28,6 @@ import android.os.IBinder; import android.util.Log; import android.view.*; import android.view.inputmethod.InputMethodManager; -import com.android.launcher3.R; import java.util.ArrayList; diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java index 56886a19c..8726f30c1 100644 --- a/src/com/android/launcher3/DragLayer.java +++ b/src/com/android/launcher3/DragLayer.java @@ -224,22 +224,19 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName()); mHoverPointClosesFolder = true; return true; - } else if (isOverFolder) { - mHoverPointClosesFolder = false; - } else { - return true; } + mHoverPointClosesFolder = false; + break; case MotionEvent.ACTION_HOVER_MOVE: isOverFolder = isEventOverFolder(currentFolder, ev); if (!isOverFolder && !mHoverPointClosesFolder) { sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName()); mHoverPointClosesFolder = true; return true; - } else if (isOverFolder) { - mHoverPointClosesFolder = false; - } else { + } else if (!isOverFolder) { return true; } + mHoverPointClosesFolder = false; } } } diff --git a/src/com/android/launcher3/DragView.java b/src/com/android/launcher3/DragView.java index b66b55c9d..ea34e46f9 100644 --- a/src/com/android/launcher3/DragView.java +++ b/src/com/android/launcher3/DragView.java @@ -14,7 +14,6 @@ * limitations under the License. */ - package com.android.launcher3; import android.animation.ValueAnimator; @@ -30,8 +29,6 @@ import android.graphics.Rect; import android.view.View; import android.view.animation.DecelerateInterpolator; -import com.android.launcher3.R; - public class DragView extends View { private static float sDragAlpha = 1f; diff --git a/src/com/android/launcher3/DrawableStateProxyView.java b/src/com/android/launcher3/DrawableStateProxyView.java index 0758de1f7..c83659ad5 100644 --- a/src/com/android/launcher3/DrawableStateProxyView.java +++ b/src/com/android/launcher3/DrawableStateProxyView.java @@ -23,8 +23,6 @@ import android.view.MotionEvent; import android.view.View; import android.widget.LinearLayout; -import com.android.launcher3.R; - public class DrawableStateProxyView extends LinearLayout { private View mView; diff --git a/src/com/android/launcher3/DrawableTileSource.java b/src/com/android/launcher3/DrawableTileSource.java deleted file mode 100644 index c1f2eff0f..000000000 --- a/src/com/android/launcher3/DrawableTileSource.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2013 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.launcher3; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; - -import com.android.gallery3d.glrenderer.BasicTexture; -import com.android.gallery3d.glrenderer.BitmapTexture; -import com.android.photos.views.TiledImageRenderer; - -public class DrawableTileSource implements TiledImageRenderer.TileSource { - private static final int GL_SIZE_LIMIT = 2048; - // This must be no larger than half the size of the GL_SIZE_LIMIT - // due to decodePreview being allowed to be up to 2x the size of the target - public static final int MAX_PREVIEW_SIZE = GL_SIZE_LIMIT / 2; - - private int mTileSize; - private int mPreviewSize; - private Drawable mDrawable; - private BitmapTexture mPreview; - - public DrawableTileSource(Context context, Drawable d, int previewSize) { - mTileSize = TiledImageRenderer.suggestedTileSize(context); - mDrawable = d; - mPreviewSize = Math.min(previewSize, MAX_PREVIEW_SIZE); - } - - @Override - public int getTileSize() { - return mTileSize; - } - - @Override - public int getImageWidth() { - return mDrawable.getIntrinsicWidth(); - } - - @Override - public int getImageHeight() { - return mDrawable.getIntrinsicHeight(); - } - - @Override - public int getRotation() { - return 0; - } - - @Override - public BasicTexture getPreview() { - if (mPreviewSize == 0) { - return null; - } - if (mPreview == null){ - float width = getImageWidth(); - float height = getImageHeight(); - while (width > MAX_PREVIEW_SIZE || height > MAX_PREVIEW_SIZE) { - width /= 2; - height /= 2; - } - Bitmap b = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(b); - mDrawable.setBounds(new Rect(0, 0, (int) width, (int) height)); - mDrawable.draw(c); - c.setBitmap(null); - mPreview = new BitmapTexture(b); - } - return mPreview; - } - - @Override - public Bitmap getTile(int level, int x, int y, Bitmap bitmap) { - int tileSize = getTileSize(); - if (bitmap == null) { - bitmap = Bitmap.createBitmap(tileSize, tileSize, Bitmap.Config.ARGB_8888); - } - Canvas c = new Canvas(bitmap); - Rect bounds = new Rect(0, 0, getImageWidth(), getImageHeight()); - bounds.offset(-x, -y); - mDrawable.setBounds(bounds); - mDrawable.draw(c); - c.setBitmap(null); - return bitmap; - } -} diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java index dc01c6933..22928ccf3 100644 --- a/src/com/android/launcher3/DynamicGrid.java +++ b/src/com/android/launcher3/DynamicGrid.java @@ -74,10 +74,10 @@ public class DynamicGrid { // The tablet profile is odd in that the landscape orientation // also includes the nav bar on the side deviceProfiles.add(new DeviceProfile("Nexus 7", - 575, 904, 5, 5, 72, 14.4f, 7, 60)); + 575, 904, 5, 6, 72, 14.4f, 7, 60)); // Larger tablet profiles always have system bars on the top & bottom deviceProfiles.add(new DeviceProfile("Nexus 10", - 727, 1207, 5, 5, 80, 14.4f, 7, 64)); + 727, 1207, 5, 6, 76, 14.4f, 7, 64)); /* deviceProfiles.add(new DeviceProfile("Nexus 7", 600, 960, 5, 5, 72, 14.4f, 5, 60)); diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 37a947c3a..758ee5bab 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -31,9 +31,7 @@ import android.text.InputType; import android.text.Selection; import android.text.Spannable; import android.util.AttributeSet; -import android.util.DisplayMetrics; import android.util.Log; -import android.util.TypedValue; import android.view.ActionMode; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -43,8 +41,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.Interpolator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.LinearLayout; @@ -149,8 +145,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList Resources res = getResources(); mMaxCountX = (int) grid.numColumns; - mMaxCountY = (int) grid.numRows; - mMaxNumItems = mMaxCountX * mMaxCountY; + // Allow scrolling folders when DISABLE_ALL_APPS is true. + if (AppsCustomizePagedView.DISABLE_ALL_APPS) { + mMaxCountY = mMaxNumItems = Integer.MAX_VALUE; + } else { + mMaxCountY = (int) grid.numRows; + mMaxNumItems = mMaxCountX * mMaxCountY; + } mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); @@ -1017,7 +1018,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList int contentAreaHeightSpec = MeasureSpec.makeMeasureSpec(getContentAreaHeight(), MeasureSpec.EXACTLY); - mContent.setFixedSize(getContentAreaWidth(), getContentAreaHeight()); + if (AppsCustomizePagedView.DISABLE_ALL_APPS) { + // Don't cap the height of the content to allow scrolling. + mContent.setFixedSize(getContentAreaWidth(), mContent.getDesiredHeight()); + } else { + mContent.setFixedSize(getContentAreaWidth(), getContentAreaHeight()); + } + mScrollView.measure(contentAreaWidthSpec, contentAreaHeightSpec); mFolderName.measure(contentAreaWidthSpec, MeasureSpec.makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY)); diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java index 5e461a7b5..644db47ac 100644 --- a/src/com/android/launcher3/FolderIcon.java +++ b/src/com/android/launcher3/FolderIcon.java @@ -36,11 +36,10 @@ import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; -import android.widget.ImageView; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.TextView; -import com.android.launcher3.R; import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.FolderInfo.FolderListener; diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java index fb75161fe..1ff94720b 100644 --- a/src/com/android/launcher3/InstallShortcutReceiver.java +++ b/src/com/android/launcher3/InstallShortcutReceiver.java @@ -24,17 +24,20 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.text.TextUtils; import android.util.Base64; import android.util.Log; import android.widget.Toast; +import org.json.JSONObject; +import org.json.JSONStringer; +import org.json.JSONTokener; + import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.json.*; - public class InstallShortcutReceiver extends BroadcastReceiver { private static final String TAG = "InstallShortcutReceiver"; private static final boolean DBG = false; @@ -221,6 +224,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { if (intent == null) { return; } + // This name is only used for comparisons and notifications, so fall back to activity name // if not supplied String name = ensureValidName(context, intent, @@ -267,6 +271,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver { //final Intent data = pendingInfo.data; final Intent intent = pendingInfo.launchIntent; final String name = pendingInfo.name; + + if (AppsCustomizePagedView.DISABLE_ALL_APPS && !isValidShortcutLaunchIntent(intent)) { + if (DBG) Log.d(TAG, "Ignoring shortcut with launchIntent:" + intent); + continue; + } + final boolean exists = LauncherModel.shortcutExists(context, name, intent); //final boolean allowDuplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true); @@ -299,6 +309,30 @@ public class InstallShortcutReceiver extends BroadcastReceiver { } } + /** + * Returns true if the intent is a valid launch intent for a shortcut. + * This is used to identify shortcuts which are different from the ones exposed by the + * applications' manifest file. + * + * When DISABLE_ALL_APPS is true, shortcuts exposed via the app's manifest should never be + * duplicated or removed(unless the app is un-installed). + * + * @param launchIntent The intent that will be launched when the shortcut is clicked. + */ + static boolean isValidShortcutLaunchIntent(Intent launchIntent) { + if (launchIntent != null + && Intent.ACTION_MAIN.equals(launchIntent.getAction()) + && launchIntent.getComponent() != null + && launchIntent.getCategories() != null + && launchIntent.getCategories().size() == 1 + && launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER) + && launchIntent.getExtras() == null + && TextUtils.isEmpty(launchIntent.getDataString())) { + return false; + } + return true; + } + private static ShortcutInfo getShortcutInfo(Context context, Intent data, Intent launchIntent) { if (launchIntent.getAction() == null) { diff --git a/src/com/android/launcher3/InstallWidgetReceiver.java b/src/com/android/launcher3/InstallWidgetReceiver.java index 0ef478074..74b9e3d99 100644 --- a/src/com/android/launcher3/InstallWidgetReceiver.java +++ b/src/com/android/launcher3/InstallWidgetReceiver.java @@ -16,8 +16,6 @@ package com.android.launcher3; -import java.util.List; - import android.appwidget.AppWidgetProviderInfo; import android.content.ClipData; import android.content.Context; @@ -33,7 +31,7 @@ import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.TextView; -import com.android.launcher3.R; +import java.util.List; /** diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 318066b56..c05769cfa 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1972,9 +1972,7 @@ public class Launcher extends Activity @Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - if (!mWorkspace.isInOverviewMode()) { - mWorkspace.enterOverviewMode(); - } + showOverviewMode(true); return false; } @@ -2174,7 +2172,7 @@ public class Launcher extends Activity } protected ComponentName getWallpaperPickerComponent() { - return new ComponentName(getPackageName(), WallpaperPickerActivity.class.getName()); + return new ComponentName(getPackageName(), LauncherWallpaperPickerActivity.class.getName()); } /** @@ -2908,8 +2906,9 @@ public class Launcher extends Activity // Shrink workspaces away if going to AppsCustomize from workspace Animator workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated); - if (!AppsCustomizePagedView.DISABLE_ALL_APPS) { - // Set the content type for the all apps space + if (!AppsCustomizePagedView.DISABLE_ALL_APPS + || contentType == AppsCustomizePagedView.ContentType.Widgets) { + // Set the content type for the all apps/widgets space mAppsCustomizeTabHost.setContentTypeImmediate(contentType); } @@ -4053,6 +4052,10 @@ public class Launcher extends Activity } mIntentsOnWorkspaceFromUpgradePath = null; } + if (mAppsCustomizeContent != null) { + mAppsCustomizeContent.onPackagesUpdated( + LauncherModel.getSortedWidgetsAndShortcuts(this)); + } } else { if (mAppsCustomizeContent != null) { mAppsCustomizeContent.setApps(apps); @@ -4141,8 +4144,7 @@ public class Launcher extends Activity } // Update the widgets pane - if (!AppsCustomizePagedView.DISABLE_ALL_APPS && - mAppsCustomizeContent != null) { + if (mAppsCustomizeContent != null) { mAppsCustomizeContent.onPackagesUpdated(widgetsAndShortcuts); } } @@ -4414,6 +4416,20 @@ public class Launcher extends Activity } } + /** + * Called when the SearchBar hint should be changed. + * + * @param hint the hint to be displayed in the search bar. + */ + protected void onSearchBarHintChanged(String hint) { + Cling cling = (Cling) findViewById(R.id.first_run_cling); + if (cling != null && cling.getVisibility() == View.VISIBLE && !hint.isEmpty()) { + TextView sbHint = (TextView) cling.findViewById(R.id.search_bar_hint); + sbHint.setText(hint); + sbHint.setVisibility(View.VISIBLE); + } + } + protected String getFirstRunClingSearchBarHint() { return ""; } diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index 5daa845f3..84a1d0411 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -22,9 +22,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.os.Handler; -import android.provider.Settings; import android.util.Log; -import android.view.Display; import java.lang.ref.WeakReference; diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java index 2a5ed6961..a081c2191 100644 --- a/src/com/android/launcher3/LauncherBackupHelper.java +++ b/src/com/android/launcher3/LauncherBackupHelper.java @@ -297,7 +297,7 @@ public class LauncherBackupHelper implements BackupHelper { Key key = getKey(Key.FAVORITE, id); keys.add(key); currentIds.add(keyToBackupKey(key)); - if (updateTime > in.t) { + if (updateTime >= in.t) { byte[] blob = packFavorite(cursor); writeRowToBackup(key, blob, out, data); } @@ -365,7 +365,7 @@ public class LauncherBackupHelper implements BackupHelper { Key key = getKey(Key.SCREEN, id); keys.add(key); currentIds.add(keyToBackupKey(key)); - if (updateTime > in.t) { + if (updateTime >= in.t) { byte[] blob = packScreen(cursor); writeRowToBackup(key, blob, out, data); } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index da805a05a..b2cfb2456 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -43,6 +43,7 @@ import android.provider.BaseColumns; import android.text.TextUtils; import android.util.Log; import android.util.Pair; + import com.android.launcher3.InstallWidgetReceiver.WidgetMimeTypeHandlerData; import java.lang.ref.WeakReference; @@ -1087,15 +1088,29 @@ public class LauncherModel extends BroadcastReceiver { } } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) { - // First, schedule to add these apps back in. + final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); - enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages)); - // Then, rebind everything. - startLoaderFromBackground(); + if (!replacing) { + enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages)); + if (mAppsCanBeOnRemoveableStorage) { + // Only rebind if we support removable storage. It catches the case where + // apps on the external sd card need to be reloaded + startLoaderFromBackground(); + } + } else { + // If we are replacing then just update the packages in the list + enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_UPDATE, + packages)); + } } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) { - String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); - enqueuePackageUpdated(new PackageUpdatedTask( - PackageUpdatedTask.OP_UNAVAILABLE, packages)); + final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); + if (!replacing) { + String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); + enqueuePackageUpdated(new PackageUpdatedTask( + PackageUpdatedTask.OP_UNAVAILABLE, packages)); + } + // else, we are replacing the packages, so ignore this event and wait for + // EXTERNAL_APPLICATIONS_AVAILABLE to update the packages at that time } else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) { // If we have changed locale we need to clear out the labels in all apps/workspace. forceReload(); diff --git a/src/com/android/launcher3/LauncherWallpaperPickerActivity.java b/src/com/android/launcher3/LauncherWallpaperPickerActivity.java new file mode 100644 index 000000000..10fe013ee --- /dev/null +++ b/src/com/android/launcher3/LauncherWallpaperPickerActivity.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2013 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.launcher3; + +import android.content.Intent; + +public class LauncherWallpaperPickerActivity extends WallpaperPickerActivity { + @Override + public void startActivityForResultSafely(Intent intent, int requestCode) { + Utilities.startActivityForResultSafely(this, intent, requestCode); + } + @Override + public boolean enableRotation() { + return Utilities.isRotationEnabled(this); + } +} diff --git a/src/com/android/launcher3/LiveWallpaperListAdapter.java b/src/com/android/launcher3/LiveWallpaperListAdapter.java deleted file mode 100644 index 152a75ded..000000000 --- a/src/com/android/launcher3/LiveWallpaperListAdapter.java +++ /dev/null @@ -1,205 +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.launcher3; - -import android.app.WallpaperInfo; -import android.app.WallpaperManager; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.graphics.drawable.Drawable; -import android.os.AsyncTask; -import android.service.wallpaper.WallpaperService; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.ListAdapter; -import android.widget.TextView; - -import org.xmlpull.v1.XmlPullParserException; - -import java.io.IOException; -import java.text.Collator; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class LiveWallpaperListAdapter extends BaseAdapter implements ListAdapter { - private static final String LOG_TAG = "LiveWallpaperListAdapter"; - - private final LayoutInflater mInflater; - private final PackageManager mPackageManager; - - private List<LiveWallpaperTile> mWallpapers; - - @SuppressWarnings("unchecked") - public LiveWallpaperListAdapter(Context context) { - mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mPackageManager = context.getPackageManager(); - - List<ResolveInfo> list = mPackageManager.queryIntentServices( - new Intent(WallpaperService.SERVICE_INTERFACE), - PackageManager.GET_META_DATA); - - mWallpapers = new ArrayList<LiveWallpaperTile>(); - - new LiveWallpaperEnumerator(context).execute(list); - } - - public int getCount() { - if (mWallpapers == null) { - return 0; - } - return mWallpapers.size(); - } - - public LiveWallpaperTile getItem(int position) { - return mWallpapers.get(position); - } - - public long getItemId(int position) { - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - View view; - - if (convertView == null) { - view = mInflater.inflate(R.layout.wallpaper_picker_live_wallpaper_item, parent, false); - } else { - view = convertView; - } - - WallpaperPickerActivity.setWallpaperItemPaddingToZero((FrameLayout) view); - - LiveWallpaperTile wallpaperInfo = mWallpapers.get(position); - wallpaperInfo.setView(view); - ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image); - ImageView icon = (ImageView) view.findViewById(R.id.wallpaper_icon); - if (wallpaperInfo.mThumbnail != null) { - image.setImageDrawable(wallpaperInfo.mThumbnail); - icon.setVisibility(View.GONE); - } else { - icon.setImageDrawable(wallpaperInfo.mInfo.loadIcon(mPackageManager)); - icon.setVisibility(View.VISIBLE); - } - - TextView label = (TextView) view.findViewById(R.id.wallpaper_item_label); - label.setText(wallpaperInfo.mInfo.loadLabel(mPackageManager)); - - return view; - } - - public static class LiveWallpaperTile extends WallpaperPickerActivity.WallpaperTileInfo { - private Drawable mThumbnail; - private WallpaperInfo mInfo; - public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) { - mThumbnail = thumbnail; - mInfo = info; - } - @Override - public void onClick(WallpaperPickerActivity a) { - Intent preview = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER); - preview.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, - mInfo.getComponent()); - a.onLiveWallpaperPickerLaunch(); - Utilities.startActivityForResultSafely( - a, preview, WallpaperPickerActivity.PICK_LIVE_WALLPAPER); - } - } - - private class LiveWallpaperEnumerator extends - AsyncTask<List<ResolveInfo>, LiveWallpaperTile, Void> { - private Context mContext; - private int mWallpaperPosition; - - public LiveWallpaperEnumerator(Context context) { - super(); - mContext = context; - mWallpaperPosition = 0; - } - - @Override - protected Void doInBackground(List<ResolveInfo>... params) { - final PackageManager packageManager = mContext.getPackageManager(); - - List<ResolveInfo> list = params[0]; - - Collections.sort(list, new Comparator<ResolveInfo>() { - final Collator mCollator; - - { - mCollator = Collator.getInstance(); - } - - public int compare(ResolveInfo info1, ResolveInfo info2) { - return mCollator.compare(info1.loadLabel(packageManager), - info2.loadLabel(packageManager)); - } - }); - - for (ResolveInfo resolveInfo : list) { - WallpaperInfo info = null; - try { - info = new WallpaperInfo(mContext, resolveInfo); - } catch (XmlPullParserException e) { - Log.w(LOG_TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e); - continue; - } catch (IOException e) { - Log.w(LOG_TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e); - continue; - } - - - Drawable thumb = info.loadThumbnail(packageManager); - Intent launchIntent = new Intent(WallpaperService.SERVICE_INTERFACE); - launchIntent.setClassName(info.getPackageName(), info.getServiceName()); - LiveWallpaperTile wallpaper = new LiveWallpaperTile(thumb, info, launchIntent); - publishProgress(wallpaper); - } - // Send a null object to show loading is finished - publishProgress((LiveWallpaperTile) null); - - return null; - } - - @Override - protected void onProgressUpdate(LiveWallpaperTile...infos) { - for (LiveWallpaperTile info : infos) { - if (info == null) { - LiveWallpaperListAdapter.this.notifyDataSetChanged(); - break; - } - if (info.mThumbnail != null) { - info.mThumbnail.setDither(true); - } - if (mWallpaperPosition < mWallpapers.size()) { - mWallpapers.set(mWallpaperPosition, info); - } else { - mWallpapers.add(info); - } - mWallpaperPosition++; - } - } - } -} diff --git a/src/com/android/launcher3/PageIndicator.java b/src/com/android/launcher3/PageIndicator.java index 08e5f721a..62ea03bcc 100644 --- a/src/com/android/launcher3/PageIndicator.java +++ b/src/com/android/launcher3/PageIndicator.java @@ -16,22 +16,12 @@ package com.android.launcher3; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; import android.animation.LayoutTransition; -import android.animation.TimeInterpolator; -import android.content.ComponentName; import android.content.Context; -import android.content.res.Configuration; -import android.content.res.Resources; import android.content.res.TypedArray; import android.util.AttributeSet; -import android.util.Log; import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; import android.widget.LinearLayout; -import com.android.launcher3.R; import java.util.ArrayList; diff --git a/src/com/android/launcher3/PageIndicatorMarker.java b/src/com/android/launcher3/PageIndicatorMarker.java index b1025d6fe..f012db74b 100644 --- a/src/com/android/launcher3/PageIndicatorMarker.java +++ b/src/com/android/launcher3/PageIndicatorMarker.java @@ -16,17 +16,11 @@ package com.android.launcher3; -import android.animation.AnimatorListenerAdapter; -import android.animation.LayoutTransition; import android.content.Context; import android.content.res.Resources; import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.FrameLayout; -import com.android.launcher3.R; +import android.widget.ImageView; public class PageIndicatorMarker extends FrameLayout { @SuppressWarnings("unused") diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index fa52f52b1..8d5d8dd4d 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -32,7 +32,6 @@ import android.graphics.Rect; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.support.v4.view.accessibility.AccessibilityEventCompat; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; @@ -51,7 +50,6 @@ import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.view.animation.LinearInterpolator; -import android.widget.Scroller; import java.util.ArrayList; diff --git a/src/com/android/launcher3/PagedViewIconCache.java b/src/com/android/launcher3/PagedViewIconCache.java index 8d8924b7e..93887ea23 100644 --- a/src/com/android/launcher3/PagedViewIconCache.java +++ b/src/com/android/launcher3/PagedViewIconCache.java @@ -16,17 +16,17 @@ package com.android.launcher3; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.pm.ComponentInfo; import android.content.pm.ResolveInfo; import android.graphics.Bitmap; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + /** * Simple cache mechanism for PagedView outlines. */ diff --git a/src/com/android/launcher3/PagedViewWidget.java b/src/com/android/launcher3/PagedViewWidget.java index d2f897a33..db4aeb940 100644 --- a/src/com/android/launcher3/PagedViewWidget.java +++ b/src/com/android/launcher3/PagedViewWidget.java @@ -30,8 +30,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; -import com.android.launcher3.R; - /** * The linear layout used strictly for the widget/wallpaper tab of the customization tray */ diff --git a/src/com/android/launcher3/SavedWallpaperImages.java b/src/com/android/launcher3/SavedWallpaperImages.java deleted file mode 100644 index 58add7022..000000000 --- a/src/com/android/launcher3/SavedWallpaperImages.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2013 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.launcher3; - -import android.app.Activity; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.util.Log; -import android.util.Pair; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ListAdapter; - -import com.android.photos.BitmapRegionTileSource; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; - - -public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { - private static String TAG = "Launcher3.SavedWallpaperImages"; - private ImageDb mDb; - ArrayList<SavedWallpaperTile> mImages; - Context mContext; - LayoutInflater mLayoutInflater; - - public static class SavedWallpaperTile extends WallpaperPickerActivity.WallpaperTileInfo { - private int mDbId; - private Drawable mThumb; - public SavedWallpaperTile(int dbId, Drawable thumb) { - mDbId = dbId; - mThumb = thumb; - } - @Override - public void onClick(WallpaperPickerActivity a) { - String imageFilename = a.getSavedImages().getImageFilename(mDbId); - File file = new File(a.getFilesDir(), imageFilename); - BitmapRegionTileSource.FilePathBitmapSource bitmapSource = - new BitmapRegionTileSource.FilePathBitmapSource(file.getAbsolutePath(), 1024); - a.setCropViewTileSource(bitmapSource, false, true, null); - } - @Override - public void onSave(WallpaperPickerActivity a) { - boolean finishActivityWhenDone = true; - String imageFilename = a.getSavedImages().getImageFilename(mDbId); - a.setWallpaper(imageFilename, finishActivityWhenDone); - } - @Override - public void onDelete(WallpaperPickerActivity a) { - a.getSavedImages().deleteImage(mDbId); - } - @Override - public boolean isSelectable() { - return true; - } - @Override - public boolean isNamelessWallpaper() { - return true; - } - } - - public SavedWallpaperImages(Activity context) { - mDb = new ImageDb(context); - mContext = context; - mLayoutInflater = context.getLayoutInflater(); - } - - public void loadThumbnailsAndImageIdList() { - mImages = new ArrayList<SavedWallpaperTile>(); - SQLiteDatabase db = mDb.getReadableDatabase(); - Cursor result = db.query(ImageDb.TABLE_NAME, - new String[] { ImageDb.COLUMN_ID, - ImageDb.COLUMN_IMAGE_THUMBNAIL_FILENAME }, // cols to return - null, // select query - null, // args to select query - null, - null, - ImageDb.COLUMN_ID + " DESC", - null); - - while (result.moveToNext()) { - String filename = result.getString(1); - File file = new File(mContext.getFilesDir(), filename); - - Bitmap thumb = BitmapFactory.decodeFile(file.getAbsolutePath()); - if (thumb != null) { - mImages.add(new SavedWallpaperTile(result.getInt(0), new BitmapDrawable(thumb))); - } - } - result.close(); - } - - public int getCount() { - return mImages.size(); - } - - public SavedWallpaperTile getItem(int position) { - return mImages.get(position); - } - - public long getItemId(int position) { - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - Drawable thumbDrawable = mImages.get(position).mThumb; - if (thumbDrawable == null) { - Log.e(TAG, "Error decoding thumbnail for wallpaper #" + position); - } - return WallpaperPickerActivity.createImageTileView( - mLayoutInflater, position, convertView, parent, thumbDrawable); - } - - public String getImageFilename(int id) { - Pair<String, String> filenames = getImageFilenames(id); - if (filenames != null) { - return filenames.second; - } - return null; - } - - private Pair<String, String> getImageFilenames(int id) { - SQLiteDatabase db = mDb.getReadableDatabase(); - Cursor result = db.query(ImageDb.TABLE_NAME, - new String[] { ImageDb.COLUMN_IMAGE_THUMBNAIL_FILENAME, - ImageDb.COLUMN_IMAGE_FILENAME }, // cols to return - ImageDb.COLUMN_ID + " = ?", // select query - new String[] { Integer.toString(id) }, // args to select query - null, - null, - null, - null); - if (result.getCount() > 0) { - result.moveToFirst(); - String thumbFilename = result.getString(0); - String imageFilename = result.getString(1); - result.close(); - return new Pair<String, String>(thumbFilename, imageFilename); - } else { - return null; - } - } - - public void deleteImage(int id) { - Pair<String, String> filenames = getImageFilenames(id); - File imageFile = new File(mContext.getFilesDir(), filenames.first); - imageFile.delete(); - File thumbFile = new File(mContext.getFilesDir(), filenames.second); - thumbFile.delete(); - SQLiteDatabase db = mDb.getWritableDatabase(); - db.delete(ImageDb.TABLE_NAME, - ImageDb.COLUMN_ID + " = ?", // SELECT query - new String[] { - Integer.toString(id) // args to SELECT query - }); - } - - public void writeImage(Bitmap thumbnail, byte[] imageBytes) { - try { - File imageFile = File.createTempFile("wallpaper", "", mContext.getFilesDir()); - FileOutputStream imageFileStream = - mContext.openFileOutput(imageFile.getName(), Context.MODE_PRIVATE); - imageFileStream.write(imageBytes); - imageFileStream.close(); - - File thumbFile = File.createTempFile("wallpaperthumb", "", mContext.getFilesDir()); - FileOutputStream thumbFileStream = - mContext.openFileOutput(thumbFile.getName(), Context.MODE_PRIVATE); - thumbnail.compress(Bitmap.CompressFormat.JPEG, 95, thumbFileStream); - thumbFileStream.close(); - - SQLiteDatabase db = mDb.getWritableDatabase(); - ContentValues values = new ContentValues(); - values.put(ImageDb.COLUMN_IMAGE_THUMBNAIL_FILENAME, thumbFile.getName()); - values.put(ImageDb.COLUMN_IMAGE_FILENAME, imageFile.getName()); - db.insert(ImageDb.TABLE_NAME, null, values); - } catch (IOException e) { - Log.e(TAG, "Failed writing images to storage " + e); - } - } - - static class ImageDb extends SQLiteOpenHelper { - final static int DB_VERSION = 1; - final static String DB_NAME = "saved_wallpaper_images.db"; - final static String TABLE_NAME = "saved_wallpaper_images"; - final static String COLUMN_ID = "id"; - final static String COLUMN_IMAGE_THUMBNAIL_FILENAME = "image_thumbnail"; - final static String COLUMN_IMAGE_FILENAME = "image"; - - Context mContext; - - public ImageDb(Context context) { - super(context, new File(context.getCacheDir(), DB_NAME).getPath(), null, DB_VERSION); - // Store the context for later use - mContext = context; - } - - @Override - public void onCreate(SQLiteDatabase database) { - database.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + - COLUMN_ID + " INTEGER NOT NULL, " + - COLUMN_IMAGE_THUMBNAIL_FILENAME + " TEXT NOT NULL, " + - COLUMN_IMAGE_FILENAME + " TEXT NOT NULL, " + - "PRIMARY KEY (" + COLUMN_ID + " ASC) " + - ");"); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - if (oldVersion != newVersion) { - // Delete all the records; they'll be repopulated as this is a cache - db.execSQL("DELETE FROM " + TABLE_NAME); - } - } - } -} diff --git a/src/com/android/launcher3/ScrimView.java b/src/com/android/launcher3/ScrimView.java index 6831fe3d4..68200fe64 100644 --- a/src/com/android/launcher3/ScrimView.java +++ b/src/com/android/launcher3/ScrimView.java @@ -17,11 +17,8 @@ package com.android.launcher3; import android.content.Context; -import android.content.res.Resources; -import android.content.res.TypedArray; import android.graphics.Rect; import android.util.AttributeSet; -import android.view.View; import android.widget.FrameLayout; public class ScrimView extends FrameLayout implements Insettable { diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java index fc087a897..660f32c79 100644 --- a/src/com/android/launcher3/ShortcutInfo.java +++ b/src/com/android/launcher3/ShortcutInfo.java @@ -20,9 +20,9 @@ import android.content.ComponentName; import android.content.ContentValues; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.pm.PackageInfo; import android.graphics.Bitmap; import android.util.Log; diff --git a/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java b/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java deleted file mode 100644 index 494694cbd..000000000 --- a/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java +++ /dev/null @@ -1,139 +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.launcher3; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.FrameLayout; -import android.widget.ListAdapter; -import android.widget.TextView; - -import java.util.ArrayList; -import java.util.List; - -public class ThirdPartyWallpaperPickerListAdapter extends BaseAdapter implements ListAdapter { - private static final String LOG_TAG = "LiveWallpaperListAdapter"; - - private final LayoutInflater mInflater; - private final PackageManager mPackageManager; - private final int mIconSize; - - private List<ThirdPartyWallpaperTile> mThirdPartyWallpaperPickers = - new ArrayList<ThirdPartyWallpaperTile>(); - - public static class ThirdPartyWallpaperTile extends WallpaperPickerActivity.WallpaperTileInfo { - private ResolveInfo mResolveInfo; - public ThirdPartyWallpaperTile(ResolveInfo resolveInfo) { - mResolveInfo = resolveInfo; - } - @Override - public void onClick(WallpaperPickerActivity a) { - final ComponentName itemComponentName = new ComponentName( - mResolveInfo.activityInfo.packageName, mResolveInfo.activityInfo.name); - Intent launchIntent = new Intent(Intent.ACTION_SET_WALLPAPER); - launchIntent.setComponent(itemComponentName); - Utilities.startActivityForResultSafely( - a, launchIntent, WallpaperPickerActivity.PICK_WALLPAPER_THIRD_PARTY_ACTIVITY); - } - } - - public ThirdPartyWallpaperPickerListAdapter(Context context) { - mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mPackageManager = context.getPackageManager(); - mIconSize = context.getResources().getDimensionPixelSize(R.dimen.wallpaperItemIconSize); - final PackageManager pm = mPackageManager; - - final Intent pickWallpaperIntent = new Intent(Intent.ACTION_SET_WALLPAPER); - final List<ResolveInfo> apps = - pm.queryIntentActivities(pickWallpaperIntent, 0); - - // Get list of image picker intents - Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT); - pickImageIntent.setType("image/*"); - final List<ResolveInfo> imagePickerActivities = - pm.queryIntentActivities(pickImageIntent, 0); - final ComponentName[] imageActivities = new ComponentName[imagePickerActivities.size()]; - for (int i = 0; i < imagePickerActivities.size(); i++) { - ActivityInfo activityInfo = imagePickerActivities.get(i).activityInfo; - imageActivities[i] = new ComponentName(activityInfo.packageName, activityInfo.name); - } - - outerLoop: - for (ResolveInfo info : apps) { - final ComponentName itemComponentName = - new ComponentName(info.activityInfo.packageName, info.activityInfo.name); - final String itemPackageName = itemComponentName.getPackageName(); - // Exclude anything from our own package, and the old Launcher, - // and live wallpaper picker - if (itemPackageName.equals(context.getPackageName()) || - itemPackageName.equals("com.android.launcher") || - itemPackageName.equals("com.android.wallpaper.livepicker")) { - continue; - } - // Exclude any package that already responds to the image picker intent - for (ResolveInfo imagePickerActivityInfo : imagePickerActivities) { - if (itemPackageName.equals( - imagePickerActivityInfo.activityInfo.packageName)) { - continue outerLoop; - } - } - mThirdPartyWallpaperPickers.add(new ThirdPartyWallpaperTile(info)); - } - } - - public int getCount() { - return mThirdPartyWallpaperPickers.size(); - } - - public ThirdPartyWallpaperTile getItem(int position) { - return mThirdPartyWallpaperPickers.get(position); - } - - public long getItemId(int position) { - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - View view; - - if (convertView == null) { - view = mInflater.inflate(R.layout.wallpaper_picker_third_party_item, parent, false); - } else { - view = convertView; - } - - WallpaperPickerActivity.setWallpaperItemPaddingToZero((FrameLayout) view); - - ResolveInfo info = mThirdPartyWallpaperPickers.get(position).mResolveInfo; - TextView label = (TextView) view.findViewById(R.id.wallpaper_item_label); - label.setText(info.loadLabel(mPackageManager)); - Drawable icon = info.loadIcon(mPackageManager); - icon.setBounds(new Rect(0, 0, mIconSize, mIconSize)); - label.setCompoundDrawables(null, icon, null, null); - return view; - } -} diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 9ffd044b4..cbc978585 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -65,6 +65,12 @@ public final class Utilities { static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff }; static int sColorIndex = 0; + + // To turn on these properties, type + // adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS] + static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher_force_rotate"; + public static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY); + /** * Returns a FastBitmapDrawable with the icon, accurately sized. */ @@ -82,6 +88,16 @@ public final class Utilities { icon.setBounds(0, 0, sIconTextureWidth, sIconTextureHeight); } + private static boolean isPropertyEnabled(String propertyName) { + return Log.isLoggable(propertyName, Log.VERBOSE); + } + + public static boolean isRotationEnabled(Context c) { + boolean enableRotation = sForceEnableRotation || + c.getResources().getBoolean(R.bool.allow_rotation); + return enableRotation; + } + /** * Returns a bitmap suitable for the all apps view. Used to convert pre-ICS * icon bitmaps that are stored in the database (which were 74x74 pixels at hdpi size) diff --git a/src/com/android/launcher3/WallpaperRootView.java b/src/com/android/launcher3/WallpaperRootView.java deleted file mode 100644 index ceaa043a7..000000000 --- a/src/com/android/launcher3/WallpaperRootView.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2013 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.launcher3; - -import android.content.Context; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.widget.RelativeLayout; - -public class WallpaperRootView extends RelativeLayout { - private final WallpaperPickerActivity a; - public WallpaperRootView(Context context, AttributeSet attrs) { - super(context, attrs); - a = (WallpaperPickerActivity) context; - } - public WallpaperRootView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - a = (WallpaperPickerActivity) context; - } - - protected boolean fitSystemWindows(Rect insets) { - a.setWallpaperStripYOffset(insets.bottom); - return true; - } -} diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 6b719b258..b6276c0f2 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -565,6 +565,7 @@ public class Workspace extends SmoothPagedView public void createCustomContentPage() { CellLayout customScreen = (CellLayout) mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null); + customScreen.disableBackground(); mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen); mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID); @@ -1155,11 +1156,6 @@ public class Workspace extends SmoothPagedView } } - // Only show page outlines as we pan if we are on large screen - if (LauncherAppState.getInstance().isScreenLarge()) { - showOutlines(); - } - // If we are not fading in adjacent screens, we still need to restore the alpha in case the // user scrolls while we are transitioning (should not affect dispatchDraw optimizations) if (!mWorkspaceFadeInAdjacentScreens) { @@ -1184,11 +1180,6 @@ public class Workspace extends SmoothPagedView // is under a new page (to scroll to) mDragController.forceTouchMove(); } - } else { - // If we are not mid-dragging, hide the page outlines if we are on a large screen - if (LauncherAppState.getInstance().isScreenLarge()) { - hideOutlines(); - } } if (mDelayedResizeRunnable != null) { @@ -1241,7 +1232,7 @@ public class Workspace extends SmoothPagedView String spKey = WallpaperCropActivity.getSharedPreferencesKey(); SharedPreferences sp = mLauncher.getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS); - WallpaperPickerActivity.suggestWallpaperDimension(mLauncher.getResources(), + LauncherWallpaperPickerActivity.suggestWallpaperDimension(mLauncher.getResources(), sp, mLauncher.getWindowManager(), mWallpaperManager); return null; } @@ -3115,13 +3106,11 @@ public class Workspace extends SmoothPagedView display.getCurrentSizeRange(smallestSize, largestSize); int countX = (int) grid.numColumns; int countY = (int) grid.numRows; - int constrainedLongEdge = largestSize.y; - int constrainedShortEdge = smallestSize.y; if (orientation == CellLayout.LANDSCAPE) { if (mLandscapeCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.LANDSCAPE); - int width = constrainedLongEdge - padding.left - padding.right; - int height = constrainedShortEdge - padding.top - padding.bottom; + int width = largestSize.x - padding.left - padding.right; + int height = smallestSize.y - padding.top - padding.bottom; mLandscapeCellLayoutMetrics = new Rect(); mLandscapeCellLayoutMetrics.set( grid.calculateCellWidth(width, countX), @@ -3131,8 +3120,8 @@ public class Workspace extends SmoothPagedView } else if (orientation == CellLayout.PORTRAIT) { if (mPortraitCellLayoutMetrics == null) { Rect padding = grid.getWorkspacePadding(CellLayout.PORTRAIT); - int width = constrainedShortEdge - padding.left - padding.right; - int height = constrainedLongEdge - padding.top - padding.bottom; + int width = smallestSize.x - padding.left - padding.right; + int height = largestSize.y - padding.top - padding.bottom; mPortraitCellLayoutMetrics = new Rect(); mPortraitCellLayoutMetrics.set( grid.calculateCellWidth(width, countX), |