提交 85bfc4c5 编写于 作者: H Hamdi Kahloun

Update PlatformPluginTest.java & PlatformPlugin.java

上级 28555c1f
......@@ -14,6 +14,7 @@ import android.view.HapticFeedbackConstants;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
......@@ -268,9 +269,11 @@ public class PlatformPlugin {
window.setStatusBarColor(systemChromeStyle.statusBarColor);
}
}
if (systemChromeStyle.systemNavigationBarDividerColor != null) {
// Not available until Android P.
// window.setNavigationBarDividerColor(systemNavigationBarDividerColor);
if (systemChromeStyle.systemNavigationBarDividerColor != null
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
window.setNavigationBarDividerColor(systemChromeStyle.systemNavigationBarDividerColor);
}
view.setSystemUiVisibility(flags);
currentTheme = systemChromeStyle;
......
......@@ -2,6 +2,7 @@ package io.flutter.plugin.platform;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
......@@ -18,7 +19,9 @@ import android.net.Uri;
import android.view.View;
import android.view.Window;
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
import io.flutter.embedding.engine.systemchannels.PlatformChannel.Brightness;
import io.flutter.embedding.engine.systemchannels.PlatformChannel.ClipboardContentFormat;
import io.flutter.embedding.engine.systemchannels.PlatformChannel.SystemChromeStyle;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
......@@ -110,4 +113,23 @@ public class PlatformPluginTest {
clipboardManager.setPrimaryClip(clip);
assertFalse(platformPlugin.mPlatformMessageHandler.clipboardHasStrings());
}
@Config(sdk = 29)
@Test
public void setNavigationBarDividerColor() {
View fakeDecorView = mock(View.class);
Window fakeWindow = mock(Window.class);
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
Activity fakeActivity = mock(Activity.class);
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
SystemChromeStyle style =
new SystemChromeStyle(0XFF000000, null, 0XFFC70039, null, 0XFF006DB3);
platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);
assertEquals(0XFF006DB3, fakeActivity.getWindow().getNavigationBarDividerColor());
assertEquals(0XFFC70039, fakeActivity.getWindow().getStatusBarColor());
assertEquals(0XFF000000, fakeActivity.getWindow().getNavigationBarColor());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册