1 /*
2  * Copyright (C) 2015 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.view;
18 
19 import android.graphics.RecordingCanvas;
20 import android.graphics.Rect;
21 
22 /**
23  * These callbacks are used to communicate window configuration changes while the user is performing
24  * window changes.
25  * Note: Note that at the time of onWindowDragResizeStart the content size isn't known. A consumer
26  * should therfore not draw anything before the additional onContentDraw call has arrived.
27  * @hide
28  */
29 public interface WindowCallbacks {
30 
31     /**
32      * Called by the system when the window got changed by the user, before the layouter got called.
33      * It also gets called when the insets changed, or when the window switched between a fullscreen
34      * layout or a non-fullscreen layout. It can be used to perform a "quick and dirty" resize which
35      * should never take more then 4ms to complete.
36      *
37      * <p>At the time the layouting has not happened yet.
38      *
39      * @param newBounds The new window frame bounds.
40      * @param fullscreen Whether the window is currently drawing in fullscreen.
41      * @param systemInsets The current visible system insets for the window.
42      * @param stableInsets The stable insets for the window.
43      */
onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets, Rect stableInsets)44     void onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets,
45             Rect stableInsets);
46 
47     /**
48      * Called when a drag resize starts.
49      *
50      * @param initialBounds The initial bounds where the window will be.
51      * @param fullscreen Whether the window is currently drawing in fullscreen.
52      * @param systemInsets The current visible system insets for the window.
53      * @param stableInsets The stable insets for the window.
54      */
onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets, Rect stableInsets)55     void onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets,
56             Rect stableInsets);
57 
58     /**
59      * Called when a drag resize ends.
60      */
onWindowDragResizeEnd()61     void onWindowDragResizeEnd();
62 
63     /**
64      * The content will now be drawn to these bounds. Returns true if
65      * a draw should be requested after the next content draw.
66      */
onContentDrawn(int offsetX, int offsetY, int sizeX, int sizeY)67     boolean onContentDrawn(int offsetX, int offsetY, int sizeX, int sizeY);
68 
69     /**
70      * Called to request the window to draw one frame.
71      * @param reportNextDraw Whether it should report when the requested draw finishes.
72      */
onRequestDraw(boolean reportNextDraw)73     void onRequestDraw(boolean reportNextDraw);
74 
75     /**
76      * Called after all the content has drawn and the callback now has the ability to draw something
77      * on top of everything. Call {@link ViewRootImpl#requestInvalidateRootRenderNode} when this
78      * content needs to be redrawn.
79      *
80      * @param canvas The canvas to draw on.
81      */
onPostDraw(RecordingCanvas canvas)82     void onPostDraw(RecordingCanvas canvas);
83 }
84