com.actionbarsherlock.R Java Examples

The following examples show how to use com.actionbarsherlock.R. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourcesCompat.java    From zen4android with MIT License 6 votes vote down vote up
/**
 * Support implementation of {@code getResources().getInteger()} that we
 * can use to simulate filtering based on width qualifiers on pre-3.2.
 *
 * @param context Context to load integers from on 3.2+ and to fetch the
 * display metrics.
 * @param id Id of integer to load.
 * @return Associated integer value as reflected by the current display
 * metrics.
 */
public static int getResources_getInteger(Context context, int id) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        return context.getResources().getInteger(id);
    }

    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    float widthDp = metrics.widthPixels / metrics.density;

    if (id == R.integer.abs__max_action_buttons) {
        if (widthDp >= 600) {
            return 5; //values-w600dp
        }
        if (widthDp >= 500) {
            return 4; //values-w500dp
        }
        if (widthDp >= 360) {
            return 3; //values-w360dp
        }
        return 2; //values
    }

    throw new IllegalArgumentException("Unknown integer resource ID " + id);
}
 
Example #2
Source File: IcsToast.java    From zen4android with MIT License 6 votes vote down vote up
public static Toast makeText(Context context, CharSequence s, int duration) {
    if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
        return Toast.makeText(context, s, duration);
    }
    IcsToast toast = new IcsToast(context);
    toast.setDuration(duration);
    TextView view = new TextView(context);
    view.setText(s);
    // Original AOSP using reference on @android:color/bright_foreground_dark
    // bright_foreground_dark - reference on @android:color/background_light
    // background_light - 0xffffffff
    view.setTextColor(0xffffffff);
    view.setGravity(Gravity.CENTER);
    view.setBackgroundResource(R.drawable.abs__toast_frame);
    toast.setView(view);
    return toast;
}
 
Example #3
Source File: ActionBarContainer.java    From zen4android with MIT License 6 votes vote down vote up
public ActionBarContainer(Context context, AttributeSet attrs) {
    super(context, attrs);

    setBackgroundDrawable(null);

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SherlockActionBar);
    mBackground = a.getDrawable(R.styleable.SherlockActionBar_background);
    mStackedBackground = a.getDrawable(
            R.styleable.SherlockActionBar_backgroundStacked);

    //Fix for issue #379
    if (mStackedBackground instanceof ColorDrawable && 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(
                R.styleable.SherlockActionBar_backgroundSplit);
    }
    a.recycle();

    setWillNotDraw(mIsSplit ? mSplitBackground == null :
            mBackground == null && mStackedBackground == null);
}
 
Example #4
Source File: ActionBarContextView.java    From android-apps with MIT License 6 votes vote down vote up
public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0);
    setBackgroundDrawable(a.getDrawable(
            R.styleable.SherlockActionMode_background));
    mTitleStyleRes = a.getResourceId(
            R.styleable.SherlockActionMode_titleTextStyle, 0);
    mSubtitleStyleRes = a.getResourceId(
            R.styleable.SherlockActionMode_subtitleTextStyle, 0);

    mContentHeight = a.getLayoutDimension(
            R.styleable.SherlockActionMode_height, 0);

    mSplitBackground = a.getDrawable(
            R.styleable.SherlockActionMode_backgroundSplit);

    a.recycle();
}
 
Example #5
Source File: ActionBarContextView.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0);
    setBackgroundDrawable(a.getDrawable(
            R.styleable.SherlockActionMode_background));
    mTitleStyleRes = a.getResourceId(
            R.styleable.SherlockActionMode_titleTextStyle, 0);
    mSubtitleStyleRes = a.getResourceId(
            R.styleable.SherlockActionMode_subtitleTextStyle, 0);

    mContentHeight = a.getLayoutDimension(
            R.styleable.SherlockActionMode_height, 0);

    mSplitBackground = a.getDrawable(
            R.styleable.SherlockActionMode_backgroundSplit);

    a.recycle();
}
 
Example #6
Source File: SearchView.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
/**
 * For a given suggestion and a given cursor row, get the action message. If
 * not provided by the specific row/column, also check for a single
 * definition (for the action key).
 *
 * @param c The cursor providing suggestions
 * @param actionKey The actionkey record being examined
 *
 * @return Returns a string, or null if no action key message for this
 *         suggestion
 */
