<commit_before>/*
 * Copyright (C) 2013 readyState Software Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.readystatesoftware.systembartint;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout.LayoutParams;

/**
 * Class to manage status and navigation bar tint effects when using KitKat 
 * translucent system UI modes.
 *
 */
public class SystemBarTintManager {

	/**
	 * The default system bar tint color value.
	 */
	public static final int DEFAULT_TINT_COLOR = Color.parseColor("#99000000");

	private SystemBarConfig mConfig;
	private boolean mStatusBarAvailable;
	private boolean mNavBarAvailable;
	private boolean mStatusBarTintEnabled;
	private boolean mNavBarTintEnabled;
	private View mStatusBarTintView;
	private View mNavBarTintView;

	/**
	 * Constructor. Call this in the host activity onCreate method after its 
	 * content view has been set. You should always create new instances when 
	 * the host activity is recreated.
	 * 
	 * @param activity The host activity.
	 */
	@TargetApi(19) 
	public SystemBarTintManager(Activity activity) {

		Window win = activity.getWindow();
		ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			// check theme attrs
			int[] attrs = {android.R.attr.windowTranslucentStatus,
					android.R.attr.windowTranslucentNavigation};
			TypedArray a = activity.obtainStyledAttributes(attrs);
            try {
			mStatusBarAvailable = a.getBoolean(0, false);
			mNavBarAvailable = a.getBoolean(1, false);
            } finally {
                a.recycle();
            }

			// check window flags
			WindowManager.LayoutParams winParams = win.getAttributes();
			int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
			if ((winParams.flags & bits) != 0) {
				mStatusBarAvailable = true;
			}
			bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
			if ((winParams.flags & bits) != 0) {
				mNavBarAvailable = true;
			}
		}
		
		mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);<commit_msg>Tab formatting<commit_after>/*
 * Copyright (C) 2013 readyState Software Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.readystatesoftware.systembartint;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout.LayoutParams;

/**
 * Class to manage status and navigation bar tint effects when using KitKat 
 * translucent system UI modes.
 *
 */
public class SystemBarTintManager {

	/**
	 * The default system bar tint color value.
	 */
	public static final int DEFAULT_TINT_COLOR = Color.parseColor("#99000000");

	private SystemBarConfig mConfig;
	private boolean mStatusBarAvailable;
	private boolean mNavBarAvailable;
	private boolean mStatusBarTintEnabled;
	private boolean mNavBarTintEnabled;
	private View mStatusBarTintView;
	private View mNavBarTintView;

	/**
	 * Constructor. Call this in the host activity onCreate method after its 
	 * content view has been set. You should always create new instances when 
	 * the host activity is recreated.
	 * 
	 * @param activity The host activity.
	 */
	@TargetApi(19) 
	public SystemBarTintManager(Activity activity) {

		Window win = activity.getWindow();
		ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			// check theme attrs
			int[] attrs = {android.R.attr.windowTranslucentStatus,
					android.R.attr.windowTranslucentNavigation};
			TypedArray a = activity.obtainStyledAttributes(attrs);
            try {
			    mStatusBarAvailable = a.getBoolean(0, false);
			    mNavBarAvailable = a.getBoolean(1, false);
            } finally {
                a.recycle();
            }

			// check window flags
			WindowManager.LayoutParams winParams = win.getAttributes();
			int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
			if ((winParams.flags & bits) != 0) {
				mStatusBarAvailable = true;
			}
			bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
			if ((winParams.flags & bits) != 0) {
				mNavBarAvailable = true;
			}
		}
		
		mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
{'fraction_non_alphanumeric': 0.08522638257872474, 'fraction_numerical': 0.006893310355632148, 'mean_word_length': 4.156704361873991, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2771701', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1741, 'n_words': 544}