Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0caebb50 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android Git Automerger
Browse files

am 026dc143: Merge "Fix configuration changes in status bars." into klp-dev

* commit '026dc143':
  Fix configuration changes in status bars.
parents e2a67ac2 026dc143
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -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);
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -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) {
+17 −12
Original line number Diff line number Diff line
@@ -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);