Example usage for android.util AttributeSet getAttributeBooleanValue

List of usage examples for android.util AttributeSet getAttributeBooleanValue

Introduction

In this page you can find the example usage for android.util AttributeSet getAttributeBooleanValue.

Prototype

public boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue);

Source Link

Document

Return the boolean value of 'attribute'.

Usage

From source file:de.fahrgemeinschaft.util.ReoccuringWeekDaysView.java

public ReoccuringWeekDaysView(Context context, AttributeSet attrs) {
    super(context, attrs);
    clickable = attrs.getAttributeBooleanValue(android, CLICKABLE, true);
    String[] weekDays = new DateFormatSymbols().getShortWeekdays();
    for (int i = 2; i <= weekDays.length; i++) {
        TextView day = makeRecurringDayButton(getContext());
        day.setText(weekDays[i < weekDays.length ? i : 1].substring(0, 2));
        addView(day);//from w  w  w .  j a v a2s.c  om
    }
    setFocusable(true);
}

From source file:com.hichinaschool.flashcards.preferences.StepsPreference.java

private boolean getAllowEmptyFromAttributes(AttributeSet attrs) {
    return attrs == null ? true
            : attrs.getAttributeBooleanValue(AnkiDroidApp.APP_NAMESPACE, "allowEmpty", true);
}

From source file:com.ichi2.preferences.StepsPreference.java

private boolean getAllowEmptyFromAttributes(AttributeSet attrs) {
    if (attrs == null) {
        return true;
    }//  ww w . j  av  a 2 s . c o m
    return attrs.getAttributeBooleanValue(AnkiDroidApp.XML_CUSTOM_NAMESPACE, "allowEmpty", true);
}

From source file:com.anysoftkeyboard.addons.AddOnsFactory.java

@Nullable
private E createAddOnFromXmlAttributes(AttributeSet attrs, Context packContext) {
    final CharSequence prefId = getTextFromResourceOrText(packContext, attrs, XML_PREF_ID_ATTRIBUTE);
    final CharSequence name = getTextFromResourceOrText(packContext, attrs, XML_NAME_RES_ID_ATTRIBUTE);

    if ((!mDevAddOnsIncluded) && attrs.getAttributeBooleanValue(null, XML_DEV_ADD_ON_ATTRIBUTE, false)) {
        Logger.w(mTag,/* ww w.jav a 2s . com*/
                "Discarding add-on %s (name %s) since it is marked as DEV addon, and we're not a TESTING_BUILD build.",
                prefId, name);
        return null;
    }

    final boolean isHidden = attrs.getAttributeBooleanValue(null, XML_HIDDEN_ADD_ON_ATTRIBUTE, false);
    final CharSequence description = getTextFromResourceOrText(packContext, attrs, XML_DESCRIPTION_ATTRIBUTE);

    final int sortIndex = attrs.getAttributeUnsignedIntValue(null, XML_SORT_INDEX_ATTRIBUTE, 1);

    // asserting
    if (TextUtils.isEmpty(prefId) || TextUtils.isEmpty(name)) {
        Logger.e(mTag, "External add-on does not include all mandatory details! Will not create add-on.");
        return null;
    } else {

        Logger.d(mTag, "External addon details: prefId:" + prefId + " name:" + name);
        return createConcreteAddOn(mContext, packContext, prefId, name, description, isHidden, sortIndex,
                attrs);
    }
}

From source file:de.madvertise.android.sdk.MadView.java

/**
 * Reads all parameters, not needed for a request to the ad server (colors,
 * refresh timeout, ...)//from   w ww. ja v a  2  s .  c o m
 * 
 * @param attrs
 *            attribute set for the view
 */
