Merge "Remove ConfigurationController from Dependency#get to fully rely on Dagger" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f1e34af723
@@ -16,6 +16,7 @@ package com.android.systemui;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
@@ -23,21 +24,29 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Custom {@link FrameLayout} that re-inflates when changes to {@link Configuration} happen.
|
||||
* Currently supports changes to density, asset path, and locale.
|
||||
*/
|
||||
public class AutoReinflateContainer extends FrameLayout implements
|
||||
ConfigurationController.ConfigurationListener {
|
||||
public class AutoReinflateContainer extends FrameLayout {
|
||||
|
||||
private static final Set<Integer> SUPPORTED_CHANGES = Set.of(
|
||||
ActivityInfo.CONFIG_LOCALE,
|
||||
ActivityInfo.CONFIG_UI_MODE,
|
||||
ActivityInfo.CONFIG_ASSETS_PATHS,
|
||||
ActivityInfo.CONFIG_DENSITY,
|
||||
ActivityInfo.CONFIG_FONT_SCALE
|
||||
);
|
||||
|
||||
private final List<InflateListener> mInflateListeners = new ArrayList<>();
|
||||
private final int mLayout;
|
||||
|
||||
private final Configuration mLastConfig = new Configuration();
|
||||
|
||||
public AutoReinflateContainer(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -51,15 +60,14 @@ public class AutoReinflateContainer extends FrameLayout implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Dependency.get(ConfigurationController.class).addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
Dependency.get(ConfigurationController.class).removeCallback(this);
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
int diff = mLastConfig.updateFrom(newConfig);
|
||||
for (int change: SUPPORTED_CHANGES) {
|
||||
if ((diff & change) != 0) {
|
||||
inflateLayout();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void inflateLayoutImpl() {
|
||||
@@ -80,26 +88,6 @@ public class AutoReinflateContainer extends FrameLayout implements
|
||||
listener.onInflated(getChildAt(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDensityOrFontScaleChanged() {
|
||||
inflateLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onThemeChanged() {
|
||||
inflateLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiModeChanged() {
|
||||
inflateLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocaleListChanged() {
|
||||
inflateLayout();
|
||||
}
|
||||
|
||||
public interface InflateListener {
|
||||
/**
|
||||
* Called whenever a new view is inflated.
|
||||
|
||||
@@ -106,7 +106,6 @@ import com.android.systemui.statusbar.policy.AccessibilityController;
|
||||
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
|
||||
import com.android.systemui.statusbar.policy.BluetoothController;
|
||||
import com.android.systemui.statusbar.policy.CastController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.DataSaverController;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.ExtensionController;
|
||||
@@ -134,14 +133,14 @@ import com.android.systemui.util.leak.LeakDetector;
|
||||
import com.android.systemui.util.leak.LeakReporter;
|
||||
import com.android.systemui.util.sensors.AsyncSensorManager;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
/**
|
||||
* Class to handle ugly dependencies throughout sysui until we determine the
|
||||
* long-term dependency injection solution.
|
||||
@@ -270,7 +269,6 @@ public class Dependency {
|
||||
@Inject Lazy<NotificationShadeWindowController> mNotificationShadeWindowController;
|
||||
@Inject Lazy<StatusBarWindowController> mTempStatusBarWindowController;
|
||||
@Inject Lazy<DarkIconDispatcher> mDarkIconDispatcher;
|
||||
@Inject Lazy<ConfigurationController> mConfigurationController;
|
||||
@Inject Lazy<StatusBarIconController> mStatusBarIconController;
|
||||
@Inject Lazy<ScreenLifecycle> mScreenLifecycle;
|
||||
@Inject Lazy<WakefulnessLifecycle> mWakefulnessLifecycle;
|
||||
@@ -441,8 +439,6 @@ public class Dependency {
|
||||
|
||||
mProviders.put(DarkIconDispatcher.class, mDarkIconDispatcher::get);
|
||||
|
||||
mProviders.put(ConfigurationController.class, mConfigurationController::get);
|
||||
|
||||
mProviders.put(StatusBarIconController.class, mStatusBarIconController::get);
|
||||
|
||||
mProviders.put(ScreenLifecycle.class, mScreenLifecycle::get);
|
||||
|
||||
@@ -116,7 +116,6 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest {
|
||||
.thenReturn(TEST_AUTO_DISMISS_TIME);
|
||||
when(mVSProvider.isReorderingAllowed()).thenReturn(true);
|
||||
mDependency.injectMockDependency(NotificationShadeWindowController.class);
|
||||
mDependency.injectMockDependency(ConfigurationController.class);
|
||||
super.setUp();
|
||||
|
||||
mHeadsUpManager = new TestableHeadsUpManagerPhone(
|
||||
|
||||
@@ -45,6 +45,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
@@ -53,16 +55,18 @@ import java.util.function.Consumer;
|
||||
@SmallTest
|
||||
public class ExtensionControllerImplTest extends SysuiTestCase {
|
||||
|
||||
@Mock
|
||||
private ConfigurationController mConfigurationController;
|
||||
|
||||
private PluginManager mPluginManager;
|
||||
private TunerService mTunerService;
|
||||
private ExtensionController mExtensionController;
|
||||
private ConfigurationController mConfigurationController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mPluginManager = mDependency.injectMockDependency(PluginManager.class);
|
||||
mTunerService = mDependency.injectMockDependency(TunerService.class);
|
||||
mConfigurationController = mDependency.injectMockDependency(ConfigurationController.class);
|
||||
mExtensionController = new ExtensionControllerImpl(
|
||||
mContext,
|
||||
mock(LeakDetector.class),
|
||||
|
||||
Reference in New Issue
Block a user