Example usage for android.content.res Resources getBoolean

List of usage examples for android.content.res Resources getBoolean

Introduction

In this page you can find the example usage for android.content.res Resources getBoolean.

Prototype

public boolean getBoolean(@BoolRes int id) throws NotFoundException 

Source Link

Document

Return a boolean associated with a particular resource ID.

Usage

From source file:ac.robinson.mediaphone.MediaPhoneActivity.java

protected void configureBluetoothObserver(SharedPreferences mediaPhoneSettings, Resources res) {
    boolean watchForFiles = res.getBoolean(R.bool.default_watch_for_files);
    try {/*from   w  w w.j  a  v  a 2s.co m*/
        watchForFiles = mediaPhoneSettings.getBoolean(getString(R.string.key_watch_for_files), watchForFiles);
    } catch (Exception e) {
        watchForFiles = res.getBoolean(R.bool.default_watch_for_files);
    }
    if (watchForFiles) {
        // file changes are handled in startWatchingBluetooth();
        ((MediaPhoneApplication) getApplication()).startWatchingBluetooth(false); // don't watch if bt not enabled
    } else {
        ((MediaPhoneApplication) getApplication()).stopWatchingBluetooth();
    }
}

From source file:android.hqs.view.pager.indicator.TitlePageIndicator.java

/**
 * ?//  ww  w  . j  a  v  a 2s  .  c  o  m
 * @param context
 * @param attrs
 * @param defStyle
 */
@SuppressWarnings("deprecation")
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultLinePosition = res.getInteger(R.integer.default_title_indicator_line_position);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
    final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, 0);

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mLinePosition = LinePosition
            .fromValue(a.getInteger(R.styleable.TitlePageIndicator_linePosition, defaultLinePosition));
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_android_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize);
    final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    Drawable background = a.getDrawable(R.styleable.TitlePageIndicator_android_background);
    if (background != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setBackground(background);
        } else {
            setBackgroundDrawable(background);
        }
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:github.why168.swipeback.view.SwipeBackLayout.java

private boolean oldCheckDeviceHasNavigationBar(Activity activity) {
    boolean hasNavigationBar = false;
    Resources resources = activity.getResources();
    int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
    if (id > 0) {
        hasNavigationBar = resources.getBoolean(id);
    }/*from www .  j  av  a2  s  . c  o  m*/
    try {
        Class systemPropertiesClass = Class.forName("android.os.SystemProperties");
        Method m = systemPropertiesClass.getMethod("get", String.class);
        String navBarOverride = (String) m.invoke(systemPropertiesClass, "qemu.hw.mainkeys");
        if ("1".equals(navBarOverride)) {
            hasNavigationBar = false;
        } else if ("0".equals(navBarOverride)) {
            hasNavigationBar = true;
        }
    } catch (Exception e) {
    }
    return hasNavigationBar;
}

From source file:com.home.library.vpi.TitlePageIndicator.java