// TODO private static String getActionKeyMessage(Cursor c, SearchableInfo.ActionKeyInfo actionKey) {
// TODO     String result = null;
// TODO     // check first in the cursor data, for a suggestion-specific message
// TODO     final String column = actionKey.getSuggestActionMsgColumn();
// TODO     if (column != null) {
// TODO         result = SuggestionsAdapter.getColumnString(c, column);
// TODO     }
// TODO     // If the cursor didn't give us a message, see if there's a single
// TODO     // message defined
// TODO     // for the actionkey (for all suggestions)
// TODO     if (result == null) {
// TODO         result = actionKey.getSuggestActionMsg();
// TODO     }
// TODO     return result;
// TODO }

private int getSearchIconId() {
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(R.attr.searchViewSearchIcon,
            outValue, true);
    return outValue.resourceId;
}
 
Example #7
Source File: SearchView.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
private void adjustDropDownSizeAndPosition() {
    if (mDropDownAnchor.getWidth() > 1) {
        Resources res = getContext().getResources();
        int anchorPadding = mSearchPlate.getPaddingLeft();
        Rect dropDownPadding = new Rect();
        int iconOffset = mIconifiedByDefault
                ? res.getDimensionPixelSize(R.dimen.abs__dropdownitem_icon_width)
                + res.getDimensionPixelSize(R.dimen.abs__dropdownitem_text_padding_left)
                : 0;
        mQueryTextView.getDropDownBackground().getPadding(dropDownPadding);
        mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset)
                + anchorPadding);
        mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left
                + dropDownPadding.right + iconOffset - (anchorPadding));
    }
}
 
Example #8
Source File: ScrollingTabContainerView.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) {
    //Workaround for not being able to pass a defStyle on pre-3.0
    final TabView tabView = (TabView)mInflater.inflate(R.layout.abs__action_bar_tab, null);
    tabView.init(this, tab, forAdapter);

    if (forAdapter) {
        tabView.setBackgroundDrawable(null);
        tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT,
                mContentHeight));
    } else {
        tabView.setFocusable(true);

        if (mTabClickListener == null) {
            mTabClickListener = new TabClickListener();
        }
        tabView.setOnClickListener(mTabClickListener);
    }
    return tabView;
}
 
Example #9
Source File: ActionBarContainer.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
public ActionBarContainer(Context context, AttributeSet attrs) {
    super(context, attrs);

    setBackgroundDrawable(null);

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SherlockActionBar);
    mBackground = a.getDrawable(R.styleable.SherlockActionBar_background);
    mStackedBackground = a.getDrawable(
            R.styleable.SherlockActionBar_backgroundStacked);

    //Fix for issue #379
    if (mStackedBackground instanceof ColorDrawable && 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(
                R.styleable.SherlockActionBar_backgroundSplit);
    }
    a.recycle();

    setWillNotDraw(mIsSplit ? mSplitBackground == null :
            mBackground == null && mStackedBackground == null);
}
 
Example #10
Source File: SearchView.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
private void adjustDropDownSizeAndPosition() {
    if (mDropDownAnchor.getWidth() > 1) {
        Resources res = getContext().getResources();
        int anchorPadding = mSearchPlate.getPaddingLeft();
        Rect dropDownPadding = new Rect();
        int iconOffset = mIconifiedByDefault
                ? res.getDimensionPixelSize(R.dimen.abs__dropdownitem_icon_width)
                + res.getDimensionPixelSize(R.dimen.abs__dropdownitem_text_padding_left)
                : 0;
        mQueryTextView.getDropDownBackground().getPadding(dropDownPadding);
        mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset)
                + anchorPadding);
        mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left
                + dropDownPadding.right + iconOffset - (anchorPadding));
    }
}
 
Example #11
Source File: ResourcesCompat.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
/**
 * Support implementation of {@code getResources().getInteger()} that we
 * can use to simulate filtering based on width qualifiers on pre-3.2.
 *
 * @param context Context to load integers from on 3.2+ and to fetch the
 * display metrics.
 * @param id Id of integer to load.
 * @return Associated integer value as reflected by the current display
 * metrics.
 */
