List of usage examples for android.content.res Resources getDimension
public float getDimension(@DimenRes int id) throws NotFoundException
From source file:com.silentcircle.contacts.calllognew.CallLogAdapter.java
public CallLogAdapter(Context context, CallFetcher callFetcher, ContactInfoHelper contactInfoHelper, CallItemExpandedListener callItemExpandedListener, OnPhoneNumberPickerActionListener actionListener, boolean isCallLog) { super(context); mContext = context;/*w w w . ja va2 s. c om*/ mCallFetcher = callFetcher; mContactInfoHelper = contactInfoHelper; mIsCallLog = isCallLog; mCallItemExpandedListener = callItemExpandedListener; mPhoneNumberPickerActionListener = actionListener; mContactInfoCache = ExpirableCache.create(CONTACT_INFO_CACHE_SIZE); mRequests = new LinkedList<ContactInfoRequest>(); Resources resources = mContext.getResources(); CallTypeHelper callTypeHelper = new CallTypeHelper(context); mCallLogBackgroundColor = ViewUtil.getColorFromAttributeId(context, R.attr.call_log_primary_background_color); mExpandedBackgroundColor = ViewUtil.getColorFromAttributeId(context, R.attr.call_log_expanded_background_color); mExpandedTranslationZ = resources.getDimension(R.dimen.call_log_expanded_translation_z); mContactPhotoManager = ContactPhotoManagerNew.getInstance(mContext); mPhoneNumberHelper = new PhoneNumberDisplayHelper(resources); PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(resources, callTypeHelper, new PhoneNumberUtilsWrapper()); mCallLogViewsHelper = new CallLogListItemHelper(phoneCallDetailsHelper, mPhoneNumberHelper, resources); mCallLogGroupBuilder = new CallLogGroupBuilder(this); }
From source file:com.forrestguice.suntimeswidget.SuntimesActivity.java
private void adjustNoteIconSize(NoteData note, ImageView icon) { Resources resources = getResources(); int iconWidth = (int) resources.getDimension(R.dimen.sunIconLarge_width); int iconHeight = ((note.noteIconResource == R.drawable.ic_noon_large) ? iconWidth : (int) resources.getDimension(R.dimen.sunIconLarge_height)); ViewGroup.LayoutParams iconParams = icon.getLayoutParams(); iconParams.width = iconWidth;/*from ww w . j ava 2 s . c om*/ iconParams.height = iconHeight; }
From source file:com.github.omadahealth.slidepager.lib.views.ProgressView.java
@Override protected void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { final Bundle bundle = (Bundle) state; Resources res = getContext().getResources(); mShowStreaks = bundle.getBoolean(INSTANCE_SHOW_STREAKS, true); mShowProgressText = bundle.getBoolean(INSTANCE_SHOW_PROGRESS_TEXT, true); mShowProgressPlusMark = bundle.getBoolean(INSTANCE_SHOW_PROGRESS_PLUSMARK, true); mHasToReanimate = bundle.getBoolean(INSTANCE_REANIMATE, true); mCompletedColor = bundle.getInt(INSTANCE_COMPLETED_COLOR, res.getColor(R.color.default_progress_completed_reach_color)); mCompletedFillColor = bundle.getInt(INSTANCE_COMPLETED_FILL_COLOR, res.getColor(R.color.default_progress_completed_fill_color)); mNotCompletedReachColor = bundle.getInt(INSTANCE_NOT_COMPLETED_COLOR, res.getColor(R.color.default_progress_not_completed_reach_color)); mNotCompletedOutlineColor = bundle.getInt(INSTANCE_NOT_COMPLETED_OUTLINE_COLOR, res.getColor(R.color.default_progress_not_completed_outline_color)); mNotCompletedOutlineSize = bundle.getFloat(INSTANCE_NOT_COMPLETED_OUTLINE_SIZE, res.getDimension(R.dimen.circular_bar_default_outline_width)); mNotCompletedFutureOutlineSize = bundle.getFloat(INSTANCE_NOT_COMPLETED_FUTURE_OUTLINE_SIZE, res.getDimension(R.dimen.circular_bar_default_future_outline_width)); mNotCompletedFillColor = bundle.getInt(INSTANCE_NOT_COMPLETED_FILL_COLOR, res.getColor(R.color.default_progress_not_completed_fill_color)); mSpecialReachColor = bundle.getInt(INSTANCE_SPECIAL_COMPLETED_COLOR, res.getColor(R.color.default_progress_special_reach_color)); mSpecialOutlineColor = bundle.getInt(INSTANCE_SPECIAL_COMPLETED_OUTLINE_COLOR, res.getColor(R.color.default_progress_special_outline_color)); mSpecialFillColor = bundle.getInt(INSTANCE_SPECIAL_COMPLETED_FILL_COLOR, res.getColor(R.color.default_progress_special_fill_color)); mProgressTextColor = bundle.getInt(INSTANCE_TEXT_COLOR, res.getColor(R.color.default_progress_text_color)); mReachedWidth = bundle.getFloat(INSTANCE_REACHED_WIDTH, res.getDimension(R.dimen.default_progress_reached_width)); super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE)); return;/*from w w w . j a v a 2 s . c o m*/ } super.onRestoreInstanceState(state); }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java
public AnyKeyboardViewBase(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mDefaultAddOn = new DefaultAddOn(context, context); mKeyPreviewsManager = new KeyPreviewsManager(context, this, mPreviewPopupTheme); mKeyPressTimingHandler = new KeyPressTimingHandler(this); mPaint = new Paint(); mPaint.setAntiAlias(true);/* w w w .j av a 2 s . c o m*/ mPaint.setTextAlign(Align.CENTER); mPaint.setAlpha(255); mDrawOperation = new KeyboardDrawOperation(this); mKeyBackgroundPadding = new Rect(0, 0, 0, 0); resetKeyboardTheme(KeyboardThemeFactory.getCurrentKeyboardTheme(context.getApplicationContext())); final Resources res = getResources(); reloadSwipeThresholdsSettings(res); final float slide = res.getDimension(R.dimen.mini_keyboard_slide_allowance); mKeyDetector = createKeyDetector(slide); mKeyRepeatInterval = 50; AnyApplication.getConfig().addChangedListener(this); mNextAlphabetKeyboardName = getResources().getString(R.string.change_lang_regular); mNextSymbolsKeyboardName = getResources().getString(R.string.change_symbols_regular); }
From source file:com.blestep.sportsbracelet.view.TimelineChartViewSleep.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr) { mUiHandler = new Handler(Looper.getMainLooper(), mMessenger); final Resources res = getResources(); final ViewConfiguration vc = ViewConfiguration.get(ctx); mTouchSlop = vc.getScaledTouchSlop() / 2; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(ctx); int footerLabelColor = ContextCompat.getColor(getContext(), R.color.tlcSleepFooterLabelColor); int barItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepBarItemBg); int highlightBarItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepHighlightBarItemBg); int barDeepItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepBarDeepItemBg); int highlightBarDeepItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepHighlightBarDeepItemBg); mBarItemBgPaint = new Paint(); mBarItemBgPaint.setColor(barItemBg); mHighlightBarItemBgPaint = new Paint(); mHighlightBarItemBgPaint.setColor(highlightBarItemBg); mBarDeepItemBgPaint = new Paint(); mBarDeepItemBgPaint.setColor(barDeepItemBg); mHighlightBarDeepItemBgPaint = new Paint(); mHighlightBarDeepItemBgPaint.setColor(highlightBarDeepItemBg); mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight); mViewAreaBgPaint = new Paint(); mGraphAreaBgPaint = new Paint(); mGraphAreaBgPaint.setColor(Color.TRANSPARENT); mFooterAreaBgPaint = new Paint(); mFooterAreaBgPaint.setColor(Color.TRANSPARENT); mGraphBottomLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGraphBottomLinePaint.setColor(Color.WHITE); mGraphBottomLinePaint.setStrokeWidth(1); // labelPaint?? mLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mLabelFgPaint.setColor(footerLabelColor); // DisplayMetrics dp = getResources().getDisplayMetrics(); // float labelSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, res.getDimension(R.dimen.tlcDefFooterLabelSize), dp); mLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mHighlightLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mHighlightLabelFgPaint.setColor(Color.WHITE); mHighlightLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth); mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace); mTopSpaceHeight = res.getDimension(R.dimen.tlcDefTopSpace); // SurfaceView requires a background if (getBackground() == null) { setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); }/*from w w w .ja va 2 s . com*/ // Initialize stuff setupBackgroundHandler(); setupTickLabels(); // Initialize the drawing refs (this will be update when we have // the real size of the canvas) computeBoundAreas(); }
From source file:cl.monsoon.s1next.widget.PhotoView.java
/** * Initializes the header and any static values */// w w w.j a v a 2 s. c o m private void initialize() { Context context = getContext(); if (!sInitialized) { sInitialized = true; Resources resources = context.getResources(); sCropSize = resources.getDimensionPixelSize(R.dimen.photo_view_crop_width); sCropDimPaint = new Paint(); sCropDimPaint.setAntiAlias(true); sCropDimPaint.setColor(ContextCompat.getColor(context, R.color.photo_view_crop_dim_color)); sCropDimPaint.setStyle(Style.FILL); sCropPaint = new Paint(); sCropPaint.setAntiAlias(true); sCropPaint.setColor(ContextCompat.getColor(context, R.color.photo_view_crop_dim_color)); sCropPaint.setStyle(Style.STROKE); sCropPaint.setStrokeWidth(resources.getDimension(R.dimen.photo_view_crop_stroke_width)); final ViewConfiguration configuration = ViewConfiguration.get(context); final int touchSlop = configuration.getScaledTouchSlop(); sTouchSlopSquare = touchSlop * touchSlop; } mGestureDetector = new GestureDetectorCompat(context, this, null); scaleGestureDetector = new ScaleGestureDetector(context, this); mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(scaleGestureDetector); mScaleRunnable = new ScaleRunnable(this); mTranslateRunnable = new TranslateRunnable(this); mSnapRunnable = new SnapRunnable(this); mRotateRunnable = new RotateRunnable(this); }
From source file:com.android.volley.ui.PhotoView.java
/** * Initializes the header and any static values *//*from w w w. j av a2 s .c om*/ private void initialize() { Context context = getContext(); if (!sInitialized) { sInitialized = true; Resources resources = context.getApplicationContext().getResources(); sCropSize = resources.getDimensionPixelSize(R.dimen.photo_crop_width); sCropDimPaint = new Paint(); sCropDimPaint.setAntiAlias(true); sCropDimPaint.setColor(resources.getColor(R.color.photo_crop_dim_color)); sCropDimPaint.setStyle(Style.FILL); sCropPaint = new Paint(); sCropPaint.setAntiAlias(true); sCropPaint.setColor(resources.getColor(R.color.photo_crop_highlight_color)); sCropPaint.setStyle(Style.STROKE); sCropPaint.setStrokeWidth(resources.getDimension(R.dimen.photo_crop_stroke_width)); final ViewConfiguration configuration = ViewConfiguration.get(context); final int touchSlop = configuration.getScaledTouchSlop(); sTouchSlopSquare = touchSlop * touchSlop; } mGestureDetector = new GestureDetectorCompat(context, this, null); mScaleGetureDetector = new ScaleGestureDetector(context, this); mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(mScaleGetureDetector); mScaleRunnable = new ScaleRunnable(this); mTranslateRunnable = new TranslateRunnable(this); mSnapRunnable = new SnapRunnable(this); mRotateRunnable = new RotateRunnable(this); }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle, final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) { mWordViews = wordViews;//from w ww. jav a 2 s .c o m mDividerViews = dividerViews; mDebugInfoViews = debugInfoViews; final TextView wordView = wordViews.get(0); final View dividerView = dividerViews.get(0); mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight(); dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mDividerWidth = dividerView.getMeasuredWidth(); final Resources res = wordView.getResources(); mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView); mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0); mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0); mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0); mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0); mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0); mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip, DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); mCenterSuggestionWeight = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE); mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow, DEFAULT_MAX_MORE_SUGGESTIONS_ROW); mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f); a.recycle(); mMoreSuggestionsHint = getMoreSuggestionsHint(res, res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect); mCenterPositionInStrip = mSuggestionsCountInStrip / 2; // Assuming there are at least three suggestions. Also, note that the suggestions are // laid out according to script direction, so this is left of the center for LTR scripts // and right of the center for RTL scripts. mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1; mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap); mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height); }
From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripLayoutHelper.java
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle, final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) { mWordViews = wordViews;/* w w w. j a v a 2 s.co m*/ mDividerViews = dividerViews; mDebugInfoViews = debugInfoViews; final TextView wordView = wordViews.get(0); final View dividerView = dividerViews.get(0); mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight(); dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mDividerWidth = dividerView.getMeasuredWidth(); final Resources res = wordView.getResources(); mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView); mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0); mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0); mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0); mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0); mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0); mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip, DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); mCenterSuggestionWeight = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE); mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow, DEFAULT_MAX_MORE_SUGGESTIONS_ROW); mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f); a.recycle(); mMoreSuggestionsHint = getMoreSuggestionsHint(res, res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect); mCenterPositionInStrip = mSuggestionsCountInStrip / 2; // Assuming there are at least three suggestions. Also, note that the suggestions are // laid out according to script direction, so this is left of the center for LTR scripts // and right of the center for RTL scripts. mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1; mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap); mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height); }
From source file:com.udmurtlyk.extrainputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle, final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) { mWordViews = wordViews;/* w ww .j a va2s.co m*/ mDividerViews = dividerViews; mDebugInfoViews = debugInfoViews; final TextView wordView = wordViews.get(0); final View dividerView = dividerViews.get(0); mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight(); dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mDividerWidth = dividerView.getMeasuredWidth(); final Resources res = wordView.getResources(); mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView); mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0); mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0); mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0); mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0); mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0); mColorShortcut = a.getColor(R.styleable.SuggestionStripView_colorShortcut, 0); mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip, DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); mCenterSuggestionWeight = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE); mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow, DEFAULT_MAX_MORE_SUGGESTIONS_ROW); mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f); a.recycle(); mMoreSuggestionsHint = getMoreSuggestionsHint(res, res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect); mCenterPositionInStrip = mSuggestionsCountInStrip / 2; // Assuming there are at least three suggestions. Also, note that the suggestions are // laid out according to script direction, so this is left of the center for LTR scripts // and right of the center for RTL scripts. mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1; mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap); mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height); }