public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//w  w w.j ava 2s  .  c o  m

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultLinePosition = res.getInteger(R.integer.default_title_indicator_line_position);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
    final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);
    final int defaultBackGroundColor = res.getColor(R.color.default_title_background_color);

    final boolean defaultFades = res.getBoolean(R.bool.default_title_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_title_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_title_indicator_fade_length);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, 0);

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mLinePosition = LinePosition
            .fromValue(a.getInteger(R.styleable.TitlePageIndicator_linePosition, defaultLinePosition));
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_android_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);
    mBackGroundColor = a.getColor(R.styleable.TitlePageIndicator_titleBackGround, defaultBackGroundColor);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize);
    mFooterColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintText.setColor(mColorText);
    mPaintText.setAlpha(0xFF);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(mFooterColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(mFooterColor);

    mBackGroundPaint.setColor(mBackGroundColor);
    mInitBackGroundPaintAlpha = mBackGroundPaint.getAlpha();

    setFades(a.getBoolean(R.styleable.TitlePageIndicator_titleFades, defaultFades));
    setFadeDelay(a.getInteger(R.styleable.TitlePageIndicator_titleFadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.TitlePageIndicator_titleFadeLength, defaultFadeLength));

    Drawable background = a.getDrawable(R.styleable.TitlePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.ushahidi.platform.mobile.app.presentation.view.ui.widget.TitlePageIndicator.java

public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;//from   w ww .jav a2 s.  co m
    }

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final int defaultSelectedFooterColor = res.getColor(R.color.default_title_indicator_selected_footer_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultLinePosition = res.getInteger(R.integer.default_title_indicator_line_position);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
    final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, 0);

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mLinePosition = LinePosition
            .fromValue(a.getInteger(R.styleable.TitlePageIndicator_linePosition, defaultLinePosition));
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_android_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize);

    final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);

    mSelectedFooterColor = a.getColor(R.styleable.TitlePageIndicator_selectedFooterColor,
            defaultSelectedFooterColor);

    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(mSelectedFooterColor);

    Drawable background = a.getDrawable(R.styleable.TitlePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:ac.robinson.mediaphone.MediaPhoneActivity.java

private void loadAllPreferences() {
    SharedPreferences mediaPhoneSettings = PreferenceManager
            .getDefaultSharedPreferences(MediaPhoneActivity.this);
    Resources res = getResources();

    // bluetooth observer
    configureBluetoothObserver(mediaPhoneSettings, res);

    // importing confirmation
    boolean confirmImporting = res.getBoolean(R.bool.default_confirm_importing);
    try {//  www. ja  va  2s .  co  m
        confirmImporting = mediaPhoneSettings.getBoolean(getString(R.string.key_confirm_importing),
                confirmImporting);
    } catch (Exception e) {
        confirmImporting = res.getBoolean(R.bool.default_confirm_importing);
    }
    MediaPhone.IMPORT_CONFIRM_IMPORTING = confirmImporting;

    // delete after import
    boolean deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing);
    try {
        deleteAfterImport = mediaPhoneSettings.getBoolean(getString(R.string.key_delete_after_importing),
                deleteAfterImport);
    } catch (Exception e) {
        deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing);
    }
    MediaPhone.IMPORT_DELETE_AFTER_IMPORTING = deleteAfterImport;

    // minimum frame duration
    TypedValue resourceValue = new TypedValue();
    res.getValue(R.attr.default_minimum_frame_duration, resourceValue, true);
    float minimumFrameDuration;
    try {
        minimumFrameDuration = mediaPhoneSettings.getFloat(getString(R.string.key_minimum_frame_duration),
                resourceValue.getFloat());
        if (minimumFrameDuration <= 0) {
            throw new NumberFormatException();
        }
    } catch (Exception e) {
        minimumFrameDuration = resourceValue.getFloat();
    }
    MediaPhone.PLAYBACK_EXPORT_MINIMUM_FRAME_DURATION = Math.round(minimumFrameDuration * 1000);

    // word duration
    res.getValue(R.attr.default_word_duration, resourceValue, true);
    float wordDuration;
    try {
        wordDuration = mediaPhoneSettings.getFloat(getString(R.string.key_word_duration),
                resourceValue.getFloat());
        if (wordDuration <= 0) {
            throw new NumberFormatException();
        }
    } catch (Exception e) {
        wordDuration = resourceValue.getFloat();
    }
    MediaPhone.PLAYBACK_EXPORT_WORD_DURATION = Math.round(wordDuration * 1000);

    // screen orientation
    int requestedOrientation = res.getInteger(R.integer.default_screen_orientation);
    try {
        String requestedOrientationString = mediaPhoneSettings
                .getString(getString(R.string.key_screen_orientation), null);
        requestedOrientation = Integer.valueOf(requestedOrientationString);
    } catch (Exception e) {
        requestedOrientation = res.getInteger(R.integer.default_screen_orientation);
    }
    setRequestedOrientation(requestedOrientation);

    // other preferences
    loadPreferences(mediaPhoneSettings);
}