public static int getResources_getInteger(Context context, int id) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        return context.getResources().getInteger(id);
    }

    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    float widthDp = metrics.widthPixels / metrics.density;

    if (id == R.integer.abs__max_action_buttons) {
        if (widthDp >= 600) {
            return 5; //values-w600dp
        }
        if (widthDp >= 500) {
            return 4; //values-w500dp
        }
        if (widthDp >= 360) {
            return 3; //values-w360dp
        }
        return 2; //values
    }

    throw new IllegalArgumentException("Unknown integer resource ID " + id);
}
 
Example #12
Source File: SearchView.java    From zen4android with MIT License 6 votes vote down vote up
private void adjustDropDownSizeAndPosition() {
    if (mDropDownAnchor.getWidth() > 1) {
        Resources res = getContext().getResources();
        int anchorPadding = mSearchPlate.getPaddingLeft();
        Rect dropDownPadding = new Rect();
        int iconOffset = mIconifiedByDefault
                ? res.getDimensionPixelSize(R.dimen.abs__dropdownitem_icon_width)
                + res.getDimensionPixelSize(R.dimen.abs__dropdownitem_text_padding_left)
                : 0;
        mQueryTextView.getDropDownBackground().getPadding(dropDownPadding);
        mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset)
                + anchorPadding);
        mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left
                + dropDownPadding.right + iconOffset - (anchorPadding));
    }
}
 
Example #13
Source File: AbsActionBarView.java    From zen4android with MIT License 6 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        super.onConfigurationChanged(newConfig);
    } else if (mMenuView != null) {
        mMenuView.onConfigurationChanged(newConfig);
    }

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
            R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();
    if (mSplitWhenNarrow) {
        setSplitActionBar(getResources_getBoolean(getContext(),
                R.bool.abs__split_action_bar_is_narrow));
    }
    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.onConfigurationChanged(newConfig);
    }
}
 
Example #14
Source File: AbsActionBarView.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        super.onConfigurationChanged(newConfig);
    } else if (mMenuView != null) {
        mMenuView.onConfigurationChanged(newConfig);
    }

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
            R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();
    if (mSplitWhenNarrow) {
        setSplitActionBar(getResources_getBoolean(getContext(),
                R.bool.abs__split_action_bar_is_narrow));
    }
    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.onConfigurationChanged(newConfig);
    }
}
 
Example #15
Source File: SearchView.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
/**
 * For a given suggestion and a given cursor row, get the action message. If
 * not provided by the specific row/column, also check for a single
 * definition (for the action key).
 *
 * @param c The cursor providing suggestions
 * @param actionKey The actionkey record being examined
 *
 * @return Returns a string, or null if no action key message for this
 *         suggestion
 */
// TODO private static String getActionKeyMessage(Cursor c, SearchableInfo.ActionKeyInfo actionKey) {
// TODO     String result = null;
// TODO     // check first in the cursor data, for a suggestion-specific message
// TODO     final String column = actionKey.getSuggestActionMsgColumn();
// TODO     if (column != null) {
// TODO         result = SuggestionsAdapter.getColumnString(c, column);
// TODO     }
// TODO     // If the cursor didn't give us a message, see if there's a single
// TODO     // message defined
// TODO     // for the actionkey (for all suggestions)
// TODO     if (result == null) {
// TODO         result = actionKey.getSuggestActionMsg();
// TODO     }
// TODO     return result;
// TODO }

private int getSearchIconId() {
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(R.attr.searchViewSearchIcon,
            outValue, true);
    return outValue.resourceId;
}
 
Example #16
Source File: MenuPopupHelper.java    From android-apps with MIT License 6 votes vote down vote up
public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);

    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);

    View anchor = mAnchorView;
    if (anchor != null) {
        final boolean addGlobalListener = mTreeObserver == null;
        mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest
        if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this);
        ((View_HasStateListenerSupport)anchor).addOnAttachStateChangeListener(this);
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }

    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
 
Example #17
Source File: SearchView.java    From zen4android with MIT License 6 votes vote down vote up
/**
 * For a given suggestion and a given cursor row, get the action message. If
 * not provided by the specific row/column, also check for a single
 * definition (for the action key).
 *
 * @param c The cursor providing suggestions
 * @param actionKey The actionkey record being examined
 *
 * @return Returns a string, or null if no action key message for this
 *         suggestion
 */
