mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Android] Add systemNavigationBarDividerColor (flutter/engine#22538)
This commit is contained in:
parent
9e41df4acd
commit
1be95d91c7
@ -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,10 @@ 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 >= 28) {
|
||||
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;
|
||||
|
||||
@ -15,10 +15,12 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
|
||||
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 +112,25 @@ 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);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);
|
||||
|
||||
assertEquals(0XFF006DB3, fakeActivity.getWindow().getNavigationBarDividerColor());
|
||||
assertEquals(0XFFC70039, fakeActivity.getWindow().getStatusBarColor());
|
||||
assertEquals(0XFF000000, fakeActivity.getWindow().getNavigationBarColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user