<commit_before>package com.jakewharton.android.actionbarsherlock.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.v4.app.ActionBar;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import com.jakewharton.android.actionbarsherlock.R;

public final class ActionBarWatson extends RelativeLayout {
	/** Default display options if none are defined in the theme. */
	private static final int DEFAULT_DISPLAY_OPTIONS = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME;
	
	/** Default navigation mode if one is not defined in the theme. */
	private static final int DEFAULT_NAVIGATION_MODE = ActionBar.NAVIGATION_MODE_STANDARD;
	
	
	
	/** Home logo and icon action item. */
	private final HomeItem mHome;
	
	/** Title view. */
	private final TextView mTitle;
	
	/** Subtitle view. */
	private final TextView mSubtitle;
	
	/** List view. */
	private final Spinner mListView;
	
	/** Custom view parent. */
	private final FrameLayout mCustomView;
	
	/** Container for all action items. */
	private final LinearLayout mActionsView;

	/** Container for all tab items. */
	private final LinearLayout mTabsView;
	
	/**
	 * Display state flags.
	 * 
	 * @see #getDisplayOptions()
	 * @see #getDisplayOptionValue(int)
	 * @see #setDisplayOptions(int)
	 * @see #setDisplayOptions(int, int)
	 * @see #setDisplayOption(int, boolean)
	 * @see #reloadDisplay()
	 */
	private int mFlags;
	
	/**
	 * Current navigation mode
	 * 
	 * @see #getNavigationMode()
	 * @see #setNavigationMode(int)
	 */
	private int mNavigationMode = -1;

	
	

	public ActionBarWatson(Context context) {
		this(context, null);
	}
	
	public ActionBarWatson(Context context, AttributeSet attrs) {
		this(context, attrs, R.attr.actionBarStyle);
	}
	
	public ActionBarWatson(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		LayoutInflater.from(context).inflate(R.layout.actionbarwatson, this, true);
		
		final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar, defStyle, 0);
		
		
		/// HOME ////
		
		mHome = (HomeItem)findViewById(R.id.actionbarwatson_home);
		
		//Load the up indicator
		final Drawable homeAsUpIndicator = a.getDrawable(R.styleable.SherlockTheme_homeAsUpIndicator);
		mHome.setUpIndicator(homeAsUpIndicator);

		//Try to load the logo from the theme
		final Drawable homeLogo = a.getDrawable(R.styleable.SherlockActionBar_logo);
		if (homeLogo != null) {
			mHome.setLogo(homeLogo);
		}
		
		//Try to load the icon from the theme
		final Drawable homeIcon = a.getDrawable(R.styleable.SherlockActionBar_icon);
		mHome.setIcon(homeIcon);

		
		//// TITLE ////
		
		mTitle = (TextView)findViewById(R.id.actionbarwatson_title);
		
		//Try to load title style from the theme
		final int titleTextStyle = a.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0);
		if (titleTextStyle != 0) {
			mTitle.setTextAppearance(context, titleTextStyle);
		}
		
		//Try to load title from the theme
		final CharSequence title = a.getString(R.styleable.SherlockActionBar_title);
		if (title != null) {
			setTitle(title);
		}
		
		
		//// SUBTITLE ////
		
		mSubtitle = (TextView)findViewById(R.id.actionbarwatson_subtitle);
		
		//Try to load subtitle style from the theme
		final int subtitleTextStyle = a.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyle, 0);
		if (subtitleTextStyle != 0) {
			mSubtitle.setTextAppearance(context, subtitleTextStyle);
		}
		
		//Try to load subtitle from theme
		final CharSequence subtitle = a.getString(R.styleable.SherlockActionBar_subtitle);
		if (subtitle != null) {
			setSubtitle(subtitle);
		}
		
		
		//// NAVIGATION ////
		
		mListView = (Spinner)findViewById(R.id.actionbarwatson_nav_list);
		mTabsView = (LinearLayout)findViewById(R.id.actionbarwatson_nav_tabs);
		
		
		//// CUSTOM VIEW ////
		
		mCustomView = (FrameLayout)findViewById(R.id.actionbarwatson_custom);
		
		//Try to load a custom view from the theme. This will NOT automatically
		//trigger the visibility of the custom layout, however.
		final int customViewResourceId = a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0);
		if (customViewResourceId != 0) {
			setCustomView(customViewResourceId);
		}
		
		
		mActionsView = (LinearLayout)findViewById(R.id.actionbarwatson_actions);
		
		
		//Try to get the display options defined in the theme, or fall back to
		//displaying the title and home icon
		setDisplayOptions(a.getInteger(R.styleable.SherlockActionBar_displayOptions, DEFAULT_DISPLAY_OPTIONS));
		
		//Try to get the navigation defined in the theme, or, fall back to
		//use standard navigation by default (this will call reloadDisplay)
		setNavigationMode(a.getInteger(R.styleable.SherlockActionBar_navigationMode, DEFAULT_NAVIGATION_MODE));
		
		a.recycle();<commit_msg>Fix home as up indicator by pulling an additional TypedArray for the theme.<commit_after>package com.jakewharton.android.actionbarsherlock.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.v4.app.ActionBar;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import com.jakewharton.android.actionbarsherlock.R;

public final class ActionBarWatson extends RelativeLayout {
	/** Default display options if none are defined in the theme. */
	private static final int DEFAULT_DISPLAY_OPTIONS = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME;
	
