/// <summary> /// 是否隐藏屏幕刘海 /// </summary> /// <returns></returns> public static bool?IsHideNotch(Context context) { if (AndroidROM.Current.IsMIUI) // https://dev.mi.com/console/doc/detail?pId=1293#_4 { return(MI.IsHideNotch(context)); } else if (AndroidROM.Current.IsEMUI) { return(HUAWEI.IsHideNotch(context)); } return(null); }
/// <summary> /// 是否为刘海屏设备 /// </summary> /// <param name="activity"></param> /// <returns></returns> public static bool?IsNotch(Activity activity) { if (Build.VERSION.SdkInt >= BuildVersionCodes.P) { return(activity?.Window?.DecorView.RootWindowInsets?.DisplayCutout != null); } else if (AndroidROM.Current.IsMIUI) { return(MI.IsNotch()); } else if (AndroidROM.Current.IsEMUI) { return(HUAWEI.HasNotchInScreen(activity)); } else if (AndroidROM.Current.IsColorOS) { return(OPPO.IsNotch(activity)); } else if (AndroidROM.Current.IsFuntouchOS) { return(Vivo.IsNotch(activity)); } return(null); }