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.launcher3.allapps; 17 18 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB; 19 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB; 20 21 import android.content.Context; 22 import android.util.AttributeSet; 23 24 import com.android.launcher3.PagedView; 25 import com.android.launcher3.views.ActivityContext; 26 import com.android.launcher3.workprofile.PersonalWorkPagedView; 27 28 /** 29 * A {@link PagedView} for showing different views for the personal and work profile respectively 30 * in the {@link BaseAllAppsContainerView}. 31 */ 32 public class AllAppsPagedView extends PersonalWorkPagedView { 33 AllAppsPagedView(Context context)34 public AllAppsPagedView(Context context) { 35 this(context, null); 36 } 37 AllAppsPagedView(Context context, AttributeSet attrs)38 public AllAppsPagedView(Context context, AttributeSet attrs) { 39 this(context, attrs, 0); 40 } 41 AllAppsPagedView(Context context, AttributeSet attrs, int defStyle)42 public AllAppsPagedView(Context context, AttributeSet attrs, int defStyle) { 43 super(context, attrs, defStyle); 44 } 45 46 @Override snapToPageWithVelocity(int whichPage, int velocity)47 protected boolean snapToPageWithVelocity(int whichPage, int velocity) { 48 boolean resp = super.snapToPageWithVelocity(whichPage, velocity); 49 if (resp && whichPage != mCurrentPage) { 50 ActivityContext.lookupContext(getContext()).getStatsLogManager().logger() 51 .log(mCurrentPage < whichPage 52 ? LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB 53 : LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB); 54 } 55 return resp; 56 } 57 } 58