1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.support.v4.view;
18 
19 import android.graphics.Rect;
20 
21 /**
22  * Describes a set of insets for window content.
23  *
24  * <p>WindowInsetsCompats are immutable and may be expanded to include more inset types in the
25  * future. To adjust insets, use one of the supplied clone methods to obtain a new
26  * WindowInsetsCompat instance with the adjusted properties.</p>
27  */
28 public class WindowInsetsCompat {
29 
30     /** Private ctor */
WindowInsetsCompat()31     WindowInsetsCompat() {}
32 
33     /**
34      * Returns the left system window inset in pixels.
35      *
36      * <p>The system window inset represents the area of a full-screen window that is
37      * partially or fully obscured by the status bar, navigation bar, IME or other system windows.
38      * </p>
39      *
40      * @return The left system window inset
41      */
getSystemWindowInsetLeft()42     public int getSystemWindowInsetLeft() {
43         return 0;
44     }
45 
46     /**
47      * Returns the top system window inset in pixels.
48      *
49      * <p>The system window inset represents the area of a full-screen window that is
50      * partially or fully obscured by the status bar, navigation bar, IME or other system windows.
51      * </p>
52      *
53      * @return The top system window inset
54      */
getSystemWindowInsetTop()55     public int getSystemWindowInsetTop() {
56         return 0;
57     }
58 
59     /**
60      * Returns the right system window inset in pixels.
61      *
62      * <p>The system window inset represents the area of a full-screen window that is
63      * partially or fully obscured by the status bar, navigation bar, IME or other system windows.
64      * </p>
65      *
66      * @return The right system window inset
67      */
getSystemWindowInsetRight()68     public int getSystemWindowInsetRight() {
69         return 0;
70     }
71 
72     /**
73      * Returns the bottom system window inset in pixels.
74      *
75      * <p>The system window inset represents the area of a full-screen window that is
76      * partially or fully obscured by the status bar, navigation bar, IME or other system windows.
77      * </p>
78      *
79      * @return The bottom system window inset
80      */
getSystemWindowInsetBottom()81     public int getSystemWindowInsetBottom() {
82         return 0;
83     }
84 
85     /**
86      * Returns true if this WindowInsets has nonzero system window insets.
87      *
88      * <p>The system window inset represents the area of a full-screen window that is
89      * partially or fully obscured by the status bar, navigation bar, IME or other system windows.
90      * </p>
91      *
92      * @return true if any of the system window inset values are nonzero
93      */
hasSystemWindowInsets()94     public boolean hasSystemWindowInsets() {
95         return false;
96     }
97 
98     /**
99      * Returns true if this WindowInsets has any nonzero insets.
100      *
101      * @return true if any inset values are nonzero
102      */
hasInsets()103     public boolean hasInsets() {
104         return false;
105     }
106 
107     /**
108      * Check if these insets have been fully consumed.
109      *
110      * <p>Insets are considered "consumed" if the applicable <code>consume*</code> methods
111      * have been called such that all insets have been set to zero. This affects propagation of
112      * insets through the view hierarchy; insets that have not been fully consumed will continue
113      * to propagate down to child views.</p>
114      *
115      * <p>The result of this method is equivalent to the return value of
116      * {@link android.view.View#fitSystemWindows(android.graphics.Rect)}.</p>
117      *
118      * @return true if the insets have been fully consumed.
119      */
isConsumed()120     public boolean isConsumed() {
121         return false;
122     }
123 
124     /**
125      * Returns true if the associated window has a round shape.
126      *
127      * <p>A round window's left, top, right and bottom edges reach all the way to the
128      * associated edges of the window but the corners may not be visible. Views responding
129      * to round insets should take care to not lay out critical elements within the corners
130      * where they may not be accessible.</p>
131      *
132      * @return True if the window is round
133      */
isRound()134     public boolean isRound() {
135         return false;
136     }
137 
138     /**
139      * Returns a copy of this WindowInsets with the system window insets fully consumed.
140      *
141      * @return A modified copy of this WindowInsets
142      */
consumeSystemWindowInsets()143     public WindowInsetsCompat consumeSystemWindowInsets() {
144         return this;
145     }
146 
147     /**
148      * Returns a copy of this WindowInsets with selected system window insets replaced
149      * with new values.
150      *
151      * @param left New left inset in pixels
152      * @param top New top inset in pixels
153      * @param right New right inset in pixels
154      * @param bottom New bottom inset in pixels
155      * @return A modified copy of this WindowInsets
156      */
replaceSystemWindowInsets(int left, int top, int right, int bottom)157     public WindowInsetsCompat replaceSystemWindowInsets(int left, int top, int right, int bottom) {
158         return this;
159     }
160 
161     /**
162      * Returns a copy of this WindowInsets with selected system window insets replaced
163      * with new values.
164      *
165      * @param systemWindowInsets New system window insets. Each field is the inset in pixels
166      *                           for that edge
167      * @return A modified copy of this WindowInsets
168      */
replaceSystemWindowInsets(Rect systemWindowInsets)169     public WindowInsetsCompat replaceSystemWindowInsets(Rect systemWindowInsets) {
170         return this;
171     }
172 
173     /**
174      * Returns the top stable inset in pixels.
175      *
176      * <p>The stable inset represents the area of a full-screen window that <b>may</b> be
177      * partially or fully obscured by the system UI elements.  This value does not change
178      * based on the visibility state of those elements; for example, if the status bar is
179      * normally shown, but temporarily hidden, the stable inset will still provide the inset
180      * associated with the status bar being shown.</p>
181      *
182      * @return The top stable inset
183      */
getStableInsetTop()184     public int getStableInsetTop() {
185         return 0;
186     }
187 
188 
189     /**
190      * Returns the left stable inset in pixels.
191      *
192      * <p>The stable inset represents the area of a full-screen window that <b>may</b> be
193      * partially or fully obscured by the system UI elements.  This value does not change
194      * based on the visibility state of those elements; for example, if the status bar is
195      * normally shown, but temporarily hidden, the stable inset will still provide the inset
196      * associated with the status bar being shown.</p>
197      *
198      * @return The left stable inset
199      */
getStableInsetLeft()200     public int getStableInsetLeft() {
201         return 0;
202     }
203 
204     /**
205      * Returns the right stable inset in pixels.
206      *
207      * <p>The stable inset represents the area of a full-screen window that <b>may</b> be
208      * partially or fully obscured by the system UI elements.  This value does not change
209      * based on the visibility state of those elements; for example, if the status bar is
210      * normally shown, but temporarily hidden, the stable inset will still provide the inset
211      * associated with the status bar being shown.</p>
212      *
213      * @return The right stable inset
214      */
getStableInsetRight()215     public int getStableInsetRight() {
216         return 0;
217     }
218 
219 
220     /**
221      * Returns the bottom stable inset in pixels.
222      *
223      * <p>The stable inset represents the area of a full-screen window that <b>may</b> be
224      * partially or fully obscured by the system UI elements.  This value does not change
225      * based on the visibility state of those elements; for example, if the status bar is
226      * normally shown, but temporarily hidden, the stable inset will still provide the inset
227      * associated with the status bar being shown.</p>
228      *
229      * @return The bottom stable inset
230      */
getStableInsetBottom()231     public int getStableInsetBottom() {
232         return 0;
233     }
234 
235     /**
236      * Returns true if this WindowInsets has nonzero stable insets.
237      *
238      * <p>The stable inset represents the area of a full-screen window that <b>may</b> be
239      * partially or fully obscured by the system UI elements.  This value does not change
240      * based on the visibility state of those elements; for example, if the status bar is
241      * normally shown, but temporarily hidden, the stable inset will still provide the inset
242      * associated with the status bar being shown.</p>
243      *
244      * @return true if any of the stable inset values are nonzero
245      */
hasStableInsets()246     public boolean hasStableInsets() {
247         return false;
248     }
249 
250     /**
251      * Returns a copy of this WindowInsets with the stable insets fully consumed.
252      *
253      * @return A modified copy of this WindowInsetsCompat
254      */
consumeStableInsets()255     public WindowInsetsCompat consumeStableInsets() {
256         return this;
257     }
258 
259 }
260