當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.getBoolean方法代碼示例

本文整理匯總了Java中android.content.res.Resources.getBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getBoolean方法的具體用法?Java Resources.getBoolean怎麽用?Java Resources.getBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.getBoolean方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkDeviceHasNavigationBar

import android.content.res.Resources; //導入方法依賴的package包/類
public static boolean checkDeviceHasNavigationBar(Context context) {
    boolean hasNavigationBar = false;
    Resources rs = context.getResources();
    int id = rs.getIdentifier("config_showNavigationBar", "bool", "android");
    if (id > 0) {
        hasNavigationBar = rs.getBoolean(id);
    }
    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;

}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:23,代碼來源:AndroidWorkaround.java

示例2: initValues

import android.content.res.Resources; //導入方法依賴的package包/類
private void initValues(Context context, boolean editMode) {
  Resources res = context.getResources();
  mInterpolator = new AccelerateInterpolator();
  if (!editMode) {
    mSectionsCount = res.getInteger(R.integer.spb_default_sections_count);
    mSpeed = Float.parseFloat(res.getString(R.string.spb_default_speed));
    mReversed = res.getBoolean(R.bool.spb_default_reversed);
    mProgressiveStartActivated = res.getBoolean(R.bool.spb_default_progressiveStart_activated);
    mColors = new int[]{res.getColor(R.color.spb_default_color)};
    mStrokeSeparatorLength = res.getDimensionPixelSize(R.dimen.spb_default_stroke_separator_length);
    mStrokeWidth = res.getDimensionPixelOffset(R.dimen.spb_default_stroke_width);
  } else {
    mSectionsCount = 4;
    mSpeed = 1f;
    mReversed = false;
    mProgressiveStartActivated = false;
    mColors = new int[]{0xff33b5e5};
    mStrokeSeparatorLength = 4;
    mStrokeWidth = 4;
  }
  mProgressiveStartSpeed = mSpeed;
  mProgressiveStopSpeed = mSpeed;
  mGradients = false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:SmoothProgressDrawable.java

示例3: hasNavBar

import android.content.res.Resources; //導入方法依賴的package包/類
@TargetApi(14)
private boolean hasNavBar(Context context) {
    Resources res = context.getResources();
    int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android");
    if (resourceId != 0) {
        boolean hasNav = res.getBoolean(resourceId);
        // check override flag (see static block)
        if ("1".equals(sNavBarOverride)) {
            hasNav = false;
        } else if ("0".equals(sNavBarOverride)) {
            hasNav = true;
        }
        return hasNav;
    } else { // fallback
        return !ViewConfiguration.get(context).hasPermanentMenuKey();
    }
}
 
開發者ID:dufangyu1990,項目名稱:LeCatApp,代碼行數:18,代碼來源:SystemBarTintManager.java

示例4: checkDeviceHasNavigationBar

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * 檢測是否具有底部導航欄。(一加手機上判斷不準確,希望有猿友能修複這個 bug)
 *
 * @return
 */
public static boolean checkDeviceHasNavigationBar() {
    boolean hasNavigationBar = false;
    Resources resources = XFrame.getResources();
    int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
    if (id > 0) {
        hasNavigationBar = resources.getBoolean(id);
    }
    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;
}
 
開發者ID:youth5201314,項目名稱:XFrame,代碼行數:27,代碼來源:XDensityUtils.java

示例5: SpacingAndPunctuations

import android.content.res.Resources; //導入方法依賴的package包/類
public SpacingAndPunctuations(final Resources res) {
    mSortedWordSeparators = StringUtils.toSortedCodePointArray(
            res.getString(R.string.symbols_word_separators));
    mSortedSentenceTerminators = StringUtils.toSortedCodePointArray(
            res.getString(R.string.symbols_sentence_terminators));
    mSentenceSeparator = res.getInteger(R.integer.sentence_separator);
    mAbbreviationMarker = res.getInteger(R.integer.abbreviation_marker);
    mSentenceSeparatorAndSpace = new String(new int[] {
            mSentenceSeparator, Constants.CODE_SPACE }, 0, 2);
    mCurrentLanguageHasSpaces = res.getBoolean(R.bool.current_language_has_spaces);
    final Locale locale = res.getConfiguration().locale;
    // Heuristic: we use American Typography rules because it's the most common rules for all
    // English variants. German rules (not "German typography") also have small gotchas.
    mUsesAmericanTypography = Locale.ENGLISH.getLanguage().equals(locale.getLanguage());
    mUsesGermanRules = Locale.GERMAN.getLanguage().equals(locale.getLanguage());
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:17,代碼來源:SpacingAndPunctuations.java

示例6: CirclePageIndicator

import android.content.res.Resources; //導入方法依賴的package包/類
public CirclePageIndicator(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

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

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:41,代碼來源:CirclePageIndicator.java

示例7: hasNavBar

import android.content.res.Resources; //導入方法依賴的package包/類
public static boolean hasNavBar(Activity activity) {
    Resources resources = activity.getResources();
    int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
    if (id > 0) {
        return resources.getBoolean(id);
    } else {    // Check for keys
        boolean hasMenuKey = ViewConfiguration.get(activity).hasPermanentMenuKey();
        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        return !hasMenuKey && !hasBackKey;
    }
}
 
開發者ID:HoraApps,項目名稱:Liz,代碼行數:12,代碼來源:ViewUtil.java

示例8: CirclePageIndicator

import android.content.res.Resources; //導入方法依賴的package包/類
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

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

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
開發者ID:nelladragon,項目名稱:scab,代碼行數:41,代碼來源:CirclePageIndicator.java

示例9: UnderlinePageIndicator

import android.content.res.Resources; //導入方法依賴的package包/類
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    final Resources res = getResources();

    //Load defaults from resources
    final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color);

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

    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

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

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:31,代碼來源:UnderlinePageIndicator.java

示例10: getStyleColumnCount

import android.content.res.Resources; //導入方法依賴的package包/類
public int getStyleColumnCount(Context context, int style) {
    Resources res = context.getResources();
    boolean landscape = res.getBoolean(R.bool.landscape);
    int styleColumnCount = getDefaultStyleColumnCount(context, style);
    if (landscape &&
            (style == res.getInteger(R.integer.STYLE_CARDS_VALUE) ||
                    style == res.getInteger(R.integer.STYLE_CARDS_2_VALUE))) {
        return styleColumnCount + 1;
    }
    return styleColumnCount;
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:12,代碼來源:Settings.java

示例11: TitleBitmapFactory

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * @param context   The current Android's context.
 * @param incognito Whether the title are for incognito mode.
 * @param nullFaviconResourceId A drawable resource id of a default favicon.
 */
public TitleBitmapFactory(Context context, boolean incognito, int nullFaviconResourceId) {
    mNullFaviconResourceId = nullFaviconResourceId;

    Resources res = context.getResources();
    int textColor = ApiCompatibilityUtils.getColor(res, incognito
            ? R.color.compositor_tab_title_bar_text_incognito
            : R.color.compositor_tab_title_bar_text);
    float textSize = res.getDimension(R.dimen.compositor_tab_title_text_size);

    boolean fakeBoldText = res.getBoolean(R.bool.compositor_tab_title_fake_bold_text);

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setColor(textColor);

    mTextPaint.setTextSize(textSize);
    mTextPaint.setFakeBoldText(fakeBoldText);
    mTextPaint.density = res.getDisplayMetrics().density;

    FontMetrics textFontMetrics = mTextPaint.getFontMetrics();
    mTextHeight = (float) Math.ceil(textFontMetrics.bottom - textFontMetrics.top);
    mTextYOffset = -textFontMetrics.top;

    mFaviconDimension = res.getDimensionPixelSize(R.dimen.compositor_tab_title_favicon_size);
    mViewHeight = (int) Math.max(mFaviconDimension, mTextHeight);

    int width = res.getDisplayMetrics().widthPixels;
    int height = res.getDisplayMetrics().heightPixels;
    mMaxWidth = (int) (TITLE_WIDTH_PERCENTAGE * Math.max(width, height));

    // Set the favicon dimension here.
    mFaviconDimension = Math.min(mMaxWidth, mFaviconDimension);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:38,代碼來源:TitleBitmapFactory.java

示例12: hasNavigationBar

import android.content.res.Resources; //導入方法依賴的package包/類
private boolean hasNavigationBar(Context context) {
    Resources resources = context.getResources();
    int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
    return id > 0 && resources.getBoolean(id);
}
 
開發者ID:fantasy1022,項目名稱:FancyTrendView,代碼行數:6,代碼來源:FancyTrendAdapter.java

示例13: updateAutobrightnessConfig

import android.content.res.Resources; //導入方法依賴的package包/類
private static void updateAutobrightnessConfig(int[] lux, int[] brightness) {
    if (mDisplayPowerController == null || mContext == null) return;

    if (DEBUG) log("updateAutobrightnessConfig called");
    Resources res = mContext.getResources();
    boolean mtkVirtualValuesSupport = false;
    boolean mtkVirtualValues = false;

    int screenBrightnessDim = res.getInteger(res.getIdentifier(
            "config_screenBrightnessDim", "integer", "android"));
    int screenBrightnessMinimum = res.getInteger(res.getIdentifier(
            "config_screenBrightnessSettingMinimum", "integer", "android"));
    screenBrightnessMinimum = Math.min(screenBrightnessDim, screenBrightnessMinimum);

    boolean useSwAutobrightness = XposedHelpers.getBooleanField(
            mDisplayPowerController, "mUseSoftwareAutoBrightnessConfig");

    if (useSwAutobrightness) {
        // brightness array must have one more element than lux array
        int[] brightnessAdj = new int[lux.length + 1];
        for (int i = 0; i < brightnessAdj.length; i++) {
            if (i < brightness.length) {
                brightnessAdj[i] = brightness[i];
            } else {
                brightnessAdj[i] = 255;
            }
        }
        if (DEBUG) log("updateAutobrightnessConfig: lux=" + Utils.intArrayToString(lux) +
                "; brightnessAdj=" + Utils.intArrayToString(brightnessAdj));

        if (Utils.isMtkDevice()) {
            try {
                mtkVirtualValues = (boolean) XposedHelpers.getStaticBooleanField(
                        mDisplayPowerController.getClass(), "MTK_ULTRA_DIMMING_SUPPORT");
                int resId = res.getIdentifier("config_screenBrightnessVirtualValues",
                        "bool", "android");
                if (resId != 0) {
                    mtkVirtualValues &= res.getBoolean(resId);
                }
                mtkVirtualValuesSupport = true;
                if (DEBUG) log("MTK brightness virtual values: " + mtkVirtualValues);
            } catch (Throwable t) {
                if (DEBUG) log("Couldn't detect MTK virtual values feature");
            }
        }

        Object autoBrightnessSpline = mtkVirtualValuesSupport ? XposedHelpers.callMethod(
                mDisplayPowerController, "createAutoBrightnessSpline",
                lux, brightnessAdj, mtkVirtualValues) :
                XposedHelpers.callMethod(mDisplayPowerController,
                        "createAutoBrightnessSpline", lux, brightnessAdj);
        if (autoBrightnessSpline != null) {
            Object abrCtrl = XposedHelpers.getObjectField(mDisplayPowerController,
                    "mAutomaticBrightnessController");
            XposedHelpers.setObjectField(abrCtrl,
                    "mScreenAutoBrightnessSpline", autoBrightnessSpline);
            if (brightnessAdj[0] < screenBrightnessMinimum) {
                screenBrightnessMinimum = brightnessAdj[0];
            }
        } else {
            XposedHelpers.setBooleanField(mDisplayPowerController, "mUseSoftwareAutoBrightnessConfig", false);
            log("Error computing auto-brightness spline: lux=" + Utils.intArrayToString(lux) +
                    "; brightnessAdj=" + Utils.intArrayToString(brightnessAdj));
        }
    }

    int screenBrightnessRangeMinimum = mtkVirtualValuesSupport ?
            (Integer) XposedHelpers.callMethod(mDisplayPowerController, "clampAbsoluteBrightness",
                    screenBrightnessMinimum, mtkVirtualValues) :
            (Integer) XposedHelpers.callMethod(
                    mDisplayPowerController, "clampAbsoluteBrightness", screenBrightnessMinimum);
    XposedHelpers.setIntField(mDisplayPowerController, "mScreenBrightnessRangeMinimum",
            screenBrightnessRangeMinimum);

    if (DEBUG) log("Autobrightness config updated");
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:77,代碼來源:ModDisplay.java

示例14: readFromBuildConfigIfToShowKeyPreviewPopupOption

import android.content.res.Resources; //導入方法依賴的package包/類
public static boolean readFromBuildConfigIfToShowKeyPreviewPopupOption(final Resources res) {
    return res.getBoolean(R.bool.config_enable_show_key_preview_popup_option);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:4,代碼來源:Settings.java


注:本文中的android.content.res.Resources.getBoolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。