1 /* 2 * Copyright (C) 2020 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 package com.android.launcher3.util; 17 18 import android.graphics.Point; 19 import android.graphics.Rect; 20 21 import androidx.annotation.Nullable; 22 23 /** 24 * Utility class to hold information about window position and layout 25 */ 26 public class WindowBounds { 27 28 public final Rect bounds; 29 public final Rect insets; 30 public final Point availableSize; 31 WindowBounds(Rect bounds, Rect insets)32 public WindowBounds(Rect bounds, Rect insets) { 33 this.bounds = bounds; 34 this.insets = insets; 35 availableSize = new Point(bounds.width() - insets.left - insets.right, 36 bounds.height() - insets.top - insets.bottom); 37 } 38 39 @Override equals(@ullable Object obj)40 public boolean equals(@Nullable Object obj) { 41 if (!(obj instanceof WindowBounds)) { 42 return false; 43 } 44 WindowBounds other = (WindowBounds) obj; 45 return other.bounds.equals(bounds) && other.insets.equals(insets); 46 } 47 } 48