From source file:ru.phplego.core.etc.viewpagerindicator.TitlePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_title_indicator_footer_color"));
    final float defaultFooterLineHeight = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_footer_line_height"));
    final int defaultFooterIndicatorStyle = res.getInteger(Res.getId(Application.getContext().getPackageName(),
            "integer", "default_title_indicator_footer_indicator_style"));
    final float defaultFooterIndicatorHeight = res
            .getDimension(Res.getId(Application.getContext().getPackageName(), "dimen",
                    "default_title_indicator_footer_indicator_height"));
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(Res.getId(Application.getContext().getPackageName(), "dimen",
                    "default_title_indicator_footer_indicator_underline_padding"));
    final float defaultFooterPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_footer_padding"));
    final int defaultSelectedColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_title_indicator_selected_color"));
    final boolean defaultSelectedBold = res.getBoolean(Res.getId(Application.getContext().getPackageName(),
            "bool", "default_title_indicator_selected_bold"));
    final int defaultTextColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_title_indicator_text_color"));
    final float defaultTextSize = res.getDimension(
            Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_text_size"));
    final float defaultTitlePadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_title_padding"));
    final float defaultClipPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_clip_padding"));
    final float defaultTopPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_title_indicator_top_padding"));

    //Retrieve styles attributes
    //TypedArray a = context.obtainStyledAttributes(attrs, Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator"), defStyle, Res.getId(Application.getContext().getPackageName(), "style", "Widget_TitlePageIndicator"));
    TypedArray a = context.obtainStyledAttributes(attrs,
            Res.getIds(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator"), defStyle,
            Res.getId(Application.getContext().getPackageName(), "style", "Widget_TitlePageIndicator"));

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_footerLineHeight"), defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle
            .fromValue(a.getInteger(Res.getId(Application.getContext().getPackageName(), "styleable",
                    "TitlePageIndicator_footerIndicatorStyle"), defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_footerIndicatorHeight"), defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable",
                    "TitlePageIndicator_footerIndicatorUnderlinePadding"),
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_footerPadding"), defaultFooterPadding);
    mTopPadding = a.getDimension(//  w w  w  .  j  ava 2  s .c  o  m
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_topPadding"),
            defaultTopPadding);
    mTitlePadding = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_titlePadding"), defaultTitlePadding);
    mClipPadding = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_clipPadding"),
            defaultClipPadding);
    mColorSelected = a.getColor(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_selectedColor"), defaultSelectedColor);
    mColorText = a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_textColor"),
            defaultTextColor);
    mBoldText = a.getBoolean(Res.getId(Application.getContext().getPackageName(), "styleable",
            "TitlePageIndicator_selectedBold"), defaultSelectedBold);

    final float textSize = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_textSize"),
            defaultTextSize);
    final int footerColor = a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerColor"),
            defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:net.czlee.debatekeeper.DebatingActivity.java

/**
 * Gets the preferences from the shared preferences file and applies them.
 *//* ww w. jav a 2s  .  c o  m*/
private void applyPreferences() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean silentMode, vibrateMode, overtimeBellsEnabled;
    boolean poiBuzzerEnabled, poiVibrateEnabled, prepTimerEnabled;
    int firstOvertimeBell, overtimeBellPeriod;
    String userCountDirectionValue, userPrepTimeCountDirectionValue, poiFlashScreenModeValue,
            backgroundColourAreaValue;
    FlashScreenMode flashScreenMode, poiFlashScreenMode;

    Resources res = getResources();

    final String TAG = "applyPreferences";

    try {

        // The boolean preferences
        silentMode = prefs.getBoolean(res.getString(R.string.pref_silentMode_key),
                res.getBoolean(R.bool.prefDefault_silentMode));
        vibrateMode = prefs.getBoolean(res.getString(R.string.pref_vibrateMode_key),
                res.getBoolean(R.bool.prefDefault_vibrateMode));
        overtimeBellsEnabled = prefs.getBoolean(res.getString(R.string.pref_overtimeBellsEnable_key),
                res.getBoolean(R.bool.prefDefault_overtimeBellsEnable));

        mSpeechKeepScreenOn = prefs.getBoolean(res.getString(R.string.pref_keepScreenOn_key),
                res.getBoolean(R.bool.prefDefault_keepScreenOn));
        mPrepTimeKeepScreenOn = prefs.getBoolean(res.getString(R.string.pref_prepTimer_keepScreenOn_key),
                res.getBoolean(R.bool.prefDefault_prepTimer_keepScreenOn));

        mPoiTimerEnabled = prefs.getBoolean(res.getString(R.string.pref_poiTimer_enable_key),
                res.getBoolean(R.bool.prefDefault_poiTimer_enable));
        poiBuzzerEnabled = prefs.getBoolean(res.getString(R.string.pref_poiTimer_buzzerEnable_key),
                res.getBoolean(R.bool.prefDefault_poiTimer_buzzerEnable));
        poiVibrateEnabled = prefs.getBoolean(res.getString(R.string.pref_poiTimer_vibrateEnable_key),
                res.getBoolean(R.bool.prefDefault_poiTimer_vibrateEnable));

        prepTimerEnabled = prefs.getBoolean(res.getString(R.string.pref_prepTimer_enable_key),
                res.getBoolean(R.bool.prefDefault_prepTimer_enable));

        // Overtime bell integers
        if (overtimeBellsEnabled) {
            firstOvertimeBell = prefs.getInt(res.getString(R.string.pref_firstOvertimeBell_key),
                    res.getInteger(R.integer.prefDefault_firstOvertimeBell));
            overtimeBellPeriod = prefs.getInt(res.getString(R.string.pref_overtimeBellPeriod_key),
                    res.getInteger(R.integer.prefDefault_overtimeBellPeriod));
        } else {
            firstOvertimeBell = 0;
            overtimeBellPeriod = 0;
        }

        // List preference: POI flash screen mode
        poiFlashScreenModeValue = prefs.getString(res.getString(R.string.pref_poiTimer_flashScreenMode_key),
                res.getString(R.string.prefDefault_poiTimer_flashScreenMode));
        poiFlashScreenMode = FlashScreenMode.toEnum(poiFlashScreenModeValue);

        // List preference: Count direction
        //  - Backwards compatibility measure
        // This changed in version 0.9, to remove the generallyUp and generallyDown options.
        // Therefore, if we find either of those, we need to replace it with alwaysUp or
        // alwaysDown, respectively.
        userCountDirectionValue = prefs.getString(res.getString(R.string.pref_countDirection_key),
                res.getString(R.string.prefDefault_countDirection));
        if (userCountDirectionValue.equals("generallyUp") || userCountDirectionValue.equals("generallyDown")) {
            // Replace the preference with alwaysUp or alwaysDown, respectively.
            SharedPreferences.Editor editor = prefs.edit();
            String newValue = (userCountDirectionValue.equals("generallyUp")) ? "alwaysUp" : "alwaysDown";
            editor.putString(res.getString(R.string.pref_countDirection_key), newValue);
            editor.apply();
            Log.i(TAG, "countDirection: replaced " + userCountDirectionValue + " with " + newValue);
            userCountDirectionValue = newValue;
        }
        mCountDirection = CountDirection.toEnum(userCountDirectionValue);

        // List preference: Count direction for prep time
        userPrepTimeCountDirectionValue = prefs.getString(
                res.getString(R.string.pref_prepTimer_countDirection_key),
                res.getString(R.string.prefDefault_prepTimer_countDirection));
        mPrepTimeCountDirection = CountDirection.toEnum(userPrepTimeCountDirectionValue);

        // List preference: Background colour area
        BackgroundColourArea oldBackgroundColourArea = mBackgroundColourArea;
        backgroundColourAreaValue = prefs.getString(res.getString(R.string.pref_backgroundColourArea_key),
                res.getString(R.string.prefDefault_backgroundColourArea));
        mBackgroundColourArea = BackgroundColourArea.toEnum(backgroundColourAreaValue);
        if (oldBackgroundColourArea != mBackgroundColourArea) {
            Log.v(TAG, "background colour preference changed - refreshing");
            resetBackgroundColoursToTransparent();
            ((DebateTimerDisplayPagerAdapter) mViewPager.getAdapter()).refreshBackgroundColours();
        }

        // List preference: Flash screen mode
        //  - Backwards compatibility measure
        // This changed from a boolean to a list preference in version 0.6, so there is
        // backwards compatibility to take care of.  Backwards compatibility applies if
        // (a) the list preference is NOT present AND (b) the boolean preference IS present.
        // In this case, retrieve the boolean preference, delete it and write the corresponding
        // list preference.  In all other cases, just take the list preference (using the
        // normal default mechanism if it isn't present, i.e. neither are present).

        if (!prefs.contains(res.getString(R.string.pref_flashScreenMode_key))
                && prefs.contains(res.getString(R.string.pref_flashScreenBool_key))) {
            // Boolean preference.
            // First, get the string and convert it to an enum.
            boolean flashScreenModeBool = prefs.getBoolean(res.getString(R.string.pref_flashScreenBool_key),
                    false);
            flashScreenMode = (flashScreenModeBool) ? FlashScreenMode.SOLID_FLASH : FlashScreenMode.OFF;

            // Then, convert that enum to the list preference value (a string) and write that
            // back to the preferences.  Also, remove the old boolean preference.
            String flashStringModePrefValue = flashScreenMode.toPrefValue();
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString(res.getString(R.string.pref_flashScreenMode_key), flashStringModePrefValue);
            editor.remove(res.getString(R.string.pref_flashScreenBool_key));
            editor.apply();
            Log.i(TAG, "flashScreenMode: replaced boolean preference with list preference: "
                    + flashStringModePrefValue);

        } else {
            // List preference.
            // Get the string and convert it to an enum.
            String flashScreenModeValue;
            flashScreenModeValue = prefs.getString(res.getString(R.string.pref_flashScreenMode_key),
                    res.getString(R.string.prefDefault_flashScreenMode));
            flashScreenMode = FlashScreenMode.toEnum(flashScreenModeValue);
        }

    } catch (ClassCastException e) {
        Log.e(TAG, "caught ClassCastException!");
        return;
    }

    if (mDebateManager != null) {
        mDebateManager.setOvertimeBells(firstOvertimeBell, overtimeBellPeriod);
        mDebateManager.setPrepTimeEnabled(prepTimerEnabled);
        applyPrepTimeBells();

        // This is necessary if the debate structure has changed, i.e. if prep time has been
        // enabled or disabled.
        mViewPager.getAdapter().notifyDataSetChanged();

    } else {
        Log.v(TAG, "Couldn't restore overtime bells, mDebateManager doesn't yet exist");
    }

    if (mBinder != null) {
        AlertManager am = mBinder.getAlertManager();

        // Volume control stream is linked to silent mode
        am.setSilentMode(silentMode);
        setVolumeControlStream((silentMode) ? AudioManager.STREAM_RING : AudioManager.STREAM_MUSIC);

        am.setVibrateMode(vibrateMode);
        am.setFlashScreenMode(flashScreenMode);

        am.setPoiBuzzerEnabled(poiBuzzerEnabled);
        am.setPoiVibrateEnabled(poiVibrateEnabled);
        am.setPoiFlashScreenMode(poiFlashScreenMode);

        this.updateKeepScreenOn();

        Log.v(TAG, "successfully applied");
    } else {
        Log.v(TAG, "Couldn't restore AlertManager preferences; mBinder doesn't yet exist");
    }

}

