diff options
author | Daniel Sandler <dsandler@android.com> | 2013-09-30 15:02:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-09-30 15:02:43 +0000 |
commit | 026dc1432ef70308ef44dafcc28998436e304e75 (patch) | |
tree | e5791f1d0c5a2543ebbd9efc1a46afd3a522bd4e | |
parent | 57d96f0e92e8af842878660a8271e65cec2426d3 (diff) | |
parent | 777dcdeeb67c570168e04d5096d2a7a9eb408cea (diff) | |
download | frameworks_base-026dc1432ef70308ef44dafcc28998436e304e75.zip frameworks_base-026dc1432ef70308ef44dafcc28998436e304e75.tar.gz frameworks_base-026dc1432ef70308ef44dafcc28998436e304e75.tar.bz2 |
Merge "Fix configuration changes in status bars." into klp-dev
3 files changed, 37 insertions, 20 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 49777d4..932fe20 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -123,7 +123,7 @@ public abstract class BaseStatusBar extends SystemUI implements protected int mCurrentUserId = 0; - protected int mLayoutDirection; + protected int mLayoutDirection = -1; // invalid private Locale mLocale; protected boolean mUseHeadsUp = false; @@ -299,8 +299,6 @@ public abstract class BaseStatusBar extends SystemUI implements IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_SWITCHED); mContext.registerReceiver(mBroadcastReceiver, filter); - - mLocale = mContext.getResources().getConfiguration().locale; } public void userSwitched(int newUserId) { @@ -320,11 +318,17 @@ public abstract class BaseStatusBar extends SystemUI implements @Override protected void onConfigurationChanged(Configuration newConfig) { - final Locale newLocale = mContext.getResources().getConfiguration().locale; - if (! newLocale.equals(mLocale)) { - mLocale = newLocale; - mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale); - refreshLayout(mLayoutDirection); + final Locale locale = mContext.getResources().getConfiguration().locale; + final int ld = TextUtils.getLayoutDirectionFromLocale(locale); + if (! locale.equals(mLocale) || ld != mLayoutDirection) { + if (DEBUG) { + Log.v(TAG, String.format( + "config changed locale/LD: %s (%d) -> %s (%d)", mLocale, mLayoutDirection, + locale, ld)); + } + mLocale = locale; + mLayoutDirection = ld; + refreshLayout(ld); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java b/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java index ecf7b35..16fe1aa 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar; +import android.content.res.Configuration; import android.provider.Settings; import android.util.Log; @@ -70,6 +71,13 @@ public class SystemBars extends SystemUI implements ServiceMonitor.Callbacks { } @Override + protected void onConfigurationChanged(Configuration newConfig) { + if (mStatusBar != null) { + mStatusBar.onConfigurationChanged(newConfig); + } + } + + @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mStatusBar != null) { mStatusBar.dump(fd, pw, args); 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 fbc94b1..c47d0eb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -38,6 +38,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Canvas; @@ -633,7 +634,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { // receive broadcasts IntentFilter filter = new IntentFilter(); - filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); @@ -2433,17 +2433,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { notifyNavigationBarScreenOn(false); notifyHeadsUpScreenOn(false); } - else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { - if (DEBUG) { - Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); - } - mDisplay.getSize(mCurrentDisplaySize); - - updateResources(); - repositionNavigationBar(); - updateExpandedViewPos(EXPANDED_LEAVE_ALONE); - updateShowSearchHoldoff(); - } else if (Intent.ACTION_SCREEN_ON.equals(action)) { mScreenOn = true; // work around problem where mDisplay.getRotation() is not stable while screen is off (bug 7086018) @@ -2466,6 +2455,22 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { } }; + // SystemUIService notifies SystemBars of configuration changes, which then calls down here + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); // calls refreshLayout + + if (DEBUG) { + Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); + } + mDisplay.getSize(mCurrentDisplaySize); + + updateResources(); + repositionNavigationBar(); + updateExpandedViewPos(EXPANDED_LEAVE_ALONE); + updateShowSearchHoldoff(); + } + @Override public void userSwitched(int newUserId) { if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId); |