	/** Default navigation mode if one is not defined in the theme. */
	private static final int DEFAULT_NAVIGATION_MODE = ActionBar.NAVIGATION_MODE_STANDARD;
	
	
	
	/** Home logo and icon action item. */
	private final HomeItem mHome;
	
	/** Title view. */
	private final TextView mTitle;
	
	/** Subtitle view. */
	private final TextView mSubtitle;
	
	/** List view. */
	private final Spinner mListView;
	
	/** Custom view parent. */
	private final FrameLayout mCustomView;
	
	/** Container for all action items. */
	private final LinearLayout mActionsView;

	/** Container for all tab items. */
	private final LinearLayout mTabsView;
	
	/**
	 * Display state flags.
	 * 
	 * @see #getDisplayOptions()
	 * @see #getDisplayOptionValue(int)
	 * @see #setDisplayOptions(int)
	 * @see #setDisplayOptions(int, int)
	 * @see #setDisplayOption(int, boolean)
	 * @see #reloadDisplay()
	 */
	private int mFlags;
	
	/**
	 * Current navigation mode
	 * 
	 * @see #getNavigationMode()
	 * @see #setNavigationMode(int)
	 */
	private int mNavigationMode = -1;

	
	

	public ActionBarWatson(Context context) {
		this(context, null);
	}
	
	public ActionBarWatson(Context context, AttributeSet attrs) {
		this(context, attrs, R.attr.actionBarStyle);
	}
	
	public ActionBarWatson(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		LayoutInflater.from(context).inflate(R.layout.actionbarwatson, this, true);
		
		final TypedArray attrsActionBar = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar, defStyle, 0);
		final TypedArray attrsTheme = context.obtainStyledAttributes(attrs, R.styleable.SherlockTheme, defStyle, 0);
		
		
		/// HOME ////
		
		mHome = (HomeItem)findViewById(R.id.actionbarwatson_home);
		
		//Load the up indicator
		final Drawable homeAsUpIndicator = attrsTheme.getDrawable(R.styleable.SherlockTheme_homeAsUpIndicator);
		mHome.setUpIndicator(homeAsUpIndicator);

		//Try to load the logo from the theme
		final Drawable homeLogo = attrsActionBar.getDrawable(R.styleable.SherlockActionBar_logo);
		if (homeLogo != null) {
			mHome.setLogo(homeLogo);
		}
		
		//Try to load the icon from the theme
		final Drawable homeIcon = attrsActionBar.getDrawable(R.styleable.SherlockActionBar_icon);
		mHome.setIcon(homeIcon);

		
		//// TITLE ////
		
		mTitle = (TextView)findViewById(R.id.actionbarwatson_title);
		
		//Try to load title style from the theme
		final int titleTextStyle = attrsActionBar.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0);
		if (titleTextStyle != 0) {
			mTitle.setTextAppearance(context, titleTextStyle);
		}
		
		//Try to load title from the theme
		final CharSequence title = attrsActionBar.getString(R.styleable.SherlockActionBar_title);
		if (title != null) {
			setTitle(title);
		}
		
		
		//// SUBTITLE ////
		
		mSubtitle = (TextView)findViewById(R.id.actionbarwatson_subtitle);
		
		//Try to load subtitle style from the theme
		final int subtitleTextStyle = attrsActionBar.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyle, 0);
		if (subtitleTextStyle != 0) {
			mSubtitle.setTextAppearance(context, subtitleTextStyle);
		}
		
		//Try to load subtitle from theme
		final CharSequence subtitle = attrsActionBar.getString(R.styleable.SherlockActionBar_subtitle);
		if (subtitle != null) {
			setSubtitle(subtitle);
		}
		
		
		//// NAVIGATION ////
		
		mListView = (Spinner)findViewById(R.id.actionbarwatson_nav_list);
		mTabsView = (LinearLayout)findViewById(R.id.actionbarwatson_nav_tabs);
		
		
		//// CUSTOM VIEW ////
		
		mCustomView = (FrameLayout)findViewById(R.id.actionbarwatson_custom);
		
		//Try to load a custom view from the theme. This will NOT automatically
		//trigger the visibility of the custom layout, however.
		final int customViewResourceId = attrsActionBar.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0);
		if (customViewResourceId != 0) {
			setCustomView(customViewResourceId);
		}
		
		
		mActionsView = (LinearLayout)findViewById(R.id.actionbarwatson_actions);
		
		
		//Try to get the display options defined in the theme, or fall back to
		//displaying the title and home icon
		setDisplayOptions(attrsActionBar.getInteger(R.styleable.SherlockActionBar_displayOptions, DEFAULT_DISPLAY_OPTIONS));
		
		//Try to get the navigation defined in the theme, or, fall back to
		//use standard navigation by default (this will call reloadDisplay)
		setNavigationMode(attrsActionBar.getInteger(R.styleable.SherlockActionBar_navigationMode, DEFAULT_NAVIGATION_MODE));
		
		
		//Reduce, Reuse, Recycle!
		attrsActionBar.recycle();
		attrsTheme.recycle();
{'fraction_non_alphanumeric': 0.09846096792137957, 'fraction_numerical': 0.0017615427405896532, 'mean_word_length': 4.348041646008924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2657171', 'n_tokens_mistral': 3686, 'n_tokens_neox': 3197, 'n_words': 804}