// TODO private static String getActionKeyMessage(Cursor c, SearchableInfo.ActionKeyInfo actionKey) {
// TODO     String result = null;
// TODO     // check first in the cursor data, for a suggestion-specific message
// TODO     final String column = actionKey.getSuggestActionMsgColumn();
// TODO     if (column != null) {
// TODO         result = SuggestionsAdapter.getColumnString(c, column);
// TODO     }
// TODO     // If the cursor didn't give us a message, see if there's a single
// TODO     // message defined
// TODO     // for the actionkey (for all suggestions)
// TODO     if (result == null) {
// TODO         result = actionKey.getSuggestActionMsg();
// TODO     }
// TODO     return result;
// TODO }

private int getSearchIconId() {
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(R.attr.searchViewSearchIcon,
            outValue, true);
    return outValue.resourceId;
}
 
Example #18
Source File: ActionMenuPresenter.java    From android-apps with MIT License 5 votes vote down vote up
public static boolean reserveOverflow(Context context) {
    //Check for theme-forced overflow action item
    TypedArray a = context.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);
    boolean result = a.getBoolean(R.styleable.SherlockTheme_absForceOverflow, false);
    a.recycle();
    if (result) {
        return true;
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB);
    } else {
        return !HasPermanentMenuKey.get(context);
    }
}
 
Example #19
Source File: ListMenuItemView.java    From android-apps with MIT License 5 votes vote down vote up
private void insertRadioButton() {
    LayoutInflater inflater = getInflater();
    mRadioButton =
            (RadioButton) inflater.inflate(R.layout.abs__list_menu_item_radio,
            this, false);
    addView(mRadioButton);
}
 
Example #20
Source File: ActionBarView.java    From android-apps with MIT License 5 votes vote down vote up
public void setHomeButtonEnabled(boolean enable) {
    mHomeLayout.setEnabled(enable);
    mHomeLayout.setFocusable(enable);
    // Make sure the home button has an accurate content description for accessibility.
    if (!enable) {
        mHomeLayout.setContentDescription(null);
    } else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_up_description));
    } else {
        mHomeLayout.setContentDescription(mContext.getResources().getText(
                R.string.abs__action_bar_home_description));
    }
}
 
Example #21
Source File: ActionMenuItemView.java    From android-apps with MIT License 5 votes vote down vote up
public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) {
    //TODO super(context, attrs, defStyle);
    super(context, attrs);
    mAllowTextWithIcon = getResources_getBoolean(context,
            R.bool.abs__config_allowActionMenuItemTextWithIcon);
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SherlockActionMenuItemView, 0, 0);
    mMinWidth = a.getDimensionPixelSize(
            R.styleable.SherlockActionMenuItemView_android_minWidth, 0);
    a.recycle();
}
 
Example #22
Source File: ListMenuItemView.java    From android-apps with MIT License 5 votes vote down vote up
private void insertCheckBox() {
    LayoutInflater inflater = getInflater();
    mCheckBox =
            (CheckBox) inflater.inflate(R.layout.abs__list_menu_item_checkbox,
            this, false);
    addView(mCheckBox);
}
 
Example #23
Source File: ListMenuItemView.java    From android-apps with MIT License 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    setBackgroundDrawable(mBackground);

    mTitleView = (TextView) findViewById(R.id.abs__title);
    if (mTextAppearance != -1) {
        mTitleView.setTextAppearance(mTextAppearanceContext,
                                     mTextAppearance);
    }

    mShortcutView = (TextView) findViewById(R.id.abs__shortcut);
}
 
Example #24
Source File: ActivityChooserView.java    From android-apps with MIT License 5 votes vote down vote up
/**
 * Shows the popup no matter if it was already showing.
 *
 * @param maxActivityCount The max number of activities to display.
 */
