Provide interface to customise the Dialog and content View before showing a message.
This will allow easy support of devices with notch by providing several lines of code.
Testing steps
Solution was tested with several versions before and after Android O.
The following is an example how to draw fullscreen and behind the notch for Interstitial and Banner templates.
You can override each of the methods to support different types of templates.
MessageTemplates.setCustomizer(new DialogCustomizer() {
@Override
public void customizeInterstitial(Dialog messageDialog, View messageContent) {
Window window = messageDialog.getWindow();
if (window == null) {
return;
}
// hide status bar
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
// draw view fullscreen
messageContent.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
// draw under notch
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
window.getAttributes().layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
}
@Override
public void customizeBanner(Dialog messageDialog, View messageContent) {
customizeInterstitial(messageDialog, messageContent);
}
});
Background
Provide interface to customise the Dialog and content View before showing a message. This will allow easy support of devices with notch by providing several lines of code.
Testing steps
Solution was tested with several versions before and after Android O.
The following is an example how to draw fullscreen and behind the notch for Interstitial and Banner templates. You can override each of the methods to support different types of templates.