150d7bfd8224f9da170dac668888bcf0831373051Adam Powell/* 250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Copyright (C) 2014 The Android Open Source Project 350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * you may not use this file except in compliance with the License. 650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * You may obtain a copy of the License at 750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * http://www.apache.org/licenses/LICENSE-2.0 950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 1050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Unless required by applicable law or agreed to in writing, software 1150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * distributed under the License is distributed on an "AS IS" BASIS, 1250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * See the License for the specific language governing permissions and 1450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * limitations under the License. 1550d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 1650d7bfd8224f9da170dac668888bcf0831373051Adam Powell 1750d7bfd8224f9da170dac668888bcf0831373051Adam Powell 1850d7bfd8224f9da170dac668888bcf0831373051Adam Powellpackage android.view; 1950d7bfd8224f9da170dac668888bcf0831373051Adam Powell 2050d7bfd8224f9da170dac668888bcf0831373051Adam Powellimport android.graphics.Rect; 2150d7bfd8224f9da170dac668888bcf0831373051Adam Powell 2250d7bfd8224f9da170dac668888bcf0831373051Adam Powell/** 2350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Describes a set of insets for window content. 2450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 2550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>WindowInsets are immutable and may be expanded to include more inset types in the future. 2650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * To adjust insets, use one of the supplied clone methods to obtain a new WindowInsets instance 2750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * with the adjusted properties.</p> 2850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 2950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @see View.OnApplyWindowInsetsListener 3050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @see View#onApplyWindowInsets(WindowInsets) 3150d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 32f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powellpublic final class WindowInsets { 33fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 3450d7bfd8224f9da170dac668888bcf0831373051Adam Powell private Rect mSystemWindowInsets; 3550d7bfd8224f9da170dac668888bcf0831373051Adam Powell private Rect mWindowDecorInsets; 36fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos private Rect mStableInsets; 3750d7bfd8224f9da170dac668888bcf0831373051Adam Powell private Rect mTempRect; 38973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell private boolean mIsRound; 3950d7bfd8224f9da170dac668888bcf0831373051Adam Powell 400d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell private boolean mSystemWindowInsetsConsumed = false; 410d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell private boolean mWindowDecorInsetsConsumed = false; 42fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos private boolean mStableInsetsConsumed = false; 430d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell 4450d7bfd8224f9da170dac668888bcf0831373051Adam Powell private static final Rect EMPTY_RECT = new Rect(0, 0, 0, 0); 4550d7bfd8224f9da170dac668888bcf0831373051Adam Powell 4650d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 4750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Since new insets may be added in the future that existing apps couldn't 4850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * know about, this fully empty constant shouldn't be made available to apps 4950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * since it would allow them to inadvertently consume unknown insets by returning it. 5050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @hide 5150d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 52720924b6a9770f03355999102a11d98c5954407cAdam Powell public static final WindowInsets CONSUMED; 53720924b6a9770f03355999102a11d98c5954407cAdam Powell 54720924b6a9770f03355999102a11d98c5954407cAdam Powell static { 55fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos CONSUMED = new WindowInsets(null, null, null, false); 566642e51ac5d0351f02fc929817603d7371e08e10Michael Kolb } 576642e51ac5d0351f02fc929817603d7371e08e10Michael Kolb 586642e51ac5d0351f02fc929817603d7371e08e10Michael Kolb /** @hide */ 59fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos public WindowInsets(Rect systemWindowInsets, Rect windowDecorInsets, Rect stableInsets, 60fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos boolean isRound) { 610d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell mSystemWindowInsetsConsumed = systemWindowInsets == null; 620d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell mSystemWindowInsets = mSystemWindowInsetsConsumed ? EMPTY_RECT : systemWindowInsets; 630d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell 640d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell mWindowDecorInsetsConsumed = windowDecorInsets == null; 650d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell mWindowDecorInsets = mWindowDecorInsetsConsumed ? EMPTY_RECT : windowDecorInsets; 660d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell 67fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos mStableInsetsConsumed = stableInsets == null; 68fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos mStableInsets = mStableInsetsConsumed ? EMPTY_RECT : stableInsets; 69fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 70973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell mIsRound = isRound; 7150d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 7250d7bfd8224f9da170dac668888bcf0831373051Adam Powell 7350d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 7450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Construct a new WindowInsets, copying all values from a source WindowInsets. 7550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 7650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @param src Source to copy insets from 7750d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 7850d7bfd8224f9da170dac668888bcf0831373051Adam Powell public WindowInsets(WindowInsets src) { 7950d7bfd8224f9da170dac668888bcf0831373051Adam Powell mSystemWindowInsets = src.mSystemWindowInsets; 8050d7bfd8224f9da170dac668888bcf0831373051Adam Powell mWindowDecorInsets = src.mWindowDecorInsets; 81fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos mStableInsets = src.mStableInsets; 820d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell mSystemWindowInsetsConsumed = src.mSystemWindowInsetsConsumed; 830d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell mWindowDecorInsetsConsumed = src.mWindowDecorInsetsConsumed; 84fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos mStableInsetsConsumed = src.mStableInsetsConsumed; 85973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell mIsRound = src.mIsRound; 8650d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 8750d7bfd8224f9da170dac668888bcf0831373051Adam Powell 8850d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** @hide */ 8950d7bfd8224f9da170dac668888bcf0831373051Adam Powell public WindowInsets(Rect systemWindowInsets) { 90fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos this(systemWindowInsets, null, null, false); 9150d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 9250d7bfd8224f9da170dac668888bcf0831373051Adam Powell 9350d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 9450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Used to provide a safe copy of the system window insets to pass through 9550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * to the existing fitSystemWindows method and other similar internals. 9650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @hide 9750d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 9850d7bfd8224f9da170dac668888bcf0831373051Adam Powell public Rect getSystemWindowInsets() { 9950d7bfd8224f9da170dac668888bcf0831373051Adam Powell if (mTempRect == null) { 10050d7bfd8224f9da170dac668888bcf0831373051Adam Powell mTempRect = new Rect(); 10150d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 102eba8782a1f8412a3510fc78a71b843ef6e89bdbbJustin Koh if (mSystemWindowInsets != null) { 103eba8782a1f8412a3510fc78a71b843ef6e89bdbbJustin Koh mTempRect.set(mSystemWindowInsets); 104eba8782a1f8412a3510fc78a71b843ef6e89bdbbJustin Koh } else { 105eba8782a1f8412a3510fc78a71b843ef6e89bdbbJustin Koh // If there were no system window insets, this is just empty. 106eba8782a1f8412a3510fc78a71b843ef6e89bdbbJustin Koh mTempRect.setEmpty(); 107eba8782a1f8412a3510fc78a71b843ef6e89bdbbJustin Koh } 10850d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mTempRect; 10950d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 11050d7bfd8224f9da170dac668888bcf0831373051Adam Powell 11150d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 11250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the left system window inset in pixels. 11350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 11450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The system window inset represents the area of a full-screen window that is 11550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by the status bar, navigation bar, IME or other system windows. 11650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * </p> 11750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 11850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The left system window inset 11950d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 12050d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getSystemWindowInsetLeft() { 12150d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mSystemWindowInsets.left; 12250d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 12350d7bfd8224f9da170dac668888bcf0831373051Adam Powell 12450d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 12550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the top system window inset in pixels. 12650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 12750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The system window inset represents the area of a full-screen window that is 12850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by the status bar, navigation bar, IME or other system windows. 12950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * </p> 13050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 13150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The top system window inset 13250d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 13350d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getSystemWindowInsetTop() { 13450d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mSystemWindowInsets.top; 13550d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 13650d7bfd8224f9da170dac668888bcf0831373051Adam Powell 13750d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 13850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the right system window inset in pixels. 13950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 14050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The system window inset represents the area of a full-screen window that is 14150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by the status bar, navigation bar, IME or other system windows. 14250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * </p> 14350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 14450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The right system window inset 14550d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 14650d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getSystemWindowInsetRight() { 14750d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mSystemWindowInsets.right; 14850d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 14950d7bfd8224f9da170dac668888bcf0831373051Adam Powell 15050d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 15150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the bottom system window inset in pixels. 15250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 15350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The system window inset represents the area of a full-screen window that is 15450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by the status bar, navigation bar, IME or other system windows. 15550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * </p> 15650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 15750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The bottom system window inset 15850d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 15950d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getSystemWindowInsetBottom() { 16050d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mSystemWindowInsets.bottom; 16150d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 16250d7bfd8224f9da170dac668888bcf0831373051Adam Powell 16350d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 16450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the left window decor inset in pixels. 16550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 16650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The window decor inset represents the area of the window content area that is 16750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by decorations within the window provided by the framework. 16850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * This can include action bars, title bars, toolbars, etc.</p> 16950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 17050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The left window decor inset 171f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide pending API 17250d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 17350d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getWindowDecorInsetLeft() { 17450d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mWindowDecorInsets.left; 17550d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 17650d7bfd8224f9da170dac668888bcf0831373051Adam Powell 17750d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 17850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the top window decor inset in pixels. 17950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 18050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The window decor inset represents the area of the window content area that is 18150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by decorations within the window provided by the framework. 18250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * This can include action bars, title bars, toolbars, etc.</p> 18350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 18450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The top window decor inset 185f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide pending API 18650d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 18750d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getWindowDecorInsetTop() { 18850d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mWindowDecorInsets.top; 18950d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 19050d7bfd8224f9da170dac668888bcf0831373051Adam Powell 19150d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 19250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the right window decor inset in pixels. 19350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 19450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The window decor inset represents the area of the window content area that is 19550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by decorations within the window provided by the framework. 19650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * This can include action bars, title bars, toolbars, etc.</p> 19750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 19850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The right window decor inset 199f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide pending API 20050d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 20150d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getWindowDecorInsetRight() { 20250d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mWindowDecorInsets.right; 20350d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 20450d7bfd8224f9da170dac668888bcf0831373051Adam Powell 20550d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 20650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns the bottom window decor inset in pixels. 20750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 20850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The window decor inset represents the area of the window content area that is 20950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by decorations within the window provided by the framework. 21050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * This can include action bars, title bars, toolbars, etc.</p> 21150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 21250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return The bottom window decor inset 213f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide pending API 21450d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 21550d7bfd8224f9da170dac668888bcf0831373051Adam Powell public int getWindowDecorInsetBottom() { 21650d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mWindowDecorInsets.bottom; 21750d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 21850d7bfd8224f9da170dac668888bcf0831373051Adam Powell 21950d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 22050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns true if this WindowInsets has nonzero system window insets. 22150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 22250d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The system window inset represents the area of a full-screen window that is 22350d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by the status bar, navigation bar, IME or other system windows. 22450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * </p> 22550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 22650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return true if any of the system window inset values are nonzero 22750d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 22850d7bfd8224f9da170dac668888bcf0831373051Adam Powell public boolean hasSystemWindowInsets() { 22950d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mSystemWindowInsets.left != 0 || mSystemWindowInsets.top != 0 || 23050d7bfd8224f9da170dac668888bcf0831373051Adam Powell mSystemWindowInsets.right != 0 || mSystemWindowInsets.bottom != 0; 23150d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 23250d7bfd8224f9da170dac668888bcf0831373051Adam Powell 23350d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 23450d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns true if this WindowInsets has nonzero window decor insets. 23550d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 23650d7bfd8224f9da170dac668888bcf0831373051Adam Powell * <p>The window decor inset represents the area of the window content area that is 23750d7bfd8224f9da170dac668888bcf0831373051Adam Powell * partially or fully obscured by decorations within the window provided by the framework. 23850d7bfd8224f9da170dac668888bcf0831373051Adam Powell * This can include action bars, title bars, toolbars, etc.</p> 23950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 24050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return true if any of the window decor inset values are nonzero 241f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide pending API 24250d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 24350d7bfd8224f9da170dac668888bcf0831373051Adam Powell public boolean hasWindowDecorInsets() { 24450d7bfd8224f9da170dac668888bcf0831373051Adam Powell return mWindowDecorInsets.left != 0 || mWindowDecorInsets.top != 0 || 24550d7bfd8224f9da170dac668888bcf0831373051Adam Powell mWindowDecorInsets.right != 0 || mWindowDecorInsets.bottom != 0; 24650d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 24750d7bfd8224f9da170dac668888bcf0831373051Adam Powell 24850d7bfd8224f9da170dac668888bcf0831373051Adam Powell /** 24950d7bfd8224f9da170dac668888bcf0831373051Adam Powell * Returns true if this WindowInsets has any nonzero insets. 25050d7bfd8224f9da170dac668888bcf0831373051Adam Powell * 25150d7bfd8224f9da170dac668888bcf0831373051Adam Powell * @return true if any inset values are nonzero 25250d7bfd8224f9da170dac668888bcf0831373051Adam Powell */ 25350d7bfd8224f9da170dac668888bcf0831373051Adam Powell public boolean hasInsets() { 25450d7bfd8224f9da170dac668888bcf0831373051Adam Powell return hasSystemWindowInsets() || hasWindowDecorInsets(); 25550d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 25650d7bfd8224f9da170dac668888bcf0831373051Adam Powell 257973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell /** 2580d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * Check if these insets have been fully consumed. 2590d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * 2600d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * <p>Insets are considered "consumed" if the applicable <code>consume*</code> methods 2610d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * have been called such that all insets have been set to zero. This affects propagation of 2620d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * insets through the view hierarchy; insets that have not been fully consumed will continue 2630d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * to propagate down to child views.</p> 2640d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * 2650d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * <p>The result of this method is equivalent to the return value of 2660d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * {@link View#fitSystemWindows(android.graphics.Rect)}.</p> 2670d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * 2680d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell * @return true if the insets have been fully consumed. 2690d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell */ 2700d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell public boolean isConsumed() { 271fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return mSystemWindowInsetsConsumed && mWindowDecorInsetsConsumed && mStableInsetsConsumed; 2720d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell } 2730d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell 2740d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell /** 275973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * Returns true if the associated window has a round shape. 276973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * 277973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * <p>A round window's left, top, right and bottom edges reach all the way to the 278973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * associated edges of the window but the corners may not be visible. Views responding 279973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * to round insets should take care to not lay out critical elements within the corners 280973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * where they may not be accessible.</p> 281973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * 282973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell * @return True if the window is round 283973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell */ 284973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell public boolean isRound() { 285973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell return mIsRound; 286973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell } 287973ddaacaef255b8659d35cfe4151dd5b7436138Adam Powell 288f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell /** 289f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * Returns a copy of this WindowInsets with the system window insets fully consumed. 290f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * 291f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @return A modified copy of this WindowInsets 292f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell */ 293f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell public WindowInsets consumeSystemWindowInsets() { 29450d7bfd8224f9da170dac668888bcf0831373051Adam Powell final WindowInsets result = new WindowInsets(this); 2950d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell result.mSystemWindowInsets = EMPTY_RECT; 2960d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell result.mSystemWindowInsetsConsumed = true; 29750d7bfd8224f9da170dac668888bcf0831373051Adam Powell return result; 29850d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 29950d7bfd8224f9da170dac668888bcf0831373051Adam Powell 300f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell /** 301f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * Returns a copy of this WindowInsets with selected system window insets fully consumed. 302f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * 303f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param left true to consume the left system window inset 304f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param top true to consume the top system window inset 305f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param right true to consume the right system window inset 306f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param bottom true to consume the bottom system window inset 307f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @return A modified copy of this WindowInsets 308f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide pending API 309f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell */ 310f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell public WindowInsets consumeSystemWindowInsets(boolean left, boolean top, 31150d7bfd8224f9da170dac668888bcf0831373051Adam Powell boolean right, boolean bottom) { 31250d7bfd8224f9da170dac668888bcf0831373051Adam Powell if (left || top || right || bottom) { 31350d7bfd8224f9da170dac668888bcf0831373051Adam Powell final WindowInsets result = new WindowInsets(this); 3140d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell result.mSystemWindowInsets = new Rect( 3150d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell left ? 0 : mSystemWindowInsets.left, 31650d7bfd8224f9da170dac668888bcf0831373051Adam Powell top ? 0 : mSystemWindowInsets.top, 31750d7bfd8224f9da170dac668888bcf0831373051Adam Powell right ? 0 : mSystemWindowInsets.right, 31850d7bfd8224f9da170dac668888bcf0831373051Adam Powell bottom ? 0 : mSystemWindowInsets.bottom); 31950d7bfd8224f9da170dac668888bcf0831373051Adam Powell return result; 32050d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 32150d7bfd8224f9da170dac668888bcf0831373051Adam Powell return this; 32250d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 32350d7bfd8224f9da170dac668888bcf0831373051Adam Powell 324f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell /** 325f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * Returns a copy of this WindowInsets with selected system window insets replaced 326f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * with new values. 327f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * 328f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param left New left inset in pixels 329f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param top New top inset in pixels 330f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param right New right inset in pixels 331f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @param bottom New bottom inset in pixels 332f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @return A modified copy of this WindowInsets 333f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell */ 334f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell public WindowInsets replaceSystemWindowInsets(int left, int top, 335f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell int right, int bottom) { 33650d7bfd8224f9da170dac668888bcf0831373051Adam Powell final WindowInsets result = new WindowInsets(this); 33750d7bfd8224f9da170dac668888bcf0831373051Adam Powell result.mSystemWindowInsets = new Rect(left, top, right, bottom); 33850d7bfd8224f9da170dac668888bcf0831373051Adam Powell return result; 33950d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 34050d7bfd8224f9da170dac668888bcf0831373051Adam Powell 341f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell /** 342d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell * Returns a copy of this WindowInsets with selected system window insets replaced 343d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell * with new values. 344d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell * 345d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell * @param systemWindowInsets New system window insets. Each field is the inset in pixels 346d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell * for that edge 347d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell * @return A modified copy of this WindowInsets 348d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell */ 349d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell public WindowInsets replaceSystemWindowInsets(Rect systemWindowInsets) { 350d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell final WindowInsets result = new WindowInsets(this); 351d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell result.mSystemWindowInsets = new Rect(systemWindowInsets); 352d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell return result; 353d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell } 354d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell 355d72068b38ec4e5732dde6093e39b2602babc27a3Adam Powell /** 356f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide 357f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell */ 358f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell public WindowInsets consumeWindowDecorInsets() { 35950d7bfd8224f9da170dac668888bcf0831373051Adam Powell final WindowInsets result = new WindowInsets(this); 36050d7bfd8224f9da170dac668888bcf0831373051Adam Powell result.mWindowDecorInsets.set(0, 0, 0, 0); 3610d9fdbad751318b1e9a7a2789bf0e9240252e15fAdam Powell result.mWindowDecorInsetsConsumed = true; 36250d7bfd8224f9da170dac668888bcf0831373051Adam Powell return result; 36350d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 36450d7bfd8224f9da170dac668888bcf0831373051Adam Powell 365f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell /** 366f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide 367f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell */ 368f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell public WindowInsets consumeWindowDecorInsets(boolean left, boolean top, 36950d7bfd8224f9da170dac668888bcf0831373051Adam Powell boolean right, boolean bottom) { 37050d7bfd8224f9da170dac668888bcf0831373051Adam Powell if (left || top || right || bottom) { 37150d7bfd8224f9da170dac668888bcf0831373051Adam Powell final WindowInsets result = new WindowInsets(this); 37250d7bfd8224f9da170dac668888bcf0831373051Adam Powell result.mWindowDecorInsets = new Rect(left ? 0 : mWindowDecorInsets.left, 37350d7bfd8224f9da170dac668888bcf0831373051Adam Powell top ? 0 : mWindowDecorInsets.top, 37450d7bfd8224f9da170dac668888bcf0831373051Adam Powell right ? 0 : mWindowDecorInsets.right, 37550d7bfd8224f9da170dac668888bcf0831373051Adam Powell bottom ? 0 : mWindowDecorInsets.bottom); 37650d7bfd8224f9da170dac668888bcf0831373051Adam Powell return result; 37750d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 37850d7bfd8224f9da170dac668888bcf0831373051Adam Powell return this; 37950d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 38050d7bfd8224f9da170dac668888bcf0831373051Adam Powell 381f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell /** 382f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell * @hide 383f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell */ 384f4a3941ebe0dab5eeded96059a6a5f7c1d075e64Adam Powell public WindowInsets replaceWindowDecorInsets(int left, int top, int right, int bottom) { 38550d7bfd8224f9da170dac668888bcf0831373051Adam Powell final WindowInsets result = new WindowInsets(this); 38650d7bfd8224f9da170dac668888bcf0831373051Adam Powell result.mWindowDecorInsets = new Rect(left, top, right, bottom); 38750d7bfd8224f9da170dac668888bcf0831373051Adam Powell return result; 38850d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 38950d7bfd8224f9da170dac668888bcf0831373051Adam Powell 390fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos /** 391067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * Returns the top stable inset in pixels. 392067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 393067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * <p>The stable inset represents the area of a full-screen window that <b>may</b> be 394067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * partially or fully obscured by the system UI elements. This value does not change 395067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * based on the visibility state of those elements; for example, if the status bar is 396067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * normally shown, but temporarily hidden, the stable inset will still provide the inset 397067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * associated with the status bar being shown.</p> 398067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 399067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * @return The top stable inset 400fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos */ 401fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos public int getStableInsetTop() { 402fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return mStableInsets.top; 403fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos } 404fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 405fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos /** 406067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * Returns the left stable inset in pixels. 407067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 408067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * <p>The stable inset represents the area of a full-screen window that <b>may</b> be 409067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * partially or fully obscured by the system UI elements. This value does not change 410067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * based on the visibility state of those elements; for example, if the status bar is 411067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * normally shown, but temporarily hidden, the stable inset will still provide the inset 412067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * associated with the status bar being shown.</p> 413067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 414067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * @return The left stable inset 415fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos */ 416fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos public int getStableInsetLeft() { 417fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return mStableInsets.left; 418fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos } 419fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 420fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos /** 421067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * Returns the right stable inset in pixels. 422067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 423067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * <p>The stable inset represents the area of a full-screen window that <b>may</b> be 424067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * partially or fully obscured by the system UI elements. This value does not change 425067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * based on the visibility state of those elements; for example, if the status bar is 426067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * normally shown, but temporarily hidden, the stable inset will still provide the inset 427067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * associated with the status bar being shown.</p> 428067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 429067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * @return The right stable inset 430fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos */ 431fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos public int getStableInsetRight() { 432fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return mStableInsets.right; 433fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos } 434fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 435fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos /** 436067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * Returns the bottom stable inset in pixels. 437067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 438067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * <p>The stable inset represents the area of a full-screen window that <b>may</b> be 439067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * partially or fully obscured by the system UI elements. This value does not change 440067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * based on the visibility state of those elements; for example, if the status bar is 441067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * normally shown, but temporarily hidden, the stable inset will still provide the inset 442067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * associated with the status bar being shown.</p> 443067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 444067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * @return The bottom stable inset 445fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos */ 446fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos public int getStableInsetBottom() { 447fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return mStableInsets.bottom; 448fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos } 449fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 450fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos /** 451067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * Returns true if this WindowInsets has nonzero stable insets. 452067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 453067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * <p>The stable inset represents the area of a full-screen window that <b>may</b> be 454067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * partially or fully obscured by the system UI elements. This value does not change 455067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * based on the visibility state of those elements; for example, if the status bar is 456067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * normally shown, but temporarily hidden, the stable inset will still provide the inset 457067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * associated with the status bar being shown.</p> 458067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 459067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * @return true if any of the stable inset values are nonzero 460fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos */ 461fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos public boolean hasStableInsets() { 462fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return mStableInsets.top != 0 || mStableInsets.left != 0 || mStableInsets.right != 0 463fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos || mStableInsets.bottom != 0; 464fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos } 465fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 466fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos /** 467067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * Returns a copy of this WindowInsets with the stable insets fully consumed. 468067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * 469067e5f68b9216b233df1c6529db182ff9b2887abDianne Hackborn * @return A modified copy of this WindowInsets 470fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos */ 471fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos public WindowInsets consumeStableInsets() { 472fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos final WindowInsets result = new WindowInsets(this); 473fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos result.mStableInsets = EMPTY_RECT; 474fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos result.mStableInsetsConsumed = true; 475fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return result; 476fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos } 477fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos 47850d7bfd8224f9da170dac668888bcf0831373051Adam Powell @Override 47950d7bfd8224f9da170dac668888bcf0831373051Adam Powell public String toString() { 480fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos return "WindowInsets{systemWindowInsets=" + mSystemWindowInsets 481fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos + " windowDecorInsets=" + mWindowDecorInsets 482fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos + " stableInsets=" + mStableInsets + 483fa10423fa00f3495e451016acba9b6848eb995c9Adrian Roos (isRound() ? " round}" : "}"); 48450d7bfd8224f9da170dac668888bcf0831373051Adam Powell } 48550d7bfd8224f9da170dac668888bcf0831373051Adam Powell} 486