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

Commit fde9618e authored by PETER LIANG's avatar PETER LIANG Committed by Android (Google) Code Review
Browse files

Merge "Fix sometimes couldn’t receive the configuration change callback after rotating."

parents 26418287 a5535784
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -182,9 +182,9 @@ public class AccessibilityFloatingMenuController implements
        if (mFloatingMenu == null) {
            if (mFeatureFlags.isEnabled(A11Y_FLOATING_MENU_FLING_SPRING_ANIMATIONS)) {
                final Display defaultDisplay = mDisplayManager.getDisplay(DEFAULT_DISPLAY);
                mFloatingMenu = new MenuViewLayerController(
                        mContext.createWindowContext(defaultDisplay,
                                TYPE_NAVIGATION_BAR_PANEL, /* options= */ null), mWindowManager,
                final Context windowContext = mContext.createWindowContext(defaultDisplay,
                        TYPE_NAVIGATION_BAR_PANEL, /* options= */ null);
                mFloatingMenu = new MenuViewLayerController(windowContext, mWindowManager,
                        mAccessibilityManager);
            } else {
                mFloatingMenu = new AccessibilityFloatingMenu(mContext);
+2 −14
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.systemui.accessibility.floatingmenu;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.ComponentCallbacks;
import android.content.res.Configuration;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
@@ -34,7 +32,7 @@ import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
 * Controls the interaction between {@link MagnetizedObject} and
 * {@link MagnetizedObject.MagneticTarget}.
 */
class DismissAnimationController implements ComponentCallbacks {
class DismissAnimationController {
    private static final float COMPLETELY_OPAQUE = 1.0f;
    private static final float COMPLETELY_TRANSPARENT = 0.0f;
    private static final float CIRCLE_VIEW_DEFAULT_SCALE = 1.0f;
@@ -105,16 +103,6 @@ class DismissAnimationController implements ComponentCallbacks {
        mMagnetizedObject.addTarget(magneticTarget);
    }

    @Override
    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        updateResources();
    }

    @Override
    public void onLowMemory() {
        // Do nothing
    }

    void showDismissView(boolean show) {
        if (show) {
            mDismissView.show();
@@ -165,7 +153,7 @@ class DismissAnimationController implements ComponentCallbacks {
        }
    }

    private void updateResources() {
    void updateResources() {
        final float maxDismissSize = mDismissView.getResources().getDimensionPixelSize(
                R.dimen.dismiss_circle_size);
        mMinDismissSize = mDismissView.getResources().getDimensionPixelSize(
+22 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.View.MeasureSpec.AT_MOST;
import static android.view.View.MeasureSpec.UNSPECIFIED;

import android.annotation.SuppressLint;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -48,7 +49,7 @@ import com.android.systemui.recents.TriangleShape;
 * . It's just shown on the left or right of the anchor view.
 */
@SuppressLint("ViewConstructor")
class MenuEduTooltipView extends FrameLayout {
class MenuEduTooltipView extends FrameLayout implements ComponentCallbacks {
    private int mFontSize;
    private int mTextViewMargin;
    private int mTextViewPadding;
@@ -73,9 +74,7 @@ class MenuEduTooltipView extends FrameLayout {
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        updateResources();
        updateMessageView();
        updateArrowView();
@@ -83,6 +82,25 @@ class MenuEduTooltipView extends FrameLayout {
        updateLocationAndVisibility();
    }

    @Override
    public void onLowMemory() {
        // Do nothing.
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        getContext().registerComponentCallbacks(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();

        getContext().unregisterComponentCallbacks(this);
    }

    void show(CharSequence message) {
        mMessageView.setText(message);

+12 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.util.TypedValue.COMPLEX_UNIT_PX;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

import android.annotation.IntDef;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
@@ -33,6 +34,8 @@ import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.android.settingslib.Utils;
import com.android.systemui.R;

@@ -44,7 +47,7 @@ import java.lang.annotation.RetentionPolicy;
 * the {@link MenuView}.
 */
class MenuMessageView extends LinearLayout implements
        ViewTreeObserver.OnComputeInternalInsetsListener {
        ViewTreeObserver.OnComputeInternalInsetsListener, ComponentCallbacks {
    private final TextView mTextView;
    private final Button mUndoButton;

@@ -73,12 +76,15 @@ class MenuMessageView extends LinearLayout implements
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        updateResources();
    }

    @Override
    public void onLowMemory() {
        // Do nothing.
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
@@ -93,6 +99,7 @@ class MenuMessageView extends LinearLayout implements

        updateResources();

        getContext().registerComponentCallbacks(this);
        getViewTreeObserver().addOnComputeInternalInsetsListener(this);
    }

@@ -100,6 +107,7 @@ class MenuMessageView extends LinearLayout implements
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();

        getContext().unregisterComponentCallbacks(this);
        getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
    }

+22 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.accessibility.floatingmenu;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

import android.annotation.SuppressLint;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.PointF;
@@ -46,7 +47,7 @@ import java.util.List;
 */
@SuppressLint("ViewConstructor")
class MenuView extends FrameLayout implements
        ViewTreeObserver.OnComputeInternalInsetsListener {
        ViewTreeObserver.OnComputeInternalInsetsListener, ComponentCallbacks {
    private static final int INDEX_MENU_ITEM = 0;
    private final List<AccessibilityTarget> mTargetFeatures = new ArrayList<>();
    private final AccessibilityTargetAdapter mAdapter;
@@ -106,14 +107,31 @@ class MenuView extends FrameLayout implements
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        loadLayoutResources();

        mTargetFeaturesView.setOverScrollMode(mMenuViewAppearance.getMenuScrollMode());
    }

    @Override
    public void onLowMemory() {
        // Do nothing.
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        getContext().registerComponentCallbacks(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();

        getContext().unregisterComponentCallbacks(this);
    }

    void setOnTargetFeaturesChangeListener(OnTargetFeaturesChangeListener listener) {
        mFeaturesChangeListener = listener;
    }
Loading