Merge "Removing all compatibility code below Lollipop" into ub-launcher3-master
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index e0c86e2..f618546 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -472,9 +472,13 @@
mExtractedColors.load(this);
mHotseat.updateColor(mExtractedColors, !mPaused);
mWorkspace.getPageIndicator().updateColor(mExtractedColors);
+ boolean lightStatusBar = (FeatureFlags.LIGHT_STATUS_BAR
+ && mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX,
+ ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT);
// It's possible that All Apps is visible when this is run,
- // so always use light status bar in that case.
- activateLightStatusBar(isAllAppsVisible(), false);
+ // so always use light status bar in that case. Only change nav bar color to status bar
+ // color when All Apps is visible.
+ activateLightStatusBar(lightStatusBar || isAllAppsVisible(), isAllAppsVisible());
}
}
@@ -483,28 +487,24 @@
/**
* Sets the status bar to be light or not. Light status bar means dark icons.
- * @param activate if true, make sure the status bar is light, otherwise base on wallpaper.
- * @param changeNavBar make sure the nav bar is light only if this param and {@param activate}
- * is also true.
+ * @param lightStatusBar make sure the status bar is light
+ * @param changeNavBar if true, make the nav bar theme in sync with status bar.
*/
- public void activateLightStatusBar(boolean activate, boolean changeNavBar) {
- boolean lightStatusBar = activate || (FeatureFlags.LIGHT_STATUS_BAR
- && mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX,
- ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT);
+ public void activateLightStatusBar(boolean lightStatusBar, boolean changeNavBar) {
int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility();
int newSystemUiFlags = oldSystemUiFlags;
if (lightStatusBar) {
newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR ;
+ if (changeNavBar && Utilities.isAtLeastO()) {
+ newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR;
+ }
} else {
newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
- }
- if (Utilities.isAtLeastO() && activate) {
- if (changeNavBar) {
- newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR;
- } else {
+ if (changeNavBar && Utilities.isAtLeastO()) {
newSystemUiFlags &= ~(SYSTEM_UI_FLAG_LIGHT_NAV_BAR);
}
}
+
if (newSystemUiFlags != oldSystemUiFlags) {
getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags);
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index ed148fe..bf774e6 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -247,7 +247,6 @@
private boolean mStripScreensOnPageStopMoving = false;
private DragPreviewProvider mOutlineProvider = null;
- public static final int DRAG_BITMAP_PADDING = DragPreviewProvider.DRAG_BITMAP_PADDING;
private boolean mWorkspaceFadeInAdjacentScreens;
final WallpaperOffsetInterpolator mWallpaperOffset;
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 99cac41..c199fef 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -288,7 +288,7 @@
// Use a light status bar (dark icons) if all apps is behind at least half of the status
// bar. If the status bar is already light due to wallpaper extraction, keep it that way.
boolean forceLight = shift <= mStatusBarHeight / 2;
- mLauncher.activateLightStatusBar(forceLight, forceLight);
+ mLauncher.activateLightStatusBar(forceLight, true);
}
/**
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index d656c84..4279cc3 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -655,7 +655,7 @@
} else if (child instanceof FolderIcon) {
// Account for holographic blur padding on the drag view
toY += Math.round(scale * (child.getPaddingTop() - dragView.getDragRegionTop()));
- toY -= scale * Workspace.DRAG_BITMAP_PADDING / 2;
+ toY -= scale * dragView.getBlurSizeOutline() / 2;
toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
// Center in the x coordinate about the target's drawable
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index 93f5be5..c946235 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -49,6 +49,7 @@
private Bitmap mBitmap;
private Bitmap mCrossFadeBitmap;
@Thunk Paint mPaint;
+ private final int mBlurSizeOutline;
private final int mRegistrationX;
private final int mRegistrationY;
private final float mInitialScale;
@@ -140,6 +141,8 @@
measure(ms, ms);
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
+ mBlurSizeOutline = getResources().getDimensionPixelSize(R.dimen.blur_size_medium_outline);
+
setElevation(getResources().getDimension(R.dimen.drag_elevation));
}
@@ -385,4 +388,8 @@
target.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
Color.blue(color) / 255f, Color.alpha(color) / 255f);
}
+
+ public int getBlurSizeOutline() {
+ return mBlurSizeOutline;
+ }
}
diff --git a/src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java b/src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java
index 37cc9ad..e558487 100644
--- a/src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java
+++ b/src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java
@@ -41,7 +41,7 @@
private final int[] mOutlineSize;
public ExternalDragPreviewProvider(Launcher launcher, ItemInfo addInfo) {
- super(null);
+ super(null, launcher);
mLauncher = launcher;
mAddInfo = addInfo;
@@ -51,7 +51,7 @@
public Rect getPreviewBounds() {
Rect rect = new Rect();
DeviceProfile dp = mLauncher.getDeviceProfile();
- rect.left = DRAG_BITMAP_PADDING / 2;
+ rect.left = blurSizeOutline / 2;
rect.top = (mOutlineSize[1] - dp.cellHeightPx) / 2;
rect.right = rect.left + dp.iconSizePx;
rect.bottom = rect.top + dp.iconSizePx;
@@ -69,8 +69,8 @@
// Use 0.9f times the radius for the actual circle to account for icon normalization.
float radius = getPreviewBounds().width() * 0.5f;
- canvas.drawCircle(DRAG_BITMAP_PADDING / 2 + radius,
- DRAG_BITMAP_PADDING / 2 + radius, radius * 0.9f, paint);
+ canvas.drawCircle(blurSizeOutline / 2 + radius,
+ blurSizeOutline / 2 + radius, radius * 0.9f, paint);
HolographicOutlineHelper.getInstance(mLauncher).applyExpensiveOutlineWithBlur(b, canvas);
canvas.setBitmap(null);
diff --git a/src/com/android/launcher3/graphics/DragPreviewProvider.java b/src/com/android/launcher3/graphics/DragPreviewProvider.java
index e205c42..7f1790a 100644
--- a/src/com/android/launcher3/graphics/DragPreviewProvider.java
+++ b/src/com/android/launcher3/graphics/DragPreviewProvider.java
@@ -16,6 +16,7 @@
package com.android.launcher3.graphics;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -28,6 +29,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PreloadIconDrawable;
+import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.folder.FolderIcon;
@@ -37,8 +39,6 @@
*/
public class DragPreviewProvider {
- public static final int DRAG_BITMAP_PADDING = 2;
-
private final Rect mTempRect = new Rect();
protected final View mView;
@@ -46,17 +46,25 @@
// The padding added to the drag view during the preview generation.
public final int previewPadding;
+ protected final int blurSizeOutline;
+
public Bitmap generatedDragOutline;
public DragPreviewProvider(View view) {
+ this(view, view.getContext());
+ }
+
+ public DragPreviewProvider(View view, Context context) {
mView = view;
+ blurSizeOutline =
+ context.getResources().getDimensionPixelSize(R.dimen.blur_size_medium_outline);
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
- previewPadding = DRAG_BITMAP_PADDING - bounds.left - bounds.top;
+ previewPadding = blurSizeOutline - bounds.left - bounds.top;
} else {
- previewPadding = DRAG_BITMAP_PADDING;
+ previewPadding = blurSizeOutline;
}
}
@@ -68,8 +76,8 @@
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
- destCanvas.translate(DRAG_BITMAP_PADDING / 2 - bounds.left,
- DRAG_BITMAP_PADDING / 2 - bounds.top);
+ destCanvas.translate(blurSizeOutline / 2 - bounds.left,
+ blurSizeOutline / 2 - bounds.top);
d.draw(destCanvas);
} else {
final Rect clipRect = mTempRect;
@@ -84,8 +92,8 @@
textVisible = true;
}
}
- destCanvas.translate(-mView.getScrollX() + DRAG_BITMAP_PADDING / 2,
- -mView.getScrollY() + DRAG_BITMAP_PADDING / 2);
+ destCanvas.translate(-mView.getScrollX() + blurSizeOutline / 2,
+ -mView.getScrollY() + blurSizeOutline / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
mView.draw(destCanvas);
@@ -118,7 +126,7 @@
height = (int) (mView.getHeight() * scale);
}
- Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
+ Bitmap b = Bitmap.createBitmap(width + blurSizeOutline, height + blurSizeOutline,
Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
@@ -156,7 +164,7 @@
height = (int) Math.floor(mView.getHeight() * scale);
}
- Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
+ Bitmap b = Bitmap.createBitmap(width + blurSizeOutline, height + blurSizeOutline,
Bitmap.Config.ALPHA_8);
canvas.setBitmap(b);
diff --git a/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java b/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java
index fc474f5..ab8de6b 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java
@@ -64,13 +64,13 @@
int size = Launcher.getLauncher(mView.getContext()).getDeviceProfile().iconSizePx;
final Bitmap b = Bitmap.createBitmap(
- size + DRAG_BITMAP_PADDING,
- size + DRAG_BITMAP_PADDING,
+ size + blurSizeOutline,
+ size + blurSizeOutline,
config);
canvas.setBitmap(b);
canvas.save(Canvas.MATRIX_SAVE_FLAG);
- canvas.translate(DRAG_BITMAP_PADDING / 2, DRAG_BITMAP_PADDING / 2);
+ canvas.translate(blurSizeOutline / 2, blurSizeOutline / 2);
canvas.scale(((float) size) / bounds.width(), ((float) size) / bounds.height(), 0, 0);
canvas.translate(bounds.left, bounds.top);
d.draw(canvas);
diff --git a/src/com/android/launcher3/widget/PendingItemPreviewProvider.java b/src/com/android/launcher3/widget/PendingItemPreviewProvider.java
index 722fbb8..3a49a6c 100644
--- a/src/com/android/launcher3/widget/PendingItemPreviewProvider.java
+++ b/src/com/android/launcher3/widget/PendingItemPreviewProvider.java
@@ -53,8 +53,8 @@
canvas.setBitmap(b);
Rect src = new Rect(0, 0, mPreviewBitmap.getWidth(), mPreviewBitmap.getHeight());
- float scaleFactor = Math.min((w - DRAG_BITMAP_PADDING) / (float) mPreviewBitmap.getWidth(),
- (h - DRAG_BITMAP_PADDING) / (float) mPreviewBitmap.getHeight());
+ float scaleFactor = Math.min((w - blurSizeOutline) / (float) mPreviewBitmap.getWidth(),
+ (h - blurSizeOutline) / (float) mPreviewBitmap.getHeight());
int scaledWidth = (int) (scaleFactor * mPreviewBitmap.getWidth());
int scaledHeight = (int) (scaleFactor * mPreviewBitmap.getHeight());
Rect dst = new Rect(0, 0, scaledWidth, scaledHeight);