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

Commit ef19e9d4 authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Automerger Merge Worker
Browse files

Merge "[Dagger] Move StatusBarIconController and FeatureFlags from...

Merge "[Dagger] Move StatusBarIconController and FeatureFlags from KeyguardStatusBarView to its controller." into sc-v2-dev am: 8c67d4c7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15327939

Change-Id: Ib6f8e8f5e3c509e80b57d9ae6b1628e1380330ac
parents 8dcab4f8 8c67d4c7
Loading
Loading
Loading
Loading
+5 −38
Original line number Diff line number Diff line
@@ -43,17 +43,12 @@ import android.widget.TextView;

import com.android.settingslib.Utils;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * The header group on Keyguard.
@@ -80,15 +75,11 @@ public class KeyguardStatusBarView extends RelativeLayout {
    private int mSystemIconsSwitcherHiddenExpandedMargin;
    private int mSystemIconsBaseMargin;
    private View mSystemIconsContainer;
    private TintedIconManager mIconManager;
    private List<String> mBlockedIcons = new ArrayList<>();

    private View mCutoutSpace;
    private ViewGroup mStatusIconArea;
    private int mLayoutState = LAYOUT_NONE;

    private FeatureFlags mFeatureFlags;

    /**
     * Draw this many pixels into the left/right side of the cutout to optimally use the space
     */
@@ -122,8 +113,6 @@ public class KeyguardStatusBarView extends RelativeLayout {
        mStatusIconContainer = findViewById(R.id.statusIcons);

        loadDimens();
        loadBlockList();
        mFeatureFlags = Dependency.get(FeatureFlags.class);
    }

    @Override
@@ -183,14 +172,6 @@ public class KeyguardStatusBarView extends RelativeLayout {
                R.dimen.rounded_corner_content_padding);
    }

    // Set hidden status bar items
    private void loadBlockList() {
        Resources r = getResources();
        mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_volume));
        mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_alarm_clock));
        mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_call_strength));
    }

    private void updateVisibilities() {
        if (mMultiUserAvatar.getParent() != mStatusIconArea
                && !mKeyguardUserSwitcherEnabled) {
@@ -327,20 +308,6 @@ public class KeyguardStatusBarView extends RelativeLayout {
        return true;
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        mIconManager = new TintedIconManager(findViewById(R.id.statusIcons), mFeatureFlags);
        mIconManager.setBlockList(mBlockedIcons);
        Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        Dependency.get(StatusBarIconController.class).removeIconGroup(mIconManager);
    }

    /** Should only be called from {@link KeyguardStatusBarViewController}. */
    void onUserInfoChanged(Drawable picture) {
        mMultiUserAvatar.setImageDrawable(picture);
@@ -421,9 +388,9 @@ public class KeyguardStatusBarView extends RelativeLayout {
    }

    /** Should only be called from {@link KeyguardStatusBarViewController}. */
    void onThemeChanged() {
    void onThemeChanged(StatusBarIconController.TintedIconManager iconManager) {
        mBatteryView.setColorsFromContext(mContext);
        updateIconsAndTextColors();
        updateIconsAndTextColors(iconManager);
    }

    /** Should only be called from {@link KeyguardStatusBarViewController}. */
@@ -433,7 +400,7 @@ public class KeyguardStatusBarView extends RelativeLayout {
        mBatteryView.updatePercentView();
    }

    private void updateIconsAndTextColors() {
    private void updateIconsAndTextColors(StatusBarIconController.TintedIconManager iconManager) {
        @ColorInt int textColor = Utils.getColorAttrDefaultColor(mContext,
                R.attr.wallpaperTextColor);
        @ColorInt int iconColor = Utils.getColorStateListDefaultColor(mContext,
@@ -441,8 +408,8 @@ public class KeyguardStatusBarView extends RelativeLayout {
                R.color.light_mode_icon_color_single_tone);
        float intensity = textColor == Color.WHITE ? 0 : 1;
        mCarrierLabel.setTextColor(iconColor);
        if (mIconManager != null) {
            mIconManager.setTint(iconColor);
        if (iconManager != null) {
            iconManager.setTint(iconColor);
        }

        applyDarkness(R.id.battery, mEmptyRect, intensity, iconColor);
+36 −2
Original line number Diff line number Diff line
@@ -20,10 +20,12 @@ import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedul
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_OUT;

import android.animation.ValueAnimator;
import android.content.res.Resources;

import androidx.annotation.NonNull;

import com.android.keyguard.CarrierTextController;
import com.android.systemui.R;
import com.android.systemui.statusbar.events.SystemStatusAnimationCallback;
import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -33,6 +35,9 @@ import com.android.systemui.util.ViewController;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import javax.inject.Inject;

@@ -43,6 +48,8 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    private final SystemStatusAnimationScheduler mAnimationScheduler;
    private final BatteryController mBatteryController;
    private final UserInfoController mUserInfoController;
    private final StatusBarIconController mStatusBarIconController;
    private final StatusBarIconController.TintedIconManager.Factory mTintedIconManagerFactory;

    private final ConfigurationController.ConfigurationListener mConfigurationListener =
            new ConfigurationController.ConfigurationListener() {
@@ -94,7 +101,10 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    private final UserInfoController.OnUserInfoChangedListener mOnUserInfoChangedListener =
            (name, picture, userAccount) -> mView.onUserInfoChanged(picture);

    private final List<String> mBlockedIcons;

    private boolean mBatteryListening;
    private StatusBarIconController.TintedIconManager mTintedIconManager;

    @Inject
    public KeyguardStatusBarViewController(
@@ -103,13 +113,23 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
            ConfigurationController configurationController,
            SystemStatusAnimationScheduler animationScheduler,
            BatteryController batteryController,
            UserInfoController userInfoController) {
            UserInfoController userInfoController,
            StatusBarIconController statusBarIconController,
            StatusBarIconController.TintedIconManager.Factory tintedIconManagerFactory) {
        super(view);
        mCarrierTextController = carrierTextController;
        mConfigurationController = configurationController;
        mAnimationScheduler = animationScheduler;
        mBatteryController = batteryController;
        mUserInfoController = userInfoController;
        mStatusBarIconController = statusBarIconController;
        mTintedIconManagerFactory = tintedIconManagerFactory;

        Resources r = getResources();
        mBlockedIcons = Collections.unmodifiableList(Arrays.asList(
                r.getString(com.android.internal.R.string.status_bar_volume),
                r.getString(com.android.internal.R.string.status_bar_alarm_clock),
                r.getString(com.android.internal.R.string.status_bar_call_strength)));
    }

    @Override
@@ -123,19 +143,33 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
        mConfigurationController.addCallback(mConfigurationListener);
        mAnimationScheduler.addCallback(mAnimationCallback);
        mUserInfoController.addCallback(mOnUserInfoChangedListener);
        if (mTintedIconManager == null) {
            mTintedIconManager =
                    mTintedIconManagerFactory.create(mView.findViewById(R.id.statusIcons));
            mTintedIconManager.setBlockList(mBlockedIcons);
            mStatusBarIconController.addIconGroup(mTintedIconManager);
        }
        onThemeChanged();
    }

    @Override
    protected void onViewDetached() {
        // Don't receive future #onViewAttached calls so that we don't accidentally have two
        // controllers registered for the same view.
        // TODO(b/194181195): This shouldn't be necessary.
        destroy();

        mConfigurationController.removeCallback(mConfigurationListener);
        mAnimationScheduler.removeCallback(mAnimationCallback);
        mUserInfoController.removeCallback(mOnUserInfoChangedListener);
        if (mTintedIconManager != null) {
            mStatusBarIconController.removeIconGroup(mTintedIconManager);
        }
    }

    /** Should be called when the theme changes. */
    public void onThemeChanged() {
        mView.onThemeChanged();
        mView.onThemeChanged(mTintedIconManager);
    }

    /** Sets whether this controller should listen to battery updates. */
+4 −0
Original line number Diff line number Diff line
@@ -971,6 +971,10 @@ public class NotificationPanelViewController extends PanelViewController {

        KeyguardStatusBarViewComponent statusBarViewComponent =
                mKeyguardStatusBarViewComponentFactory.build(keyguardStatusBarView);
        if (mKeyguardStatusBarViewController != null) {
            // TODO(b/194181195): This shouldn't be necessary.
            mKeyguardStatusBarViewController.onViewDetached();
        }
        mKeyguardStatusBarViewController =
                statusBarViewComponent.getKeyguardStatusBarViewController();
        mKeyguardStatusBarViewController.init();
+17 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.demomode.DemoModeCommandReceiver;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
@@ -50,6 +51,8 @@ import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

public interface StatusBarIconController {

    /**
@@ -213,6 +216,20 @@ public interface StatusBarIconController {
            icons.setColor(mColor);
            return icons;
        }

        @SysUISingleton
        public static class Factory {
            private final FeatureFlags mFeatureFlags;

            @Inject
            public Factory(FeatureFlags featureFlags) {
                mFeatureFlags = featureFlags;
            }

            public TintedIconManager create(ViewGroup group) {
                return new TintedIconManager(group, mFeatureFlags);
            }
        }
    }

    /**
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import android.view.ViewGroup;

import com.android.internal.statusbar.StatusBarIcon;
@@ -88,6 +89,13 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
    /** */
    @Override
    public void addIconGroup(IconManager group) {
        for (IconManager existingIconManager : mIconGroups) {
            if (existingIconManager.mGroup == group.mGroup) {
                Log.e(TAG, "Adding new IconManager for the same ViewGroup. This could cause "
                        + "unexpected results.");
            }
        }

        mIconGroups.add(group);
        List<Slot> allSlots = getSlots();
        for (int i = 0; i < allSlots.size(); i++) {
Loading