From source file:com.androzic.MapActivity.java

/** Called when the activity is first created. */
@SuppressLint("ShowToast")
@Override/*  ww w .j av  a 2  s .c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.e(TAG, "onCreate()");

    ready = false;
    isFullscreen = false;

    backToast = Toast.makeText(this, R.string.backQuit, Toast.LENGTH_SHORT);
    finishHandler = new FinishHandler(this);

    application = (Androzic) getApplication();

    // FIXME Should find a better place for this
    application.mapObjectsOverlay = new MapObjectsOverlay(this);

    // check if called after crash
    if (!application.mapsInited) {
        restarting = true;
        startActivity(new Intent(this, Splash.class)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
                .putExtras(getIntent()));
        finish();
        return;
    }

    application.setMapActivity(this);

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    setRequestedOrientation(Integer.parseInt(settings.getString(getString(R.string.pref_orientation), "-1")));
    settings.registerOnSharedPreferenceChangeListener(this);
    Resources resources = getResources();

    if (settings.getBoolean(getString(R.string.pref_hideactionbar),
            resources.getBoolean(R.bool.def_hideactionbar))) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    panelActions = getResources().getStringArray(R.array.panel_action_values);

    setContentView(R.layout.act_main);
    coordinates = (TextView) findViewById(R.id.coordinates);
    satInfo = (TextView) findViewById(R.id.sats);
    currentFile = (TextView) findViewById(R.id.currentfile);
    mapZoom = (TextView) findViewById(R.id.currentzoom);
    waypointName = (TextView) findViewById(R.id.waypointname);
    waypointExtra = (TextView) findViewById(R.id.waypointextra);
    routeName = (TextView) findViewById(R.id.routename);
    routeExtra = (TextView) findViewById(R.id.routeextra);
    speedValue = (TextView) findViewById(R.id.speed);
    speedUnit = (TextView) findViewById(R.id.speedunit);
    trackValue = (TextView) findViewById(R.id.track);
    trackUnit = (TextView) findViewById(R.id.trackunit);
    elevationValue = (TextView) findViewById(R.id.elevation);
    elevationUnit = (TextView) findViewById(R.id.elevationunit);
    distanceValue = (TextView) findViewById(R.id.distance);
    distanceUnit = (TextView) findViewById(R.id.distanceunit);
    xtkValue = (TextView) findViewById(R.id.xtk);
    xtkUnit = (TextView) findViewById(R.id.xtkunit);
    bearingValue = (TextView) findViewById(R.id.bearing);
    bearingUnit = (TextView) findViewById(R.id.bearingunit);
    turnValue = (TextView) findViewById(R.id.turn);
    trackBar = (SeekBar) findViewById(R.id.trackbar);
    waitBar = (TextView) findViewById(R.id.waitbar);
    map = (MapView) findViewById(R.id.mapview);

    // set button actions
    findViewById(R.id.zoomin).setOnClickListener(this);
    findViewById(R.id.zoomout).setOnClickListener(this);
    findViewById(R.id.nextmap).setOnClickListener(this);
    findViewById(R.id.prevmap).setOnClickListener(this);
    findViewById(R.id.maps).setOnClickListener(this);
    findViewById(R.id.waypoints).setOnClickListener(this);
    findViewById(R.id.info).setOnClickListener(this);
    findViewById(R.id.follow).setOnClickListener(this);
    findViewById(R.id.locate).setOnClickListener(this);
    findViewById(R.id.tracking).setOnClickListener(this);
    findViewById(R.id.expand).setOnClickListener(this);
    findViewById(R.id.finishedit).setOnClickListener(this);
    findViewById(R.id.addpoint).setOnClickListener(this);
    findViewById(R.id.insertpoint).setOnClickListener(this);
    findViewById(R.id.removepoint).setOnClickListener(this);
    findViewById(R.id.orderpoints).setOnClickListener(this);
    findViewById(R.id.finishtrackedit).setOnClickListener(this);
    findViewById(R.id.cutafter).setOnClickListener(this);
    findViewById(R.id.cutbefore).setOnClickListener(this);

    Panel panel = (Panel) findViewById(R.id.panel);
    panel.setOnPanelListener(this);
    panel.setInterpolator(new ExpoInterpolator(Type.OUT));

    wptQuickAction = new QuickAction3D(this, QuickAction3D.VERTICAL);
    wptQuickAction.addActionItem(new ActionItem(qaAddWaypointToRoute, getString(R.string.menu_addtoroute),
            resources.getDrawable(R.drawable.ic_action_add)));
    wptQuickAction.setOnActionItemClickListener(waypointActionItemClickListener);

    rteQuickAction = new QuickAction3D(this, QuickAction3D.VERTICAL);
    rteQuickAction.addActionItem(new ActionItem(qaNavigateToWaypoint, getString(R.string.menu_thisnavpoint),
            resources.getDrawable(R.drawable.ic_action_directions)));
    rteQuickAction.setOnActionItemClickListener(routeActionItemClickListener);

    mobQuickAction = new QuickAction3D(this, QuickAction3D.VERTICAL);
    mobQuickAction.addActionItem(new ActionItem(qaNavigateToMapObject, getString(R.string.menu_navigate),
            resources.getDrawable(R.drawable.ic_action_directions)));
    mobQuickAction.setOnActionItemClickListener(mapObjectActionItemClickListener);

    trackBar.setOnSeekBarChangeListener(this);

    map.initialize(application);

    dimView = new RelativeLayout(this);

    String navWpt = settings.getString(getString(R.string.nav_wpt), "");
    if (!"".equals(navWpt) && savedInstanceState == null) {
        Intent intent = new Intent(getApplicationContext(), NavigationService.class)
                .setAction(NavigationService.NAVIGATE_MAPOBJECT);
        intent.putExtra(NavigationService.EXTRA_NAME, navWpt);
        intent.putExtra(NavigationService.EXTRA_LATITUDE,
                (double) settings.getFloat(getString(R.string.nav_wpt_lat), 0));
        intent.putExtra(NavigationService.EXTRA_LONGITUDE,
                (double) settings.getFloat(getString(R.string.nav_wpt_lon), 0));
        intent.putExtra(NavigationService.EXTRA_PROXIMITY, settings.getInt(getString(R.string.nav_wpt_prx), 0));
        startService(intent);
    }

    String navRoute = settings.getString(getString(R.string.nav_route), "");
    if (!"".equals(navRoute) && settings.getBoolean(getString(R.string.pref_navigation_loadlast),
            getResources().getBoolean(R.bool.def_navigation_loadlast)) && savedInstanceState == null) {
        int ndir = settings.getInt(getString(R.string.nav_route_dir), 0);
        int nwpt = settings.getInt(getString(R.string.nav_route_wpt), -1);
        try {
            int rt = -1;
            Route route = application.getRouteByFile(navRoute);
            if (route != null) {
                route.show = true;
                rt = application.getRouteIndex(route);
            } else {
                File rtf = new File(navRoute);
                // FIXME It's bad - it can be not a first route in a file
                route = OziExplorerFiles.loadRoutesFromFile(rtf, application.charset).get(0);
                rt = application.addRoute(route);
            }
            RouteOverlay newRoute = new RouteOverlay(this, route);
            application.routeOverlays.add(newRoute);
            startService(new Intent(this, NavigationService.class).setAction(NavigationService.NAVIGATE_ROUTE)
                    .putExtra(NavigationService.EXTRA_ROUTE_INDEX, rt)
                    .putExtra(NavigationService.EXTRA_ROUTE_DIRECTION, ndir)
                    .putExtra(NavigationService.EXTRA_ROUTE_START, nwpt));
        } catch (Exception e) {
            Log.e(TAG, "Failed to start navigation", e);
        }
    }

    // set activity preferences
    onSharedPreferenceChanged(settings, getString(R.string.pref_exit));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitprecision));
    // set map preferences
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapadjacent));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapcropborder));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapdrawborder));
    onSharedPreferenceChanged(settings, getString(R.string.pref_cursorcolor));
    onSharedPreferenceChanged(settings, getString(R.string.pref_grid_mapshow));
    onSharedPreferenceChanged(settings, getString(R.string.pref_grid_usershow));
    onSharedPreferenceChanged(settings, getString(R.string.pref_grid_preference));
    onSharedPreferenceChanged(settings, getString(R.string.pref_panelactions));

    if (getIntent().getExtras() != null)
        onNewIntent(getIntent());

    ready = true;
}

From source file:com.tct.mail.browse.ConversationItemView.java

public ConversationItemView(Context context, String account) {
    super(context);
    Utils.traceBeginSection("CIVC constructor");
    setClickable(true);/*from  www. j av a 2 s.  com*/
    setLongClickable(true);
    mContext = context.getApplicationContext();
    final Resources res = mContext.getResources();
    mTabletDevice = Utils.useTabletUI(res);
    mListCollapsible = res.getBoolean(R.bool.list_collapsible);
    mAccount = account;

    getItemViewResources(mContext);

    final int layoutDir = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault());

    mSendersTextView = new TextView(mContext);
    mSendersTextView.setIncludeFontPadding(false);

    mSubjectTextView = new TextView(mContext);
    mSubjectTextView.setEllipsize(TextUtils.TruncateAt.END);
    mSubjectTextView.setSingleLine(); // allow partial words to be elided
    mSubjectTextView.setIncludeFontPadding(false);
    ViewCompat.setLayoutDirection(mSubjectTextView, layoutDir);
    //AM: peng-zhang 2015-02-15 EMAIL BUGFIX_932279 MOD_S
    //ViewUtils.setTextAlignment(mSubjectTextView, View.TEXT_ALIGNMENT_VIEW_START);
    if (0 == layoutDir) {
        ViewUtils.setTextAlignment(mSubjectTextView, View.TEXT_ALIGNMENT_VIEW_START);
    } else if (1 == layoutDir) {
        ViewUtils.setTextAlignment(mSubjectTextView, View.TEXT_ALIGNMENT_VIEW_END);
    }
    //AM: peng-zhang 2015-02-15 EMAIL BUGFIX_932279 MOD_E
    mSnippetTextView = new TextView(mContext);
    mSnippetTextView.setEllipsize(TextUtils.TruncateAt.END);
    mSnippetTextView.setSingleLine(); // allow partial words to be elided
    mSnippetTextView.setIncludeFontPadding(false);
    mSnippetTextView.setTypeface(SANS_SERIF_LIGHT);
    mSnippetTextView.setTextColor(getResources().getColor(R.color.snippet_text_color));
    ViewCompat.setLayoutDirection(mSnippetTextView, layoutDir);
    //AM: peng-zhang 2015-02-16 EMAIL BUGFIX_932279 MOD_S
    //ViewUtils.setTextAlignment(mSnippetTextView, View.TEXT_ALIGNMENT_VIEW_START);
    if (0 == layoutDir) {
        ViewUtils.setTextAlignment(mSnippetTextView, View.TEXT_ALIGNMENT_VIEW_START);
    } else if (1 == layoutDir) {
        ViewUtils.setTextAlignment(mSnippetTextView, View.TEXT_ALIGNMENT_VIEW_END);
    }
    //AM: peng-zhang 2015-02-16 EMAIL BUGFIX_932279 MOD_E
    mSendersImageView = new CheckableContactFlipDrawable(res, sCabAnimationDuration);
    mSendersImageView.setCallback(this);
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_S
    mStatusTextView = new TextView(mContext);
    mStatusTextView.setIncludeFontPadding(false);
    mStatusTextView.setTextColor(getResources().getColor(R.color.status_text_color));
    ViewCompat.setLayoutDirection(mStatusTextView, layoutDir);
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_E
    Utils.traceEndSection();
}