private void showPopupUnchecked(int maxActivityCount) {
    if (mAdapter.getDataModel() == null) {
        throw new IllegalStateException("No data model. Did you call #setDataModel?");
    }

    getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);

    final boolean defaultActivityButtonShown =
        mDefaultActivityButton.getVisibility() == VISIBLE;

    final int activityCount = mAdapter.getActivityCount();
    final int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0;
    if (maxActivityCount != ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED
            && activityCount > maxActivityCount + maxActivityCountOffset) {
        mAdapter.setShowFooterView(true);
        mAdapter.setMaxActivityCount(maxActivityCount - 1);
    } else {
        mAdapter.setShowFooterView(false);
        mAdapter.setMaxActivityCount(maxActivityCount);
    }

    IcsListPopupWindow popupWindow = getListPopupWindow();
    if (!popupWindow.isShowing()) {
        if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) {
            mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown);
        } else {
            mAdapter.setShowDefaultActivity(false, false);
        }
        final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth);
        popupWindow.setContentWidth(contentWidth);
        popupWindow.show();
        if (mProvider != null) {
            mProvider.subUiVisibilityChanged(true);
        }
        popupWindow.getListView().setContentDescription(mContext.getString(
                R.string.abs__activitychooserview_choose_application));
    }
}
 
Example #25
Source File: MenuInflater.java    From android-apps with MIT License 5 votes vote down vote up
/**
 * Called when the parser is pointing to a group tag.
 */
public void readGroup(AttributeSet attrs) {
    TypedArray a = mContext.obtainStyledAttributes(attrs,
            R.styleable.SherlockMenuGroup);

    groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId);
    groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory);
    groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder);
    groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable);
    groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible);
    groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled);

    a.recycle();
}
 
Example #26
Source File: ActionMenuPresenter.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void initForMenu(Context context, MenuBuilder menu) {
    super.initForMenu(context, menu);

    final Resources res = context.getResources();

    if (!mReserveOverflowSet) {
        mReserveOverflow = reserveOverflow(mContext);
    }

    if (!mWidthLimitSet) {
        mWidthLimit = res.getDisplayMetrics().widthPixels / 2;
    }

    // Measure for initial configuration
    if (!mMaxItemsSet) {
        mMaxItems = getResources_getInteger(context, R.integer.abs__max_action_buttons);
    }

    int width = mWidthLimit;
    if (mReserveOverflow) {
        if (mOverflowButton == null) {
            mOverflowButton = new OverflowMenuButton(mSystemContext);
            final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
            mOverflowButton.measure(spec, spec);
        }
        width -= mOverflowButton.getMeasuredWidth();
    } else {
        mOverflowButton = null;
    }

    mActionItemWidthLimit = width;

    mMinCellSize = (int) (ActionMenuView.MIN_CELL_SIZE * res.getDisplayMetrics().density);

    // Drop a scrap view as it may no longer reflect the proper context/config.
    mScrapActionButtonView = null;
}
 
Example #27
Source File: ActionBarImpl.java    From android-apps with MIT License 5 votes vote down vote up
public ActionBarImpl(Activity activity, int features) {
    mActivity = activity;
    Window window = activity.getWindow();
    View decor = window.getDecorView();
    init(decor);

    //window.hasFeature() workaround for pre-3.0
    if ((features & (1 << Window.FEATURE_ACTION_BAR_OVERLAY)) == 0) {
        mContentView = (NineFrameLayout)decor.findViewById(android.R.id.content);
    }
}
 
Example #28
Source File: MenuInflater.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called when the parser is pointing to a group tag.
 */
public void readGroup(AttributeSet attrs) {
    TypedArray a = mContext.obtainStyledAttributes(attrs,
            R.styleable.SherlockMenuGroup);

    groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId);
    groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory);
    groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder);
    groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable);
    groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible);
    groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled);

    a.recycle();
}
 
Example #29
Source File: ActionMenuPresenter.java    From android-apps with MIT License 5 votes vote down vote up
public OverflowMenuButton(Context context) {
    super(context, null, R.attr.actionOverflowButtonStyle);

    setClickable(true);
    setFocusable(true);
    setVisibility(VISIBLE);
    setEnabled(true);
}
 
Example #30
Source File: ScrollingTabContainerView.java    From zen4android with MIT License 5 votes vote down vote up
public ScrollingTabContainerView(Context context) {
    super(context);
    setHorizontalScrollBarEnabled(false);

    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
            R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();

    mInflater = LayoutInflater.from(context);

    mTabLayout = createTabLayout();
    addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
}