private void initParameters(AttributeSet attrs) {
    if (attrs != null) {
        String packageName = "http://schemas.android.com/apk/res/" + getContext().getPackageName();
        if (packageName != null) {
            MadUtil.logMessage(null, Log.DEBUG, "namespace = " + packageName);
        }
        testMode = attrs.getAttributeBooleanValue(packageName, "isTestMode", IS_TESTMODE_DEFAULT);
        textColor = attrs.getAttributeIntValue(packageName, "textColor", MadUtil.TEXT_COLOR_DEFAULT);
        backgroundColor = attrs.getAttributeIntValue(packageName, "backgroundColor",
                MadUtil.BACKGROUND_COLOR_DEFAULT);
        secondsToRefreshAd = attrs.getAttributeIntValue(packageName, "secondsToRefresh",
                MadUtil.SECONDS_TO_REFRESH_AD_DEFAULT);
        bannerType = attrs.getAttributeValue(packageName, "bannerType");
        if (bannerType == null)
            bannerType = MadUtil.BANNER_TYPE_DEFAULT;
        deliverOnlyText = attrs.getAttributeBooleanValue(packageName, "deliverOnlyText",
                MadUtil.DELIVER_ONLY_TEXT_DEFAULT);
        textSize = attrs.getAttributeIntValue(packageName, "textSize", MadUtil.TEXT_SIZE_DEFAULT);
    } else {
        MadUtil.logMessage(null, Log.DEBUG, "AttributeSet is null!");
    }

    if (secondsToRefreshAd != 0 && secondsToRefreshAd < 60)
        secondsToRefreshAd = MadUtil.SECONDS_TO_REFRESH_AD_DEFAULT;

    if (bannerType.equals("iab"))
        bannerHeight = MadUtil.IAB_BANNER_HEIGHT_DEFAULT;

    MadUtil.logMessage(null, Log.DEBUG, "Using following attributes values:");
    MadUtil.logMessage(null, Log.DEBUG, " testMode = " + testMode);
    MadUtil.logMessage(null, Log.DEBUG, " textColor = " + textColor);
    MadUtil.logMessage(null, Log.DEBUG, " backgroundColor = " + backgroundColor);
    MadUtil.logMessage(null, Log.DEBUG, " secondsToRefreshAd = " + secondsToRefreshAd);
    MadUtil.logMessage(null, Log.DEBUG, " bannerType = " + bannerType);
    MadUtil.logMessage(null, Log.DEBUG, " deliverOnlyText = " + deliverOnlyText);
    MadUtil.logMessage(null, Log.DEBUG, " textSize = " + textSize);
    MadUtil.logMessage(null, Log.DEBUG, " bannerHeight = " + bannerHeight);
}

From source file:com.ttxgps.zoom.GestureImageView.java

public GestureImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    String scaleType = attrs.getAttributeValue(GLOBAL_NS, "scaleType");

    if (scaleType == null || scaleType.trim().length() == 0) {
        setScaleType(ScaleType.CENTER_INSIDE);
    }/*from www  . j a v  a  2  s  . c o  m*/

    setMinScale(attrs.getAttributeFloatValue(LOCAL_NS, "min-scale", minScale));
    setMaxScale(attrs.getAttributeFloatValue(LOCAL_NS, "max-scale", maxScale));
    setStrict(attrs.getAttributeBooleanValue(LOCAL_NS, "strict", strict));
    setRecycle(attrs.getAttributeBooleanValue(LOCAL_NS, "recycle", recycle));
    zoom = attrs.getAttributeBooleanValue(LOCAL_NS, "zoom", zoom);
    initImage(false);
}

From source file:com.anysoftkeyboard.keyboards.KeyboardFactory.java

@Override
protected KeyboardAddOnAndBuilder createConcreteAddOn(Context askContext, Context context, String prefId,
        int nameId, String description, boolean isHidden, int sortIndex, AttributeSet attrs) {
    final int layoutResId = attrs.getAttributeResourceValue(null, XML_LAYOUT_RES_ID_ATTRIBUTE,
            AddOn.INVALID_RES_ID);//from  ww  w.  j a  v  a  2 s.c om
    final int landscapeLayoutResId = attrs.getAttributeResourceValue(null,
            XML_LANDSCAPE_LAYOUT_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID);
    final int iconResId = attrs.getAttributeResourceValue(null, XML_ICON_RES_ID_ATTRIBUTE,
            R.drawable.sym_keyboard_notification_icon);
    final String defaultDictionary = attrs.getAttributeValue(null, XML_DICTIONARY_NAME_ATTRIBUTE);
    final String additionalIsLetterExceptions = attrs.getAttributeValue(null,
            XML_ADDITIONAL_IS_LETTER_EXCEPTIONS_ATTRIBUTE);
    String sentenceSeparators = attrs.getAttributeValue(null, XML_SENTENCE_SEPARATOR_CHARACTERS_ATTRIBUTE);
    if (TextUtils.isEmpty(sentenceSeparators))
        sentenceSeparators = DEFAULT_SENTENCE_SEPARATORS;
    final int physicalTranslationResId = attrs.getAttributeResourceValue(null,
            XML_PHYSICAL_TRANSLATION_RES_ID_ATTRIBUTE, AddOn.INVALID_RES_ID);
    // A keyboard is enabled by default if it is the first one (index==1)
    final boolean keyboardDefault = attrs.getAttributeBooleanValue(null, XML_DEFAULT_ATTRIBUTE, sortIndex == 1);

    // asserting
    if ((prefId == null) || (nameId == AddOn.INVALID_RES_ID) || (layoutResId == AddOn.INVALID_RES_ID)) {
        Logger.e(TAG, "External Keyboard does not include all mandatory details! Will not create keyboard.");
        return null;
    } else {
        if (BuildConfig.DEBUG) {
            Logger.d(TAG,
                    "External keyboard details: prefId:" + prefId + " nameId:" + nameId + " resId:"
                            + layoutResId + " landscapeResId:" + landscapeLayoutResId + " iconResId:"
                            + iconResId + " defaultDictionary:" + defaultDictionary);
        }
        return new KeyboardAddOnAndBuilder(askContext, context, prefId, nameId, layoutResId,
                landscapeLayoutResId, defaultDictionary, iconResId, physicalTranslationResId,
                additionalIsLetterExceptions, sentenceSeparators, description, isHidden, sortIndex,
                keyboardDefault);
    }
}

