From 1b4869fcbc572ef70a4b24d59e7979f5d60ffeed Mon Sep 17 00:00:00 2001 From: Sukesh Ram Date: Mon, 6 Jun 2022 21:40:11 +0000 Subject: [PATCH] Add app predictions to secondary display app drawer & fix tab UI. Bug: 233926067 Test: Manual Change-Id: I2f45a4b30964b365bf149e8864a3af2ea909a237 (cherry picked from commit 9e5fe63a2290b9c912bf50d66176a34b224f37e8) Merged-In: I2f45a4b30964b365bf149e8864a3af2ea909a237 --- quickstep/res/values/override.xml | 2 + .../SecondaryDisplayPredictionsImpl.java | 54 +++++++++++++++++++ res/layout/secondary_launcher.xml | 31 +---------- res/values/config.xml | 1 + .../SecondaryDisplayLauncher.java | 39 +++++++++++++- .../SecondaryDisplayPredictions.java | 48 +++++++++++++++++ ...java => SecondaryDisplayLauncherTest.java} | 2 +- 7 files changed, 146 insertions(+), 31 deletions(-) create mode 100644 quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java create mode 100644 src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictions.java rename tests/src/com/android/launcher3/secondarydisplay/{SDLauncherTest.java => SecondaryDisplayLauncherTest.java} (97%) diff --git a/quickstep/res/values/override.xml b/quickstep/res/values/override.xml index 705ec9d48c..4f472f0625 100644 --- a/quickstep/res/values/override.xml +++ b/quickstep/res/values/override.xml @@ -25,4 +25,6 @@ com.android.launcher3.model.QuickstepModelDelegate + com.android.launcher3.secondarydisplay.SecondaryDisplayPredictionsImpl + diff --git a/quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java b/quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java new file mode 100644 index 0000000000..5bf727a60b --- /dev/null +++ b/quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.launcher3.secondarydisplay; + +import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT; + +import android.content.Context; + +import com.android.launcher3.appprediction.AppsDividerView; +import com.android.launcher3.appprediction.PredictionRowView; +import com.android.launcher3.model.BgDataModel; +import com.android.launcher3.util.OnboardingPrefs; +import com.android.launcher3.views.ActivityContext; + +/** + * Implementation of SecondaryDisplayPredictions. + */ +@SuppressWarnings("unused") +public final class SecondaryDisplayPredictionsImpl extends SecondaryDisplayPredictions { + private final ActivityContext mActivityContext; + + public SecondaryDisplayPredictionsImpl(Context context) { + mActivityContext = ActivityContext.lookupContext(context); + } + + @Override + void updateAppDivider() { + OnboardingPrefs onboardingPrefs = mActivityContext.getOnboardingPrefs(); + mActivityContext.getAppsView().getFloatingHeaderView() + .findFixedRowByType(AppsDividerView.class) + .setShowAllAppsLabel(!onboardingPrefs.hasReachedMaxCount(ALL_APPS_VISITED_COUNT)); + onboardingPrefs.incrementEventCount(ALL_APPS_VISITED_COUNT); + } + + @Override + public void setPredictedApps(BgDataModel.FixedContainerItems item) { + mActivityContext.getAppsView().getFloatingHeaderView() + .findFixedRowByType(PredictionRowView.class) + .setPredictedApps(item.items); + } +} diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml index 272d8d6c5f..cccaa39263 100644 --- a/res/layout/secondary_launcher.xml +++ b/res/layout/secondary_launcher.xml @@ -76,35 +76,8 @@ android:paddingTop="@dimen/all_apps_header_top_padding" android:orientation="vertical" > - - -