1 /* 2 * Copyright (C) 2017 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.allapps; 17 18 import android.content.Context; 19 import android.graphics.Rect; 20 import android.util.AttributeSet; 21 import android.view.MotionEvent; 22 23 import com.android.launcher3.Launcher; 24 import com.android.launcher3.LauncherState; 25 26 /** 27 * AllAppsContainerView with launcher specific callbacks 28 */ 29 public class LauncherAllAppsContainerView extends AllAppsContainerView { 30 31 private final Launcher mLauncher; 32 LauncherAllAppsContainerView(Context context)33 public LauncherAllAppsContainerView(Context context) { 34 this(context, null); 35 } 36 LauncherAllAppsContainerView(Context context, AttributeSet attrs)37 public LauncherAllAppsContainerView(Context context, AttributeSet attrs) { 38 this(context, attrs, 0); 39 } 40 LauncherAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr)41 public LauncherAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr) { 42 super(context, attrs, defStyleAttr); 43 mLauncher = Launcher.getLauncher(context); 44 } 45 46 @Override onInterceptTouchEvent(MotionEvent ev)47 public boolean onInterceptTouchEvent(MotionEvent ev) { 48 // The AllAppsContainerView houses the QSB and is hence visible from the Workspace 49 // Overview states. We shouldn't intercept for the scrubber in these cases. 50 if (!mLauncher.isInState(LauncherState.ALL_APPS)) { 51 mTouchHandler = null; 52 return false; 53 } 54 55 return super.onInterceptTouchEvent(ev); 56 } 57 58 @Override onTouchEvent(MotionEvent ev)59 public boolean onTouchEvent(MotionEvent ev) { 60 if (!mLauncher.isInState(LauncherState.ALL_APPS)) { 61 return false; 62 } 63 return super.onTouchEvent(ev); 64 } 65 66 @Override setInsets(Rect insets)67 public void setInsets(Rect insets) { 68 super.setInsets(insets); 69 int allAppsStartingPositionY = mLauncher.getDeviceProfile().availableHeightPx 70 - mLauncher.getDeviceProfile().allAppsOpenVerticalTranslate; 71 mLauncher.getAllAppsController().setScrollRangeDelta(allAppsStartingPositionY); 72 } 73 74 @Override onActivePageChanged(int currentActivePage)75 public void onActivePageChanged(int currentActivePage) { 76 super.onActivePageChanged(currentActivePage); 77 } 78 } 79