From source file:de.madvertise.android.sdk.MadvertiseView.java

/**
 * Reads all parameters, not needed for a request to the ad server (colors,
 * refresh timeout, ...)//from   w ww  .  ja  va  2  s .c o  m
 *
 * @param attrs attribute set for the view
 */
private void initParameters(final AttributeSet attrs) {
    mDp = getContext().getApplicationContext().getResources().getDisplayMetrics().density;

    if (attrs != null) {
        String packageName = "http://schemas.android.com/apk/res/"
                + getContext().getApplicationContext().getPackageName();
        if (packageName != null) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "namespace = " + packageName);
        }

        mTestMode = attrs.getAttributeBooleanValue(packageName, "isTestMode", IS_TESTMODE_DEFAULT);

        mTextColor = attrs.getAttributeIntValue(packageName, "textColor", MadvertiseUtil.TEXT_COLOR_DEFAULT);

        mBackgroundColor = attrs.getAttributeIntValue(packageName, "backgroundColor",
                MadvertiseUtil.BACKGROUND_COLOR_DEFAULT);

        mSecondsToRefreshAd = attrs.getAttributeIntValue(packageName, "secondsToRefresh",
                MadvertiseUtil.SECONDS_TO_REFRESH_AD_DEFAULT);

        if (attrs.getAttributeValue(packageName, "bannerType") != null) {
            mBannerType = attrs.getAttributeValue(packageName, "bannerType");
        }

        if (attrs.getAttributeValue(packageName, "animation") != null) {
            mAnimationType = attrs.getAttributeValue(packageName, "animation");
        }

        mDeliverOnlyText = attrs.getAttributeBooleanValue(packageName, "deliverOnlyText",
                MadvertiseUtil.DELIVER_ONLY_TEXT_DEFAULT);

        if (!mBannerType.equals(MadvertiseUtil.BANNER_TYPE_MMA) && mDeliverOnlyText) {
            MadvertiseUtil.logMessage(null, Log.DEBUG,
                    "Only banners in mma-format can show text. Setting deliferOnlyText to false.");
            mDeliverOnlyText = false;
        }

        mTextSize = attrs.getAttributeIntValue(packageName, "textSize", MadvertiseUtil.TEXT_SIZE_DEFAULT);

        if (mTextSize > 20) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "The text size must be set to 20 at maximum.");
            mTextSize = 20;
        } else if (mTextSize < 10) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "The text size must be set to 10 at minimum.");
            mTextSize = 10;
        }

        mIsMraid = attrs.getAttributeBooleanValue(packageName, "mraid", true);

        final String placementTypeStr = attrs.getAttributeValue(packageName, "placement_type");
        if (placementTypeStr != null && placementTypeStr.equalsIgnoreCase("inline")) {
            mPlacementType = MadvertiseUtil.PLACEMENT_TYPE_INLINE;
        } else if (placementTypeStr != null && placementTypeStr.equalsIgnoreCase("interstitial")) {
            mPlacementType = MadvertiseUtil.PLACEMENT_TYPE_INTERSTITIAL;
        }
    } else {
        MadvertiseUtil.logMessage(null, Log.DEBUG, "AttributeSet is null. Using default parameters");
    }

    if (mSecondsToRefreshAd != 0 && mSecondsToRefreshAd < 30) {
        mSecondsToRefreshAd = MadvertiseUtil.SECONDS_TO_REFRESH_AD_DEFAULT;
        MadvertiseUtil.logMessage(null, Log.DEBUG, "Refresh intervall must be higher than 60");
    }

    calculateBannerDimensions();

    MadvertiseUtil.logMessage(null, Log.DEBUG, "Using following attributes values:");
    MadvertiseUtil.logMessage(null, Log.DEBUG, " testMode = " + mTestMode);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " textColor = " + mTextColor);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " backgroundColor = " + mBackgroundColor);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " secondsToRefreshAd = " + mSecondsToRefreshAd);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerType = " + mBannerType);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " animationType = " + mAnimationType);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " deliverOnlyText = " + mDeliverOnlyText);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " textSize = " + mTextSize);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " isMraid = " + mIsMraid);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " placementType = " + mPlacementType);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerWidth = " + mBannerWidth);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerHeight = " + mBannerHeight);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerWidthDp = " + mBannerWidthDp);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerHeightDp = " + mBannerHeightDp);
}

