diff options
author | 2016-04-21 14:28:47 +0100 | |
---|---|---|
committer | 2016-04-21 14:32:07 +0100 | |
commit | 9b1fdff2e70e695a0104dbc63fc26e434dc7f188 (patch) | |
tree | 72d169a6fd903bf9443a0c7e609747899e0642c9 | |
parent | b99d6af3ab406db14d161cdc0000ed521957d7ca (diff) |
Reinflate QS view on Locale configuration change
The existing DensityContainer already did this for density changes,
repurposed it to handle other Configuration changes. Also renamed
to AutoReinflateContainer.
Bug: 27952059
Change-Id: Ieb572abcbafe49aec73b16e1bcb8c294011afdd3
-rw-r--r-- | packages/SystemUI/res/layout/status_bar_expanded.xml | 4 | ||||
-rw-r--r-- | packages/SystemUI/res/values/attrs.xml | 2 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/AutoReinflateContainer.java (renamed from packages/SystemUI/src/com/android/systemui/DensityContainer.java) | 31 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java | 25 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java | 8 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java | 8 |
6 files changed, 48 insertions, 30 deletions
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index ccefb5fe0a5b..658571e8674d 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -39,8 +39,8 @@ android:clipToPadding="false" android:clipChildren="false"> - <com.android.systemui.DensityContainer - android:id="@+id/qs_density_container" + <com.android.systemui.AutoReinflateContainer + android:id="@+id/qs_auto_reinflate_container" android:layout="@layout/qs_panel" android:layout_width="@dimen/notification_panel_width" android:layout_height="match_parent" diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml index 1543360761bf..4306fcc9873c 100644 --- a/packages/SystemUI/res/values/attrs.xml +++ b/packages/SystemUI/res/values/attrs.xml @@ -98,7 +98,7 @@ <attr name="metricsAction" format="integer" /> </declare-styleable> - <declare-styleable name="DensityContainer"> + <declare-styleable name="AutoReinflateContainer"> <attr name="android:layout" /> </declare-styleable> diff --git a/packages/SystemUI/src/com/android/systemui/DensityContainer.java b/packages/SystemUI/src/com/android/systemui/AutoReinflateContainer.java index 2e3cb4977488..0afab88288a4 100644 --- a/packages/SystemUI/src/com/android/systemui/DensityContainer.java +++ b/packages/SystemUI/src/com/android/systemui/AutoReinflateContainer.java @@ -19,6 +19,7 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.TypedArray; import android.util.AttributeSet; +import android.util.LocaleList; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; @@ -26,31 +27,47 @@ import android.widget.FrameLayout; import java.util.ArrayList; import java.util.List; -public class DensityContainer extends FrameLayout { +/** + * Custom {@link FrameLayout} that re-inflates when changes to {@link Configuration} happen. + * Currently supports changes to density and locale. + */ +public class AutoReinflateContainer extends FrameLayout { private final List<InflateListener> mInflateListeners = new ArrayList<>(); private final int mLayout; private int mDensity; + private LocaleList mLocaleList; - public DensityContainer(Context context, @Nullable AttributeSet attrs) { + 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.DensityContainer); - if (!a.hasValue(R.styleable.DensityContainer_android_layout)) { - throw new IllegalArgumentException("DensityContainer must contain a layout"); + 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.DensityContainer_android_layout, 0); + mLayout = a.getResourceId(R.styleable.AutoReinflateContainer_android_layout, 0); inflateLayout(); } @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - int density = newConfig.densityDpi; + 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; + } + + if (shouldInflateLayout) { inflateLayout(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 48cf631bb683..8617104799d7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -41,9 +41,9 @@ import android.widget.FrameLayout; import android.widget.TextView; import com.android.internal.logging.MetricsLogger; import com.android.keyguard.KeyguardStatusView; +import com.android.systemui.AutoReinflateContainer; +import com.android.systemui.AutoReinflateContainer.InflateListener; import com.android.systemui.DejankUtils; -import com.android.systemui.DensityContainer; -import com.android.systemui.DensityContainer.InflateListener; import com.android.systemui.EventLogConstants; import com.android.systemui.EventLogTags; import com.android.systemui.Interpolators; @@ -92,7 +92,7 @@ public class NotificationPanelView extends PanelView implements private KeyguardUserSwitcher mKeyguardUserSwitcher; private KeyguardStatusBarView mKeyguardStatusBar; protected QSContainer mQsContainer; - private DensityContainer mQsDensityContainer; + private AutoReinflateContainer mQsAutoReinflateContainer; private KeyguardStatusView mKeyguardStatusView; private TextView mClockView; private View mReserveNotificationSpace; @@ -219,8 +219,9 @@ public class NotificationPanelView extends PanelView implements super.onFinishInflate(); mKeyguardStatusBar = (KeyguardStatusBarView) findViewById(R.id.keyguard_header); mKeyguardStatusView = (KeyguardStatusView) findViewById(R.id.keyguard_status_view); - mQsDensityContainer = (DensityContainer) findViewById(R.id.qs_density_container); - mQsDensityContainer.addInflateListener(new InflateListener() { + mQsAutoReinflateContainer = + (AutoReinflateContainer) findViewById(R.id.qs_auto_reinflate_container); + mQsAutoReinflateContainer.addInflateListener(new InflateListener() { @Override public void onInflated(View v) { mQsContainer = (QSContainer) v.findViewById(R.id.quick_settings_container); @@ -280,11 +281,11 @@ public class NotificationPanelView extends PanelView implements int panelWidth = getResources().getDimensionPixelSize(R.dimen.notification_panel_width); int panelGravity = getResources().getInteger(R.integer.notification_panel_layout_gravity); FrameLayout.LayoutParams lp = - (FrameLayout.LayoutParams) mQsDensityContainer.getLayoutParams(); + (FrameLayout.LayoutParams) mQsAutoReinflateContainer.getLayoutParams(); if (lp.width != panelWidth) { lp.width = panelWidth; lp.gravity = panelGravity; - mQsDensityContainer.setLayoutParams(lp); + mQsAutoReinflateContainer.setLayoutParams(lp); mQsContainer.post(mUpdateHeader); } @@ -790,8 +791,8 @@ public class NotificationPanelView extends PanelView implements } private boolean isInQsArea(float x, float y) { - return (x >= mQsDensityContainer.getX() - && x <= mQsDensityContainer.getX() + mQsDensityContainer.getWidth()) + return (x >= mQsAutoReinflateContainer.getX() + && x <= mQsAutoReinflateContainer.getX() + mQsAutoReinflateContainer.getWidth()) && (y <= mNotificationStackScroller.getBottomMostNotificationBottom() || y <= mQsContainer.getY() + mQsContainer.getHeight()); } @@ -1339,8 +1340,8 @@ public class NotificationPanelView extends PanelView implements return false; } View header = mKeyguardShowing ? mKeyguardStatusBar : mQsContainer.getHeader(); - boolean onHeader = x >= mQsDensityContainer.getX() - && x <= mQsDensityContainer.getX() + mQsDensityContainer.getWidth() + boolean onHeader = x >= mQsAutoReinflateContainer.getX() + && x <= mQsAutoReinflateContainer.getX() + mQsAutoReinflateContainer.getWidth() && y >= header.getTop() && y <= header.getBottom(); if (mQsExpanded) { return onHeader || (yDiff < 0 && isInQsArea(x, y)); @@ -2227,7 +2228,7 @@ public class NotificationPanelView extends PanelView implements protected void setVerticalPanelTranslation(float translation) { mNotificationStackScroller.setTranslationX(translation); - mQsDensityContainer.setTranslationX(translation); + mQsAutoReinflateContainer.setTranslationX(translation); } protected void updateStackHeight(float stackHeight) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java index 35fb2a50306e..36e59db1ac7b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java @@ -24,7 +24,7 @@ import android.view.View; import android.view.ViewStub; import android.view.WindowInsets; import android.widget.FrameLayout; -import com.android.systemui.DensityContainer; +import com.android.systemui.AutoReinflateContainer; import com.android.systemui.R; import com.android.systemui.qs.QSContainer; import com.android.systemui.qs.customize.QSCustomizer; @@ -33,10 +33,10 @@ import com.android.systemui.qs.customize.QSCustomizer; * The container with notification stack scroller and quick settings inside. */ public class NotificationsQuickSettingsContainer extends FrameLayout - implements ViewStub.OnInflateListener, DensityContainer.InflateListener { + implements ViewStub.OnInflateListener, AutoReinflateContainer.InflateListener { - private DensityContainer mQsContainer; + private AutoReinflateContainer mQsContainer; private View mUserSwitcher; private View mStackScroller; private View mKeyguardStatusBar; @@ -54,7 +54,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout @Override protected void onFinishInflate() { super.onFinishInflate(); - mQsContainer = (DensityContainer) findViewById(R.id.qs_density_container); + mQsContainer = (AutoReinflateContainer) findViewById(R.id.qs_auto_reinflate_container); mQsContainer.addInflateListener(this); mStackScroller = findViewById(R.id.notification_stack_scroller); mStackScrollerMargin = ((LayoutParams) mStackScroller.getLayoutParams()).bottomMargin; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 712f8143cbc5..c36c482e785e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -103,10 +103,10 @@ import com.android.keyguard.KeyguardHostView.OnDismissAction; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.ViewMediatorCallback; +import com.android.systemui.AutoReinflateContainer; +import com.android.systemui.AutoReinflateContainer.InflateListener; import com.android.systemui.BatteryMeterView; import com.android.systemui.DemoMode; -import com.android.systemui.DensityContainer; -import com.android.systemui.DensityContainer.InflateListener; import com.android.systemui.EventLogConstants; import com.android.systemui.EventLogTags; import com.android.systemui.Interpolators; @@ -871,8 +871,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } // Set up the quick settings tile panel - DensityContainer container = (DensityContainer) mStatusBarWindow.findViewById( - R.id.qs_density_container); + AutoReinflateContainer container = (AutoReinflateContainer) mStatusBarWindow.findViewById( + R.id.qs_auto_reinflate_container); if (container != null) { final QSTileHost qsh = SystemUIFactory.getInstance().createQSTileHost(mContext, this, mBluetoothController, mLocationController, mRotationLockController, |