1 /* 2 * Copyright (C) 2018 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.quickstep.util; 17 18 import android.content.Context; 19 import android.graphics.Rect; 20 import android.view.View; 21 import android.view.ViewGroup; 22 23 import com.android.launcher3.DeviceProfile; 24 import com.android.launcher3.util.DisplayController; 25 import com.android.launcher3.util.NavigationMode; 26 import com.android.quickstep.LauncherActivityInterface; 27 import com.android.quickstep.orientation.RecentsPagedOrientationHandler; 28 29 public class LayoutUtils { 30 31 /** 32 * The height for the swipe up motion 33 */ getDefaultSwipeHeight(Context context, DeviceProfile dp)34 public static float getDefaultSwipeHeight(Context context, DeviceProfile dp) { 35 float swipeHeight = dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx; 36 if (DisplayController.getNavigationMode(context) == NavigationMode.NO_BUTTON) { 37 swipeHeight -= dp.getInsets().bottom; 38 } 39 return swipeHeight; 40 } 41 getShelfTrackingDistance(Context context, DeviceProfile dp, RecentsPagedOrientationHandler orientationHandler)42 public static int getShelfTrackingDistance(Context context, DeviceProfile dp, 43 RecentsPagedOrientationHandler orientationHandler) { 44 // Track the bottom of the window. 45 Rect taskSize = new Rect(); 46 LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize, 47 orientationHandler); 48 return orientationHandler.getDistanceToBottomOfRect(dp, taskSize); 49 } 50 51 /** 52 * Recursively sets view and all children enabled/disabled. 53 * @param view Top most parent view to change. 54 * @param enabled True = enable, False = disable. 55 */ setViewEnabled(View view, boolean enabled)56 public static void setViewEnabled(View view, boolean enabled) { 57 view.setEnabled(enabled); 58 if (view instanceof ViewGroup) { 59 for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { 60 setViewEnabled(((ViewGroup) view).getChildAt(i), enabled); 61 } 62 } 63 } 64 } 65