From source file:net.qiujuer.genius.ui.widget.GeniusAbsSeekBar.java

public GeniusAbsSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFocusable(true);//w w  w  .  j av a  2  s .c  o  m
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    // New
    final Resources resources = getResources();
    final ColorStateList transparent = ColorStateList.valueOf(Color.TRANSPARENT);

    mAttributes = new SeekBarAttributes(this, resources);

    mRipple = new AlmostRippleDrawable(transparent);
    mRipple.setCallback(this);

    mSeekBarDrawable = new SeekBarDrawable(transparent, transparent, transparent);
    mSeekBarDrawable.setCallback(this);

    if (!isInEditMode()) {
        mIndicator = new GeniusPopupIndicator(context);
        mIndicator.setListener(mFloaterListener);
    }

    // Set Size
    setTrackStroke(resources.getDimensionPixelSize(R.dimen.genius_seekBar_trackStroke));
    setScrubberStroke(resources.getDimensionPixelSize(R.dimen.genius_seekBar_scrubberStroke));
    setThumbRadius(resources.getDimensionPixelSize(R.dimen.genius_seekBar_thumbSize));
    setTouchRadius(resources.getDimensionPixelSize(R.dimen.genius_seekBar_touchSize));
    setTickRadius(resources.getDimensionPixelSize(R.dimen.genius_seekBar_tickSize));

    // Init
    init(attrs, defStyle);

    // End
    setNumericTransformer(new DefaultNumericTransformer());
    isRtl();

    if (attrs != null)
        setEnabled(attrs.getAttributeBooleanValue(GeniusUi.androidStyleNameSpace, "enabled", isEnabled()));
    else
        setEnabled(isEnabled());
}

From source file:net.qiujuer.genius.widget.GeniusAbsSeekBar.java

public GeniusAbsSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFocusable(true);/* w w  w .j a v  a  2 s . co m*/
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    // New
    final Resources resources = getResources();
    final ColorStateList transparent = ColorStateList.valueOf(Color.TRANSPARENT);

    mAttributes = new SeekBarAttributes(this, resources);

    mRipple = new AlmostRippleDrawable(transparent);
    mRipple.setCallback(this);

    mSeekBarDrawable = new SeekBarDrawable(transparent, transparent, transparent);
    mSeekBarDrawable.setCallback(this);

    if (!isInEditMode()) {
        mIndicator = new GeniusPopupIndicator(context);
        mIndicator.setListener(mFloaterListener);
    }

    // Set Size
    setTrackStroke(resources.getDimensionPixelSize(R.dimen.genius_seekBar_trackStroke));
    setScrubberStroke(resources.getDimensionPixelSize(R.dimen.genius_seekBar_scrubberStroke));
    setThumbRadius(resources.getDimensionPixelSize(R.dimen.genius_seekBar_thumbSize));
    setTouchRadius(resources.getDimensionPixelSize(R.dimen.genius_seekBar_touchSize));
    setTickRadius(resources.getDimensionPixelSize(R.dimen.genius_seekBar_tickSize));

    // Init
    init(attrs, defStyle);

    // End
    setNumericTransformer(new DefaultNumericTransformer());
    isRtl();

    if (attrs != null)
        setEnabled(attrs.getAttributeBooleanValue(GeniusUI.androidStyleNameSpace, "enabled", isEnabled()));
    else
        setEnabled(isEnabled());
}