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

Commit 04c89fe3 authored by Sihua Ma's avatar Sihua Ma Committed by Android (Google) Code Review
Browse files

Merge "Add QuickstepWidgetHolder for widget handling" into tm-qpr-dev

parents 49d1951b 1db8bc24
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
    <string name="stats_log_manager_class" translatable="false">com.android.quickstep.logging.StatsLogCompatManager</string>
    <string name="test_information_handler_class" translatable="false">com.android.quickstep.QuickstepTestInformationHandler</string>
    <string name="window_manager_proxy_class" translatable="false">com.android.quickstep.util.SystemWindowManagerProxy</string>
    <string name="widget_holder_factory_class" translatable="false">com.android.launcher3.uioverrides.QuickstepWidgetHolder$QuickstepHolderFactory</string>

    <!-- The number of thumbnails and icons to keep in the cache. The thumbnail cache size also
         determines how many thumbnails will be fetched in the background. -->
+0 −15
Original line number Diff line number Diff line
@@ -17,14 +17,9 @@
package com.android.launcher3.uioverrides;

import android.app.Person;
import android.appwidget.AppWidgetHost;
import android.content.pm.ShortcutInfo;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.Utilities;
import com.android.launcher3.widget.LauncherWidgetHolder;

/**
 * A wrapper for the hidden API calls
@@ -37,14 +32,4 @@ public class ApiWrapper {
        Person[] persons = si.getPersons();
        return persons == null ? Utilities.EMPTY_PERSON_ARRAY : persons;
    }

    /**
     * Set the interaction handler for the host
     * @param host AppWidgetHost that needs the interaction handler
     * @param handler InteractionHandler for the views in the host
     */
    public static void setHostInteractionHandler(@NonNull AppWidgetHost host,
            @Nullable LauncherWidgetHolder.LauncherWidgetInteractionHandler handler) {
        host.setInteractionHandler(handler::onInteraction);
    }
}
+70 −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.uioverrides;

import static com.android.launcher3.widget.LauncherWidgetHolder.APPWIDGET_HOST_ID;

import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.os.Looper;

import androidx.annotation.NonNull;

import com.android.launcher3.LauncherAppState;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
import com.android.launcher3.widget.LauncherWidgetHolder;

import java.util.function.IntConsumer;

/**
 * {@link AppWidgetHost} that is used to receive the changes to the widgets without
 * storing any {@code Activity} info like that of the launcher.
 */
final class QuickstepAppWidgetHost extends AppWidgetHost {
    private final @NonNull Context mContext;
    private final @NonNull IntConsumer mAppWidgetRemovedCallback;
    private final @NonNull LauncherWidgetHolder.ProviderChangedListener mProvidersChangedListener;

    QuickstepAppWidgetHost(@NonNull Context context, @NonNull IntConsumer appWidgetRemovedCallback,
            @NonNull LauncherWidgetHolder.ProviderChangedListener listener,
            @NonNull Looper looper) {
        super(context, APPWIDGET_HOST_ID, null, looper);
        mContext = context;
        mAppWidgetRemovedCallback = appWidgetRemovedCallback;
        mProvidersChangedListener = listener;
    }

    @Override
    protected void onProvidersChanged() {
        mProvidersChangedListener.notifyWidgetProvidersChanged();
    }

    @Override
    public void onAppWidgetRemoved(int appWidgetId) {
        mAppWidgetRemovedCallback.accept(appWidgetId);
    }

    @Override
    protected void onProviderChanged(int appWidgetId, @NonNull AppWidgetProviderInfo appWidget) {
        LauncherAppWidgetProviderInfo info = LauncherAppWidgetProviderInfo.fromProviderInfo(
                mContext, appWidget);
        super.onProviderChanged(appWidgetId, info);
        // The super method updates the dimensions of the providerInfo. Update the
        // launcher spans accordingly.
        info.initSpans(mContext, LauncherAppState.getIDP(mContext));
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -34,11 +34,9 @@ import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.LauncherWidgetHolder;

/** Provides a Quickstep specific animation when launching an activity from an app widget. */
class QuickstepInteractionHandler
        implements LauncherWidgetHolder.LauncherWidgetInteractionHandler {
class QuickstepInteractionHandler implements RemoteViews.InteractionHandler {

    private static final String TAG = "QuickstepInteractionHandler";

+6 −4
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ import com.android.launcher3.logging.StatsLogManager.StatsLogger;
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
import com.android.launcher3.model.WellbeingModel;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.proxy.ProxyActivityStarter;
import com.android.launcher3.proxy.StartActivityParams;
@@ -106,6 +105,7 @@ import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.taskbar.LauncherTaskbarUIController;
import com.android.launcher3.taskbar.TaskbarManager;
import com.android.launcher3.uioverrides.QuickstepWidgetHolder.QuickstepHolderFactory;
import com.android.launcher3.uioverrides.states.QuickstepAtomicAnimationFactory;
import com.android.launcher3.uioverrides.touchcontrollers.NavBarToHomeTouchController;
import com.android.launcher3.uioverrides.touchcontrollers.NoButtonNavbarToOverviewTouchController;
@@ -517,9 +517,11 @@ public class QuickstepLauncher extends Launcher {

    @Override
    protected LauncherWidgetHolder createAppWidgetHolder() {
        LauncherWidgetHolder appWidgetHolder = super.createAppWidgetHolder();
        appWidgetHolder.setInteractionHandler(new QuickstepInteractionHandler(this));
        return appWidgetHolder;
        final QuickstepHolderFactory factory =
                (QuickstepHolderFactory) LauncherWidgetHolder.HolderFactory.newFactory(this);
        return factory.newInstance(this,
                appWidgetId -> getWorkspace().removeWidget(appWidgetId),
                new QuickstepInteractionHandler(this));
    }

    @Override
Loading