Merge "Fix configuration changes in status bars." into klp-dev

This commit is contained in:
Daniel Sandler
2013-09-30 15:02:43 +00:00
committed by Android (Google) Code Review
3 changed files with 37 additions and 20 deletions

View File

@@ -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);
}
}

View File

@@ -16,6 +16,7 @@
package com.android.systemui.statusbar;
import android.content.res.Configuration;
import android.provider.Settings;
import android.util.Log;
@@ -69,6 +70,13 @@ public class SystemBars extends SystemUI implements ServiceMonitor.Callbacks {
return 0;
}
@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) {

View File

@@ -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);