// Path: app/src/main/java/com/github/mzule/androidweekly/util/Tinter.java
// public class Tinter {
// 
//     /**
//      * 如果当前系统版本支持Tint,则开启,否则,不作任何事情.
//      *
//      * @param activity
//      */
//     public static void enableIfSupport(Activity activity) {
//         if (isSupport()) {
//             tint(activity, true);
//         }
//     }
// 
//     /**
//      * 当前系统版本是否支持Tint
//      *
//      * @return
//      */
//     public static boolean isSupport() {
//         return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
//     }
// 
//     @TargetApi(19)
//     private static void tint(Activity activity, boolean on) {
//         Window win = activity.getWindow();
//         WindowManager.LayoutParams winParams = win.getAttributes();
//         final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
//         if (on) {
//             winParams.flags |= bits;
//         } else {
//             winParams.flags &= ~bits;
//         }
//         win.setAttributes(winParams);
// 
//         Class<? extends Window> clazz = win.getClass();
//         try {
//             Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
//             Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
//             int darkModeFlag = field.getInt(layoutParams);
//             Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
//             extraFlagField.invoke(win, darkModeFlag, darkModeFlag);
//         } catch (Throwable e) {
//         }
// 
//     }
// }


import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.github.mzule.androidweekly.util.Tinter;
package com.github.mzule.androidweekly.ui.view;



/**
 * 占位符View,在支持Tint的设备上,高度为信号栏的高度,在不支持Tint的设备上,高度为0,可以用来作为UI布局的占位符
 * Created by CaoDongping on 11/11/15.
 */
public class TintStatusBar extends View {
    private int statusBarHeight;

    public TintStatusBar(Context context) {
        super(context);
        init();
    }

    public TintStatusBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public TintStatusBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    public void init() {
        statusBarHeight = getStatusBarHeight();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
            int height = 0;
// Path: app/src/main/java/com/github/mzule/androidweekly/util/Tinter.java
// public class Tinter {
// 
//     /**
//      * 如果当前系统版本支持Tint,则开启,否则,不作任何事情.
//      *
//      * @param activity
//      */
//     public static void enableIfSupport(Activity activity) {
//         if (isSupport()) {
//             tint(activity, true);
//         }
//     }
// 
//     /**
//      * 当前系统版本是否支持Tint
//      *
//      * @return
//      */
//     public static boolean isSupport() {
//         return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
//     }
// 
//     @TargetApi(19)
//     private static void tint(Activity activity, boolean on) {
//         Window win = activity.getWindow();
//         WindowManager.LayoutParams winParams = win.getAttributes();
//         final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
//         if (on) {
//             winParams.flags |= bits;
//         } else {
//             winParams.flags &= ~bits;
//         }
//         win.setAttributes(winParams);
// 
//         Class<? extends Window> clazz = win.getClass();
//         try {
//             Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
//             Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
//             int darkModeFlag = field.getInt(layoutParams);
//             Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
//             extraFlagField.invoke(win, darkModeFlag, darkModeFlag);
//         } catch (Throwable e) {
//         }
// 
//     }
// }


// Path: app/src/main/java/com/github/mzule/androidweekly/ui/view/TintStatusBar.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.github.mzule.androidweekly.util.Tinter;

package com.github.mzule.androidweekly.ui.view;



/**
 * 占位符View,在支持Tint的设备上,高度为信号栏的高度,在不支持Tint的设备上,高度为0,可以用来作为UI布局的占位符
 * Created by CaoDongping on 11/11/15.
 */
public class TintStatusBar extends View {
    private int statusBarHeight;

    public TintStatusBar(Context context) {
        super(context);
        init();
    }

    public TintStatusBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public TintStatusBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    public void init() {
        statusBarHeight = getStatusBarHeight();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
            int height = 0;
            if (Tinter.isSupport()) {