package com.za.signature.util;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;

/***
 * 沉浸式状态栏
 *
 * @since 2018-11-24
 * @author king
 */
public class StatusBarCompat {
    private static final int INVALID_VAL = -1;
    private static final int COLOR_DEFAULT = Color.parseColor("#20000000");

    public static void compat(Activity activity, int statusColor) {
        if (statusColor != INVALID_VAL) {
            activity.getWindow().setStatusBarColor(statusColor);
        }
    }

    public static void compat(Activity activity) {
        compat(activity, INVALID_VAL);
    }


    public static int getStatusBarHeight(Context context) {
        int result = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }
}
