Merge "Revert "Draw rounded corners above the taskbar"" into sc-v2-dev
This commit is contained in:
@@ -36,7 +36,6 @@ import android.view.ContextThemeWrapper;
|
|||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.RoundedCorner;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@@ -84,7 +83,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
|||||||
private final TaskbarControllers mControllers;
|
private final TaskbarControllers mControllers;
|
||||||
|
|
||||||
private final WindowManager mWindowManager;
|
private final WindowManager mWindowManager;
|
||||||
private final RoundedCorner mLeftCorner, mRightCorner;
|
|
||||||
private WindowManager.LayoutParams mWindowLayoutParams;
|
private WindowManager.LayoutParams mWindowLayoutParams;
|
||||||
private boolean mIsFullscreen;
|
private boolean mIsFullscreen;
|
||||||
// The size we should return to when we call setTaskbarWindowFullscreen(false)
|
// The size we should return to when we call setTaskbarWindowFullscreen(false)
|
||||||
@@ -138,12 +136,10 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
|||||||
? windowContext.getApplicationContext()
|
? windowContext.getApplicationContext()
|
||||||
: windowContext.getApplicationContext().createDisplayContext(display);
|
: windowContext.getApplicationContext().createDisplayContext(display);
|
||||||
mWindowManager = c.getSystemService(WindowManager.class);
|
mWindowManager = c.getSystemService(WindowManager.class);
|
||||||
mLeftCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_LEFT);
|
|
||||||
mRightCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
mLastRequestedNonFullscreenHeight = getDefaultTaskbarWindowHeight();
|
mLastRequestedNonFullscreenHeight = mDeviceProfile.taskbarSize;
|
||||||
mWindowLayoutParams = new WindowManager.LayoutParams(
|
mWindowLayoutParams = new WindowManager.LayoutParams(
|
||||||
MATCH_PARENT,
|
MATCH_PARENT,
|
||||||
mLastRequestedNonFullscreenHeight,
|
mLastRequestedNonFullscreenHeight,
|
||||||
@@ -173,14 +169,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
|||||||
return mNavMode == Mode.THREE_BUTTONS;
|
return mNavMode == Mode.THREE_BUTTONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoundedCorner getLeftCorner() {
|
|
||||||
return mLeftCorner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RoundedCorner getRightCorner() {
|
|
||||||
return mRightCorner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LayoutInflater getLayoutInflater() {
|
public LayoutInflater getLayoutInflater() {
|
||||||
return mLayoutInflater;
|
return mLayoutInflater;
|
||||||
@@ -262,12 +250,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
|||||||
setTaskbarWindowHeight(fullscreen ? MATCH_PARENT : mLastRequestedNonFullscreenHeight);
|
setTaskbarWindowHeight(fullscreen ? MATCH_PARENT : mLastRequestedNonFullscreenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTaskbarWindowFullscreen() {
|
|
||||||
return mIsFullscreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the TaskbarContainer height (pass {@link #getDefaultTaskbarWindowHeight()} to reset).
|
* Updates the TaskbarContainer height (pass deviceProfile.taskbarSize to reset).
|
||||||
*/
|
*/
|
||||||
public void setTaskbarWindowHeight(int height) {
|
public void setTaskbarWindowHeight(int height) {
|
||||||
if (mWindowLayoutParams.height == height || mIsDestroyed) {
|
if (mWindowLayoutParams.height == height || mIsDestroyed) {
|
||||||
@@ -287,14 +271,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
|||||||
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
|
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the default height of the window, including the static corner radii above taskbar.
|
|
||||||
*/
|
|
||||||
public int getDefaultTaskbarWindowHeight() {
|
|
||||||
return mDeviceProfile.taskbarSize
|
|
||||||
+ Math.max(mLeftCorner.getRadius(), mRightCorner.getRadius());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onTaskbarIconClicked(View view) {
|
protected void onTaskbarIconClicked(View view) {
|
||||||
Object tag = view.getTag();
|
Object tag = view.getTag();
|
||||||
if (tag instanceof Task) {
|
if (tag instanceof Task) {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.launcher3.taskbar;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -41,12 +40,9 @@ import com.android.systemui.shared.system.ViewTreeObserverWrapper.OnComputeInset
|
|||||||
public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||||
|
|
||||||
private final Paint mTaskbarBackgroundPaint;
|
private final Paint mTaskbarBackgroundPaint;
|
||||||
private final Path mInvertedLeftCornerPath, mInvertedRightCornerPath;
|
|
||||||
private final OnComputeInsetsListener mTaskbarInsetsComputer = this::onComputeTaskbarInsets;
|
private final OnComputeInsetsListener mTaskbarInsetsComputer = this::onComputeTaskbarInsets;
|
||||||
|
|
||||||
// Initialized in init.
|
|
||||||
private TaskbarDragLayerController.TaskbarDragLayerCallbacks mControllerCallbacks;
|
private TaskbarDragLayerController.TaskbarDragLayerCallbacks mControllerCallbacks;
|
||||||
private float mLeftCornerRadius, mRightCornerRadius;
|
|
||||||
|
|
||||||
private float mTaskbarBackgroundOffset;
|
private float mTaskbarBackgroundOffset;
|
||||||
|
|
||||||
@@ -69,32 +65,10 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
|||||||
mTaskbarBackgroundPaint = new Paint();
|
mTaskbarBackgroundPaint = new Paint();
|
||||||
mTaskbarBackgroundPaint.setColor(getResources().getColor(R.color.taskbar_background));
|
mTaskbarBackgroundPaint.setColor(getResources().getColor(R.color.taskbar_background));
|
||||||
mTaskbarBackgroundPaint.setAlpha(0);
|
mTaskbarBackgroundPaint.setAlpha(0);
|
||||||
mTaskbarBackgroundPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
|
|
||||||
mTaskbarBackgroundPaint.setStyle(Paint.Style.FILL);
|
|
||||||
|
|
||||||
// Will be set in init(), but this ensures they are always non-null.
|
|
||||||
mInvertedLeftCornerPath = new Path();
|
|
||||||
mInvertedRightCornerPath = new Path();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(TaskbarDragLayerController.TaskbarDragLayerCallbacks callbacks) {
|
public void init(TaskbarDragLayerController.TaskbarDragLayerCallbacks callbacks) {
|
||||||
mControllerCallbacks = callbacks;
|
mControllerCallbacks = callbacks;
|
||||||
|
|
||||||
// Create the paths for the inverted rounded corners above the taskbar. Start with a filled
|
|
||||||
// square, and then subtracting out a circle from the appropriate corner.
|
|
||||||
mLeftCornerRadius = mActivity.getLeftCorner().getRadius();
|
|
||||||
mRightCornerRadius = mActivity.getRightCorner().getRadius();
|
|
||||||
Path square = new Path();
|
|
||||||
square.addRect(0, 0, mLeftCornerRadius, mLeftCornerRadius, Path.Direction.CW);
|
|
||||||
Path circle = new Path();
|
|
||||||
circle.addCircle(mLeftCornerRadius, 0, mLeftCornerRadius, Path.Direction.CW);
|
|
||||||
mInvertedLeftCornerPath.op(square, circle, Path.Op.DIFFERENCE);
|
|
||||||
square.reset();
|
|
||||||
square.addRect(0, 0, mRightCornerRadius, mRightCornerRadius, Path.Direction.CW);
|
|
||||||
circle.reset();
|
|
||||||
circle.addCircle(0, 0, mRightCornerRadius, Path.Direction.CW);
|
|
||||||
mInvertedRightCornerPath.op(square, circle, Path.Op.DIFFERENCE);
|
|
||||||
|
|
||||||
recreateControllers();
|
recreateControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,20 +121,8 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
|||||||
protected void dispatchDraw(Canvas canvas) {
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
float backgroundHeight = mControllerCallbacks.getTaskbarBackgroundHeight()
|
float backgroundHeight = mControllerCallbacks.getTaskbarBackgroundHeight()
|
||||||
* (1f - mTaskbarBackgroundOffset);
|
* (1f - mTaskbarBackgroundOffset);
|
||||||
canvas.save();
|
canvas.drawRect(0, canvas.getHeight() - backgroundHeight, canvas.getWidth(),
|
||||||
canvas.translate(0, canvas.getHeight() - backgroundHeight);
|
canvas.getHeight(), mTaskbarBackgroundPaint);
|
||||||
|
|
||||||
// Draw the background behind taskbar content.
|
|
||||||
canvas.drawRect(0, 0, canvas.getWidth(), backgroundHeight, mTaskbarBackgroundPaint);
|
|
||||||
|
|
||||||
// Draw the inverted rounded corners above the taskbar.
|
|
||||||
canvas.translate(0, -mLeftCornerRadius);
|
|
||||||
canvas.drawPath(mInvertedLeftCornerPath, mTaskbarBackgroundPaint);
|
|
||||||
canvas.translate(0, mLeftCornerRadius);
|
|
||||||
canvas.translate(canvas.getWidth() - mRightCornerRadius, -mRightCornerRadius);
|
|
||||||
canvas.drawPath(mInvertedRightCornerPath, mTaskbarBackgroundPaint);
|
|
||||||
|
|
||||||
canvas.restore();
|
|
||||||
super.dispatchDraw(canvas);
|
super.dispatchDraw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
package com.android.launcher3.taskbar;
|
package com.android.launcher3.taskbar;
|
||||||
|
|
||||||
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
|
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
|
||||||
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_CONTENT;
|
|
||||||
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_FRAME;
|
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_FRAME;
|
||||||
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
|
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
|
||||||
|
|
||||||
@@ -133,14 +132,13 @@ public class TaskbarDragLayerController {
|
|||||||
// Let touches pass through us.
|
// Let touches pass through us.
|
||||||
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
|
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
|
||||||
} else if (mControllers.navbarButtonsViewController.isImeVisible()) {
|
} else if (mControllers.navbarButtonsViewController.isImeVisible()) {
|
||||||
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_CONTENT);
|
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_FRAME);
|
||||||
} else if (!mControllers.uiController.isTaskbarTouchable()) {
|
} else if (!mControllers.uiController.isTaskbarTouchable()) {
|
||||||
// Let touches pass through us.
|
// Let touches pass through us.
|
||||||
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
|
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
|
||||||
} else if (mControllers.taskbarViewController.areIconsVisible()) {
|
} else if (mControllers.taskbarViewController.areIconsVisible()) {
|
||||||
// Buttons are visible, take over the full taskbar area
|
// Buttons are visible, take over the full taskbar area
|
||||||
insetsInfo.setTouchableInsets(mActivity.isTaskbarWindowFullscreen()
|
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_FRAME);
|
||||||
? TOUCHABLE_INSETS_FRAME : TOUCHABLE_INSETS_CONTENT);
|
|
||||||
} else {
|
} else {
|
||||||
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
|
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,9 +165,8 @@ public class TaskbarViewController {
|
|||||||
int offsetY = launcherDp.getTaskbarOffsetY();
|
int offsetY = launcherDp.getTaskbarOffsetY();
|
||||||
setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
|
setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
|
||||||
|
|
||||||
int collapsedHeight = mActivity.getDefaultTaskbarWindowHeight();
|
int collapsedHeight = mActivity.getDeviceProfile().taskbarSize;
|
||||||
int expandedHeight = Math.max(collapsedHeight,
|
int expandedHeight = collapsedHeight + offsetY;
|
||||||
mActivity.getDeviceProfile().taskbarSize + offsetY);
|
|
||||||
setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(
|
setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(
|
||||||
anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));
|
anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user