package com.githang.statusbar;

import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

/**
 * 兼容M版本
 *
 * @author 黄浩杭 (huanghaohang@parkingwang.com)
 * @version 2016-06-20
 * @since 2016-06-20
 */

class StatusBarCompatM {
    @TargetApi(Build.VERSION_CODES.M)
    static void setStatusBarColor(Window window, int color, boolean lightStatusBar) {
        //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //设置状态栏颜色
        window.setStatusBarColor(color);
        View decor = window.getDecorView();
        int ui = decor.getSystemUiVisibility();
        if (lightStatusBar) {
            ui |=View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            ui &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        decor.setSystemUiVisibility(ui);
    }

}

@@ -759,16 +759,42 @@
 (color);
+%0A%0A        // %E8%AE%BE%E7%BD%AE%E6%B5%85%E8%89%B2%E7%8A%B6%E6%80%81%E6%A0%8F%E6%97%B6%E7%9A%84%E7%95%8C%E9%9D%A2%E6%98%BE%E7%A4%BA
 %0A       
@@ -1087,16 +1087,188 @@
 ity(ui);
+%0A%0A        // %E5%8E%BB%E6%8E%89%E7%B3%BB%E7%BB%9F%E7%8A%B6%E6%80%81%E6%A0%8F%E4%B8%8B%E7%9A%84windowContentOverlay%0A        View v = window.findViewById(android.R.id.content);%0A        if (v != null) %7B%0A            v.setForeground(null);%0A        %7D
 %0A    %7D%0A%0A

Remove the shadow below status bar that occurs in version greater than M.