Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bcbba897 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add app predictions to secondary display app drawer & fix tab UI." into tm-qpr-dev

parents ff5ad47a 1b4869fc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,4 +25,6 @@

  <string name="model_delegate_class" translatable="false">com.android.launcher3.model.QuickstepModelDelegate</string>

  <string name="secondary_display_predictions_class" translatable="false">com.android.launcher3.secondarydisplay.SecondaryDisplayPredictionsImpl</string>

</resources>
+54 −0
Original line number Diff line number Diff line
/*
 * 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);
    }
}
+2 −29
Original line number Diff line number Diff line
@@ -76,35 +76,8 @@
            android:paddingTop="@dimen/all_apps_header_top_padding"
            android:orientation="vertical" >

            <com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="@dimen/all_apps_header_pill_height"
                android:orientation="horizontal"
                style="@style/TextHeadline">

                <Button
                    android:id="@+id/tab_personal"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="?android:attr/selectableItemBackground"
                    android:text="@string/all_apps_personal_tab"
                    android:textAllCaps="true"
                    android:textColor="@color/all_apps_tab_text"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/tab_work"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="?android:attr/selectableItemBackground"
                    android:text="@string/all_apps_work_tab"
                    android:textAllCaps="true"
                    android:textColor="@color/all_apps_tab_text"
                    android:textSize="14sp" />
            </com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip>
            <include layout="@layout/floating_header_content" />
            <include layout="@layout/all_apps_personal_work_tabs" />
        </com.android.launcher3.allapps.FloatingHeaderView>

        <com.android.launcher3.allapps.search.AppsSearchContainerLayout
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@
    <string name="launcher_activity_logic_class" translatable="false"></string>
    <string name="model_delegate_class" translatable="false"></string>
    <string name="window_manager_proxy_class" translatable="false"></string>
    <string name="secondary_display_predictions_class" translatable="false"></string>

    <!-- View ID to use for QSB widget -->
    <item type="id" name="qsb_widget" />
+38 −1
Original line number Diff line number Diff line
@@ -29,7 +29,9 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.StringCache;
@@ -39,6 +41,8 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.BaseDragLayer;

@@ -61,6 +65,9 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
    private boolean mAppDrawerShown = false;

    private StringCache mStringCache;
    private OnboardingPrefs<?> mOnboardingPrefs;
    private boolean mBindingItems = false;
    private SecondaryDisplayPredictions mSecondaryDisplayPredictions;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -69,6 +76,8 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
        if (getWindow().getDecorView().isAttachedToWindow()) {
            initUi();
        }
        mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this));
        mSecondaryDisplayPredictions = SecondaryDisplayPredictions.newInstance(this);
    }

    @Override
@@ -204,6 +213,7 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
            mAppDrawerShown = true;
            mAppsView.setVisibility(View.VISIBLE);
            mAppsButton.setVisibility(View.INVISIBLE);
            mSecondaryDisplayPredictions.updateAppDivider();
        } else {
            mAppDrawerShown = false;
            animator.addListener(new AnimatorListenerAdapter() {
@@ -218,6 +228,26 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
        animator.start();
    }

    @Override
    public OnboardingPrefs<?> getOnboardingPrefs() {
        return mOnboardingPrefs;
    }

    @Override
    public void startBinding() {
        mBindingItems = true;
    }

    @Override
    public boolean isBindingItems() {
        return mBindingItems;
    }

    @Override
    public void finishBindingItems(IntSet pagesBoundFirst) {
        mBindingItems = false;
    }

    @Override
    public void bindDeepShortcutMap(HashMap<ComponentKey, Integer> deepShortcutMap) {
        mPopupDataProvider.setDeepShortcutMap(deepShortcutMap);
@@ -229,6 +259,13 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
        PopupContainerWithArrow.dismissInvalidPopup(this);
    }

    @Override
    public void bindExtraContainerItems(BgDataModel.FixedContainerItems item) {
        if (item.containerId == LauncherSettings.Favorites.CONTAINER_PREDICTION) {
            mSecondaryDisplayPredictions.setPredictedApps(item);
        }
    }

    @Override
    public StringCache getStringCache() {
        return mStringCache;
Loading