Files
Lawnchair/src/com/android/launcher3/LauncherRootView.java
T
Winson Chung f26d98e870 Merging ub-launcher3-qt-dev, build 5619253
Test: Manual
Bug:112282235 P3 Starting an app from Launcher very rarely takes > 10 sec
Bug:121279417 P2 Why LauncherInstrumentation.WAIT_TIME_MS == 60000?
Bug:123892607 P1 Test broken: WellbeingTests.testPauseAppFromAllApps
Bug:123900446 P1 App to home animation should zoom into the app icon
Bug:125844074 P2 Final UX and animations for Launcher DWB integration
Bug:131360075 P1 [Gesture Nav] Polish/finish landscape
Bug:131698989 P2 Add task callback for locked state change
Bug:131741395 P2 Allow windows to scale/move past overview positioning
Bug:131768436 P1 Bad placement of search bar
Bug:131854153 P1 Lots of Cuttlefish (and not only) tests are broken
Bug:131867841 P1 Changing display size does not update the grid
Bug:132460627 P1 Unable to swipe to all apps screen on devices
Bug:132687470 P1 Swiping home from forced landscape app creates cutoff task thumbnail
Bug:132756514 P1 Sometimes (when quick switching?) user gets stuck in full-screen recents view
Bug:132900132 P1 Apparently, tests start running while provisioning is still in progress
Bug:132917885 P1 Reduce swipe-up gesture region height in landscape
Bug:132975416 P1 Flake in NexusPredictionAppTracker.getAppPredictionContextExtras
Bug:132993129 P1 If predictions disabled, app predictions loading bar appears briefly on device restart
Bug:133113732 P1 [B1/C1][QT][CTS_Verifier_9.0_r1]Device Owner Tests-LockTask UI-Enable Overview button failure
Bug:133167096 P1 It is way too easy to dismiss apps from the lock screen
Bug:133651528 P1 [QT]"Pixel Launcher isn't responding" dialog pop up ,after DUT restored.
Bug:133765434 P1 [Flaky test] Launching task didn't open a new window
Bug:133765491 P1 App docked in split screen flickers with emptiness observed while rotating the device
Bug:133783088 P1 Footer showing up on all overview task snapshots even with no items showing.
Bug:133867119 P2 Lab-only flake: want to switch from workspace to all apps; Swipe failed to receive an event for the swipe end
Bug:64712476 P3 Import translations for dev branches

Change-Id: Ib4bcefdbb4027992e75e2742d72f199e13467875
(cherry picked from commit 0ef6fe00b0)
2019-05-31 20:37:38 +00:00

182 lines
6.3 KiB
Java

package com.android.launcher3;
import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV;
import static com.android.launcher3.util.SystemUiController.UI_STATE_ROOT_VIEW;
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.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewDebug;
import java.util.Collections;
import java.util.List;
public class LauncherRootView extends InsettableFrameLayout {
private final Launcher mLauncher;
private final Paint mOpaquePaint;
@ViewDebug.ExportedProperty(category = "launcher")
private final Rect mConsumedInsets = new Rect();
@ViewDebug.ExportedProperty(category = "launcher")
private static final List<Rect> SYSTEM_GESTURE_EXCLUSION_RECT =
Collections.singletonList(new Rect());
private View mAlignedView;
private WindowStateListener mWindowStateListener;
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mDisallowBackGesture;
public LauncherRootView(Context context, AttributeSet attrs) {
super(context, attrs);
mOpaquePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mOpaquePaint.setColor(Color.BLACK);
mOpaquePaint.setStyle(Paint.Style.FILL);
mLauncher = Launcher.getLauncher(context);
}
@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) {
mConsumedInsets.setEmpty();
boolean drawInsetBar = false;
if (mLauncher.isInMultiWindowMode()
&& (insets.left > 0 || insets.right > 0 || insets.bottom > 0)) {
mConsumedInsets.left = insets.left;
mConsumedInsets.right = insets.right;
mConsumedInsets.bottom = insets.bottom;
insets = new Rect(0, insets.top, 0, 0);
drawInsetBar = true;
} else if ((insets.right > 0 || insets.left > 0) &&
getContext().getSystemService(ActivityManager.class).isLowRamDevice()) {
mConsumedInsets.left = insets.left;
mConsumedInsets.right = insets.right;
insets = new Rect(0, insets.top, 0, insets.bottom);
drawInsetBar = true;
}
mLauncher.getSystemUiController().updateUiState(
UI_STATE_ROOT_VIEW, drawInsetBar ? FLAG_DARK_NAV : 0);
// Update device profile before notifying th children.
mLauncher.updateInsets(insets);
boolean resetState = !insets.equals(mInsets);
setInsets(insets);
if (mAlignedView != null) {
// Apply margins on aligned view to handle consumed insets.
MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams();
if (lp.leftMargin != mConsumedInsets.left || lp.rightMargin != mConsumedInsets.right ||
lp.bottomMargin != mConsumedInsets.bottom) {
lp.leftMargin = mConsumedInsets.left;
lp.rightMargin = mConsumedInsets.right;
lp.topMargin = mConsumedInsets.top;
lp.bottomMargin = mConsumedInsets.bottom;
mAlignedView.setLayoutParams(lp);
}
}
if (resetState) {
mLauncher.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
}
return false; // Let children get the full insets
}
@Override
public void setInsets(Rect insets) {
// If the insets haven't changed, this is a no-op. Avoid unnecessary layout caused by
// modifying child layout params.
if (!insets.equals(mInsets)) {
super.setInsets(insets);
}
}
public void dispatchInsets() {
mLauncher.updateInsets(mInsets);
super.setInsets(mInsets);
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
// If the right inset is opaque, draw a black rectangle to ensure that is stays opaque.
if (mConsumedInsets.right > 0) {
int width = getWidth();
canvas.drawRect(width - mConsumedInsets.right, 0, width, getHeight(), mOpaquePaint);
}
if (mConsumedInsets.left > 0) {
canvas.drawRect(0, 0, mConsumedInsets.left, getHeight(), mOpaquePaint);
}
if (mConsumedInsets.bottom > 0) {
int height = getHeight();
canvas.drawRect(0, height - mConsumedInsets.bottom, getWidth(), height, mOpaquePaint);
}
}
public void setWindowStateListener(WindowStateListener listener) {
mWindowStateListener = listener;
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
if (mWindowStateListener != null) {
mWindowStateListener.onWindowFocusChanged(hasWindowFocus);
}
}
@Override
protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility);
if (mWindowStateListener != null) {
mWindowStateListener.onWindowVisibilityChanged(visibility);
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(l, t, r, b);
setDisallowBackGesture(mDisallowBackGesture);
}
@TargetApi(Build.VERSION_CODES.Q)
public void setDisallowBackGesture(boolean disallowBackGesture) {
if (!Utilities.ATLEAST_Q) {
return;
}
mDisallowBackGesture = disallowBackGesture;
setSystemGestureExclusionRects(mDisallowBackGesture
? SYSTEM_GESTURE_EXCLUSION_RECT
: Collections.emptyList());
}
public interface WindowStateListener {
void onWindowFocusChanged(boolean hasFocus);
void onWindowVisibilityChanged(int visibility);
}
}