1 /* 2 * Copyright (C) 2023 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 com.android.car.carlauncher; 18 19 import androidx.annotation.IntDef; 20 21 /** 22 * Defines the constants used for custom state attributes (e.g. scrolling state, drag state) and 23 * app grid configurations (e.g. horizontal vertical paging). 24 */ 25 public interface AppGridConstants { 26 /** 27 * Page orientation for app grid. {@code PageOrientation.HORIZONTAL} will should support left 28 * and right paging. {@code PageOrientation.VERTICAL} will support up and down paging. 29 * 30 * The constant is defined separately here to differentiate this variable from device 31 * orientation, layout manager orientation, and layout param orientation. 32 */ 33 @IntDef({ 34 PageOrientation.HORIZONTAL, 35 PageOrientation.VERTICAL, 36 }) 37 @interface PageOrientation { 38 int HORIZONTAL = 0; 39 int VERTICAL = 1; 40 } 41 42 /** 43 * Integer denoting the direction of an app item. Use for adding offset to create margins 44 * between pages and tracking off page drag intent. 45 * 46 * Only {@code TOP} and {@code BOTTOM} should be processed for configuration {@code 47 * PageOrientation.VERTICAL}, and {@code LEFT} and {@code RIGHT} for 48 * {@code PageOrientation.HORIZONTAL}. 49 */ 50 @IntDef({ 51 AppItemBoundDirection.NONE, 52 AppItemBoundDirection.TOP, 53 AppItemBoundDirection.BOTTOM, 54 AppItemBoundDirection.LEFT, 55 AppItemBoundDirection.RIGHT, 56 }) 57 @interface AppItemBoundDirection { 58 int NONE = 0; 59 int TOP = 1; 60 int BOTTOM = 2; 61 int LEFT = 3; 62 int RIGHT = 4; 63 } 64 65 /** 66 * Static method for checking if the app grid orientation value represents horizontal. 67 * 68 * @param pageOrientation an integer value defined in {@code PageOrientation} 69 * @return true if the input {@code PageOrientation.HORIZONTAL}, false otherwise 70 */ isHorizontal(int pageOrientation)71 static boolean isHorizontal(int pageOrientation) { 72 return pageOrientation == PageOrientation.HORIZONTAL; 73 } 74 } 75