1 /* 2 * Copyright (C) 2022 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.secondarydisplay; 17 18 import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT; 19 20 import android.content.Context; 21 22 import com.android.launcher3.appprediction.AppsDividerView; 23 import com.android.launcher3.appprediction.PredictionRowView; 24 import com.android.launcher3.model.BgDataModel; 25 import com.android.launcher3.util.OnboardingPrefs; 26 import com.android.launcher3.views.ActivityContext; 27 28 /** 29 * Implementation of SecondaryDisplayPredictions. 30 */ 31 @SuppressWarnings("unused") 32 public final class SecondaryDisplayPredictionsImpl extends SecondaryDisplayPredictions { 33 private final ActivityContext mActivityContext; 34 SecondaryDisplayPredictionsImpl(Context context)35 public SecondaryDisplayPredictionsImpl(Context context) { 36 mActivityContext = ActivityContext.lookupContext(context); 37 } 38 39 @Override updateAppDivider()40 void updateAppDivider() { 41 OnboardingPrefs<?> onboardingPrefs = mActivityContext.getOnboardingPrefs(); 42 if (onboardingPrefs != null) { 43 mActivityContext.getAppsView().getFloatingHeaderView() 44 .findFixedRowByType(AppsDividerView.class) 45 .setShowAllAppsLabel( 46 !onboardingPrefs.hasReachedMaxCount(ALL_APPS_VISITED_COUNT)); 47 onboardingPrefs.incrementEventCount(ALL_APPS_VISITED_COUNT); 48 } 49 } 50 51 @Override setPredictedApps(BgDataModel.FixedContainerItems item)52 public void setPredictedApps(BgDataModel.FixedContainerItems item) { 53 mActivityContext.getAppsView().getFloatingHeaderView() 54 .findFixedRowByType(PredictionRowView.class) 55 .setPredictedApps(item.items); 56 } 57 } 58