Commit 0ae49c6c authored by Thomas Krex's avatar Thomas Krex
Browse files

Warnungen im sherlock unterdrückt

parent a696b275
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
package com.actionbarsherlock.internal.view.menu; package com.actionbarsherlock.internal.view.menu;
import com.actionbarsherlock.R;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
...@@ -32,247 +30,251 @@ import android.widget.LinearLayout; ...@@ -32,247 +30,251 @@ import android.widget.LinearLayout;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.R;
/** /**
* The item view for each item in the ListView-based MenuViews. * The item view for each item in the ListView-based MenuViews.
*/ */
public class ListMenuItemView extends LinearLayout implements MenuView.ItemView { public class ListMenuItemView extends LinearLayout implements MenuView.ItemView {
private MenuItemImpl mItemData; private MenuItemImpl mItemData;
private ImageView mIconView;
private RadioButton mRadioButton;
private TextView mTitleView;
private CheckBox mCheckBox;
private TextView mShortcutView;
private Drawable mBackground;
private int mTextAppearance;
private Context mTextAppearanceContext;
private boolean mPreserveIconSpacing;
//UNUSED private int mMenuType;
private LayoutInflater mInflater;
private boolean mForceShowIcon;
final Context mContext; private ImageView mIconView;
private RadioButton mRadioButton;
public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) { private TextView mTitleView;
super(context, attrs); private CheckBox mCheckBox;
mContext = context; private TextView mShortcutView;
TypedArray a = private Drawable mBackground;
context.obtainStyledAttributes( private int mTextAppearance;
attrs, R.styleable.SherlockMenuView, defStyle, 0); private Context mTextAppearanceContext;
private boolean mPreserveIconSpacing;
mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground);
mTextAppearance = a.getResourceId(R.styleable. // UNUSED private int mMenuType;
SherlockMenuView_itemTextAppearance, -1);
mPreserveIconSpacing = a.getBoolean( private LayoutInflater mInflater;
R.styleable.SherlockMenuView_preserveIconSpacing, false);
mTextAppearanceContext = context; private boolean mForceShowIcon;
a.recycle(); final Context mContext;
}
public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) {
public ListMenuItemView(Context context, AttributeSet attrs) { super(context, attrs);
this(context, attrs, 0); mContext = context;
}
TypedArray a = context.obtainStyledAttributes(attrs,
@Override R.styleable.SherlockMenuView, defStyle, 0);
protected void onFinishInflate() {
super.onFinishInflate(); mBackground = a
.getDrawable(R.styleable.SherlockMenuView_itemBackground);
setBackgroundDrawable(mBackground); mTextAppearance = a.getResourceId(
R.styleable.SherlockMenuView_itemTextAppearance, -1);
mTitleView = (TextView) findViewById(R.id.abs__title); mPreserveIconSpacing = a.getBoolean(
if (mTextAppearance != -1) { R.styleable.SherlockMenuView_preserveIconSpacing, false);
mTitleView.setTextAppearance(mTextAppearanceContext, mTextAppearanceContext = context;
mTextAppearance);
} a.recycle();
}
mShortcutView = (TextView) findViewById(R.id.abs__shortcut);
} public ListMenuItemView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
public void initialize(MenuItemImpl itemData, int menuType) { }
mItemData = itemData;
//UNUSED mMenuType = menuType; @SuppressWarnings("deprecation")
@Override
setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE); protected void onFinishInflate() {
super.onFinishInflate();
setTitle(itemData.getTitleForItemView(this));
setCheckable(itemData.isCheckable()); setBackgroundDrawable(mBackground);
setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut());
setIcon(itemData.getIcon()); mTitleView = (TextView) findViewById(R.id.abs__title);
setEnabled(itemData.isEnabled()); if (mTextAppearance != -1) {
} mTitleView.setTextAppearance(mTextAppearanceContext,
mTextAppearance);
public void setForceShowIcon(boolean forceShow) { }
mPreserveIconSpacing = mForceShowIcon = forceShow;
} mShortcutView = (TextView) findViewById(R.id.abs__shortcut);
}
public void setTitle(CharSequence title) {
if (title != null) { public void initialize(MenuItemImpl itemData, int menuType) {
mTitleView.setText(title); mItemData = itemData;
// UNUSED mMenuType = menuType;
if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE);
} else { setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE);
} setTitle(itemData.getTitleForItemView(this));
} setCheckable(itemData.isCheckable());
setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut());
public MenuItemImpl getItemData() { setIcon(itemData.getIcon());
return mItemData; setEnabled(itemData.isEnabled());
} }
public void setCheckable(boolean checkable) { public void setForceShowIcon(boolean forceShow) {
mPreserveIconSpacing = mForceShowIcon = forceShow;
if (!checkable && mRadioButton == null && mCheckBox == null) { }
return;
} public void setTitle(CharSequence title) {
if (title != null) {
if (mRadioButton == null) { mTitleView.setText(title);
insertRadioButton();
} if (mTitleView.getVisibility() != VISIBLE)
if (mCheckBox == null) { mTitleView.setVisibility(VISIBLE);
insertCheckBox(); } else {
} if (mTitleView.getVisibility() != GONE)
mTitleView.setVisibility(GONE);
// Depending on whether its exclusive check or not, the checkbox or }
// radio button will be the one in use (and the other will be otherCompoundButton) }
final CompoundButton compoundButton;
final CompoundButton otherCompoundButton; public MenuItemImpl getItemData() {
return mItemData;
if (mItemData.isExclusiveCheckable()) { }
compoundButton = mRadioButton;
otherCompoundButton = mCheckBox; public void setCheckable(boolean checkable) {
} else {
compoundButton = mCheckBox; if (!checkable && mRadioButton == null && mCheckBox == null) {
otherCompoundButton = mRadioButton; return;
} }
if (checkable) { if (mRadioButton == null) {
compoundButton.setChecked(mItemData.isChecked()); insertRadioButton();
}
final int newVisibility = checkable ? VISIBLE : GONE; if (mCheckBox == null) {
if (compoundButton.getVisibility() != newVisibility) { insertCheckBox();
compoundButton.setVisibility(newVisibility); }
}
// Depending on whether its exclusive check or not, the checkbox or
// Make sure the other compound button isn't visible // radio button will be the one in use (and the other will be
if (otherCompoundButton.getVisibility() != GONE) { // otherCompoundButton)
otherCompoundButton.setVisibility(GONE); final CompoundButton compoundButton;
} final CompoundButton otherCompoundButton;
} else {
mCheckBox.setVisibility(GONE); if (mItemData.isExclusiveCheckable()) {
mRadioButton.setVisibility(GONE); compoundButton = mRadioButton;
} otherCompoundButton = mCheckBox;
} } else {
compoundButton = mCheckBox;
public void setChecked(boolean checked) { otherCompoundButton = mRadioButton;
CompoundButton compoundButton; }
if (mItemData.isExclusiveCheckable()) { if (checkable) {
if (mRadioButton == null) { compoundButton.setChecked(mItemData.isChecked());
insertRadioButton();
} final int newVisibility = checkable ? VISIBLE : GONE;
compoundButton = mRadioButton; if (compoundButton.getVisibility() != newVisibility) {
} else { compoundButton.setVisibility(newVisibility);
if (mCheckBox == null) { }
insertCheckBox();
} // Make sure the other compound button isn't visible
compoundButton = mCheckBox; if (otherCompoundButton.getVisibility() != GONE) {
} otherCompoundButton.setVisibility(GONE);
}
compoundButton.setChecked(checked); } else {
} mCheckBox.setVisibility(GONE);
mRadioButton.setVisibility(GONE);
public void setShortcut(boolean showShortcut, char shortcutKey) { }
final int newVisibility = (showShortcut && mItemData.shouldShowShortcut()) }
? VISIBLE : GONE;
public void setChecked(boolean checked) {
if (newVisibility == VISIBLE) { CompoundButton compoundButton;
mShortcutView.setText(mItemData.getShortcutLabel());
} if (mItemData.isExclusiveCheckable()) {
if (mRadioButton == null) {
if (mShortcutView.getVisibility() != newVisibility) { insertRadioButton();
mShortcutView.setVisibility(newVisibility); }
} compoundButton = mRadioButton;
} } else {
if (mCheckBox == null) {
public void setIcon(Drawable icon) { insertCheckBox();
final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon; }
if (!showIcon && !mPreserveIconSpacing) { compoundButton = mCheckBox;
return; }
}
compoundButton.setChecked(checked);
if (mIconView == null && icon == null && !mPreserveIconSpacing) { }
return;
} public void setShortcut(boolean showShortcut, char shortcutKey) {
final int newVisibility = (showShortcut && mItemData
if (mIconView == null) { .shouldShowShortcut()) ? VISIBLE : GONE;
insertIconView();
} if (newVisibility == VISIBLE) {
mShortcutView.setText(mItemData.getShortcutLabel());
if (icon != null || mPreserveIconSpacing) { }
mIconView.setImageDrawable(showIcon ? icon : null);
if (mShortcutView.getVisibility() != newVisibility) {
if (mIconView.getVisibility() != VISIBLE) { mShortcutView.setVisibility(newVisibility);
mIconView.setVisibility(VISIBLE); }
} }
} else {
mIconView.setVisibility(GONE); public void setIcon(Drawable icon) {
} final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon;
} if (!showIcon && !mPreserveIconSpacing) {
return;
@Override }
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mIconView != null && mPreserveIconSpacing) { if (mIconView == null && icon == null && !mPreserveIconSpacing) {
// Enforce minimum icon spacing return;
ViewGroup.LayoutParams lp = getLayoutParams(); }
LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
if (lp.height > 0 && iconLp.width <= 0) { if (mIconView == null) {
iconLp.width = lp.height; insertIconView();
} }
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (icon != null || mPreserveIconSpacing) {
} mIconView.setImageDrawable(showIcon ? icon : null);
private void insertIconView() { if (mIconView.getVisibility() != VISIBLE) {
LayoutInflater inflater = getInflater(); mIconView.setVisibility(VISIBLE);
mIconView = (ImageView) inflater.inflate(R.layout.abs__list_menu_item_icon, }
this, false); } else {
addView(mIconView, 0); mIconView.setVisibility(GONE);
} }
}
private void insertRadioButton() {
LayoutInflater inflater = getInflater(); @Override
mRadioButton = protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
(RadioButton) inflater.inflate(R.layout.abs__list_menu_item_radio, if (mIconView != null && mPreserveIconSpacing) {
this, false); // Enforce minimum icon spacing
addView(mRadioButton); ViewGroup.LayoutParams lp = getLayoutParams();
} LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
if (lp.height > 0 && iconLp.width <= 0) {
private void insertCheckBox() { iconLp.width = lp.height;
LayoutInflater inflater = getInflater(); }
mCheckBox = }
(CheckBox) inflater.inflate(R.layout.abs__list_menu_item_checkbox, super.onMeasure(widthMeasureSpec, heightMeasureSpec);
this, false); }
addView(mCheckBox);
} private void insertIconView() {
LayoutInflater inflater = getInflater();
public boolean prefersCondensedTitle() { mIconView = (ImageView) inflater.inflate(
return false; R.layout.abs__list_menu_item_icon, this, false);
} addView(mIconView, 0);
}
public boolean showsIcon() {
return mForceShowIcon; private void insertRadioButton() {
} LayoutInflater inflater = getInflater();
mRadioButton = (RadioButton) inflater.inflate(
private LayoutInflater getInflater() { R.layout.abs__list_menu_item_radio, this, false);
if (mInflater == null) { addView(mRadioButton);
mInflater = LayoutInflater.from(mContext); }
}
return mInflater; private void insertCheckBox() {
} LayoutInflater inflater = getInflater();
mCheckBox = (CheckBox) inflater.inflate(
R.layout.abs__list_menu_item_checkbox, this, false);
addView(mCheckBox);
}
public boolean prefersCondensedTitle() {
return false;
}
public boolean showsIcon() {
return mForceShowIcon;
}
private LayoutInflater getInflater() {
if (mInflater == null) {
mInflater = LayoutInflater.from(mContext);
}
return mInflater;
}
} }
...@@ -26,226 +26,245 @@ import android.util.AttributeSet; ...@@ -26,226 +26,245 @@ import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.actionbarsherlock.R; import com.actionbarsherlock.R;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout;
/** /**
* This class acts as a container for the action bar view and action mode context views. * This class acts as a container for the action bar view and action mode
* It applies special styles as needed to help handle animated transitions between them. * context views. It applies special styles as needed to help handle animated
* transitions between them.
*
* @hide * @hide
*/ */
@SuppressWarnings("deprecation")
public class ActionBarContainer extends NineFrameLayout { public class ActionBarContainer extends NineFrameLayout {
private boolean mIsTransitioning; private boolean mIsTransitioning;
private View mTabContainer; private View mTabContainer;
private ActionBarView mActionBarView; private ActionBarView mActionBarView;
private Drawable mBackground; private Drawable mBackground;
private Drawable mStackedBackground; private Drawable mStackedBackground;
private Drawable mSplitBackground; private Drawable mSplitBackground;
private boolean mIsSplit; private boolean mIsSplit;
private boolean mIsStacked; private boolean mIsStacked;
public ActionBarContainer(Context context) { public ActionBarContainer(Context context) {
this(context, null); this(context, null);
} }
public ActionBarContainer(Context context, AttributeSet attrs) { public ActionBarContainer(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
setBackgroundDrawable(null); setBackgroundDrawable(null);
TypedArray a = context.obtainStyledAttributes(attrs, TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.SherlockActionBar); R.styleable.SherlockActionBar);
mBackground = a.getDrawable(R.styleable.SherlockActionBar_background); mBackground = a.getDrawable(R.styleable.SherlockActionBar_background);
mStackedBackground = a.getDrawable( mStackedBackground = a
R.styleable.SherlockActionBar_backgroundStacked); .getDrawable(R.styleable.SherlockActionBar_backgroundStacked);
//Fix for issue #379 // Fix for issue #379
if (mStackedBackground instanceof ColorDrawable && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { if (mStackedBackground instanceof ColorDrawable
mStackedBackground = new IcsColorDrawable((ColorDrawable) mStackedBackground); && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
} mStackedBackground = new IcsColorDrawable(
(ColorDrawable) mStackedBackground);
if (getId() == R.id.abs__split_action_bar) { }
mIsSplit = true;
mSplitBackground = a.getDrawable( if (getId() == R.id.abs__split_action_bar) {
R.styleable.SherlockActionBar_backgroundSplit); mIsSplit = true;
} mSplitBackground = a
a.recycle(); .getDrawable(R.styleable.SherlockActionBar_backgroundSplit);
}
setWillNotDraw(mIsSplit ? mSplitBackground == null : a.recycle();
mBackground == null && mStackedBackground == null);