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

Commit 7334dcad authored by Ondrej Novak's avatar Ondrej Novak Committed by Android (Google) Code Review
Browse files

Merge "Register fallback even if background already exists"

parents 8037fe3c 8e416767
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -2512,12 +2512,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                if (a.hasValue(R.styleable.Window_windowBackground)) {
                    mBackgroundDrawable = a.getDrawable(R.styleable.Window_windowBackground);
                }

            }
            if (a.hasValue(R.styleable.Window_windowBackgroundFallback)) {
                mBackgroundFallbackDrawable =
                        a.getDrawable(R.styleable.Window_windowBackgroundFallback);
            }
            }
            if (mLoadElevation) {
                mElevation = a.getDimension(R.styleable.Window_windowElevation, 0);
            }
+18 −0
Original line number Diff line number Diff line
@@ -118,6 +118,24 @@ public final class PhoneWindowTest {
        assertThat(colorDrawable.getColor(), is(Color.BLUE));
    }

    @Test
    public void testWindowBackgroundFallbackWithExplicitBackgroundSet_colorLiteral() {
        createPhoneWindowWithTheme(R.style.WindowBackgroundFallbackColorLiteral);
        // set background before decorView is created
        mPhoneWindow.setBackgroundDrawable(new ColorDrawable(Color.CYAN));
        installDecor();
        // clear background so that fallback is used
        mPhoneWindow.setBackgroundDrawable(null);

        DecorView decorView = (DecorView) mPhoneWindow.getDecorView();
        Drawable fallbackDrawable = decorView.getBackgroundFallback();

        assertThat(fallbackDrawable instanceof ColorDrawable, is(true));

        ColorDrawable colorDrawable = (ColorDrawable) fallbackDrawable;
        assertThat(colorDrawable.getColor(), is(Color.BLUE));
    }

    private void createPhoneWindowWithTheme(int theme) {
        mPhoneWindow = new PhoneWindow(new ContextThemeWrapper(mContext, theme));
    }