mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Adding margin to Drag layer instead of checking for right insets at every place
Bug: 25692432 Change-Id: I853f41a17c54b30b7772b9fd8556d9465de84752
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.util.DisplayMetrics;
|
||||
@@ -84,9 +83,6 @@ public class InvariantDeviceProfile {
|
||||
DeviceProfile landscapeProfile;
|
||||
DeviceProfile portraitProfile;
|
||||
|
||||
// On Marshmallow the status bar is no longer opaque, when drawn on the right.
|
||||
public boolean isRightInsetOpaque;
|
||||
|
||||
InvariantDeviceProfile() {
|
||||
}
|
||||
|
||||
@@ -170,9 +166,6 @@ public class InvariantDeviceProfile {
|
||||
largeSide, smallSide, true /* isLandscape */);
|
||||
portraitProfile = new DeviceProfile(context, this, smallestSize, largestSize,
|
||||
smallSide, largeSide, false /* isLandscape */);
|
||||
|
||||
isRightInsetOpaque = !Utilities.ATLEAST_MARSHMALLOW ||
|
||||
context.getSystemService(ActivityManager.class).isLowRamDevice();
|
||||
}
|
||||
|
||||
ArrayList<InvariantDeviceProfile> getPredefinedDeviceProfiles() {
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class LauncherRootView extends InsettableFrameLayout {
|
||||
|
||||
private final Paint mOpaquePaint;
|
||||
private boolean mDrawRightInsetBar;
|
||||
|
||||
private View mAlignedView;
|
||||
|
||||
public LauncherRootView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -20,11 +25,33 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
mOpaquePaint.setStyle(Paint.Style.FILL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
if (getChildCount() > 0) {
|
||||
// LauncherRootView contains only one child, which should be aligned
|
||||
// based on the horizontal insets.
|
||||
mAlignedView = getChildAt(0);
|
||||
}
|
||||
super.onFinishInflate();
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
@Override
|
||||
protected boolean fitSystemWindows(Rect insets) {
|
||||
setInsets(insets);
|
||||
mDrawRightInsetBar = mInsets.right > 0 && LauncherAppState
|
||||
.getInstance().getInvariantDeviceProfile().isRightInsetOpaque;
|
||||
mDrawRightInsetBar = insets.right > 0 &&
|
||||
(!Utilities.ATLEAST_MARSHMALLOW ||
|
||||
getContext().getSystemService(ActivityManager.class).isLowRamDevice());
|
||||
setInsets(mDrawRightInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets);
|
||||
|
||||
if (mAlignedView != null) {
|
||||
// Apply margins on aligned view to handle left/right insets.
|
||||
MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams();
|
||||
if (lp.leftMargin != insets.left || lp.rightMargin != insets.right) {
|
||||
lp.leftMargin = insets.left;
|
||||
lp.rightMargin = insets.right;
|
||||
mAlignedView.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
return true; // I'll take it from here
|
||||
}
|
||||
|
||||
@@ -202,9 +202,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
protected final Rect mInsets = new Rect();
|
||||
protected final boolean mIsRtl;
|
||||
|
||||
// When set to true, full screen content and overscroll effect is shited inside by right inset.
|
||||
protected boolean mIgnoreRightInset;
|
||||
|
||||
// Edge effect
|
||||
private final LauncherEdgeEffect mEdgeGlowLeft = new LauncherEdgeEffect();
|
||||
private final LauncherEdgeEffect mEdgeGlowRight = new LauncherEdgeEffect();
|
||||
@@ -822,8 +819,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
childWidthMode = MeasureSpec.EXACTLY;
|
||||
childHeightMode = MeasureSpec.EXACTLY;
|
||||
|
||||
childWidth = getViewportWidth() - mInsets.left
|
||||
- (mIgnoreRightInset ? mInsets.right : 0);
|
||||
childWidth = getViewportWidth() - mInsets.left - mInsets.right;
|
||||
childHeight = getViewportHeight();
|
||||
}
|
||||
if (referenceChildWidth == 0) {
|
||||
@@ -1182,9 +1178,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
|
||||
getEdgeVerticalPostion(sTmpIntPoint);
|
||||
|
||||
int width = mIgnoreRightInset ? (display.width() - mInsets.right) : display.width();
|
||||
canvas.translate(sTmpIntPoint[0] - display.top, -width);
|
||||
mEdgeGlowRight.setSize(sTmpIntPoint[1] - sTmpIntPoint[0], width);
|
||||
canvas.translate(sTmpIntPoint[0] - display.top, -display.width());
|
||||
mEdgeGlowRight.setSize(sTmpIntPoint[1] - sTmpIntPoint[0], display.width());
|
||||
if (mEdgeGlowRight.draw(canvas)) {
|
||||
postInvalidateOnAnimation();
|
||||
}
|
||||
|
||||
@@ -455,7 +455,6 @@ public class Workspace extends PagedView
|
||||
setWallpaperDimension();
|
||||
|
||||
setEdgeGlowColor(getResources().getColor(R.color.workspace_edge_effect_color));
|
||||
mIgnoreRightInset = app.getInvariantDeviceProfile().isRightInsetOpaque;
|
||||
}
|
||||
|
||||
private void setupLayoutTransition() {
|
||||
|
||||
Reference in New Issue
Block a user