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

Commit 29e48d1f authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Convert NavigationBar to subclass ViewController.

Adds a NavigationBarComponent to take the place of
NavigationBar.Factory, simplifying initialization of the
NavigationBar.

Bug: 218354102
Test: manual && atest SystemUITests
Change-Id: I203bb272266d29c4ca49420ff34255b81ff30104
parent 5593d1dd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.fragments.FragmentService;
import com.android.systemui.log.dagger.LogModule;
import com.android.systemui.lowlightclock.LowLightClockController;
import com.android.systemui.model.SysUiState;
import com.android.systemui.navigationbar.NavigationBarComponent;
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.Recents;
@@ -132,6 +133,7 @@ import dagger.Provides;
        },
        subcomponents = {
            CentralSurfacesComponent.class,
            NavigationBarComponent.class,
            NotificationRowComponent.class,
            DozeComponent.class,
            ExpandableNotificationRowComponent.class,
+142 −147

File changed.

Preview size limit exceeded, changes collapsed.

+63 −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.systemui.navigationbar;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.android.systemui.dagger.qualifiers.DisplayId;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;

import javax.inject.Scope;

import dagger.BindsInstance;
import dagger.Subcomponent;

/**
 * Subcomponent for a NavigationBar.
 *
 * Generally creatd on a per-display basis.
 */
@Subcomponent(modules = { NavigationBarModule.class })
@NavigationBarComponent.NavigationBarScope
public interface NavigationBarComponent {

    /** Factory for {@link NavigationBarComponent}. */
    @Subcomponent.Factory
    interface Factory {
        NavigationBarComponent create(
                @BindsInstance @DisplayId Context context,
                @BindsInstance @Nullable Bundle savedState);
    }

    /** */
    NavigationBar getNavigationBar();

    /**
     * Scope annotation for singleton items within the NavigationBarComponent.
     */
    @Documented
    @Retention(RUNTIME)
    @Scope
    @interface NavigationBarScope {}
}
+8 −10
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.util.SparseArray;
import android.view.Display;
import android.view.IWindowManager;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;

import androidx.annotation.NonNull;
@@ -84,7 +83,7 @@ public class NavigationBarController implements

    private final Context mContext;
    private final Handler mHandler;
    private final NavigationBar.Factory mNavigationBarFactory;
    private final NavigationBarComponent.Factory mNavigationBarComponentFactory;
    private final DisplayManager mDisplayManager;
    private final TaskbarDelegate mTaskbarDelegate;
    private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@@ -110,7 +109,7 @@ public class NavigationBarController implements
            ConfigurationController configurationController,
            NavBarHelper navBarHelper,
            TaskbarDelegate taskbarDelegate,
            NavigationBar.Factory navigationBarFactory,
            NavigationBarComponent.Factory navigationBarComponentFactory,
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            DumpManager dumpManager,
            AutoHideController autoHideController,
@@ -119,7 +118,7 @@ public class NavigationBarController implements
            Optional<BackAnimation> backAnimation) {
        mContext = context;
        mHandler = mainHandler;
        mNavigationBarFactory = navigationBarFactory;
        mNavigationBarComponentFactory = navigationBarComponentFactory;
        mDisplayManager = mContext.getSystemService(DisplayManager.class);
        commandQueue.addCallback(this);
        configurationController.addCallback(this);
@@ -324,14 +323,13 @@ public class NavigationBarController implements
        final Context context = isOnDefaultDisplay
                ? mContext
                : mContext.createDisplayContext(display);
        NavigationBar navBar = mNavigationBarFactory.create(
                context, context.getSystemService(WindowManager.class));

        NavigationBarComponent component = mNavigationBarComponentFactory.create(
                context, savedState);
        NavigationBar navBar = component.getNavigationBar();
        navBar.init();
        mNavigationBars.put(displayId, navBar);

        boolean navBarVisible = mStatusBarKeyguardViewManager.isNavBarVisible();
        View navigationBarView = navBar.createView(savedState, navBarVisible);
        navigationBarView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
        navBar.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
            @Override
            public void onViewAttachedToWindow(View v) {
                if (result != null) {
+65 −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.systemui.navigationbar;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;

import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.navigationbar.NavigationBarComponent.NavigationBarScope;

import dagger.Module;
import dagger.Provides;

/** Module for {@link com.android.systemui.navigationbar.NavigationBarComponent}. */
@Module
public interface NavigationBarModule {
    /** A Layout inflater specific to the display's context. */
    @Provides
    @NavigationBarScope
    @DisplayId
    static LayoutInflater provideLayoutInflater(@DisplayId Context context) {
        return LayoutInflater.from(context);
    }

    /** */
    @Provides
    @NavigationBarScope
    static NavigationBarFrame provideNavigationBarFrame(@DisplayId LayoutInflater layoutInflater) {
        return (NavigationBarFrame) layoutInflater.inflate(R.layout.navigation_bar_window, null);
    }

    /** */
    @Provides
    @NavigationBarScope
    static NavigationBarView provideNavigationBarview(
            @DisplayId LayoutInflater layoutInflater, NavigationBarFrame frame) {
        View barView = layoutInflater.inflate(R.layout.navigation_bar, frame);
        return barView.findViewById(R.id.navigation_bar_view);
    }

    /** A WindowManager specific to the display's context. */
    @Provides
    @NavigationBarScope
    @DisplayId
    static WindowManager provideWindowManager(@DisplayId Context context) {
        return context.getSystemService(WindowManager.class);
    }
}
Loading