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

Commit 8e416767 authored by Ondrej Novak's avatar Ondrej Novak
Browse files

Register fallback even if background already exists

Fallback would not be registered/drawn if background was explicitly set before calling
setContentView and the area that was supposed to be covered by fallback ended up black.
mBackgroundDrawable does not control fallback, so setting fallback should not be dependent on
it's existence.

Change-Id: I7da85e8c61dababa3a7ce930238ea0f283d19b32
Fixes: 68822553
Test: atest PhoneWindowTest
parent 421338f8
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));
    }