Loading packages/SystemUI/src/com/android/systemui/AutoReinflateContainer.java +30 −24 Original line number Diff line number Diff line Loading @@ -24,59 +24,50 @@ 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; /** * Custom {@link FrameLayout} that re-inflates when changes to {@link Configuration} happen. * Currently supports changes to density and locale. * Currently supports changes to density, asset path, and locale. */ public class AutoReinflateContainer extends FrameLayout { public class AutoReinflateContainer extends FrameLayout implements ConfigurationController.ConfigurationListener { private final List<InflateListener> mInflateListeners = new ArrayList<>(); private final int mLayout; private int mDensity; private LocaleList mLocaleList; public AutoReinflateContainer(Context context, @Nullable AttributeSet attrs) { super(context, attrs); mDensity = context.getResources().getConfiguration().densityDpi; mLocaleList = context.getResources().getConfiguration().getLocales(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AutoReinflateContainer); if (!a.hasValue(R.styleable.AutoReinflateContainer_android_layout)) { throw new IllegalArgumentException("AutoReinflateContainer must contain a layout"); } mLayout = a.getResourceId(R.styleable.AutoReinflateContainer_android_layout, 0); a.recycle(); inflateLayout(); } @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); boolean shouldInflateLayout = false; final int density = newConfig.densityDpi; if (density != mDensity) { mDensity = density; shouldInflateLayout = true; } final LocaleList localeList = newConfig.getLocales(); if (localeList != mLocaleList) { mLocaleList = localeList; shouldInflateLayout = true; protected void onAttachedToWindow() { super.onAttachedToWindow(); Dependency.get(ConfigurationController.class).addCallback(this); } if (shouldInflateLayout) { inflateLayout(); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); Dependency.get(ConfigurationController.class).removeCallback(this); } protected void inflateLayoutImpl() { LayoutInflater.from(getContext()).inflate(mLayout, this); } protected void inflateLayout() { public void inflateLayout() { removeAllViews(); inflateLayoutImpl(); final int N = mInflateListeners.size(); Loading @@ -90,6 +81,21 @@ public class AutoReinflateContainer extends FrameLayout { listener.onInflated(getChildAt(0)); } @Override public void onDensityOrFontScaleChanged() { inflateLayout(); } @Override public void onOverlayChanged() { inflateLayout(); } @Override public void onLocaleListChanged() { inflateLayout(); } public interface InflateListener { /** * Called whenever a new view is inflated. Loading packages/SystemUI/src/com/android/systemui/doze/DozeReceiver.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.doze; /** * Interface for class that cares about doze states. */ public interface DozeReceiver { void setDozing(boolean dozing); } packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerImpl.java +13 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.content.Context; import android.content.om.IOverlayManager; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.os.LocaleList; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; Loading @@ -38,6 +39,7 @@ public class ConfigurationControllerImpl implements ConfigurationController, private float mFontScale; private boolean mInCarMode; private int mUiMode; private LocaleList mLocaleList; public ConfigurationControllerImpl(Context context) { Configuration currentConfig = context.getResources().getConfiguration(); Loading @@ -46,6 +48,7 @@ public class ConfigurationControllerImpl implements ConfigurationController, mInCarMode = (currentConfig.uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_CAR; mUiMode = currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK; mLocaleList = currentConfig.getLocales(); } @Override Loading Loading @@ -73,6 +76,16 @@ public class ConfigurationControllerImpl implements ConfigurationController, mUiMode = uiMode; } final LocaleList localeList = newConfig.getLocales(); if (!localeList.equals(mLocaleList)) { mLocaleList = localeList; listeners.forEach(l -> { if (mListeners.contains(l)) { l.onLocaleListChanged(); } }); } if ((mLastConfig.updateFrom(newConfig) & ActivityInfo.CONFIG_ASSETS_PATHS) != 0) { listeners.forEach(l -> { if (mListeners.contains(l)) { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +8 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.ActivityStarterDelegate; import com.android.systemui.AutoReinflateContainer; import com.android.systemui.DejankUtils; import com.android.systemui.DemoMode; import com.android.systemui.Dependency; Loading @@ -175,6 +176,7 @@ import com.android.systemui.classifier.FalsingManager; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.doze.DozeHost; import com.android.systemui.doze.DozeLog; import com.android.systemui.doze.DozeReceiver; import com.android.systemui.fragments.ExtensionFragmentListener; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.keyguard.KeyguardViewMediator; Loading Loading @@ -1330,6 +1332,9 @@ public class StatusBar extends SystemUI implements DemoMode, if (mStatusBarKeyguardViewManager != null) { mStatusBarKeyguardViewManager.onOverlayChanged(); } if (mAmbientIndicationContainer instanceof AutoReinflateContainer) { ((AutoReinflateContainer) mAmbientIndicationContainer).inflateLayout(); } } protected void reevaluateStyles() { Loading Loading @@ -5340,6 +5345,9 @@ public class StatusBar extends SystemUI implements DemoMode, } mStatusBarWindowManager.setDozing(mDozing); mStatusBarKeyguardViewManager.setDozing(mDozing); if (mAmbientIndicationContainer instanceof DozeReceiver) { ((DozeReceiver) mAmbientIndicationContainer).setDozing(mDozing); } updateDozingState(); Trace.endSection(); } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/ConfigurationController.java +1 −0 Original line number Diff line number Diff line Loading @@ -28,5 +28,6 @@ public interface ConfigurationController extends CallbackController<Configuratio default void onConfigChanged(Configuration newConfig) {} default void onDensityOrFontScaleChanged() {} default void onOverlayChanged() {} default void onLocaleListChanged() {} } } Loading
packages/SystemUI/src/com/android/systemui/AutoReinflateContainer.java +30 −24 Original line number Diff line number Diff line Loading @@ -24,59 +24,50 @@ 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; /** * Custom {@link FrameLayout} that re-inflates when changes to {@link Configuration} happen. * Currently supports changes to density and locale. * Currently supports changes to density, asset path, and locale. */ public class AutoReinflateContainer extends FrameLayout { public class AutoReinflateContainer extends FrameLayout implements ConfigurationController.ConfigurationListener { private final List<InflateListener> mInflateListeners = new ArrayList<>(); private final int mLayout; private int mDensity; private LocaleList mLocaleList; public AutoReinflateContainer(Context context, @Nullable AttributeSet attrs) { super(context, attrs); mDensity = context.getResources().getConfiguration().densityDpi; mLocaleList = context.getResources().getConfiguration().getLocales(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AutoReinflateContainer); if (!a.hasValue(R.styleable.AutoReinflateContainer_android_layout)) { throw new IllegalArgumentException("AutoReinflateContainer must contain a layout"); } mLayout = a.getResourceId(R.styleable.AutoReinflateContainer_android_layout, 0); a.recycle(); inflateLayout(); } @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); boolean shouldInflateLayout = false; final int density = newConfig.densityDpi; if (density != mDensity) { mDensity = density; shouldInflateLayout = true; } final LocaleList localeList = newConfig.getLocales(); if (localeList != mLocaleList) { mLocaleList = localeList; shouldInflateLayout = true; protected void onAttachedToWindow() { super.onAttachedToWindow(); Dependency.get(ConfigurationController.class).addCallback(this); } if (shouldInflateLayout) { inflateLayout(); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); Dependency.get(ConfigurationController.class).removeCallback(this); } protected void inflateLayoutImpl() { LayoutInflater.from(getContext()).inflate(mLayout, this); } protected void inflateLayout() { public void inflateLayout() { removeAllViews(); inflateLayoutImpl(); final int N = mInflateListeners.size(); Loading @@ -90,6 +81,21 @@ public class AutoReinflateContainer extends FrameLayout { listener.onInflated(getChildAt(0)); } @Override public void onDensityOrFontScaleChanged() { inflateLayout(); } @Override public void onOverlayChanged() { inflateLayout(); } @Override public void onLocaleListChanged() { inflateLayout(); } public interface InflateListener { /** * Called whenever a new view is inflated. Loading
packages/SystemUI/src/com/android/systemui/doze/DozeReceiver.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.doze; /** * Interface for class that cares about doze states. */ public interface DozeReceiver { void setDozing(boolean dozing); }
packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerImpl.java +13 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.content.Context; import android.content.om.IOverlayManager; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.os.LocaleList; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; Loading @@ -38,6 +39,7 @@ public class ConfigurationControllerImpl implements ConfigurationController, private float mFontScale; private boolean mInCarMode; private int mUiMode; private LocaleList mLocaleList; public ConfigurationControllerImpl(Context context) { Configuration currentConfig = context.getResources().getConfiguration(); Loading @@ -46,6 +48,7 @@ public class ConfigurationControllerImpl implements ConfigurationController, mInCarMode = (currentConfig.uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_CAR; mUiMode = currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK; mLocaleList = currentConfig.getLocales(); } @Override Loading Loading @@ -73,6 +76,16 @@ public class ConfigurationControllerImpl implements ConfigurationController, mUiMode = uiMode; } final LocaleList localeList = newConfig.getLocales(); if (!localeList.equals(mLocaleList)) { mLocaleList = localeList; listeners.forEach(l -> { if (mListeners.contains(l)) { l.onLocaleListChanged(); } }); } if ((mLastConfig.updateFrom(newConfig) & ActivityInfo.CONFIG_ASSETS_PATHS) != 0) { listeners.forEach(l -> { if (mListeners.contains(l)) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +8 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.ActivityStarterDelegate; import com.android.systemui.AutoReinflateContainer; import com.android.systemui.DejankUtils; import com.android.systemui.DemoMode; import com.android.systemui.Dependency; Loading @@ -175,6 +176,7 @@ import com.android.systemui.classifier.FalsingManager; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.doze.DozeHost; import com.android.systemui.doze.DozeLog; import com.android.systemui.doze.DozeReceiver; import com.android.systemui.fragments.ExtensionFragmentListener; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.keyguard.KeyguardViewMediator; Loading Loading @@ -1330,6 +1332,9 @@ public class StatusBar extends SystemUI implements DemoMode, if (mStatusBarKeyguardViewManager != null) { mStatusBarKeyguardViewManager.onOverlayChanged(); } if (mAmbientIndicationContainer instanceof AutoReinflateContainer) { ((AutoReinflateContainer) mAmbientIndicationContainer).inflateLayout(); } } protected void reevaluateStyles() { Loading Loading @@ -5340,6 +5345,9 @@ public class StatusBar extends SystemUI implements DemoMode, } mStatusBarWindowManager.setDozing(mDozing); mStatusBarKeyguardViewManager.setDozing(mDozing); if (mAmbientIndicationContainer instanceof DozeReceiver) { ((DozeReceiver) mAmbientIndicationContainer).setDozing(mDozing); } updateDozingState(); Trace.endSection(); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/ConfigurationController.java +1 −0 Original line number Diff line number Diff line Loading @@ -28,5 +28,6 @@ public interface ConfigurationController extends CallbackController<Configuratio default void onConfigChanged(Configuration newConfig) {} default void onDensityOrFontScaleChanged() {} default void onOverlayChanged() {} default void onLocaleListChanged() {} } }