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

Commit 98c7c05d authored by Clara Bayarri's avatar Clara Bayarri Committed by Android (Google) Code Review
Browse files

Merge "Reinflate QS view on Locale configuration change" into nyc-dev

parents db042644 9b1fdff2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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"
+1 −1
Original line number Diff line number Diff line
@@ -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>

+24 −7
Original line number Diff line number Diff line
@@ -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();
        }
    }
+13 −12
Original line number Diff line number Diff line
@@ -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) {
+4 −4
Original line number Diff line number Diff line
@@ -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;
Loading